Add damage system and processing system to enemy
This commit is contained in:
24
Assets/Scripts/Components/ProcessHitComponent.cs
Normal file
24
Assets/Scripts/Components/ProcessHitComponent.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class ProcessHitComponent : MonoBehaviour
|
||||
{
|
||||
private HashSet<GameObject> ignored = new HashSet<GameObject>();
|
||||
|
||||
public UnityEvent<int> onTakeDamage;
|
||||
|
||||
public void Process(OnHitEvent.Args args)
|
||||
{
|
||||
var source = args.source;
|
||||
|
||||
if (ignored.Contains(source)) return;
|
||||
|
||||
Debug.Log("Got hit");
|
||||
|
||||
onTakeDamage.Invoke(args.damage.value);
|
||||
|
||||
ignored.Add(args.source);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user