Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Neutral : AnimalAIBehaviour
- {
- private readonly Infrastructure _infrastructure;
- private readonly TriggersContainer _triggersContainer;
- private readonly IState _idle;
- private readonly IState _patrol;
- private readonly IState _chase;
- private readonly IState _attack;
- public Neutral(StateFactory factory, IStateMachineOwner stateMachineOwner,
- TargetProviderContainer targetProviderContainer, AnimalReferences references,
- AnimalInfrastructure animalInfrastructure, Infrastructure infrastructure,
- TriggersContainer triggersContainer) :
- base
- (
- new StateMachine(owner: stateMachineOwner, debug: animalInfrastructure.Debug.Neutral),
- references,
- targetProviderContainer
- )
- {
- _infrastructure = infrastructure;
- _triggersContainer = triggersContainer;
- _idle = factory.Create(typeof(Idle));
- _patrol = factory.Create(typeof(Patrol));
- _chase = factory.Create(typeof(Chase));
- _attack = factory.Create(typeof(Attack));
- }
- protected override IState StartState => _idle;
- protected override void ConfigTransitions(StateMachine stateMachine)
- {
- stateMachine.AddTransition(_idle, _patrol, _triggersContainer.Get(Triggers.WaitEnded));
- stateMachine.AddTransition(_idle, _chase, _triggersContainer.Get(Triggers.Damaged));
- stateMachine.AddTransition(_patrol, _chase, _triggersContainer.Get(Triggers.Damaged));
- stateMachine.AddTransition(_patrol, _idle, _triggersContainer.Get(Triggers.DestinationReached));
- stateMachine.AddTransition(_chase, _attack, _triggersContainer.Get(Triggers.TargetArrived));
- stateMachine.AddTransition(_chase, _idle, _triggersContainer.Get(Triggers.TargetLost));
- stateMachine.AddTransition(_attack, _chase, _triggersContainer.Get(Triggers.TargetIsFled));
- stateMachine.AddTransition(_attack, _idle, _triggersContainer.Get(Triggers.TargetDead));
- }
- private Triggers Triggers => _infrastructure.Triggers;
- }
Advertisement
Add Comment
Please, Sign In to add comment