mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-03-05 07:41:10 +00:00
feat: add random auto teleport state
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _Project.Develop.Runtime.Utilities.Conditions;
|
||||
using _Project.Develop.Runtime.Utils.InputManagement.States;
|
||||
using Assets._Project.Develop.Runtime.Infrastructure.DI;
|
||||
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
|
||||
|
||||
namespace _Project.Develop.Runtime.Utils.InputManagement
|
||||
{
|
||||
public class InputStateMachine : StateMachine<IState>, IInitializable, IDisposable
|
||||
{
|
||||
private readonly IPlayerInput _playerInput;
|
||||
private readonly IUIInput _uiInput;
|
||||
|
||||
public InputStateMachine(List<IDisposable> disposables) : base(disposables)
|
||||
{ }
|
||||
|
||||
public InputStateMachine(DIContainer container) : base(new List<IDisposable>())
|
||||
{
|
||||
_playerInput = container.Resolve<IPlayerInput>();
|
||||
_uiInput = container.Resolve<IUIInput>();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
PlayerInputState playerInputState = new(_playerInput);
|
||||
UIInputState uiInputState = new(_uiInput);
|
||||
|
||||
ICompositeCondition playerToUiStateCondition = new CompositeCondition(LogicOperationsUtils.Or)
|
||||
.Add(new FuncCondition(() => _uiInput.IsEnabled));
|
||||
// .Add(new FuncCondition(() => _playerHorseInput.IsEnabled));
|
||||
|
||||
ICompositeCondition uiToPlayerStateCondition = new CompositeCondition(LogicOperationsUtils.Or)
|
||||
.Add(new FuncCondition(() => _playerInput.IsEnabled));
|
||||
// .Add(new FuncCondition(() => _playerHorseInput.IsEnabled));
|
||||
|
||||
AddState(playerInputState);
|
||||
AddState(uiInputState);
|
||||
|
||||
AddTransition(playerInputState, uiInputState, playerToUiStateCondition);
|
||||
AddTransition(uiInputState, playerInputState, uiToPlayerStateCondition);
|
||||
|
||||
Enter();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1a3543621b74566aa3f737018932731
|
||||
timeCreated: 1772547242
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60ce6781167b4204a72055d939441a5b
|
||||
timeCreated: 1772547589
|
||||
@@ -0,0 +1,26 @@
|
||||
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
|
||||
|
||||
namespace _Project.Develop.Runtime.Utils.InputManagement.States
|
||||
{
|
||||
public class PlayerInputState : State
|
||||
{
|
||||
private readonly IPlayerInput _playerInput;
|
||||
|
||||
public PlayerInputState(IPlayerInput playerInput)
|
||||
{
|
||||
_playerInput = playerInput;
|
||||
}
|
||||
|
||||
public override void Enter()
|
||||
{
|
||||
base.Enter();
|
||||
_playerInput.Enable();
|
||||
}
|
||||
|
||||
public override void Exit()
|
||||
{
|
||||
_playerInput.Disable();
|
||||
base.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0efa0cca886c45e295d4adcb82d59f8b
|
||||
timeCreated: 1770556305
|
||||
@@ -0,0 +1,26 @@
|
||||
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
|
||||
|
||||
namespace _Project.Develop.Runtime.Utils.InputManagement.States
|
||||
{
|
||||
public class UIInputState : State
|
||||
{
|
||||
private readonly IUIInput _uiInput;
|
||||
|
||||
public UIInputState(IUIInput uiInput)
|
||||
{
|
||||
_uiInput = uiInput;
|
||||
}
|
||||
|
||||
public override void Enter()
|
||||
{
|
||||
base.Enter();
|
||||
_uiInput.Enable();
|
||||
}
|
||||
|
||||
public override void Exit()
|
||||
{
|
||||
_uiInput.Disable();
|
||||
base.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cac35b3aedd43b1959f82e36c30ac47
|
||||
timeCreated: 1770556297
|
||||
Reference in New Issue
Block a user