Example #1
0
        // IActionStateMachineInterface
        public virtual void RequestActionState(EActionStateMachineTrack selectedTrack, EActionStateId inId, ActionStateInfo inInfo)
        {
            var newState = Creator.CreateActionState(inId, inInfo);

            ActiveActionStates[selectedTrack].End();
            ActiveActionStates[selectedTrack] = newState;
            newState.Start();
        }
        public void RequestActionState_SetsTrackToNewIdAndIsActionStateActiveReturnsTrue()
        {
            const EActionStateId           expectedStateId = EActionStateId.Locomotion;
            const EActionStateMachineTrack changedTrack    = EActionStateMachineTrack.Locomotion;

            _actionStateMachineComponent.RequestActionState(changedTrack, expectedStateId, new ActionStateInfo());

            Assert.IsTrue(_actionStateMachineComponent.IsActionStateActiveOnTrack(changedTrack, expectedStateId));
        }
        public void IsActionStateActiveOnTrack_CorrectTrackWrongId_False()
        {
            const EActionStateId           wrongId         = EActionStateId.Null;
            const EActionStateId           expectedStateId = EActionStateId.Locomotion;
            const EActionStateMachineTrack changedTrack    = EActionStateMachineTrack.Locomotion;

            _actionStateMachineComponent.RequestActionState(changedTrack, expectedStateId, new ActionStateInfo());

            Assert.IsFalse(_actionStateMachineComponent.IsActionStateActiveOnTrack(changedTrack, wrongId));
        }
        public void Update_CallsUpdateOnActionState()
        {
            const EActionStateMachineTrack track = EActionStateMachineTrack.Locomotion;

            _actionStateMachineComponent.RequestActionState(track, EActionStateId.Locomotion, new ActionStateInfo());

            var actionState = (TestActionState)_actionStateMachineComponent.GetActionStateOnTrack(track);

            _actionStateMachineComponent.TestUpdate();

            Assert.IsTrue(actionState.OnUpdateCalled);
            Assert.AreEqual(actionState.OnUpdateValue, Time.deltaTime);
        }
        public void RequestActionState_SetsCallsEndOnPriorActionStateAndStartOnNewOne()
        {
            const EActionStateId           newStateId   = EActionStateId.Null;
            const EActionStateId           oldStateId   = EActionStateId.Locomotion;
            const EActionStateMachineTrack changedTrack = EActionStateMachineTrack.Locomotion;

            _actionStateMachineComponent.RequestActionState(changedTrack, oldStateId, new ActionStateInfo());
            var oldActionState = (TestActionState)_actionStateMachineComponent.GetActionStateOnTrack(changedTrack);

            _actionStateMachineComponent.RequestActionState(changedTrack, newStateId, new ActionStateInfo());
            var newActionState = (TestActionState)_actionStateMachineComponent.GetActionStateOnTrack(changedTrack);

            Assert.IsTrue(oldActionState.OnEndCalled);
            Assert.IsTrue(newActionState.OnStartCalled);
        }
 public bool IsActionStateActiveOnTrack(EActionStateMachineTrack selectedTrack, EActionStateId expectedId)
 {
     IsActionStateActiveTrackQuery = selectedTrack;
     IsActionStateActiveIdQuery    = expectedId;
     return(IsActionStateActiveResult);
 }
 public void RequestActionState(EActionStateMachineTrack selectedTrack, EActionStateId inId, ActionStateInfo inInfo)
 {
     RequestedTrack = selectedTrack;
     RequestedId    = inId;
     RequestedInfo  = inInfo;
 }
Example #8
0
 public virtual bool IsActionStateActiveOnTrack(EActionStateMachineTrack selectedTrack, EActionStateId expectedId)
 {
     return(ActiveActionStates[selectedTrack].ActionStateId == expectedId);
 }
 public ActionState GetActionStateOnTrack(EActionStateMachineTrack inTrack)
 {
     return(ActiveActionStates[inTrack]);
 }