mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-03-05 07:41:10 +00:00
init: add project
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4400c1c289f4486836ea29e45c9f9da
|
||||
timeCreated: 1771435325
|
||||
@@ -0,0 +1,29 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utilities.InputManagement;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
|
||||
{
|
||||
public class MoveDirectionByInputSystem : IInitializableSystem, IUpdatableSystem
|
||||
{
|
||||
private readonly IPlayerInputService _playerInput;
|
||||
|
||||
private ReactiveVariable<Vector3> _moveDirection;
|
||||
|
||||
public MoveDirectionByInputSystem(IPlayerInputService playerInput)
|
||||
{
|
||||
_playerInput = playerInput;
|
||||
}
|
||||
|
||||
public void OnInit(Entity entity)
|
||||
{
|
||||
_moveDirection = entity.MoveDirection;
|
||||
}
|
||||
|
||||
public void OnUpdate(float deltaTime)
|
||||
{
|
||||
_moveDirection.Value = new Vector3(_playerInput.Move.x, 0, _playerInput.Move.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ead925d5e3184e6882ddb0c3bf60749a
|
||||
timeCreated: 1771432720
|
||||
@@ -0,0 +1,29 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utilities.InputManagement;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
|
||||
{
|
||||
public class RotateDirectionByInputSystem : IInitializableSystem, IUpdatableSystem
|
||||
{
|
||||
private readonly IPlayerInputService _playerInput;
|
||||
|
||||
private ReactiveVariable<Vector3> _rotateDirection;
|
||||
|
||||
public RotateDirectionByInputSystem(IPlayerInputService playerInput)
|
||||
{
|
||||
_playerInput = playerInput;
|
||||
}
|
||||
|
||||
public void OnInit(Entity entity)
|
||||
{
|
||||
_rotateDirection = entity.RotateDirection;
|
||||
}
|
||||
|
||||
public void OnUpdate(float deltaTime)
|
||||
{
|
||||
_rotateDirection.Value = new Vector3(_playerInput.Move.x, 0, _playerInput.Move.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8cefa96e10a40cfa0c17a4fc93112cf
|
||||
timeCreated: 1771432904
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 132a224c65af417fa7d0ff6c47dc9e21
|
||||
timeCreated: 1771427534
|
||||
@@ -0,0 +1,14 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
|
||||
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 RotateDirection : IEntityComponent { public ReactiveVariable<Vector3> Value; }
|
||||
public class RotationSpeed : IEntityComponent { public ReactiveVariable<float> Value; }
|
||||
|
||||
public class JumpForce : IEntityComponent { public ReactiveVariable<float> Value; }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbe915c5b653410585247c01d9590343
|
||||
timeCreated: 1771427563
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5a20169d346473281e2c2fe29323264
|
||||
timeCreated: 1771433138
|
||||
@@ -0,0 +1,31 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
|
||||
{
|
||||
public class AgentMovementSystem : IInitializableSystem, IUpdatableSystem
|
||||
{
|
||||
private ReactiveVariable<float> _moveSpeed;
|
||||
private NavMeshAgent _agent;
|
||||
|
||||
private Vector3 _position;
|
||||
|
||||
public void OnInit(Entity entity)
|
||||
{
|
||||
_moveSpeed = entity.MoveSpeed;
|
||||
_agent = entity.NavMeshAgent;
|
||||
// _position получить позицию
|
||||
|
||||
_agent.acceleration = 999;
|
||||
}
|
||||
|
||||
public void OnUpdate(float deltaTime)
|
||||
{
|
||||
_agent.speed = _moveSpeed.Value;
|
||||
|
||||
// _agent.SetDestination(_position);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da364e91e1ad4ac8911a602290e65656
|
||||
timeCreated: 1771435874
|
||||
@@ -0,0 +1,27 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
|
||||
{
|
||||
public class CharacterControllerMovementSystem : IInitializableSystem, IUpdatableSystem
|
||||
{
|
||||
private ReactiveVariable<Vector3> _moveDirection;
|
||||
private ReactiveVariable<float> _moveSpeed;
|
||||
private CharacterController _controller;
|
||||
|
||||
public void OnInit(Entity entity)
|
||||
{
|
||||
_moveDirection = entity.MoveDirection;
|
||||
_moveSpeed = entity.MoveSpeed;
|
||||
_controller = entity.CharacterController;
|
||||
}
|
||||
|
||||
public void OnUpdate(float deltaTime)
|
||||
{
|
||||
Vector3 velocity = _moveDirection.Value.normalized * _moveSpeed.Value;
|
||||
|
||||
_controller.Move(velocity * deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f947fab22c9b447aaca17e5b9118bbfc
|
||||
timeCreated: 1771434334
|
||||
@@ -0,0 +1,23 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
|
||||
{
|
||||
public class RigidbodyJumpSystem : IInitializableSystem, IUpdatableSystem
|
||||
{
|
||||
private ReactiveVariable<float> _jumpForce;
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
public void OnInit(Entity entity)
|
||||
{
|
||||
_jumpForce = entity.JumpForce;
|
||||
_rigidbody = entity.Rigidbody;
|
||||
}
|
||||
|
||||
public void OnUpdate(float deltaTime)
|
||||
{
|
||||
_rigidbody.AddForce(Vector3.up * _jumpForce.Value, ForceMode.Impulse);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b7c856150e8421080f58737e14efef4
|
||||
timeCreated: 1771435167
|
||||
@@ -0,0 +1,27 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
|
||||
{
|
||||
public class RigidbodyMovementSystem : IInitializableSystem, IUpdatableSystem
|
||||
{
|
||||
private ReactiveVariable<Vector3> _moveDirection;
|
||||
private ReactiveVariable<float> _moveSpeed;
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
public void OnInit(Entity entity)
|
||||
{
|
||||
_moveDirection = entity.MoveDirection;
|
||||
_moveSpeed = entity.MoveSpeed;
|
||||
_rigidbody = entity.Rigidbody;
|
||||
}
|
||||
|
||||
public void OnUpdate(float deltaTime)
|
||||
{
|
||||
Vector3 velocity = _moveDirection.Value.normalized * _moveSpeed.Value;
|
||||
|
||||
_rigidbody.velocity = velocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47ee3c1077054ccda0eac26a6ba5c4ff
|
||||
timeCreated: 1771427601
|
||||
@@ -0,0 +1,33 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
|
||||
{
|
||||
public class RigidbodyRotationSystem : IInitializableSystem, IUpdatableSystem
|
||||
{
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
private ReactiveVariable<float> _speed;
|
||||
private ReactiveVariable<Vector3> _direction;
|
||||
|
||||
public void OnInit(Entity entity)
|
||||
{
|
||||
_rigidbody = entity.Rigidbody;
|
||||
_speed = entity.RotationSpeed;
|
||||
_direction = entity.RotateDirection;
|
||||
}
|
||||
|
||||
public void OnUpdate(float deltaTime)
|
||||
{
|
||||
if (_direction.Value == Vector3.zero)
|
||||
return;
|
||||
|
||||
Quaternion lookRotation = Quaternion.LookRotation(_direction.Value.normalized);
|
||||
float step = _speed.Value * deltaTime;
|
||||
Quaternion rotation = Quaternion.RotateTowards(_rigidbody.rotation, lookRotation, step);
|
||||
|
||||
_rigidbody.MoveRotation(rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a22ef6d1d9154a0980488560316560f4
|
||||
timeCreated: 1771431944
|
||||
@@ -0,0 +1,33 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
|
||||
{
|
||||
public class TransformRotationSystem : IInitializableSystem, IUpdatableSystem
|
||||
{
|
||||
private ReactiveVariable<Vector3> _direction;
|
||||
private ReactiveVariable<float> _speed;
|
||||
private Transform _transform;
|
||||
|
||||
private const float DeadZone = 0.1f;
|
||||
|
||||
public void OnInit(Entity entity)
|
||||
{
|
||||
_direction = entity.RotateDirection;
|
||||
_speed = entity.RotationSpeed;
|
||||
_transform = entity.Transform;
|
||||
}
|
||||
|
||||
public void OnUpdate(float deltaTime)
|
||||
{
|
||||
if (_direction.Value.magnitude < DeadZone)
|
||||
return;
|
||||
|
||||
Quaternion lookRotation = Quaternion.LookRotation(_direction.Value);
|
||||
float step = _speed.Value * deltaTime;
|
||||
|
||||
_transform.rotation = Quaternion.RotateTowards(_transform.rotation, lookRotation, step);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a739c8f6f33f4758963ba69b71c36209
|
||||
timeCreated: 1771436669
|
||||
Reference in New Issue
Block a user