Better action system

This commit is contained in:
ThomasCharester committed 2026-10-30 02:58:51 +03:00
1 parent 2bd71f8dc5
commit 71bb4c3b5b
110 files changed
+73523 -86288

No files matched your search

@@ -7,63 +7,24 @@ namespace Code.OfficeGame.BattleMode.HitBoxes
// TODO Добавить меотды отключения,чтобы не получать урон во время стаггера
public class EntityHitBoxes : MonoBehaviour
{
[Serializable]
public struct HitBoxPartCollider
{
public HitBoxPartType PartType;
public BoxCollider Collider;
}
[SerializeField] private HitBoxPartCollider[] bodyParts;
[SerializeField] private Dictionary<HitBoxPartType, BoxCollider> bodyParts;
private LayerMask _hitBoxLayerMask;
private readonly Dictionary<HitBoxPartType, BoxCollider> _colliderMap = new();
private readonly Collider[] _hitResults = new Collider[8];
// Список уже поражённых целей за один взмах, чтобы один удар не наносил урон 8 раз за 8 активных кадров
private readonly HashSet<GameObject> _alreadyHitTargets = new();
private HitBoxPartType? _activePart;
private void Awake()
{
foreach (var part in bodyParts)
foreach (var part in bodyParts.Values)
{
part.Collider.enabled = false;
_colliderMap[part.PartType] = part.Collider;
part.enabled = false;
}
_hitBoxLayerMask = LayerMask.GetMask("HitBox");
}
public void EnableHitbox(HitBoxPartType part)
public void CheckHitsForCurrentFrame(Action<Collider> onNewTargetHit, HitBoxPartType hitBoxPartType)
{
if (_activePart == part) return;
_alreadyHitTargets.Clear();
_activePart = part;
if (_colliderMap.TryGetValue(part, out var col))
{
col.enabled = true;
}
}
public void DisableAllHitboxes()
{
if (_activePart.HasValue && _colliderMap.TryGetValue(_activePart.Value, out var col))
{
col.enabled = false;
}
_activePart = null;
_alreadyHitTargets.Clear();
}
public void CheckHitsForCurrentFrame(Action<Collider> onNewTargetHit)
{
if (!_activePart.HasValue) return;
BoxCollider box = _colliderMap[_activePart.Value];
BoxCollider box = bodyParts[hitBoxPartType];
Transform boxTransform = box.transform;
// Вычисляем точный мировой центр и размер коллайдера на кости в текущем кадре анимации
@@ -98,7 +59,17 @@ namespace Code.OfficeGame.BattleMode.HitBoxes
{
Head,
Chest,
Arm,
Leg
LArm,
LElbow,
LWrist,
LLeg,
LKnee,
LAnkle,
RArm,
RElbow,
RWrist,
RLeg,
RKnee,
RAnkle
}
}