Files
2024-11-20 15:21:28 +01:00

49 lines
1.3 KiB
C#

// (c) copyright Hutong Games, LLC 2010-2016. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.StateMachine)]
[Tooltip("Forward an event received by this FSM to another target.")]
public class ForwardEvent : FsmStateAction
{
[Tooltip("Forward to this target.")]
public FsmEventTarget forwardTo;
[Tooltip("The events to forward.")]
public FsmEvent[] eventsToForward;
[Tooltip("Should this action eat the events or pass them on.")]
public bool eatEvents;
public override void Reset()
{
forwardTo = new FsmEventTarget { target = FsmEventTarget.EventTarget.FSMComponent };
eventsToForward = null;
eatEvents = true;
}
/// <summary>
/// Return true to eat the event
/// </summary>
public override bool Event(FsmEvent fsmEvent)
{
if (eventsToForward != null)
{
foreach (var e in eventsToForward)
{
if (e == fsmEvent)
{
Fsm.Event(forwardTo, fsmEvent);
return eatEvents;
}
}
}
return false;
}
}
}