Пример #1
0
 private bool ActivateActions(int startIndex)
 {
     for (int i = startIndex; i < Actions.Length; i++)
     {
         activeActionIndex = i;
         FsmStateAction fsmStateAction = Actions[i];
         if (!fsmStateAction.Enabled)
         {
             fsmStateAction.Finished = true;
             continue;
         }
         ActiveActions.Add(fsmStateAction);
         activeAction            = fsmStateAction;
         fsmStateAction.Active   = true;
         fsmStateAction.Finished = false;
         fsmStateAction.Init(this);
         fsmStateAction.Entered = true;
         fsmStateAction.OnEnter();
         if (Fsm.IsSwitchingState)
         {
             return(false);
         }
         if (!fsmStateAction.Finished && isSequence)
         {
             return(false);
         }
     }
     return(true);
 }
Пример #2
0
        public static ActionReport Log(PlayMakerFSM fsm, FsmState state, FsmStateAction action, int actionIndex, string parameter, string logLine, bool isError = false)
        {
            if (!PlayMakerGlobals.IsEditor)
            {
                return(null);
            }
            ActionReport actionReport = new ActionReport();

            actionReport.fsm         = fsm;
            actionReport.state       = state;
            actionReport.action      = action;
            actionReport.actionIndex = actionIndex;
            actionReport.parameter   = parameter;
            actionReport.logText     = logLine;
            actionReport.isError     = isError;
            ActionReport actionReport2 = actionReport;

            if (!ActionReportContains(actionReport2))
            {
                ActionReportList.Add(actionReport2);
                InfoCount++;
                return(actionReport2);
            }
            return(null);
        }
Пример #3
0
 public static string GetPath(FsmState state, FsmStateAction action)
 {
     if (action == null)
     {
         return(GetPath(state) + "[missing action] ");
     }
     return(GetPath(state) + action.GetType().Name + ": ");
 }
Пример #4
0
 public void OnGUI()
 {
     for (int i = 0; i < ActiveActions.Count; i++)
     {
         FsmStateAction fsmStateAction = ActiveActions[i];
         fsmStateAction.Init(this);
         fsmStateAction.OnGUI();
     }
     RemoveFinishedActions();
 }
Пример #5
0
 public void OnLateUpdate()
 {
     for (int i = 0; i < ActiveActions.Count; i++)
     {
         FsmStateAction fsmStateAction = ActiveActions[i];
         fsmStateAction.Init(this);
         fsmStateAction.OnLateUpdate();
     }
     CheckAllActionsFinished();
 }
Пример #6
0
 public bool OnJointBreak2D(Joint2D joint)
 {
     for (int i = 0; i < ActiveActions.Count; i++)
     {
         FsmStateAction fsmStateAction = ActiveActions[i];
         fsmStateAction.Init(this);
         fsmStateAction.DoJointBreak2D(joint);
     }
     RemoveFinishedActions();
     return(fsm.IsSwitchingState);
 }
Пример #7
0
 public bool OnControllerColliderHit(ControllerColliderHit collider)
 {
     for (int i = 0; i < ActiveActions.Count; i++)
     {
         FsmStateAction fsmStateAction = ActiveActions[i];
         fsmStateAction.Init(this);
         fsmStateAction.DoControllerColliderHit(collider);
     }
     RemoveFinishedActions();
     return(fsm.IsSwitchingState);
 }
Пример #8
0
 public bool OnTriggerExit2D(Collider2D other)
 {
     for (int i = 0; i < ActiveActions.Count; i++)
     {
         FsmStateAction fsmStateAction = ActiveActions[i];
         fsmStateAction.Init(this);
         fsmStateAction.DoTriggerExit2D(other);
     }
     RemoveFinishedActions();
     return(fsm.IsSwitchingState);
 }
Пример #9
0
 public bool OnCollisionExit2D(Collision2D collisionInfo)
 {
     for (int i = 0; i < ActiveActions.Count; i++)
     {
         FsmStateAction fsmStateAction = ActiveActions[i];
         fsmStateAction.Init(this);
         fsmStateAction.DoCollisionExit2D(collisionInfo);
     }
     RemoveFinishedActions();
     return(fsm.IsSwitchingState);
 }
Пример #10
0
 public bool OnParticleCollision(GameObject other)
 {
     for (int i = 0; i < ActiveActions.Count; i++)
     {
         FsmStateAction fsmStateAction = ActiveActions[i];
         fsmStateAction.Init(this);
         fsmStateAction.DoParticleCollision(other);
     }
     RemoveFinishedActions();
     return(fsm.IsSwitchingState);
 }
Пример #11
0
 public bool OnAnimatorIK(int layerIndex)
 {
     for (int i = 0; i < ActiveActions.Count; i++)
     {
         FsmStateAction fsmStateAction = ActiveActions[i];
         fsmStateAction.Init(this);
         fsmStateAction.DoAnimatorIK(layerIndex);
     }
     RemoveFinishedActions();
     return(fsm.IsSwitchingState);
 }
Пример #12
0
 public void OnUpdate()
 {
     if (!finished)
     {
         StateTime += Time.deltaTime;
         for (int i = 0; i < ActiveActions.Count; i++)
         {
             FsmStateAction fsmStateAction = ActiveActions[i];
             fsmStateAction.Init(this);
             fsmStateAction.OnUpdate();
         }
         CheckAllActionsFinished();
     }
 }
Пример #13
0
 public void OnExit()
 {
     active   = false;
     finished = false;
     FsmStateAction[] array = Actions;
     foreach (FsmStateAction fsmStateAction in array)
     {
         if (fsmStateAction.Entered)
         {
             activeAction = fsmStateAction;
             fsmStateAction.Init(this);
             fsmStateAction.OnExit();
         }
     }
 }
