mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-03-05 07:41:10 +00:00
update
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82344af3543e4efabe4c37c4b0131ba0
|
||||
timeCreated: 1771516021
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bf2c15d48004f91a40b388b0c0f747a
|
||||
timeCreated: 1771516038
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53e84735577342fda0ab4dc6a380d829
|
||||
timeCreated: 1771517031
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bf6fb2218944c58b52d37f7039b95ae
|
||||
timeCreated: 1771516295
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbee24a3ed9e4e558158992dc929a348
|
||||
timeCreated: 1771516662
|
||||
Reference in New Issue
Block a user