Пример #1
0
        public static void RemoveAction <T>(this PlayMakerFSM fsm, string stateName) where T : FsmStateAction
        {
            FsmState t = fsm.GetState(stateName);

            FsmStateAction[] actions = t.Actions;

            FsmStateAction action = fsm.GetAction <T>(stateName);

            actions = actions.Where(x => x != action).ToArray();
            Log(action.GetType().ToString());

            t.Actions = actions;
        }
Пример #2
0
        public static void RemoveAction(PlayMakerFSM fsm, string stateName, int index)
        {
            foreach (FsmState t in fsm.FsmStates)
            {
                if (t.Name != stateName)
                {
                    continue;
                }
                FsmStateAction[] actions = t.Actions;

                FsmStateAction action = fsm.GetAction(stateName, index);
                actions = actions.Where(x => x != action).ToArray();
                Log(action.GetType().ToString());

                t.Actions = actions;
            }
        }
    private void HandleActivateGameObject(int ourFsmIndex, PlayMakerFSM fsm, FsmState state, FsmStateAction action)
    {
        if (action.GetType() == typeof(HutongGames.PlayMaker.Actions.ActivateGameObject))
        {
            HutongGames.PlayMaker.Actions.ActivateGameObject ago = (HutongGames.PlayMaker.Actions.ActivateGameObject)(action);
            GameObject targetGameObject = ago.Fsm.GetOwnerDefaultTarget(ago.gameObject);
            string     targetGOname     = ((targetGameObject != null) ? targetGameObject.name : "UNKNOWN");

            if ((FilterTargetGameObjectName.Length > 0) && (targetGOname.Contains(FilterTargetGameObjectName) == false))
            {
                return;
            }

            results += "ActivateGameObject " + fsm.ToString() + " State " + state.Name +
                       " Enable=" + FsmBoolToString(ago.activate) +
                       " Recursive=" + FsmBoolToString(ago.recursive.Value) +
                       " on GameObject " + targetGOname +
                       "\n";
            commsList.Add(new PlaymakerCommsEntry(ourFsmIndex, fsm, state, action));
        }
    }
    //------------------------------------------------------------------------------------------------------
    private void HandleSendEvent(int ourFsmIndex, PlayMakerFSM fsm, FsmState state, FsmStateAction action)
    {
        if (action.GetType() == typeof(HutongGames.PlayMaker.Actions.SendEvent))
        {
            HutongGames.PlayMaker.Actions.SendEvent se = (HutongGames.PlayMaker.Actions.SendEvent)(action);

            if ((FilterEventName.Length > 0) && (se.sendEvent.Name.Contains(FilterEventName) == false))
            {
                return;
            }

            string TargetFsmName = se.eventTarget.fsmName.Value;
            if (TargetFsmName.Length == 0)
            {
                TargetFsmName = se.eventTarget.fsmName.Name;
            }
            if (TargetFsmName.Length == 0)
            {
                TargetFsmName = "UNKOWN";
            }

            if ((FilterTargetFsmName.Length > 0) && (TargetFsmName.Contains(FilterTargetFsmName) == false))
            {
                return;
            }

            if ((FilterTargetGameObjectName.Length > 0) && (se.eventTarget.gameObject.GameObject.ToString().Contains(FilterTargetGameObjectName) == false))
            {
                return;
            }

            results += "SendEvent " + fsm.ToString() + " State " + state.Name + " sends " + se.sendEvent.Name +
                       " to (FSM called) " + TargetFsmName +
                       " on GameObject " + se.eventTarget.gameObject.GameObject.ToString() +
                       "\n";
            commsList.Add(new PlaymakerCommsEntry(ourFsmIndex, fsm, state, action));
        }
    }
    //------------------------------------------------------------------------------------------------------
    private void HandleSendMessage(int ourFsmIndex, PlayMakerFSM fsm, FsmState state, FsmStateAction action)
    {
        if (action.GetType() == typeof(HutongGames.PlayMaker.Actions.SendMessage))
        {
            HutongGames.PlayMaker.Actions.SendMessage sm = (HutongGames.PlayMaker.Actions.SendMessage)(action);
            string     funcName       = sm.functionCall.FunctionName;
            GameObject targetGO       = sm.Fsm.GetOwnerDefaultTarget(sm.gameObject);
            string     gameObjectName = ((targetGO != null) ? targetGO.name : "UNKNOWN");

            if ((FilterMethodName.Length > 0) && (funcName.Contains(FilterMethodName) == false))
            {
                return;
            }
            if ((FilterTargetGameObjectName.Length > 0) && (gameObjectName.Contains(FilterTargetGameObjectName) == false))
            {
                return;
            }

            results += "SendMessage " + fsm.ToString() + " State " + state.Name + " calls method " + funcName + " on GameObject " + gameObjectName + "\n";

            commsList.Add(new PlaymakerCommsEntry(ourFsmIndex, fsm, state, action));
        }
    }
 public static string LogFullPathToAction(FsmStateAction action)
 {
     return(GetGameObjectPath(action.Fsm.GameObject) + ":Fsm(" +
            action.Fsm.Name + "):State(" + action.State.Name + "):Action(" + action.GetType().Name + ")");
 }