mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-03-05 07:41:10 +00:00
feat: add hero and body deal damage
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime
|
||||
{
|
||||
public class DisableCollidersOnDeathRegistrator : MonoEntityRegistrator
|
||||
{
|
||||
[SerializeField] private List<Collider> _colliders;
|
||||
|
||||
public override void Register(Entity entity)
|
||||
{
|
||||
entity.AddDisableCollidersOnDeath(_colliders);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 801746c26fe0478e80182979f64c22f2
|
||||
timeCreated: 1771677582
|
||||
@@ -1,6 +1,8 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using System.Collections.Generic;
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utilities.Conditions;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime
|
||||
{
|
||||
@@ -14,4 +16,6 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime
|
||||
public class DeathProcessInitialTime : IEntityComponent { public ReactiveVariable<float> Value; }
|
||||
public class DeathProcessCurrentTime : IEntityComponent { public ReactiveVariable<float> Value; }
|
||||
public class InDeathProcess : IEntityComponent { public ReactiveVariable<bool> Value; }
|
||||
|
||||
public class DisableCollidersOnDeath : IEntityComponent { public List<Collider> Value; }
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.Systems
|
||||
{
|
||||
public class DisableCollidersOnDeathSystem : IInitializableSystem, IDisposableSystem
|
||||
{
|
||||
private List<Collider> _colliders;
|
||||
private ReactiveVariable<bool> _isDead;
|
||||
|
||||
private IDisposable _isDeadChangedDisposable;
|
||||
|
||||
public void OnInit(Entity entity)
|
||||
{
|
||||
_colliders = entity.DisableCollidersOnDeath;
|
||||
_isDead = entity.IsDead;
|
||||
|
||||
_isDeadChangedDisposable = _isDead.Subscribe(OnIsDeadChanged);
|
||||
}
|
||||
|
||||
private void OnIsDeadChanged(bool arg1, bool isDead)
|
||||
{
|
||||
if (isDead)
|
||||
foreach (Collider collider in _colliders)
|
||||
collider.enabled = false;
|
||||
}
|
||||
|
||||
public void OnDispose()
|
||||
{
|
||||
_isDeadChangedDisposable.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79df8b8c7f584c9aafa1e98fea894da6
|
||||
timeCreated: 1771677719
|
||||
Reference in New Issue
Block a user