您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
37 行
836 B
37 行
836 B
using UnityEngine;
|
|
using UOP1.StateMachine;
|
|
using UOP1.StateMachine.ScriptableObjects;
|
|
|
|
[CreateAssetMenu(menuName = "State Machines/Conditions/Has Received Event")]
|
|
public class HasReceivedEventSO : StateConditionSO<HasReceivedEventCondition>
|
|
{
|
|
public VoidEventChannelSO voidEvent;
|
|
}
|
|
|
|
public class HasReceivedEventCondition : Condition
|
|
{
|
|
private HasReceivedEventSO _originSO => (HasReceivedEventSO)base.OriginSO; // The SO this Condition spawned from
|
|
|
|
private bool _eventTriggered;
|
|
|
|
public override void Awake(StateMachine stateMachine)
|
|
{
|
|
_eventTriggered = false;
|
|
_originSO.voidEvent.OnEventRaised += EventReceived;
|
|
}
|
|
|
|
protected override bool Statement()
|
|
{
|
|
return _eventTriggered;
|
|
}
|
|
|
|
private void EventReceived()
|
|
{
|
|
_eventTriggered = true;
|
|
}
|
|
|
|
public override void OnStateExit()
|
|
{
|
|
_eventTriggered = false;
|
|
}
|
|
}
|