private void Execute(T state, StatePhase phase) { if (_methods.ContainsKey(state)) { StateMethods methods = _methods[state]; methods.Invoke(phase); } }
public override void DrawNodePropertyEditor() { GUILayout.Space(8); EditorGUIUtility.labelWidth = 70; StateName = EditorGUILayout.TextField("Name", StateName); GUILayout.Space(3); EditorGUILayout.LabelField("Description"); StateDescription = EditorGUILayout.TextArea(StateDescription); // Draw methods UpdateMethodInfo(); GUILayout.Space(10); string methodName; if (_stateInfoNode != null && StateMethods != null) { if (StateMethods.TryGetValue("Enter", out methodName)) { DrawReadonlyTextField("Enter", methodName); } if (StateMethods.TryGetValue("Update", out methodName)) { DrawReadonlyTextField("Update", methodName); } if (StateMethods.TryGetValue("LateUpdate", out methodName)) { DrawReadonlyTextField("LateUpdate", methodName); } if (StateMethods.TryGetValue("FixedUpdate", out methodName)) { DrawReadonlyTextField("FixedUpdate", methodName); } if (StateMethods.TryGetValue("Exit", out methodName)) { DrawReadonlyTextField("Exit", methodName); } if (StateMethods.TryGetValue("Finally", out methodName)) { DrawReadonlyTextField("Finally", methodName); } } }
/// <remarks>Helper method.</remarks> protected void AnimationDidChange(UpdateContext updateContext) { var triggers = currentAnimation.TriggersThisTick(); if (triggers != null) { StateMethods.AnimationTriggers(this, triggers, updateContext); } var cue = updateContext.Definitions.GetCue(currentAnimation.CueThisTick(), this); if (cue != null) { updateContext.PlayCueWorld(cue, this); } }
/// <summary>Set a state from a previously found state object. Not for general use.</summary> public void _DirectlySetState(State nextState, TUpdateContext updateContext, bool allowStateRestart) { if (!allowStateRestart && ReferenceEquals(CurrentState, nextState)) { return; // Don't re-enter the same state } if (StateMethods.EndState != null) { StateMethods.EndState(this, updateContext, nextState); } State previousState = CurrentState; CurrentState = nextState; if (StateMethods.BeginState != null) { StateMethods.BeginState(this, updateContext, previousState); } }
// static IDictionary <Enum, HashSet <Transition> > BuildTransitions(TypeBuilder typeBuilder, Type machineType, Type stateType) { var methods = StateMethods.GetStateMethods(machineType); var transitions = new Dictionary <Enum, HashSet <Transition> >(7); for (int i = 0; i < methods.Length; i++) { Enum state = (Enum)StateExtension.GetStateCore(methods[i], stateType); HashSet <Transition> actions; if (!transitions.TryGetValue(state, out actions)) { actions = new HashSet <Transition>(); transitions.Add(state, actions); } var info = new Transition(methods[i].MetadataToken); if (!actions.Contains(info)) { info.Method = CreateTransition(typeBuilder, methods[i]); actions.Add(info); } } return(transitions); }
public void Test00_GetStateMethods() { var methods = StateMethods.GetStateMethods(typeof(Machine)); Assert.AreEqual(1, methods.Length); }