move Damageable class to Utilities assembly

This commit is contained in:
in0finite 2020-05-17 02:14:00 +02:00
parent 24ae9c853d
commit 756f7e8563
4 changed files with 47 additions and 53 deletions

View file

@ -279,11 +279,6 @@ namespace SanAndreasUnity.Behaviours.Peds.States
}
public virtual void OnDamaged(DamageInfo info)
{
}
public virtual void OnSwitchedStateByServer(byte[] data)
{

View file

@ -9,8 +9,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
void PostUpdateState ();
//void OnCollision(Collision info);
void OnDamaged(DamageInfo info);
void OnButtonPressed(string buttonName);
void OnFireButtonPressed();
void OnAimButtonPressed();

View file

@ -1,46 +1,46 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace SanAndreasUnity.Behaviours
{
public class DamageInfo
{
public float amount = 0f;
public Transform raycastHitTransform = null;
public object data = null;
}
public class Damageable : MonoBehaviour
{
[SerializeField] private float m_health = 0f;
public float Health { get { return m_health; } set { m_health = value; } }
[SerializeField] private UnityEvent m_onDamage = new UnityEvent ();
public DamageInfo LastDamageInfo { get; private set; }
public void Damage (DamageInfo info)
{
this.LastDamageInfo = info;
m_onDamage.Invoke ();
}
public void HandleDamageByDefault ()
{
DamageInfo info = this.LastDamageInfo;
this.Health -= info.amount;
if (this.Health <= 0f) {
Destroy (this.gameObject);
}
}
}
}
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace SanAndreasUnity.Utilities
{
public class DamageInfo
{
public float amount = 0f;
public Transform raycastHitTransform = null;
public object data = null;
}
public class Damageable : MonoBehaviour
{
[SerializeField] private float m_health = 0f;
public float Health { get { return m_health; } set { m_health = value; } }
[SerializeField] private UnityEvent m_onDamage = new UnityEvent ();
public DamageInfo LastDamageInfo { get; private set; }
public void Damage (DamageInfo info)
{
this.LastDamageInfo = info;
m_onDamage.Invoke ();
}
public void HandleDamageByDefault ()
{
DamageInfo info = this.LastDamageInfo;
this.Health -= info.amount;
if (this.Health <= 0f) {
Destroy (this.gameObject);
}
}
}
}