Files
beyond/Assets/ThirdParty/PlayMaker/Actions/UI/Components/PlayMakerUiEventBase.cs
2024-11-20 15:21:28 +01:00

65 lines
1.3 KiB
C#

#if !PLAYMAKER_NO_UI
using System;
using System.Collections.Generic;
using UnityEngine;
namespace HutongGames.PlayMaker
{
public abstract class PlayMakerUiEventBase : MonoBehaviour
{
public List<PlayMakerFSM> targetFsms = new List<PlayMakerFSM>();
[NonSerialized]
protected bool initialized;
public void AddTargetFsm(PlayMakerFSM fsm)
{
if (!TargetsFsm(fsm))
{
targetFsms.Add(fsm);
}
Initialize();
}
private bool TargetsFsm(PlayMakerFSM fsm)
{
for (var i = 0; i < targetFsms.Count; i++)
{
var targetFsm = targetFsms[i];
if (fsm == targetFsm)
return true;
}
return false;
}
protected void OnEnable()
{
Initialize();
}
public void PreProcess()
{
Initialize();
}
protected virtual void Initialize()
{
initialized = true;
}
protected void SendEvent(FsmEvent fsmEvent)
{
for (var i = 0; i < targetFsms.Count; i++)
{
var targetFsm = targetFsms[i];
targetFsm.Fsm.Event(gameObject, fsmEvent);
}
}
}
}
#endif