mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-16 12:58:27 +00:00
move Damageable class to Utilities assembly
This commit is contained in:
parent
24ae9c853d
commit
756f7e8563
4 changed files with 47 additions and 53 deletions
|
@ -279,11 +279,6 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
|
||||
}
|
||||
|
||||
public virtual void OnDamaged(DamageInfo info)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public virtual void OnSwitchedStateByServer(byte[] data)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue