public static void addAction(this FsmState self, FsmStateAction action)
        {
            List <FsmStateAction> actions = self.Actions.ToList();

            actions.Add(action);
            self.Actions = actions.ToArray();
        }
 public static void AddLastAction(this FsmState state, FsmStateAction action)
 {
     FsmStateAction[] actions = new FsmStateAction[state.Actions.Length + 1];
     actions[state.Actions.Length] = action;
     state.Actions.CopyTo(actions, 0);
     state.Actions = actions;
 }
Beispiel #3
0
        public PostProcessProfile GetProfile(FsmStateAction action)
        {
            switch (reference)
            {
            case PpsReferences.FromAsset:
                _pps = (PostProcessProfile)profile.Value;
                break;

            case PpsReferences.FromVolume:

                _go = action.Fsm.GetOwnerDefaultTarget(gameObject);
                if (_go != null)
                {
                    _volume = _go.GetComponent <PostProcessVolume>();

                    if (_volume != null)
                    {
                        _pps = _volume.profile;
                    }
                }
                break;
            }

            if (_pps == null)
            {
                action.Fsm.Event(profileNotFound);
            }

            return(_pps);
        }
Beispiel #4
0
        public static void AddAction(this PMFSM fsm, int stateindex, FsmStateAction action)
        {
            action.Fsm = fsm.Fsm;
            FsmState state = fsm.GetState(stateindex);

            state.Actions = state.Actions.Append(action).ToArray();
        }
Beispiel #5
0
        public static void AddAction(this PMFSM fsm, string statename, FsmStateAction action)
        {
            action.Fsm = fsm.Fsm;
            FsmState state = fsm.GetState(statename);

            state.Actions = state.Actions.Append(action).ToArray();
        }
        private static void RemoveLastActions(FsmState s, int n)
        {
            var newActions = new FsmStateAction[s.Actions.Length - n];

            Array.Copy(s.Actions, newActions, newActions.Length);
            s.Actions = newActions;
        }
    private List <FsmState> GenerateSpellFsmStateList()
    {
        List <FsmState> list = new List <FsmState>();

        foreach (FsmState state in this.m_fsm.FsmStates)
        {
            SpellStateAction action = null;
            int num2 = 0;
            for (int i = 0; i < state.Actions.Length; i++)
            {
                FsmStateAction   action2 = state.Actions[i];
                SpellStateAction action3 = action2 as SpellStateAction;
                if (action3 != null)
                {
                    num2++;
                    if (action == null)
                    {
                        action = action3;
                    }
                }
            }
            if (action != null)
            {
                list.Add(state);
            }
            if (num2 > 1)
            {
                UnityEngine.Debug.LogWarning(string.Format("{0}.GenerateSpellFsmStateList() - State \"{1}\" has {2} SpellStateActions. There should be 1.", this, state.Name, num2));
            }
        }
        return(list);
    }
 public PlaymakerCommsEntry(int anFsmIndex, PlayMakerFSM an_fsm, FsmState a_state, FsmStateAction an_action)
 {
     showMe      = showMyState = showMyFsm = true;
     ourFsmIndex = anFsmIndex;
     fsm         = an_fsm;
     state       = a_state;
     action      = an_action;
 }
Beispiel #9
0
        public static void AddFirstAction(this FsmState self, FsmStateAction action)
        {
            FsmStateAction[] actions = new FsmStateAction[self.Actions.Length + 1];
            Array.Copy(self.Actions, 0, actions, 1, self.Actions.Length);
            actions[0] = action;

            self.Actions = actions;
        }
Beispiel #10
0
 public static void AddFsmAction(this FsmState state, FsmStateAction action)
 {
     FsmStateAction[] origActions = state.Actions;
     FsmStateAction[] actions     = new FsmStateAction[origActions.Length + 1];
     origActions.CopyTo(actions, 0);
     actions[origActions.Length] = action;
     state.Actions = actions;
 }
 public AddFsmActionToObject(string sceneName, string fsmName, string objectName, bool first, FsmStateAction action, params string[] stateNames)
 {
     _sceneName  = sceneName;
     _fsmName    = fsmName;
     _objectName = objectName;
     _action     = action;
     _stateNames = stateNames;
     _first      = first;
 }
