Great timeline system (Age of AI WON)
This commit is contained in:
1 parent
2ce0391c16
commit
e312131725
182 files changed
+380070
-470221
No files matched your search
@@ -5,31 +5,41 @@ using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.HitBoxes
|
||||
{
|
||||
// TODO Добавить меотды отключения,чтобы не получать урон во время стаггера
|
||||
public class EntityHitBoxes : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Dictionary<HitBoxPartType, BoxCollider> bodyParts;
|
||||
private LayerMask _hitBoxLayerMask;
|
||||
|
||||
private readonly Dictionary<Collider, HitBoxPartType> _colliderToPart = new();
|
||||
private readonly Collider[] _hitResults = new Collider[8];
|
||||
private LayerMask _hitBoxLayerMask;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// foreach (var part in bodyParts.Values)
|
||||
// {
|
||||
// part.enabled = false;
|
||||
// }
|
||||
_hitBoxLayerMask = LayerMask.GetMask("HitBox");
|
||||
|
||||
if (bodyParts != null)
|
||||
{
|
||||
foreach (var (part, col) in bodyParts)
|
||||
{
|
||||
if (col != null) _colliderToPart[col] = part;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckHitsForCurrentFrame(Action<Collider, Collider> onNewTargetHit, HitBoxPartType hitBoxPartType)
|
||||
public bool TryGetPartType(Collider col, out HitBoxPartType partType) =>
|
||||
_colliderToPart.TryGetValue(col, out partType);
|
||||
|
||||
public void CheckHitsForCurrentFrame(
|
||||
IBattleSimulationContext simContext,
|
||||
Action<Collider, Collider, HitBoxPartType> onTargetHit,
|
||||
HitBoxPartType attackingBodyPart)
|
||||
{
|
||||
BoxCollider box = bodyParts[hitBoxPartType];
|
||||
if (bodyParts == null || !bodyParts.TryGetValue(attackingBodyPart, out BoxCollider box) || box == null)
|
||||
return;
|
||||
|
||||
simContext?.RecordHitboxVisual(box, Color.red);
|
||||
|
||||
Transform boxTransform = box.transform;
|
||||
|
||||
// TODO А ещё можно нарисовать все эти коллайдеры во время тихих рассчётов разной прозрачностью и по мере продвижения таймлайна увеличивать альфу для ближайшего коллайдера
|
||||
if(!BattleTimeline.IsSilentSimulation) HitboxDrawer.DrawBox(box, Color.red, BattleTimeline.TickDelta / Mathf.Max(0.01f, BattleTimeline.PlaybackSpeed));
|
||||
|
||||
Vector3 worldCenter = boxTransform.TransformPoint(box.center);
|
||||
Vector3 worldHalfExtents = Vector3.Scale(box.size * 0.5f, boxTransform.lossyScale);
|
||||
|
||||
@@ -44,10 +54,14 @@ namespace Code.OfficeGame.BattleMode.HitBoxes
|
||||
for (int i = 0; i < hitsCount; i++)
|
||||
{
|
||||
Collider hitCol = _hitResults[i];
|
||||
|
||||
if (hitCol.transform.root == transform.root) continue;
|
||||
|
||||
onNewTargetHit?.Invoke(box, hitCol);
|
||||
var defenderHitBoxes = hitCol.GetComponentInParent<EntityHitBoxes>();
|
||||
HitBoxPartType hitPart = HitBoxPartType.Chest;
|
||||
if (defenderHitBoxes != null)
|
||||
defenderHitBoxes.TryGetPartType(hitCol, out hitPart);
|
||||
|
||||
onTargetHit?.Invoke(box, hitCol, hitPart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user