working on humbie still

This commit is contained in:
2025-10-24 13:54:27 +02:00
parent 98cf38ac00
commit 18effac005
33 changed files with 359 additions and 129 deletions

View File

@@ -0,0 +1,67 @@
using System;
using Oddworm.Framework;
using RebootKit.Engine.Foundation;
using RebootKit.Engine.Main;
using RebootKit.Engine.Simulation;
using Unity.Mathematics;
using UnityEngine;
using Logger = RebootKit.Engine.Foundation.Logger;
namespace RebootReality.jelycho.Damage {
public class HitboxManagerActor : Actor {
static readonly Logger s_Logger = new Logger(nameof(HitboxManagerActor));
static readonly Collider[] s_CollidersBuffer = new Collider[512];
[ConfigVar("debug.hitbox", 0, "Shows hitboxes")]
static ConfigVar s_ShowHitboxesDebug;
static bool ShouldShowHitboxes() {
return s_ShowHitboxesDebug.IndexValue > 0;
}
[SerializeField] Color m_HitboxDebugColor = Color.red;
[SerializeField] float m_HitboxDebugDuration = 3.0f;
[SerializeField] LayerMask m_HurtboxesLayerMask;
//
// @MARK: HitboxManager
//
public void HitSphere(float3 origin, float radius, Actor attacker, ulong damage) {
if (RR.IsServer()) {
HitSphereLocal(origin, radius, attacker, damage);
} else {
throw new NotImplementedException("Hitting on client not implemented yet!");
}
}
void HitSphereLocal(float3 origin, float radius, Actor attacker, ulong damage) {
if (ShouldShowHitboxes()) {
DbgDraw.Sphere(origin,
Quaternion.identity,
Vector3.one * radius,
m_HitboxDebugColor,
m_HitboxDebugDuration);
}
int count = Physics.OverlapSphereNonAlloc(origin, radius, s_CollidersBuffer, m_HurtboxesLayerMask);
for (int i = 0; i < count; ++i) {
if (s_CollidersBuffer[i].TryGetComponent(out IHurtbox hurtbox)) {
float3 p = s_CollidersBuffer[i].ClosestPoint(origin);
if (ShouldShowHitboxes()) {
DbgDraw.Sphere(p, Quaternion.identity, Vector3.one * 0.1f, Color.magenta, m_HitboxDebugDuration);
}
hurtbox.ReceiveDamage(attacker, damage, p);
}
}
}
//
// @MARK: Actor
//
protected override IActorData CreateActorData() {
return new NoActorData();
}
}
}