Files
Project-M/Assets/_Project/Scripts/Simulation/Combat/TickWindowMath.cs
T
kronic 7571091394 LANTERN feel pass (DR-052 + gap list): SoD facing, underwater feel, Bathynaut kit, walk/run gait, suit lamp + new Synty anim packs
- SoD facing: PlayerFacing = body-yaw only (move-facing / cast-turn / idle-hold); every fire
  direction re-sourced to FacingMath.ResolveAim (pre-code review blocking catch); TickWindowMath
  shared windows with Movement-skip; reticle/FX coupled to the damage direction; cursor-dash kept.
- Underwater feel: sharpness 15->6, turn 720->360, MoveSpeed 6->4.2; TuningKnob 26-28
  (0 = no-override sentinels, dev-protocol bump on DebugTuningReport); stride footsteps + silt +
  cadence floor; bubbles; underwater ambience bed + distant groans; camera drag + dev scroll zoom.
- Bathynaut kit in-engine: dome/tank/shoulder-lamp + bare head grafted (GraftSmr rigid rebase,
  RecalculateTangents); EmissiveGloamSkinned shader (Rukhanka deformation); shoulder lamp CASTS
  (warm steady spot on body yaw).
- Gait: two-ring walk/run FreeformDirectional tree (walk @0.35, run @1.0) + blended-natural
  StrideScale; additive Posture(Bank) + Lead(chest-lead) layers; idle = AnimationIdles Base;
  banking driven from facing turn rate; flat terrain (Env_SeabedKit seabed squashed - CC is planar).
- New packs: Synty AnimationIdles + AnimationSwordCombat (combat pass queued) + SyntyPropBoneTool;
  four authored clips (sway/trudge/banks/lean) + Anim_Player_Underwater.blend + suit-kit FBX.
- Validation: 411/411 EditMode green; Play smokes (server==client facing, Aim-true projectile,
  bank/stride live-sampled, lamp beam verified); pre-code + post-impl adversarial reviews applied.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 13:56:02 -07:00

75 lines
4.4 KiB
C#

using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.NetCode;
namespace ProjectM.Simulation
{
/// <summary>
/// Pure tick-window predicates over replicated combat state (MeleeCombo swing window, per-socket
/// cooldown-derived fire windows). Extracted VERBATIM from PlayerAnimationDriveSystem (MC-4/B7) so the
/// predicted facing path (PlayerAimSystem) and the client animation path share one implementation.
/// Window lengths stay CALLER parameters (the anim path passes its k_AttackAnimTicks; the facing path
/// passes its own) — never baked constants. Movement-archetype sockets (dash/blink) NEVER count as
/// firing: a blink is a dodge, not a cast (this also kills the latent cooldown-tail phantom IsFiring
/// pulse the old include-all check produced — the blink socket's stamped cooldown row used to open a
/// fake window ~2.5s after each blink). Burst-safe statics (byte archetypes, no enums), EditMode-tested.
/// </summary>
public static class TickWindowMath
{
/// <summary>True while now is within [SwingStartTick, SwingStartTick + animTicks) — a per-swing pulse
/// that re-triggers on each chained swing. NetworkTick arithmetic (wrap-safe).</summary>
public static bool SwingActive(in MeleeCombo mc, NetworkTick serverTick, uint animTicks)
{
if (mc.SwingStartTick == 0u || !serverTick.IsValid) return false;
var start = new NetworkTick(mc.SwingStartTick);
var end = new NetworkTick(TickUtil.NonZero(mc.SwingStartTick + animTicks));
return start.IsValid && end.IsValid && !start.IsNewerThan(serverTick) && end.IsNewerThan(serverTick);
}
/// <summary>True while now is within the stateless fire window [NextFireTick - CooldownTicks, +animTicks)
/// reconstructed from the replicated per-socket cooldown stamp minus the locally-derived CooldownTicks
/// (recomputes identically on every world; no cached edges — edge-caches false-fire on
/// relevancy/join/rollback). Window start shifts if cooldown modifiers change mid-window — documented
/// acceptable (B7).</summary>
public static bool FireActive(uint nextFireRaw, int cooldownTicks, NetworkTick serverTick, uint animTicks)
{
if (nextFireRaw == 0u || cooldownTicks <= 0 || !serverTick.IsValid) return false;
uint startRaw = TickUtil.NonZero(nextFireRaw - (uint)cooldownTicks);
var start = new NetworkTick(startRaw);
var end = new NetworkTick(TickUtil.NonZero(startRaw + animTicks));
return start.IsValid && end.IsValid && !start.IsNewerThan(serverTick) && end.IsNewerThan(serverTick);
}
/// <summary>LANTERN 4-socket fire/cone resolution (any-socket model): firing if ANY socketed,
/// NON-Movement Spark's per-socket window is mid-fire; cone if any such active socket holds a
/// Cone-archetype Spark. Movement sockets are skipped OUTRIGHT (blink = dodge, not cast). Without a
/// blob the archetype is unknown — the socket is included (matches the old fallback behavior).</summary>
public static void SocketFireAndCone(in SocketCooldown cd, DynamicBuffer<AbilitySocket> sockets,
DynamicBuffer<EffectiveSocketStats> effSockets, BlobAssetReference<AbilityDatabaseBlob> abilityDb,
NetworkTick serverTick, uint animTicks, out bool firing, out bool cone)
{
firing = false; cone = false;
int n = math.min(SocketId.Count, math.min(sockets.Length, effSockets.Length));
bool haveDb = abilityDb.IsCreated;
for (int sk = 0; sk < n; sk++)
{
byte sid = sockets[sk].SparkId;
if (sid == 0) continue;
bool isCone = false;
if (haveDb)
{
ref var adb = ref abilityDb.Value;
if (adb.TryGetAbility(sid, out var d))
{
if (d.Archetype == (byte)AbilityArchetype.Movement) continue; // dodge, never a cast
isCone = d.Archetype == (byte)AbilityArchetype.Cone;
}
}
if (!FireActive(cd.Get(sk), effSockets[sk].CooldownTicks, serverTick, animTicks)) continue;
firing = true;
if (isCone) cone = true;
}
}
}
}