This commit is contained in:
Bragin Stepan
2026-02-19 23:19:33 +05:00
parent e07bde989a
commit 1174be2d43
70 changed files with 3307 additions and 591 deletions

View File

@@ -1,5 +1,7 @@
using _Project.Develop.Runtime.Logic.Gameplay.Features.Movement;
using _Project.Develop.Runtime.Utilities.InputManagement;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.Systems;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Movement;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using Assets._Project.Develop.Runtime.Utilities.SceneManagement;
@@ -11,13 +13,13 @@ namespace _Project.Develop.Runtime.Entities
{
private readonly EntitiesLifeContext _entitiesLifeContext;
private readonly MonoEntitiesFactory _monoEntitiesFactory;
private readonly IPlayerInputService _playerInput;
private readonly IPlayerInput _playerInput;
public EntitiesFactory(DIContainer container)
{
_entitiesLifeContext = container.Resolve<EntitiesLifeContext>();
_monoEntitiesFactory = container.Resolve<MonoEntitiesFactory>();
_playerInput = container.Resolve<IPlayerInputService>();
_playerInput = container.Resolve<IPlayerInput>();
}
public Entity CreateGhostEntity(Vector3 position)
@@ -25,18 +27,47 @@ namespace _Project.Develop.Runtime.Entities
Entity entity = CreateEmpty();
_monoEntitiesFactory.Create(entity, position, PathToResources.Entity.Ghost);
entity
.AddMoveDirection()
.AddRotateDirection()
.AddMoveSpeed(new ReactiveVariable<float>(10))
.AddRotationSpeed(new ReactiveVariable<float>(800));
.AddRotationSpeed(new ReactiveVariable<float>(800))
.AddMaxHealth(new ReactiveVariable<float>(150))
.AddCurrentHealth(new ReactiveVariable<float>(150))
.AddIsDead()
.AddIsMoving()
.AddInDeathProcess()
.AddDeathProcessInitialTime(new ReactiveVariable<float>(2))
.AddDeathProcessCurrentTime();
ICompositeCondition canMove = new CompositeCondition()
.Add(new FuncCondition(() => entity.IsDead.Value == false));
ICompositeCondition canRotate = new CompositeCondition()
.Add(new FuncCondition(() => entity.IsDead.Value == false));
ICompositeCondition mustDie = new CompositeCondition()
.Add(new FuncCondition(() => entity.CurrentHealth.Value <= 0));
ICompositeCondition mustSelfRelease = new CompositeCondition()
.Add(new FuncCondition(() => entity.IsDead.Value))
.Add(new FuncCondition(() => entity.InDeathProcess.Value == false));
entity
.AddCanMove(canMove)
.AddCanRotate(canRotate)
.AddMustDie(mustDie)
.AddMustSelfRelease(mustSelfRelease);
entity
.AddSystem(new RigidbodyMovementSystem())
.AddSystem(new RigidbodyRotationSystem())
.AddSystem(new MoveDirectionByInputSystem(_playerInput))
.AddSystem(new RotateDirectionByInputSystem(_playerInput));
.AddSystem(new RotateDirectionByInputSystem(_playerInput))
.AddSystem(new DeathSwitcherSystem())
.AddSystem(new DeathProcessTimerSystem())
.AddSystem(new SelfReleaseSystem(_entitiesLifeContext));
_entitiesLifeContext.Add(entity);

View File

@@ -78,6 +78,188 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new Assets._Project.Develop.Runtime.Gameplay.Common.NavMeshAgentComponent() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.CurrentHealth CurrentHealthC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.CurrentHealth>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> CurrentHealth => CurrentHealthC.Value;
public bool TryGetCurrentHealth(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.CurrentHealth component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddCurrentHealth()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.CurrentHealth() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>() });
}
public _Project.Develop.Runtime.Entities.Entity AddCurrentHealth(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.CurrentHealth() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MaxHealth MaxHealthC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MaxHealth>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> MaxHealth => MaxHealthC.Value;
public bool TryGetMaxHealth(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MaxHealth component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddMaxHealth()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MaxHealth() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>() });
}
public _Project.Develop.Runtime.Entities.Entity AddMaxHealth(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MaxHealth() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.IsDead IsDeadC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.IsDead>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> IsDead => IsDeadC.Value;
public bool TryGetIsDead(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.IsDead component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddIsDead()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.IsDead() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean>() });
}
public _Project.Develop.Runtime.Entities.Entity AddIsDead(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.IsDead() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MustDie MustDieC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MustDie>();
public _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition MustDie => MustDieC.Value;
public bool TryGetMustDie(out _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MustDie component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddMustDie(_Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MustDie() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MustSelfRelease MustSelfReleaseC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MustSelfRelease>();
public _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition MustSelfRelease => MustSelfReleaseC.Value;
public bool TryGetMustSelfRelease(out _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MustSelfRelease component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddMustSelfRelease(_Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.MustSelfRelease() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.DeathProcessInitialTime DeathProcessInitialTimeC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.DeathProcessInitialTime>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> DeathProcessInitialTime => DeathProcessInitialTimeC.Value;
public bool TryGetDeathProcessInitialTime(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.DeathProcessInitialTime component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddDeathProcessInitialTime()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.DeathProcessInitialTime() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>() });
}
public _Project.Develop.Runtime.Entities.Entity AddDeathProcessInitialTime(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.DeathProcessInitialTime() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.DeathProcessCurrentTime DeathProcessCurrentTimeC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.DeathProcessCurrentTime>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> DeathProcessCurrentTime => DeathProcessCurrentTimeC.Value;
public bool TryGetDeathProcessCurrentTime(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.DeathProcessCurrentTime component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddDeathProcessCurrentTime()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.DeathProcessCurrentTime() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>() });
}
public _Project.Develop.Runtime.Entities.Entity AddDeathProcessCurrentTime(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.DeathProcessCurrentTime() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.InDeathProcess InDeathProcessC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.InDeathProcess>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> InDeathProcess => InDeathProcessC.Value;
public bool TryGetInDeathProcess(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.InDeathProcess component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddInDeathProcess()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.InDeathProcess() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean>() });
}
public _Project.Develop.Runtime.Entities.Entity AddInDeathProcess(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.InDeathProcess() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveDirection MoveDirectionC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveDirection>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3> MoveDirection => MoveDirectionC.Value;
@@ -260,5 +442,24 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.JumpForce() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanJump CanJumpC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanJump>();
public _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition CanJump => CanJumpC.Value;
public bool TryGetCanJump(out _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanJump component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddCanJump(_Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanJump() {Value = value});
}
}
}

