62e48a3b0b
The 2026-08-06 audit found the shipping scene was still the abandoned co-op-Hades game with LANTERN combat bolted on, and that a third of the codebase was live code for a direction abandoned on 2026-07-13. Operator chose deletion over freezing: "everything is saved in source control if needed. I want the project to be clean." DELETED (~140 source files, Scripts 335->231, Tests 77->43): - Enemy variants + boss (H3). ChargerAuthoring / SpitterAuthoring / SwarmerAuthoring were attached to ZERO prefabs, so LungeState / SpitterState / SwarmerTag were never baked: ~272 lines of Bursted AI passes, BossAISystem (261 lines) and the whole MixBands escalation curve could not match a single chunk at runtime, while 734 lines of green tests certified them. Both shipping enemy prefabs were already byte-identical in stats. - Run/room lifecycle: RunDirector FSM, RunInfo/RunMap/RoomPlan/RoomTag, route select, portal interact, ready-check, room field/teardown. - Meta shop, prep loadout, boons (incl. KillRewardSystem and DashTrailDamageSystem, which existed only to serve boon flags). - Build palette + structures, shared storage, inventory/equipment (already recorded PAUSED in CLAUDE.md). - The HUD panels driving all of the above (HudSystem 1168 -> 610). KEPT deliberately: BaseGridMath + BaseAnchor (8 systems use PlotCenter for spawn rings, respawn and dynamic light), the resource ledger + StorageMath, the save system, region/relevancy. Three of these were in the delete set until I checked their consumers — worth remembering that the file-level manifest was wrong about them. Also folds in audit finding M5: PlayerClass was a second, server-only copy of the byte FrameId already replicates. It existed for the meta shop; with that gone, FrameId is the single frame identity. Harvest is now single-sink (ledger). HarvestMath keeps its shape so LANTERN's carried-vs-banked cargo split lands in one place, not two. 295/295 EditMode green, zero compile errors. Subscene re-bake and Play validation follow in the next commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
155 lines
7.0 KiB
C#
155 lines
7.0 KiB
C#
using ProjectM.Simulation;
|
|
using Unity.Entities;
|
|
using Unity.NetCode;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Client
|
|
{
|
|
/// <summary>
|
|
/// Client-only AMBIENT audio bed + run cues. A managed presentation <see cref="SystemBase"/>
|
|
/// (<see cref="PresentationSystemGroup"/>, main thread, no Burst) that plays a low, seamless-looping
|
|
/// procedural drone (asset-free, <c>AudioClip.Create</c> like <c>CombatFeedbackSystem.MakeClip</c>) plus
|
|
/// launch-countdown beeps and the boss-arrival roar — replicated-state observations only. Lives only in the
|
|
/// client world, so the server never creates audio and nothing here affects determinism. Volumes are
|
|
/// deliberately conservative. (The cycle-phase stingers + Core alarm retired with the siege loop — LANTERN purge.)
|
|
/// </summary>
|
|
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)]
|
|
[UpdateInGroup(typeof(PresentationSystemGroup))]
|
|
public partial class AmbientAudioSystem : SystemBase
|
|
{
|
|
AudioSource _ambient;
|
|
AudioClip _ambientClip;
|
|
GameObject _root;
|
|
|
|
AudioClip _stingBeep, _stingRoar;
|
|
int _lastCountdownSec = -1;
|
|
bool _bossRoared;
|
|
|
|
// 07-16 underwater re-voice: the bed volume + groan cadence live on FeelConfig (live-tunable).
|
|
AudioSource _groanSrc;
|
|
AudioClip _groanClip;
|
|
float _nextGroanIn = 12f; // first distant groan ~12s into a session
|
|
|
|
protected override void OnCreate()
|
|
{
|
|
_ambientClip = MakeDrone();
|
|
_groanClip = MakeGroan();
|
|
_stingBeep = MakeSting(880f, 880f, 0.09f, 0.30f); // countdown tick
|
|
_stingRoar = MakeSting(90f, 38f, 0.90f, 0.60f); // boss-arrival roar (low falling growl)
|
|
}
|
|
|
|
protected override void OnStartRunning()
|
|
{
|
|
if (_root != null) return;
|
|
_root = new GameObject("~AmbientAudio");
|
|
_ambient = _root.AddComponent<AudioSource>();
|
|
_ambient.clip = _ambientClip;
|
|
_ambient.loop = true;
|
|
_ambient.playOnAwake = false;
|
|
_ambient.spatialBlend = 0f; // 2D bed
|
|
_ambient.volume = FeelConfig.AmbienceVolume * GameVolume.Music;
|
|
_ambient.Play();
|
|
_groanSrc = _root.AddComponent<AudioSource>();
|
|
_groanSrc.playOnAwake = false;
|
|
_groanSrc.spatialBlend = 0f; // distant, directionless
|
|
_groanSrc.loop = false;
|
|
}
|
|
|
|
protected override void OnDestroy()
|
|
{
|
|
if (_root != null) Object.Destroy(_root);
|
|
}
|
|
|
|
protected override void OnUpdate()
|
|
{
|
|
if (_ambient == null) return;
|
|
|
|
float dt = SystemAPI.Time.DeltaTime;
|
|
_ambient.volume = Mathf.MoveTowards(_ambient.volume, FeelConfig.AmbienceVolume * GameVolume.Music, dt * 0.25f);
|
|
|
|
// Distant groans (07-16 gap-list): a slow low sweep with a soft attack, jittered interval + pitch —
|
|
// the murk answering back. Presentation-only wall-clock randomness is fine here.
|
|
if (_groanSrc != null && FeelConfig.GroanIntervalSec > 0f)
|
|
{
|
|
_nextGroanIn -= dt;
|
|
if (_nextGroanIn <= 0f)
|
|
{
|
|
_nextGroanIn = FeelConfig.GroanIntervalSec * (0.6f + Random.value * 0.8f);
|
|
_groanSrc.pitch = 0.85f + Random.value * 0.3f;
|
|
_groanSrc.PlayOneShot(_groanClip, FeelConfig.GroanVolume * GameVolume.Music);
|
|
}
|
|
}
|
|
|
|
// 2026-08-07 audit purge: the 3-2-1 launch countdown beeps and the boss-arrival roar keyed off
|
|
// RunInfo.Lifecycle / RoomTypeId. Both went with the run FSM and the boss.
|
|
}
|
|
|
|
// ---- Procedural audio (asset-free; mirrors CombatFeedbackSystem.MakeClip) ----
|
|
|
|
// A low, seamless-looping pad: each partial completes an integer number of cycles over the buffer
|
|
// (freq snapped to k/duration) so the loop point has no click. A slow tremolo adds motion.
|
|
// A low, seamless-looping UNDERWATER pressure bed (07-16 re-voice): sub-heavy partials + a pair of
|
|
// detuned subs whose beat completes exactly once per loop (Snap keeps every partial click-free at the
|
|
// loop point) — reads as slow water-column pressure swell rather than a musical pad.
|
|
static AudioClip MakeDrone()
|
|
{
|
|
const int rate = 44100;
|
|
const float dur = 8f;
|
|
int len = (int)(dur * rate);
|
|
var clip = AudioClip.Create("underwater_bed", len, 1, rate, false);
|
|
var data = new float[len];
|
|
float f0 = Snap(38f, dur); // deep sub
|
|
float f0b = f0 + 1f / dur; // detuned sub: beats exactly once per loop (seamless)
|
|
float f1 = Snap(55f, dur);
|
|
float f2 = Snap(82.4f, dur); // faint upper body
|
|
float swell = Snap(0.25f, dur); // very slow amplitude swell
|
|
for (int i = 0; i < len; i++)
|
|
{
|
|
float t = i / (float)rate;
|
|
float s = 0.46f * Mathf.Sin(2f * Mathf.PI * f0 * t)
|
|
+ 0.34f * Mathf.Sin(2f * Mathf.PI * f0b * t)
|
|
+ 0.22f * Mathf.Sin(2f * Mathf.PI * f1 * t)
|
|
+ 0.07f * Mathf.Sin(2f * Mathf.PI * f2 * t);
|
|
float amp = 0.7f + 0.3f * Mathf.Sin(2f * Mathf.PI * swell * t);
|
|
data[i] = s * amp * 0.5f;
|
|
}
|
|
clip.SetData(data, 0);
|
|
return clip;
|
|
}
|
|
|
|
// A distant whale-adjacent groan: slow 58->34Hz sweep with a soft sin^2 attack/decay window and a
|
|
// subtle wobble — never a jump-scare, just the deep being large somewhere off-screen.
|
|
static AudioClip MakeGroan()
|
|
{
|
|
const int rate = 44100;
|
|
const float dur = 3.4f;
|
|
int len = (int)(dur * rate);
|
|
var clip = AudioClip.Create("distant_groan", len, 1, rate, false);
|
|
var data = new float[len];
|
|
float phase = 0f;
|
|
for (int i = 0; i < len; i++)
|
|
{
|
|
float t01 = i / (float)len;
|
|
float t = i / (float)rate;
|
|
float freq = Mathf.Lerp(58f, 34f, t01) * (1f + 0.03f * Mathf.Sin(2f * Mathf.PI * 1.7f * t));
|
|
phase += 2f * Mathf.PI * freq / rate;
|
|
float window = Mathf.Sin(Mathf.PI * t01);
|
|
float env = window * window; // soft attack AND release
|
|
data[i] = (0.8f * Mathf.Sin(phase) + 0.2f * Mathf.Sin(2f * phase)) * env * 0.55f;
|
|
}
|
|
clip.SetData(data, 0);
|
|
return clip;
|
|
}
|
|
|
|
// freq snapped so freq*dur is an integer -> the waveform closes seamlessly at the loop point.
|
|
static float Snap(float freq, float dur)
|
|
{
|
|
float cycles = Mathf.Max(1f, Mathf.Round(freq * dur));
|
|
return cycles / dur;
|
|
}
|
|
|
|
// Short one-shot tone sweeping f0->f1 with an exponential decay envelope.
|
|
static AudioClip MakeSting(float f0, float f1, float dur, float vol) => FeedbackFx.MakeClip("sting", f0, f1, dur, vol, decay: 3.5f);
|
|
}
|
|
}
|