You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.0 KiB
C#
41 lines
1.0 KiB
C#
using System;
|
|
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
|
|
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.BossRoom.Gameplay.GameplayObjects
|
|
{
|
|
public class DamageReceiver : NetworkBehaviour, IDamageable
|
|
{
|
|
public event Action<ServerCharacter, int> DamageReceived;
|
|
|
|
public event Action<Collision> CollisionEntered;
|
|
|
|
[SerializeField]
|
|
NetworkLifeState m_NetworkLifeState;
|
|
|
|
public void ReceiveHP(ServerCharacter inflicter, int HP)
|
|
{
|
|
if (IsDamageable())
|
|
{
|
|
DamageReceived?.Invoke(inflicter, HP);
|
|
}
|
|
}
|
|
|
|
public IDamageable.SpecialDamageFlags GetSpecialDamageFlags()
|
|
{
|
|
return IDamageable.SpecialDamageFlags.None;
|
|
}
|
|
|
|
public bool IsDamageable()
|
|
{
|
|
return m_NetworkLifeState.LifeState.Value == LifeState.Alive;
|
|
}
|
|
|
|
void OnCollisionEnter(Collision other)
|
|
{
|
|
CollisionEntered?.Invoke(other);
|
|
}
|
|
}
|
|
}
|