Beispiel #12
0
        public Player GetPlayer(FsmStateAction action)
        {
            Player _player = null;

            switch (reference)
            {
            case PlayerReferences.localPlayer:
                _player = PhotonNetwork.LocalPlayer;
                break;

            case PlayerReferences.MasterClient:
                _player = PhotonNetwork.MasterClient;
                break;

            case PlayerReferences.ByNickName:
                _player = PhotonNetwork.CurrentRoom == null ? null :  PhotonNetwork.CurrentRoom.FindPlayerByNickname(nickname.Value);
                break;

            case PlayerReferences.ByActorNumber:
                _player = PhotonNetwork.LocalPlayer.Get(actorNumber.Value);
                break;

            case PlayerReferences.ByUserId:
                _player = PhotonNetwork.LocalPlayer.FindByUserID(userId.Value);
                break;

            case PlayerReferences.next:
                _player = PhotonNetwork.LocalPlayer.GetNext();
                break;

            case PlayerReferences.ByRoomNumber:
                _player = PhotonNetwork.CurrentRoom.FindPlayerByNumber(roomNumber.Value);
                break;

            case PlayerReferences.ByOwnedObject:

                GameObject _go = action.Fsm.GetOwnerDefaultTarget(gameObject);
                if (_go != null)
                {
                    PhotonView _pv = _go.GetComponent <PhotonView>();

                    if (_pv != null)
                    {
                        _player = _pv.Owner;
                    }
                }
                break;
            }

            if (_player == null)
            {
                action.Fsm.Event(playerNotFound);
            }

            return(_player);
        }
Beispiel #13
0
        public static void AddAction(this PlayMakerFSM fsm, string stateName, FsmStateAction action)
        {
            FsmState t = fsm.GetState(stateName);

            FsmStateAction[] actions = t.Actions;

            Array.Resize(ref actions, actions.Length + 1);
            actions[actions.Length - 1] = action;

            t.Actions = actions;
        }
        /// <summary>
        /// Add new action into play maker state.
        /// </summary>
        /// <param name="state">The state to add action to.</param>
        /// <param name="action">The action to add.</param>
        static public void AddNewAction(FsmState state, FsmStateAction action)
        {
            FsmStateAction[]      oldActions = state.Actions;
            List <FsmStateAction> temp       = new List <FsmStateAction>();

            temp.Add(action);
            foreach (var v in oldActions)
            {
                temp.Add(v);
            }
            state.Actions = temp.ToArray();
        }
Beispiel #15
0
        public static void InsertAction(this PlayMakerFSM fsm, string stateName, FsmStateAction action, int index)
        {
            FsmState t = fsm.GetState(stateName);

            List <FsmStateAction> actions = t.Actions.ToList();

            actions.Insert(index, action);

            t.Actions = actions.ToArray();

            action.Init(t);
        }
Beispiel #16
0
        public static void InjectStateHook(GameObject gameObject, string stateName, FsmStateAction customStateAction, int index = 0)
        {
            var state = GetStateFromGameObject(gameObject, stateName);

            if (state != null)
            {
                // inject our hook action to the state machine
                var actions = new List <FsmStateAction>(state.Actions);
                actions.Insert(index, customStateAction);
                state.Actions = actions.ToArray();
            }
        }
Beispiel #17
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;
        }
    public static void Apply <TStateEnum>(FSMWrapper fsmw)
        where TStateEnum : IConvertible
    {
        //check states for signal wrapper action
        var allStateNames = Enum.GetNames(typeof(TStateEnum));

        foreach (var state in fsmw.targetFsm.States)
        {
            bool shouldContainSignal = false;
            if (allStateNames.Contains(state.Name))
            {
                state.ColorIndex    = (fsmw as IFSMStateDescriber).stateColour;
                shouldContainSignal = true;
            }

            if (shouldContainSignal)
            {
                if (Array.Find(state.Actions, (a) => a is SignalWrapper) == null)
                {
                    var newAction = new SignalWrapper(typeof(TStateEnum));
                    state.Actions = new FsmStateAction[] { newAction }.Concat(
                        state.Actions
                        ).ToArray();
                }
            }
            else
            {
                var i = Array.FindIndex(state.Actions,
                                        (a) => (a is SignalWrapper && (a as SignalWrapper).enumType == typeof(TStateEnum).ToString()));
                if (i >= 0)
                {
                    var dest = new FsmStateAction[state.Actions.Length - 1];
                    if (i > 0)
                    {
                        Array.Copy(state.Actions, 0, dest, 0, i);
                    }

                    if (i < state.Actions.Length - 1)
                    {
                        Array.Copy(state.Actions, i + 1, dest, i, state.Actions.Length - i - 1);
                    }

                    state.Actions = dest;
                }
            }

            state.SaveActions();
        }
    }
Beispiel #19
0
        public static void AddAction(PlayMakerFSM fsm, string stateName, FsmStateAction action)
        {
            for (int i = 0; i < fsm.FsmStates.Length; i++)
            {
                if (fsm.FsmStates[i].Name == stateName)
                {
                    FsmStateAction[] actions = fsm.FsmStates[i].Actions;

                    Array.Resize(ref actions, actions.Length + 1);
                    actions[actions.Length - 1] = action;

                    fsm.FsmStates[i].Actions = actions;
                }
            }
        }
