public override void AddTransitions() { FSMTransition transition = null; transition = new FSMTransition(EffectStates.CREATE.ToS(), EffectStates.DESTROY.ToS()); transition.AddCondition(new TimeCondition(this.timeToLive)); this.controller.fsm.RegisterTransition(transition); }
public override void AddTransitions() { this.AddTransitionsTo(CharStates.BLOCK.ToS(), CharStates.IDLE.ToS(), CharStates.MOVE.ToS(), CharStates.FLY.ToS()); //// RELEASE FSMTransition transition = null; transition = new FSMTransition(CharStates.BLOCK.ToS(), CharStates.BLOCK.ToS(Suffixes.Release)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.FromInputMode(this.input), new InputCondition(CharVars.FromInputMode(this.input).ToS(), Operators.EQUAL, InputModes.RELEASE, InputModes.NONE)) .Build() ); this.controller.fsm.RegisterTransition(transition); transition = new FSMTransition(CharStates.BLOCK.ToS(Suffixes.Release), CharStates.FLY.ToS()); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, true)) .Build() ); transition.AddCondition(new AnimationEndCondition(this.targetObject.GetComponent<Animator>(), CharStates.BLOCK.ToS(Suffixes.Release))); this.controller.fsm.RegisterTransition(transition); transition = new FSMTransition(CharStates.BLOCK.ToS(Suffixes.Release), CharStates.IDLE.ToS()); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, false)) .Build() ); transition.AddCondition(new AnimationEndCondition(this.targetObject.GetComponent<Animator>(), CharStates.BLOCK.ToS(Suffixes.Release))); this.controller.fsm.RegisterTransition(transition); }
public override void AddTransitions() { FSMTransition transition = null; // // KNOCKBACK RECOVER // transition = new FSMTransition(CharStates.GET_HIT.ToS(Suffixes.Knockback), CharStates.GET_HIT.ToS(Suffixes.Knockback, Suffixes.Recover)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.HIT_GROUND, new BoolCondition(CharVars.HIT_GROUND.ToS(), Operators.EQUAL, false)) .WithVar(CharVars.GENERIC_COUNTER, new IntCondition(CharVars.GENERIC_COUNTER.ToS(), Operators.EQUAL, this.knockbackRecoverCount)) .Build() ); this.controller.fsm.RegisterTransition(transition); transition = new FSMTransition(CharStates.GET_HIT.ToS(Suffixes.Knockback, Suffixes.Recover), CharStates.FLY.ToS()); transition.AddCondition(new TimeCondition(this.knockbackRecoverDuration)); this.controller.fsm.RegisterTransition(transition); // // DOWN RECOVER // transition = new FSMTransition(CharStates.GET_HIT.ToS(Suffixes.Knockback), CharStates.GET_HIT.ToS(Suffixes.Down, Suffixes.Recover)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.HIT_GROUND, new BoolCondition(CharVars.HIT_GROUND.ToS(), Operators.EQUAL, true)) .WithVar(CharVars.GENERIC_COUNTER, new IntCondition(CharVars.GENERIC_COUNTER.ToS(), Operators.EQUAL, this.knockbackRecoverCount)) .Build() ); this.controller.fsm.RegisterTransition(transition); transition = new FSMTransition(CharStates.GET_HIT.ToS(Suffixes.Down, Suffixes.Recover), CharStates.CROUCH.ToS()); transition.AddCondition(new TimeCondition(this.downRecoverDuration)); this.controller.fsm.RegisterTransition(transition); }
public override void AddTransitions() { FSMTransition transition = null; transition = new FSMTransition(CharStates.BLOCK.ToS(), CharStates.BLOCK.ToS(Suffixes.Hit)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.DAMAGE_EFFECT, new IntCondition(CharVars.DAMAGE_EFFECT.ToS(), Operators.EQUAL, (int)AttackEffects.HIT)) .Build() ); this.controller.fsm.RegisterTransition(transition); transition = new FSMTransition(CharStates.BLOCK.ToS(Suffixes.Hit), CharStates.BLOCK.ToS()); transition.AddCondition(new AnimationEndCondition(this.targetObject.GetComponent<Animator>(), CharStates.BLOCK.ToS())); this.controller.fsm.RegisterTransition(transition); }
public override void AddTransitions() { FSMTransition transition = null; // // DOWN // transition = new FSMTransition(CharStates.GET_HIT.ToS(Suffixes.Down), CharStates.GET_HIT.ToS(Suffixes.Down, Suffixes.Up)); transition.AddCondition(new TimeCondition(this.downDuration)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.JUMP_MODE, new InputCondition(CharVars.JUMP_MODE.ToS(), Operators.EQUAL, InputModes.PRESS, InputModes.DOUBLE_TAP)) .Build() ); this.controller.fsm.RegisterTransition(transition); // // GET UP // transition = new FSMTransition(CharStates.GET_HIT.ToS(Suffixes.Down, Suffixes.Up), CharStates.CROUCH.ToS()); transition.AddCondition(new AnimationEndCondition(this.targetObject.GetComponent<Animator>(), CharStates.GET_HIT.ToS(Suffixes.Down, Suffixes.Up))); this.controller.fsm.RegisterTransition(transition); }
public override void AddTransitions() { FSMTransition transition = null; this.AddTransitionsTo(CharStates.CROUCH.ToS(), CharStates.IDLE.ToS(), CharStates.MOVE.ToS()); transition = new FSMTransition(CharStates.CROUCH.ToS(), CharStates.STAND.ToS()); transition.AddCondition(new AnimationEndCondition(this.targetObject.GetComponent<Animator>(), CharStates.CROUCH.ToS())); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.VERTICAL_MODE, new InputCondition(CharVars.VERTICAL_MODE.ToS(), Operators.EQUAL, InputModes.RELEASE, InputModes.NONE)) .Build() ); this.controller.fsm.RegisterTransition(transition); transition = new FSMTransition(CharStates.CROUCH.ToS(), CharStates.STAND.ToS()); transition.AddCondition(new AnimationEndCondition(this.targetObject.GetComponent<Animator>(), CharStates.CROUCH.ToS())); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.VERTICAL_VALUE, new FloatCondition(CharVars.VERTICAL_VALUE.ToS(), Operators.GREATER_THAN, -0.1f)) .Build() ); this.controller.fsm.RegisterTransition(transition); transition = new FSMTransition(CharStates.STAND.ToS(), CharStates.IDLE.ToS()); transition.AddCondition(new AnimationEndCondition(this.targetObject.GetComponent<Animator>(), CharStates.STAND.ToS())); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.HORIZONTAL_MODE, new InputCondition(CharVars.HORIZONTAL_MODE.ToS(), Operators.EQUAL, InputModes.RELEASE, InputModes.NONE)) .Build() ); this.controller.fsm.RegisterTransition(transition); transition = new FSMTransition(CharStates.STAND.ToS(), CharStates.MOVE.ToS()); transition.AddCondition(new AnimationEndCondition(this.targetObject.GetComponent<Animator>(), CharStates.STAND.ToS())); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.HORIZONTAL_MODE, new InputCondition(CharVars.HORIZONTAL_MODE.ToS(), Operators.EQUAL, InputModes.PRESS, InputModes.HOLD)) .Build() ); this.controller.fsm.RegisterTransition(transition); }
private StateWrapper BuildPursuit() { StateWrapper stateWrapper = new StateWrapper(); FSMState state = new ActionState(this.stateName); state.WithDefaultBehaviours(this.gameObject); if (this.animationBehaviour != null) { state.AddStartBehaviour(this.animationBehaviour); } state.AddStartBehaviour(new VariableCalculatorBehaviour(this.gameObject, CharVars.SPEED_MULTIPLIER.ToS()).Add(this.speedIncrease)); if (this.counterVariable != null) { state.AddStartBehaviour(new VariableCalculatorBehaviour(this.gameObject, this.counterVariable.ToS()).Add(1)); } state.AddStartBehaviour(new SetVariableBehaviour(this.gameObject, CharVars.IGNORE_DRAG.ToS(), true)); foreach (FSMBehaviour behaviour in this.customStartBehaviours) { state.AddStartBehaviour(behaviour); } foreach (FSMBehaviour behaviour in this.customUpdateBehaviours) { state.AddUpdateBehaviour(behaviour); } MoveTowardsBehaviour moveTowardsBehaviour = BehavioursBuilder.BuildMoveTowards(this.gameObject, true, true); if (this.target != null) { moveTowardsBehaviour = moveTowardsBehaviour.WithTarget(this.target); } if (this.targetVariable != null) { moveTowardsBehaviour = moveTowardsBehaviour.WithTargetVariable(this.targetVariable); } state.AddUpdateBehaviour(moveTowardsBehaviour); state.AddUpdateBehaviour(BehavioursBuilder.BuildKeepInsideBounds(this.gameObject, true, true)); foreach (ComboWrapper combo in this.combos.Values) { SetVariableBehaviour behaviour = new SetVariableBehaviour(this.gameObject, CharVars.COMBO_VARIANT.ToS(), combo.variant); foreach (ICondition condition in combo.conditions) { behaviour = behaviour.WithCondition(condition); } state.AddUpdateBehaviour(behaviour); } state.AddExitBehaviour(new VariableCalculatorBehaviour(this.gameObject, CharVars.SPEED_MULTIPLIER.ToS()).Subtract(this.speedIncrease)); state.AddExitBehaviour(new SetVariableBehaviour(this.gameObject, CharVars.IGNORE_DRAG.ToS(), false)); foreach (FSMBehaviour behaviour in this.customExitBehaviours) { state.AddExitBehaviour(behaviour); } stateWrapper.state = state; //TRANSITIONS FSMTransition transition = null; foreach (string startingState in this.startingStates) { transition = new FSMTransition(startingState, this.stateName); VarConditionsBuilder builder = new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.FromInputMode(this.input), new InputCondition(CharVars.FromInputMode(this.input).ToS(), Operators.EQUAL, InputModes.PRESS, InputModes.DOUBLE_TAP)) .WithVar(CharVars.TARGET, new ObjectCondition(this.targetVariable)); if (this.counterVariable != null) { builder = builder.WithVar(this.counterVariable, new IntCondition(this.counterVariable.ToS(), Operators.LESS_THAN, this.maxPursuits)); } transition.AddConditions(builder.Build()); stateWrapper.transitions.Add(transition); } //RETURN foreach (string animationName in this.animationNames) { foreach (ComboWrapper combo in this.combos.Values) { transition = new FSMTransition(this.stateName, combo.toState); transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.COMBO_VARIANT, new IntCondition(CharVars.COMBO_VARIANT.ToS(), Operators.EQUAL, combo.variant)) .Build() ); stateWrapper.transitions.Add(transition); } } transition = new FSMTransition(this.stateName, CharStates.FALL.ToS()); transition.AddCondition(new TimeCondition(this.timeout)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, false)) .Build() ); stateWrapper.transitions.Add(transition); transition = new FSMTransition(this.stateName, CharStates.FLY.ToS()); transition.AddCondition(new TimeCondition(this.timeout)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, true)) .Build() ); stateWrapper.transitions.Add(transition); return stateWrapper; }
private StateWrapper BuildWait() { StateWrapper stateWrapper = new StateWrapper(); FSMState state = new ActionState(this.waitStateName); state.WithDefaultBehaviours(this.gameObject); if (this.waitAnimationBehaviour != null) { state.AddStartBehaviour(this.waitAnimationBehaviour); } state.AddStartBehaviour(new StopMovementBehaviour(this.gameObject).WithXAxis().WithYAxis()); state.AddStartBehaviour(new IgnoreGravityBehaviour(this.gameObject)); state.AddStartBehaviour(new SetVariableBehaviour(this.gameObject, CharVars.IGNORE_DRAG.ToS(), false)); if (this.flip) { state.AddStartBehaviour(BehavioursBuilder.BuildFlip(this.gameObject, false).Invert()); } foreach (FSMBehaviour behaviour in this.customStartBehaviours) { state.AddStartBehaviour(behaviour); } foreach (FSMBehaviour behaviour in this.customUpdateBehaviours) { state.AddUpdateBehaviour(behaviour); } state.AddUpdateBehaviour(BehavioursBuilder.BuildKeepInsideBounds(this.gameObject, true, true)); foreach (ComboWrapper combo in this.combos.Values) { SetVariableBehaviour behaviour = new SetVariableBehaviour(this.gameObject, CharVars.COMBO_VARIANT.ToS(), combo.variant); foreach (ICondition condition in combo.conditions) { behaviour = behaviour.WithCondition(condition); } state.AddUpdateBehaviour(behaviour); } state.AddExitBehaviour(new RestoreGravityBehaviour(this.gameObject, CharVars.ORIGINAL_GRAVITY_SCALE.ToS())); foreach (FSMBehaviour behaviour in this.customExitBehaviours) { state.AddExitBehaviour(behaviour); } stateWrapper.state = state; //TRANSITIONS FSMTransition transition = null; foreach (string animationName in this.animationNames) { transition = new FSMTransition(this.stateName, this.waitStateName); transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName)); stateWrapper.transitions.Add(transition); } //RETURN foreach (ComboWrapper combo in this.combos.Values) { transition = new FSMTransition(this.waitStateName, combo.toState); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.COMBO_VARIANT, new IntCondition(CharVars.COMBO_VARIANT.ToS(), Operators.EQUAL, combo.variant)) .Build() ); stateWrapper.transitions.Add(transition); } transition = new FSMTransition(this.waitStateName, CharStates.FALL.ToS()); transition.AddCondition(new TimeCondition(this.timeout)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, false)) .Build() ); stateWrapper.transitions.Add(transition); transition = new FSMTransition(this.waitStateName, CharStates.FLY.ToS()); transition.AddCondition(new TimeCondition(this.timeout)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, true)) .Build() ); stateWrapper.transitions.Add(transition); return stateWrapper; }
private StateWrapper BuildTeleport() { StateWrapper stateWrapper = new StateWrapper(); FSMState state = new ActionState(this.stateName); state.WithDefaultBehaviours(this.gameObject); if (this.animationBehaviour != null) { state.AddStartBehaviour(this.animationBehaviour); } if (this.counterVariable != null) { state.AddStartBehaviour(new VariableCalculatorBehaviour(this.gameObject, this.counterVariable.ToS()).Add(1)); } if (this.flip && this.waitStateName == null) { state.AddStartBehaviour(BehavioursBuilder.BuildFlip(this.gameObject, false).Invert()); } if (this.soundStart != null) { state.AddStartBehaviour(new PlaySoundBehaviour(this.gameObject, this.soundStart).Force()); } if (this.effectStart != null) { state.AddStartBehaviour(new InstantiateBehaviour(this.gameObject, this.effectStart)); } foreach (FSMBehaviour behaviour in this.customStartBehaviours) { state.AddStartBehaviour(behaviour); } if (this.soundUpdate != null) { state.AddUpdateBehaviour(new PlaySoundBehaviour(this.gameObject, this.soundUpdate)); state.AddExitBehaviour(new StopSoundBehaviour(this.gameObject, this.soundUpdate)); } if (this.effectUpdate != null) { state.AddUpdateBehaviour(new InstantiateBehaviour(this.gameObject, this.effectUpdate)); } foreach (FSMBehaviour behaviour in this.customUpdateBehaviours) { state.AddUpdateBehaviour(behaviour); } state.AddUpdateBehaviour(BehavioursBuilder.BuildKeepInsideBounds(this.gameObject, true, true)); if (this.waitStateName == null) { foreach (ComboWrapper combo in this.combos.Values) { SetVariableBehaviour behaviour = new SetVariableBehaviour(this.gameObject, CharVars.COMBO_VARIANT.ToS(), combo.variant); foreach (ICondition condition in combo.conditions) { behaviour = behaviour.WithCondition(condition); } state.AddUpdateBehaviour(behaviour); } } TeleportToBehaviour teleportToBehaviour = new TeleportToBehaviour(this.gameObject, this.obstacles).TeleportAhead(this.distance); if (this.target != null) { teleportToBehaviour = teleportToBehaviour.WithTarget(this.target); } if (this.targetVariable != null) { teleportToBehaviour = teleportToBehaviour.WithTargetVariable(this.targetVariable); } state.AddExitBehaviour(teleportToBehaviour); foreach (FSMBehaviour behaviour in this.customExitBehaviours) { state.AddExitBehaviour(behaviour); } if (this.soundExit != null) { state.AddExitBehaviour(new PlaySoundBehaviour(this.gameObject, this.soundExit).Force()); } if (this.effectExit != null) { state.AddExitBehaviour(new InstantiateBehaviour(this.gameObject, this.effectExit)); } stateWrapper.state = state; //TRANSITIONS FSMTransition transition = null; foreach (string startingState in this.startingStates) { transition = new FSMTransition(startingState, this.stateName); VarConditionsBuilder builder = new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.FromInputMode(this.input), new InputCondition(CharVars.FromInputMode(this.input).ToS(), Operators.EQUAL, InputModes.PRESS, InputModes.DOUBLE_TAP)) .WithVar(CharVars.TARGET, new ObjectCondition(this.targetVariable)); if (this.counterVariable != null) { builder = builder.WithVar(this.counterVariable, new IntCondition(this.counterVariable.ToS(), Operators.LESS_THAN, this.maxTeleports)); } transition.AddConditions(builder.Build()); stateWrapper.transitions.Add(transition); } //RETURN if (this.waitStateName == null) { foreach (string animationName in this.animationNames) { foreach (ComboWrapper combo in this.combos.Values) { transition = new FSMTransition(this.stateName, combo.toState); transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.COMBO_VARIANT, new IntCondition(CharVars.COMBO_VARIANT.ToS(), Operators.EQUAL, combo.variant)) .Build() ); stateWrapper.transitions.Add(transition); } } transition = new FSMTransition(this.stateName, CharStates.FALL.ToS()); transition.AddCondition(new TimeCondition(this.timeout)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, false)) .Build() ); stateWrapper.transitions.Add(transition); transition = new FSMTransition(this.stateName, CharStates.FLY.ToS()); transition.AddCondition(new TimeCondition(this.timeout)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, true)) .Build() ); stateWrapper.transitions.Add(transition); } return stateWrapper; }
public override void AddTransitions() { FSMTransition transition = null; // // HIT // foreach (string startingState in CharStates.All()) { transition = new FSMTransition(startingState, CharStates.GET_HIT.ToS(Suffixes.Hit)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.DAMAGE_EFFECT, new IntCondition(CharVars.DAMAGE_EFFECT.ToS(), Operators.EQUAL, (int)AttackEffects.HIT)) .WithVar(CharVars.IS_BLOCKING, new BoolCondition(CharVars.IS_BLOCKING.ToS(), Operators.EQUAL, false)) .Build() ); this.controller.fsm.RegisterTransition(transition); } transition = new FSMTransition(CharStates.GET_HIT.ToS(Suffixes.Hit), CharStates.IDLE.ToS()); transition.AddCondition(new AnimationEndCondition(this.targetObject.GetComponent<Animator>(), CharStates.GET_HIT.ToS(Suffixes.Hit))); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, false)) .Build() ); transition.AddCondition(new TimeCondition(this.hitDuration)); this.controller.fsm.RegisterTransition(transition); transition = new FSMTransition(CharStates.GET_HIT.ToS(Suffixes.Hit), CharStates.FLY.ToS()); transition.AddCondition(new AnimationEndCondition(this.targetObject.GetComponent<Animator>(), CharStates.GET_HIT.ToS(Suffixes.Hit))); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, true)) .Build() ); transition.AddCondition(new TimeCondition(this.hitDuration)); this.controller.fsm.RegisterTransition(transition); }
private StateWrapper BuildAttack() { StateWrapper stateWrapper = new StateWrapper(); FSMState state = new ActionState(this.stateName); state.WithDefaultBehaviours(this.gameObject); if (this.animationBehaviour != null) { state.AddStartBehaviour(this.animationBehaviour); } state.AddStartBehaviour(new SetVariableBehaviour(this.gameObject, CharVars.ATTACK_EFFECT.ToS(), (int) AttackEffects.NONE)); if (this.stepForce != 0) { state.AddStartBehaviour( new ApplyForceBehaviour(this.gameObject) .WithDirection(new Vector2(1f, 0f)) .WithForce(this.stepForce) .WithRelativeXDirection(CharVars.FACING_DIRECTION.ToS(), false) ); } foreach (ComboWrapper combo in this.combos.Values) { SetVariableBehaviour behaviour = new SetVariableBehaviour(this.gameObject, CharVars.COMBO_VARIANT.ToS(), combo.variant); foreach (ICondition condition in combo.conditions) { behaviour = behaviour.WithCondition(condition); } state.AddUpdateBehaviour(behaviour); } foreach (FSMBehaviour behaviour in this.customStartBehaviours) { state.AddStartBehaviour(behaviour); } foreach (FSMBehaviour behaviour in this.customUpdateBehaviours) { state.AddUpdateBehaviour(behaviour); } foreach (FSMBehaviour behaviour in this.customExitBehaviours) { state.AddExitBehaviour(behaviour); } stateWrapper.state = state; FSMTransition transition = null; foreach (string startingState in this.startingStates) { transition = new FSMTransition(startingState, this.stateName); VarConditionsBuilder conditions = new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat(); if (this.fromCharge) { conditions.WithVar(CharVars.FromInputMode(this.input), new InputCondition(CharVars.FromInputMode(this.input).ToS(), Operators.EQUAL, InputModes.RELEASE, InputModes.NONE)); } else { conditions.WithVar(CharVars.FromInputMode(this.input), new InputCondition(CharVars.FromInputMode(this.input).ToS(), Operators.EQUAL, InputModes.PRESS, InputModes.DOUBLE_TAP)); } foreach (CharVar charVar in this.customTransitions.Keys) { conditions.WithVar(charVar, this.customTransitions[charVar]); } transition.AddConditions(conditions.Build()); stateWrapper.transitions.Add(transition); } // // RETURN foreach (string animationName in this.animationNames) { foreach (ComboWrapper combo in this.combos.Values) { transition = new FSMTransition(this.stateName, combo.toState); transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.COMBO_VARIANT, new IntCondition(CharVars.COMBO_VARIANT.ToS(), Operators.EQUAL, combo.variant)) .Build() ); stateWrapper.transitions.Add(transition); } transition = new FSMTransition(this.stateName, CharStates.IDLE.ToS()); transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, false)) .Build() ); stateWrapper.transitions.Add(transition); transition = new FSMTransition(this.stateName, CharStates.FLY.ToS()); transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName)); transition.AddConditions( new VarConditionsBuilder() .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat() .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, true)) .Build() ); stateWrapper.transitions.Add(transition); } return stateWrapper; }