diff --git a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/AI/BrainsFactory.cs b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/AI/BrainsFactory.cs index 7b36391..75c4553 100644 --- a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/AI/BrainsFactory.cs +++ b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/AI/BrainsFactory.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using _Project.Develop.Runtime.Entities; using _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States; -using _Project.Develop.Runtime.Logic.Gameplay.Features.Selectors; using _Project.Develop.Runtime.Utilities.Conditions; using _Project.Develop.Runtime.Utils.InputManagement; using _Project.Develop.Runtime.Utils.ReactiveManagement; @@ -56,6 +55,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI AIParallelState parallelState = new (findTargetState, teleportStateMachine); AIStateMachine rootStateMachine = new (); + rootStateMachine.AddState(parallelState); StateMachineBrain brain = new (rootStateMachine); @@ -157,9 +157,10 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI return stateMachine; } + // На сколько хорошая идея дробить на маленькие стейтмашины? private AIStateMachine CreateSteeringAttackStateMachine(Entity entity) { - AIStateMachine steeringState = CreateSteeringInputStateMachine(entity); + AIStateMachine steeringState = CreateSteeringInputStateMachine(entity); // просто это уже 3 по вложенности PlayerInputAttackTriggerState attackTriggerState = new (entity, _playerInput); AIParallelState parallelState = new (steeringState, attackTriggerState); diff --git a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/AI/States/PlayerInputAttackTriggerState.cs b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/AI/States/PlayerInputAttackTriggerState.cs index b82dd12..fccdac3 100644 --- a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/AI/States/PlayerInputAttackTriggerState.cs +++ b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/AI/States/PlayerInputAttackTriggerState.cs @@ -13,8 +13,12 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States public PlayerInputAttackTriggerState(Entity entity, IPlayerInput playerInput) { _playerInput = playerInput; - _request = entity.StartAttackRequest; + } + + public override void Enter() + { + base.Enter(); _playerInput.Attack.Enter += OnAttack; } diff --git a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Infrastructure/TestGameplay.cs b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Infrastructure/TestGameplay.cs index 9b21852..b7d7a6d 100644 --- a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Infrastructure/TestGameplay.cs +++ b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Infrastructure/TestGameplay.cs @@ -30,8 +30,8 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features _hero = _entitiesFactory.CreateHero(Vector3.zero); _brainsFactory.CreateMainHeroBrain(_hero); - // _enemy = _entitiesFactory.CreateTeleportWizard(Vector3.zero + Vector3.forward * 5); - // _brainsFactory.CreateDangerWizardBrain(_enemy, new LowestHealthTargetSelector(_enemy)); + _enemy = _entitiesFactory.CreateTeleportWizard(Vector3.zero + Vector3.forward * 5); + _brainsFactory.CreateDangerWizardBrain(_enemy, new LowestHealthTargetSelector(_enemy)); } public void Run() diff --git a/Assets/_Project/Develop/Runtime/Utilities/StatesManagement/StateMachine.cs b/Assets/_Project/Develop/Runtime/Utilities/StatesManagement/StateMachine.cs index d136db1..475eb32 100644 --- a/Assets/_Project/Develop/Runtime/Utilities/StatesManagement/StateMachine.cs +++ b/Assets/_Project/Develop/Runtime/Utilities/StatesManagement/StateMachine.cs @@ -73,6 +73,8 @@ namespace Assets._Project.Develop.Runtime.Utilities.StateMachineCore if (_currentState == null) SwitchState(_states[0]); + else + _currentState.State.Enter(); _isRunning = true; }