View File

@@ -1,5 +1,5 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.InputManagement;
using _Project.Develop.Runtime.Utils.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
@@ -7,11 +7,11 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class MoveDirectionByInputSystem : IInitializableSystem, IUpdatableSystem
{
private readonly IPlayerInputService _playerInput;
private readonly IPlayerInput _playerInput;
private ReactiveVariable<Vector3> _moveDirection;
public MoveDirectionByInputSystem(IPlayerInputService playerInput)
public MoveDirectionByInputSystem(IPlayerInput playerInput)
{
_playerInput = playerInput;
}
@@ -23,7 +23,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
public void OnUpdate(float deltaTime)
{
_moveDirection.Value = new Vector3(_playerInput.Move.x, 0, _playerInput.Move.y);
_moveDirection.Value = new Vector3(_playerInput.Move.Value.x, 0, _playerInput.Move.Value.y);
}
}
}

View File

@@ -1,5 +1,5 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.InputManagement;
using _Project.Develop.Runtime.Utils.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
@@ -7,11 +7,11 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class RotateDirectionByInputSystem : IInitializableSystem, IUpdatableSystem
{
private readonly IPlayerInputService _playerInput;
private readonly IPlayerInput _playerInput;
private ReactiveVariable<Vector3> _rotateDirection;
public RotateDirectionByInputSystem(IPlayerInputService playerInput)
public RotateDirectionByInputSystem(IPlayerInput playerInput)
{
_playerInput = playerInput;
}
@@ -23,7 +23,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
public void OnUpdate(float deltaTime)
{
_rotateDirection.Value = new Vector3(_playerInput.Move.x, 0, _playerInput.Move.y);
_rotateDirection.Value = new Vector3(_playerInput.Move.Value.x, 0, _playerInput.Move.Value.y);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ddecf634646849baa49d1c66e91377eb
timeCreated: 1771516009

View File

@@ -0,0 +1,17 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime
{
public class CurrentHealth : IEntityComponent { public ReactiveVariable<float> Value; }
public class MaxHealth : IEntityComponent { public ReactiveVariable<float> Value; }
public class IsDead : IEntityComponent { public ReactiveVariable<bool> Value; }
public class MustDie : IEntityComponent { public ICompositeCondition Value; }
public class MustSelfRelease : IEntityComponent { public ICompositeCondition Value; }
public class DeathProcessInitialTime : IEntityComponent { public ReactiveVariable<float> Value; }
public class DeathProcessCurrentTime : IEntityComponent { public ReactiveVariable<float> Value; }
public class InDeathProcess : IEntityComponent { public ReactiveVariable<bool> Value; }
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 82344af3543e4efabe4c37c4b0131ba0
timeCreated: 1771516021

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2bf2c15d48004f91a40b388b0c0f747a
timeCreated: 1771516038

View File

@@ -0,0 +1,55 @@
using System;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.Systems
{
public class DeathProcessTimerSystem : IInitializableSystem, IDisposableSystem, IUpdatableSystem
{
private ReactiveVariable<bool> _isDead;
private ReactiveVariable<bool> _inDeathProcess;
private ReactiveVariable<float> _initialTime;
private ReactiveVariable<float> _currentTime;
private IDisposable _isDeadChangedDisposable;
public void OnInit(Entity entity)
{
_isDead = entity.IsDead;
_inDeathProcess = entity.InDeathProcess;
_initialTime = entity.DeathProcessInitialTime;
_currentTime = entity.DeathProcessCurrentTime;
_isDeadChangedDisposable = _isDead.Subscribe(OnIsDeadChanged);
}
public void OnUpdate(float deltaTime)
{
if (_inDeathProcess.Value == false)
return;
_currentTime.Value -= deltaTime;
if (CooldownIsOver())
_inDeathProcess.Value = false;
}
public void OnDispose()
{
_isDeadChangedDisposable.Dispose();
}
private void OnIsDeadChanged(bool arg1, bool isDead)
{
if (isDead)
{
_currentTime.Value = _initialTime.Value;
_inDeathProcess.Value = true;
}
}
private bool CooldownIsOver() => _currentTime.Value <= 0;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 53e84735577342fda0ab4dc6a380d829
timeCreated: 1771517031

View File

@@ -0,0 +1,27 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.Systems
{
public class DeathSwitcherSystem : IInitializableSystem, IUpdatableSystem
{
private ReactiveVariable<bool> _isDead;
private ICompositeCondition _mustDie;
public void OnInit(Entity entity)
{
_isDead = entity.IsDead;
_mustDie = entity.MustDie;
}
public void OnUpdate(float deltaTime)
{
if (_isDead.Value)
return;
if(_mustDie.Evaluate())
_isDead.Value = true;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2bf6fb2218944c58b52d37f7039b95ae
timeCreated: 1771516295

View File

@@ -0,0 +1,31 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.Conditions;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.Systems
{
public class SelfReleaseSystem : IInitializableSystem, IUpdatableSystem
{
private readonly EntitiesLifeContext _entitiesLifeContext;
private Entity _entity;
private ICompositeCondition _mustSelfRelease;
public SelfReleaseSystem(EntitiesLifeContext entitiesLifeContext)
{
_entitiesLifeContext = entitiesLifeContext;
}
public void OnInit(Entity entity)
{
_entity = entity;
_mustSelfRelease = entity.MustSelfRelease;
}
public void OnUpdate(float deltaTime)
{
if (_mustSelfRelease.Evaluate())
_entitiesLifeContext.Release(_entity);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bbee24a3ed9e4e558158992dc929a348
timeCreated: 1771516662

View File

@@ -15,5 +15,6 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
public class CanRotate : IEntityComponent { public ICompositeCondition Value; }
public class JumpForce : IEntityComponent { public ReactiveVariable<float> Value; }
public class CanJump : IEntityComponent { public ICompositeCondition Value; }
}

View File

@@ -1,4 +1,5 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
@@ -9,18 +10,30 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
private ReactiveVariable<Vector3> _moveDirection;
private ReactiveVariable<float> _moveSpeed;
private CharacterController _controller;
private ReactiveVariable<bool> _isMoving;
private ICompositeCondition _canMove;
public void OnInit(Entity entity)
{
_moveDirection = entity.MoveDirection;
_moveSpeed = entity.MoveSpeed;
_controller = entity.CharacterController;
_isMoving = entity.IsMoving;
_canMove = entity.CanMove;
}
public void OnUpdate(float deltaTime)
{
if (_canMove.Evaluate() == false)
return;
Vector3 velocity = _moveDirection.Value.normalized * _moveSpeed.Value;
_isMoving.Value = velocity.magnitude > 0;
_controller.Move(velocity * deltaTime);
}
}

View File

@@ -1,4 +1,5 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
@@ -8,15 +9,21 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
private ReactiveVariable<float> _jumpForce;
private Rigidbody _rigidbody;
private ICompositeCondition _canJump;
public void OnInit(Entity entity)
{
_jumpForce = entity.JumpForce;
_rigidbody = entity.Rigidbody;
_canJump = entity.CanJump;
}
public void OnUpdate(float deltaTime)
{
if (_canJump.Evaluate() == false)
return;
_rigidbody.AddForce(Vector3.up * _jumpForce.Value, ForceMode.Impulse);
}
}

View File

@@ -1,4 +1,5 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
@@ -9,17 +10,32 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
private ReactiveVariable<Vector3> _moveDirection;
private ReactiveVariable<float> _moveSpeed;
private Rigidbody _rigidbody;
private ReactiveVariable<bool> _isMoving;
private ICompositeCondition _canMove;
public void OnInit(Entity entity)
{
_moveDirection = entity.MoveDirection;
_moveSpeed = entity.MoveSpeed;
_rigidbody = entity.Rigidbody;
_isMoving = entity.IsMoving;
_canMove = entity.CanMove;
}
public void OnUpdate(float deltaTime)
{
if (_canMove.Evaluate() == false)
{
_rigidbody.velocity = Vector3.zero;
return;
}
Vector3 velocity = _moveDirection.Value.normalized * _moveSpeed.Value;
_isMoving.Value = velocity.magnitude > 0;
_rigidbody.velocity = velocity;
}

View File

@@ -1,4 +1,5 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
@@ -10,16 +11,26 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
private ReactiveVariable<float> _speed;
private ReactiveVariable<Vector3> _direction;
private ICompositeCondition _canRotate;
public void OnInit(Entity entity)
{
_rigidbody = entity.Rigidbody;
_speed = entity.RotationSpeed;
_direction = entity.RotateDirection;
_canRotate = entity.CanRotate;
if (_direction.Value != Vector3.zero)
_rigidbody.transform.rotation = Quaternion.LookRotation(_direction.Value.normalized);
}
public void OnUpdate(float deltaTime)
{
if (_canRotate.Evaluate() == false)
return;
if (_direction.Value == Vector3.zero)
return;

View File

@@ -5,7 +5,7 @@ using System;
using System.Collections;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features;
using _Project.Develop.Runtime.Utilities.InputManagement;
using _Project.Develop.Runtime.Utils.InputManagement;
using UnityEngine;
namespace Assets._Project.Develop.Runtime.Gameplay.Infrastructure
@@ -18,7 +18,7 @@ namespace Assets._Project.Develop.Runtime.Gameplay.Infrastructure
private EntitiesLifeContext _entitiesLifeContext;
private GameplayInputArgs _gameplayArgs;
private IPlayerInputService _playerInput;
private IPlayerInput _playerInput;
public override void ProcessRegistrations(DIContainer container, IInputSceneArgs sceneArgs = null)
{

View File

@@ -1,5 +1,5 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.InputManagement;
using _Project.Develop.Runtime.Utils.InputManagement;
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using UnityEngine;
@@ -18,6 +18,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features
{
_container = container;
_container.Resolve<IPlayerInput>().Enable();
_entitiesFactory = _container.Resolve<EntitiesFactory>();
}