feat: add conditions

This commit is contained in:
Bragin Stepan
2026-02-19 20:46:32 +05:00
parent 4f01e66894
commit e07bde989a
17 changed files with 242 additions and 9 deletions

View File

@@ -19,12 +19,12 @@ namespace _Project.Develop.Runtime.Entities
_monoEntitiesFactory = container.Resolve<MonoEntitiesFactory>();
_playerInput = container.Resolve<IPlayerInputService>();
}
public Entity CreateTestEntity(Vector3 position)
public Entity CreateGhostEntity(Vector3 position)
{
Entity entity = CreateEmpty();
_monoEntitiesFactory.Create(entity, position, PathToResources.Entity.TestEntity);
_monoEntitiesFactory.Create(entity, position, PathToResources.Entity.Ghost);
entity
.AddMoveDirection()
@@ -33,10 +33,8 @@ namespace _Project.Develop.Runtime.Entities
.AddRotationSpeed(new ReactiveVariable<float>(800));
entity
.AddSystem(new CharacterControllerMovementSystem())
.AddSystem(new TransformRotationSystem())
// .AddSystem(new RigidbodyMovementSystem())
// .AddSystem(new RigidbodyRotationSystem())
.AddSystem(new RigidbodyMovementSystem())
.AddSystem(new RigidbodyRotationSystem())
.AddSystem(new MoveDirectionByInputSystem(_playerInput))
.AddSystem(new RotateDirectionByInputSystem(_playerInput));

View File

@@ -126,6 +126,49 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveSpeed() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.IsMoving IsMovingC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.IsMoving>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> IsMoving => IsMovingC.Value;
public bool TryGetIsMoving(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.IsMoving 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 AddIsMoving()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.IsMoving() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean>() });
}
public _Project.Develop.Runtime.Entities.Entity AddIsMoving(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.IsMoving() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanMove CanMoveC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanMove>();
public _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition CanMove => CanMoveC.Value;
public bool TryGetCanMove(out _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanMove component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddCanMove(_Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanMove() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotateDirection RotateDirectionC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotateDirection>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3> RotateDirection => RotateDirectionC.Value;
@@ -174,6 +217,25 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotationSpeed() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanRotate CanRotateC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanRotate>();
public _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition CanRotate => CanRotateC.Value;
public bool TryGetCanRotate(out _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanRotate component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddCanRotate(_Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanRotate() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.JumpForce JumpForceC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.JumpForce>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> JumpForce => JumpForceC.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;
@@ -6,9 +7,13 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class MoveDirection : IEntityComponent { public ReactiveVariable<Vector3> Value; }
public class MoveSpeed : IEntityComponent { public ReactiveVariable<float> Value; }
public class IsMoving : IEntityComponent { public ReactiveVariable<bool> Value; }
public class CanMove : IEntityComponent { public ICompositeCondition Value; }
public class RotateDirection : IEntityComponent { public ReactiveVariable<Vector3> Value; }
public class RotationSpeed : IEntityComponent { public ReactiveVariable<float> Value; }
public class CanRotate : IEntityComponent { public ICompositeCondition Value; }
public class JumpForce : IEntityComponent { public ReactiveVariable<float> Value; }
}

View File

@@ -23,7 +23,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features
public void Run()
{
_entity = _entitiesFactory.CreateTestEntity(Vector3.zero);
_entity = _entitiesFactory.CreateGhostEntity(Vector3.zero);
_isRunning = true;
}