feat: add team touch system

This commit is contained in:
Bragin Stepan
2026-03-13 15:29:57 +05:00
parent f9b0996922
commit 96058b6c58
12 changed files with 104 additions and 14 deletions

View File

@@ -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("Старт атаки");

View File

@@ -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()