Пример #14
0
        public bool OnEvent(FsmEvent fsmEvent)
        {
            bool result = false;

            for (int i = 0; i < ActiveActions.Count; i++)
            {
                FsmStateAction fsmStateAction = ActiveActions[i];
                fsmStateAction.Init(this);
                result = fsmStateAction.Event(fsmEvent);
            }
            if (!fsm.IsSwitchingState)
            {
                return(result);
            }
            return(true);
        }
Пример #15
0
 public FsmEventData(FsmEventData source)
 {
     SentByFsm          = source.SentByFsm;
     SentByState        = source.SentByState;
     SentByAction       = source.SentByAction;
     BoolData           = source.BoolData;
     IntData            = source.IntData;
     FloatData          = source.FloatData;
     Vector2Data        = source.Vector2Data;
     Vector3Data        = source.Vector3Data;
     StringData         = source.StringData;
     QuaternionData     = source.QuaternionData;
     RectData           = source.RectData;
     ColorData          = source.ColorData;
     ObjectData         = source.ObjectData;
     GameObjectData     = source.GameObjectData;
     MaterialData       = source.MaterialData;
     TextureData        = source.TextureData;
     Player             = source.Player;
     DisconnectionInfo  = source.DisconnectionInfo;
     ConnectionError    = source.ConnectionError;
     NetworkMessageInfo = source.NetworkMessageInfo;
     MasterServerEvent  = source.MasterServerEvent;
 }
Пример #16
0
 public void FinishAction(FsmStateAction action)
 {
     finishedActions.Add(action);
 }
Пример #17
0
 public static void LogError(PlayMakerFSM fsm, FsmState state, FsmStateAction action, int actionIndex, string logLine)
 {
     Log(fsm, state, action, actionIndex, logLine, "", isError: true);
     Debug.LogError(FsmUtility.GetPath(state, action) + logLine, fsm);
     ErrorCount++;
 }
Пример #18
0
 /// <summary>
 /// [-Convert]ActionName: fromVar to toVar
 /// </summary>
 public static string AutoNameConvert(FsmStateAction action, NamedVariable fromVariable, NamedVariable toVariable)
 {
     return(action == null ? null : AutoNameConvert(action.GetType().Name, fromVariable, toVariable));
 }
Пример #19
0
 /// <summary>
 /// ActionName: property -> store
 /// </summary>
 public static string AutoNameGetProperty(FsmStateAction action, NamedVariable property, NamedVariable store)
 {
     return(action == null ? null : AutoNameGetProperty(action.GetType().Name, property, store));
 }
Пример #20
0
 /// <summary>
 /// ActionName: min - max
 /// </summary>
 public static string AutoNameRange(FsmStateAction action, NamedVariable min, NamedVariable max)
 {
     return(action == null ? null : AutoNameRange(action.GetType().Name, min, max));
 }
Пример #21
0
 /// <summary>
 /// ActionName: var = value
 /// </summary>
 public static string AutoNameSetVar(FsmStateAction action, NamedVariable var, NamedVariable value)
 {
     return(action == null ? null : AutoNameSetVar(action.GetType().Name, var, value));
 }
Пример #22
0
 /// <summary>
 /// ActionName: event
 /// </summary>
 public static string AutoName(FsmStateAction action, FsmEvent fsmEvent)
 {
     return(action == null ? null : AutoName(action.GetType().Name, fsmEvent != null ? fsmEvent.Name : "None"));
 }
Пример #23
0
 /// <summary>
 /// ActionName: ownerDefault field1 field2 ...
 /// </summary>
 public static string AutoName(FsmStateAction action, Fsm fsm, FsmOwnerDefault target, params INamedVariable[] exposedFields)
 {
     return(action == null ? null : AutoName(action.GetType().Name, fsm, target, exposedFields));
 }
Пример #24
0
 /// <summary>
 /// ActionName: ownerDefault
 /// </summary>
 public static string AutoName(FsmStateAction action, Fsm fsm, FsmOwnerDefault ownerDefault)
 {
     return(action == null ? null : AutoName(action.GetType().Name, GetValueLabel(fsm, ownerDefault)));
 }
Пример #25
0
 /// <summary>
 /// ActionName: label1 label2 ...
 /// </summary>
 public static string AutoName(FsmStateAction action, params string[] labels)
 {
     return(action == null ? null : AutoName(action.GetType().Name, labels));
 }
Пример #26
0
 /// <summary>
 /// ActionName: field1 field2 ...
 /// </summary>
 public static string AutoName(FsmStateAction action, params INamedVariable[] exposedFields)
 {
     return(action == null ? null : AutoName(action.GetType().Name, exposedFields));
 }
Пример #27
0
 public static void RuntimeError(FsmStateAction action, string error)
 {
     action.LogError(action + colon + error);
 }
Пример #28
0
 /// <summary>
 /// Get the GameObject targeted by an action's FsmOwnerDefault variable
 /// </summary>
 public static GameObject GetOwnerDefault(FsmStateAction action, FsmOwnerDefault ownerDefault)
 {
     return(action.Fsm.GetOwnerDefaultTarget(ownerDefault));
 }
Пример #29
0
 public static string GetPath(FsmState state, FsmStateAction action, string parameter)
 {
     return(GetPath(state, action) + parameter + ": ");
 }
Пример #30
0
 public static void RuntimeError(FsmStateAction action, string error)
 {
     action.LogError(string.Concat(action, " : ", error));
 }