mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-04-19 21:19:41 +00:00
feat: add team touch system
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utilities.Conditions;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
@@ -14,15 +14,21 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.Systems
|
||||
private ReactiveVariable<bool> _inAttackProcess;
|
||||
private ICompositeCondition _canStartAttack;
|
||||
|
||||
private Entity _entity;
|
||||
private ReactiveVariable<Entity> _currentTarget;
|
||||
private IDisposable _attackRequestDisposable;
|
||||
|
||||
|
||||
public void OnInit(Entity entity)
|
||||
{
|
||||
_entity = entity;
|
||||
_startAttackRequest = entity.StartAttackRequest;
|
||||
_startAttackEvent = entity.StartAttackEvent;
|
||||
_inAttackProcess = entity.InAttackProcess;
|
||||
_canStartAttack = entity.CanStartAttack;
|
||||
|
||||
if (entity.TryGetCurrentTarget(out var currentTarget))
|
||||
_currentTarget = currentTarget;
|
||||
|
||||
_attackRequestDisposable = _startAttackRequest.Subscribe(OnAttackRequest);
|
||||
}
|
||||
|
||||
@@ -30,6 +36,15 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.Systems
|
||||
{
|
||||
if (_canStartAttack.Evaluate())
|
||||
{
|
||||
if (_currentTarget != null && _currentTarget.Value != null)
|
||||
{
|
||||
if (EntitiesHelper.AreOnSameTeam(_entity, _currentTarget.Value))
|
||||
{
|
||||
Debug.Log("Не могу атаковать своего!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_inAttackProcess.Value = true;
|
||||
_startAttackEvent.Invoke();
|
||||
Debug.Log("Старт атаки");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
|
||||
@@ -38,7 +38,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.Systems.Shoot
|
||||
|
||||
private void OnAttackDelayEnd()
|
||||
{
|
||||
_entitiesFactory.CreateProjectile(_shootPoint.position, _shootPoint.forward, _damage.Value);
|
||||
_entitiesFactory.CreateProjectile(_shootPoint.position, _shootPoint.forward, _damage.Value, _entity);
|
||||
}
|
||||
|
||||
public void OnDispose()
|
||||
|
||||
Reference in New Issue
Block a user