Beispiel #20
0
        /// <summary>
        /// Insert a FSM action in a state at a specific index.
        /// </summary>
        /// <param name="fsm">The FSM instance.</param>
        /// <param name="stateName">The name of the state.</param>
        /// <param name="action">The FSM action to insert.</param>
        /// <param name="index">The index at which to insert the action.</param>
        public static void InsertAction(PlayMakerFSM fsm, string stateName, FsmStateAction action, int index)
        {
            foreach (FsmState t in fsm.FsmStates)
            {
                if (t.Name != stateName)
                {
                    continue;
                }
                List <FsmStateAction> actions = t.Actions.ToList();

                actions.Insert(index, action);

                t.Actions = actions.ToArray();
            }
        }
 public static void RemoveAction(this FsmState state, int index)
 {
     FsmStateAction[] actions = new FsmStateAction[state.Actions.Length - 1];
     for (int i = 0; i < state.Actions.Length - 1; i++)
     {
         if (i < index)
         {
             actions[i] = state.Actions[i];
         }
         else
         {
             actions[i] = state.Actions[i + 1];
         }
     }
     state.Actions = actions;
 }
Beispiel #22
0
        private static void AddAction(PlayMakerFSM fsm, string stateName, FsmStateAction action)
        {
            foreach (FsmState t in fsm.FsmStates)
            {
                if (t.Name != stateName)
                {
                    continue;
                }
                FsmStateAction[] actions = t.Actions;

                Array.Resize(ref actions, actions.Length + 1);
                actions[actions.Length - 1] = action;

                t.Actions = actions;
            }
        }
Beispiel #23
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;
            }
        }
Beispiel #24
0
        void InsertAction(PlayMakerFSM fsm, string stateName, FsmStateAction action, int insert = -1)
        {
            FsmState state = fsm.FsmStates.FirstOrDefault(x => x.Name == stateName);

            List <FsmStateAction> actions = state.Actions.ToList();

            if (insert != -1)
            {
                actions.Insert(insert, action);
            }
            else
            {
                actions.Add(action);
            }

            state.Actions = actions.ToArray();
        }
Beispiel #25
0
        public static void RemoveFsmAction(this FsmState state, int index)
        {
            FsmStateAction[] origActions = state.Actions;
            FsmStateAction[] actions     = new FsmStateAction[origActions.Length - 1];
            int i;

            for (i = 0; i < index; i++)
            {
                actions[i] = origActions[i];
            }
            for (i = index; i < actions.Length; i++)
            {
                actions[i] = origActions[i + 1];
            }

            state.Actions = actions;
        }
 public static void InsertAction(this FsmState state, FsmStateAction action, int index)
 {
     FsmStateAction[] actions = new FsmStateAction[state.Actions.Length + 1];
     for (int i = 0; i < state.Actions.Length; i++)
     {
         if (i < index)
         {
             actions[i] = state.Actions[i];
         }
         else
         {
             actions[i + 1] = state.Actions[i];
         }
     }
     actions[index] = action;
     state.Actions  = actions;
 }
Beispiel #27
0
        public static void InsertFsmAction(this FsmState state, FsmStateAction action, int index)
        {
            FsmStateAction[] origActions = state.Actions;
            FsmStateAction[] actions     = new FsmStateAction[origActions.Length + 1];
            int i;

            for (i = 0; i < index; i++)
            {
                actions[i] = origActions[i];
            }
            actions[index] = action;
            for (i = index; i < origActions.Length; i++)
            {
                actions[i + 1] = origActions[i];
            }

            state.Actions = actions;
        }
Beispiel #28
0
        private static void AddActionFirst(PlayMakerFSM fsm, string stateName, FsmStateAction action)
        {
            foreach (FsmState t in fsm.FsmStates)
            {
                if (t.Name != stateName)
                {
                    continue;
                }
                FsmStateAction[] actions    = t.Actions;
                FsmStateAction[] actionsNew = t.Actions;

                Array.Resize(ref actions, actions.Length + 1);
                actions[0] = action;
                for (int i = 1; i < actions.Length; i++)
                {
                    actions[i] = actionsNew[i - 1];
                }
                t.Actions = actions;
            }
        }
    //------------------------------------------------------------------------------------------------------
    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));
        }
    }
Beispiel #30
0
 public static void InsertAction(this PlayMakerFSM fsm, string state, int ind, FsmStateAction action)
 {
     InsertAction(fsm, state, action, ind);
 }