73cfe2943d
Structures (Turret/Wall/Pylon) reuse the combat spine: authoring bakes Health(GhostField)+DamageEvent buffer+a Destructible tag (no HitRadius -> no friendly projectile fire; no EffectiveCharacterStats -> clamp-to-0). HealthApplyDamageSystem destroys a Destructible at 0 (occupancy auto-frees). EnemyAISystem fortress-targets the weighted-nearest of players+structures via the shared EnemyAIMath.PickWeightedNearest (StructureAggroWeight TuningConfig knob, <1 prefers structures, squared factor; snapshot above the early-return so an undefended base is razed). Persistence v3: per-structure HP threaded through 5 sites (SaveData/PendingStructure/scan-guarded/BaseRestore same-ECB born-correct/WorldLauncher via SaveApply.ToPending); SaveService floor-gate [2,3] loads old saves. Loss feedback: proximity-gated StructureFeedbackSystem; CombatFeedbackSystem suppressed for structures. Pre-code review caught the DamageEvent-buffer crash blocker + 8 majors; post-code review clean. See DR-032. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
145 lines
7.3 KiB
C#
145 lines
7.3 KiB
C#
#if UNITY_EDITOR
|
|
using ProjectM.Simulation;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Client
|
|
{
|
|
/// <summary>
|
|
/// EDITOR-ONLY in-game dev-tools overlay (IMGUI dev overlay). Buttons enqueue
|
|
/// <see cref="DebugCommandRequest"/> RPCs through <see cref="DebugCommandSendSystem"/>, so they drive the REAL
|
|
/// server-authoritative paths (and work over a live connection too, not just in-editor). Drop it on a
|
|
/// GameObject in the DevSandbox (or Game) scene. While open it forces the OS cursor visible
|
|
/// (<see cref="AimPresentation.ForceCursorVisible"/>) so its buttons stay clickable even while aiming.
|
|
/// Stripped from player builds (#if UNITY_EDITOR).
|
|
/// </summary>
|
|
public class DebugOverlay : MonoBehaviour
|
|
{
|
|
bool _open = true;
|
|
int _siegeSize = 5;
|
|
int _grantAmount = 50;
|
|
bool _tuningOpen;
|
|
Vector2 _scroll;
|
|
|
|
void OnDisable() => AimPresentation.ForceCursorVisible = false;
|
|
|
|
void OnGUI()
|
|
{
|
|
if (GUI.Button(new Rect(Screen.width - 96, 10, 86, 24), _open ? "DEV ▲" : "DEV ▼"))
|
|
_open = !_open;
|
|
|
|
AimPresentation.ForceCursorVisible = _open;
|
|
if (!_open)
|
|
return;
|
|
|
|
float panelH = Mathf.Min(760f, Screen.height - 50f);
|
|
GUILayout.BeginArea(new Rect(Screen.width - 232, 40, 222, panelH), GUI.skin.box);
|
|
GUILayout.Label("DEV TOOLS");
|
|
_scroll = GUILayout.BeginScrollView(_scroll);
|
|
|
|
GUILayout.Label("- World -");
|
|
_siegeSize = IntField("Siege size", _siegeSize);
|
|
if (GUILayout.Button("Spawn Wave / Force Siege")) DebugCommandSendSystem.SpawnWave(_siegeSize);
|
|
if (GUILayout.Button("End Siege")) DebugCommandSendSystem.EndSiege();
|
|
if (GUILayout.Button("Clear Enemies")) DebugCommandSendSystem.ClearEnemies();
|
|
if (GUILayout.Button("Force Calm")) DebugCommandSendSystem.SetCalm();
|
|
if (GUILayout.Button("Advance Goal +1")) DebugCommandSendSystem.AdvanceGoal(1);
|
|
|
|
GUILayout.Space(6);
|
|
GUILayout.Label("- Resources -");
|
|
_grantAmount = IntField("Amount", _grantAmount);
|
|
GUILayout.BeginHorizontal();
|
|
if (GUILayout.Button("Aether")) DebugCommandSendSystem.GrantResource(ResourceId.Aether, _grantAmount);
|
|
if (GUILayout.Button("Ore")) DebugCommandSendSystem.GrantResource(ResourceId.Ore, _grantAmount);
|
|
if (GUILayout.Button("Bio")) DebugCommandSendSystem.GrantResource(ResourceId.Biomass, _grantAmount);
|
|
GUILayout.EndHorizontal();
|
|
if (GUILayout.Button("Grant Damage Upgrade")) DebugCommandSendSystem.GrantUpgrade();
|
|
|
|
GUILayout.Space(6);
|
|
GUILayout.Label("- Player -");
|
|
GUILayout.BeginHorizontal();
|
|
if (GUILayout.Button("Heal")) DebugCommandSendSystem.Heal();
|
|
if (GUILayout.Button("Kill")) DebugCommandSendSystem.Kill();
|
|
if (GUILayout.Button("God")) DebugCommandSendSystem.ToggleGod();
|
|
GUILayout.EndHorizontal();
|
|
GUILayout.BeginHorizontal();
|
|
if (GUILayout.Button("Go Base")) DebugCommandSendSystem.Teleport(RegionId.Base);
|
|
if (GUILayout.Button("Go Expedition")) DebugCommandSendSystem.Teleport(RegionId.Expedition);
|
|
GUILayout.EndHorizontal();
|
|
|
|
GUILayout.Space(6);
|
|
GUILayout.Label("- Telemetry (MC-0) -");
|
|
if (DevTelemetryReadout.HasData)
|
|
{
|
|
var t = DevTelemetryReadout.Latest;
|
|
GUILayout.Label($"tick {t.LastSampleTick} husks {t.LiveEnemyCount}");
|
|
GUILayout.Label($"dash neg {t.DashIFrameNegatedHits} / wasted {t.DashesWasted}");
|
|
GUILayout.Label($"whiff open {t.ChargerWhiffWindowsOpened} / punish {t.ChargerWhiffPunishesLanded}");
|
|
}
|
|
else
|
|
{
|
|
GUILayout.Label("(waiting for server telemetry...)");
|
|
}
|
|
|
|
GUILayout.Space(6);
|
|
_tuningOpen = GUILayout.Toggle(_tuningOpen, "- Tuning (MC-0) -");
|
|
if (_tuningOpen)
|
|
{
|
|
TuningRow("Dash dist", TuningKnob.DashDistance, 0.5f, "0.0");
|
|
TuningRow("Dash iframe t", TuningKnob.IFrameWindowTicks, 1f, "0");
|
|
TuningRow("Dash recover t", TuningKnob.RecoverTailTicks, 1f, "0");
|
|
TuningRow("Dash cd t", TuningKnob.DashCooldownTicks, 1f, "0");
|
|
TuningRow("Dash sharp", TuningKnob.DashSharpness, 25f, "0");
|
|
TuningRow("Chgr windup t", TuningKnob.ChargerWindupTicks, 1f, "0");
|
|
TuningRow("Chgr lunge spd", TuningKnob.ChargerLungeSpeed, 1f, "0.0");
|
|
TuningRow("Chgr lunge t", TuningKnob.ChargerLungeDurationTicks, 1f, "0");
|
|
TuningRow("Chgr stagger t", TuningKnob.ChargerWhiffStaggerTicks, 1f, "0");
|
|
TuningRow("Grunt windup t", TuningKnob.GruntWindupTicks, 1f, "0");
|
|
GUILayout.Space(4);
|
|
TuningRow("Melee dmg", TuningKnob.MeleeDamage, 1f, "0.0");
|
|
TuningRow("Melee range", TuningKnob.MeleeRange, 0.2f, "0.0");
|
|
TuningRow("Melee cone rad", TuningKnob.MeleeConeHalfAngleRad, 0.05f, "0.00");
|
|
TuningRow("Melee recover t", TuningKnob.MeleeRecoverTicks, 1f, "0");
|
|
TuningRow("Melee chain t", TuningKnob.MeleeChainGraceTicks, 1f, "0");
|
|
TuningRow("Melee move x", TuningKnob.MeleeSwingMoveScale, 0.05f, "0.00");
|
|
TuningRow("Melee knock spd", TuningKnob.MeleeKnockbackSpeed, 1f, "0.0");
|
|
TuningRow("Melee finish x", TuningKnob.MeleeFinisherMult, 0.1f, "0.0");
|
|
TuningRow("Melee combo len", TuningKnob.MeleeComboLength, 1f, "0");
|
|
GUILayout.Space(4);
|
|
TuningRow("Struct aggro w", TuningKnob.StructureAggroWeight, 0.1f, "0.00"); // EB-1: <1 prefers structures
|
|
}
|
|
|
|
GUILayout.EndScrollView();
|
|
GUILayout.EndArea();
|
|
}
|
|
|
|
static int IntField(string label, int value)
|
|
{
|
|
GUILayout.BeginHorizontal();
|
|
GUILayout.Label(label, GUILayout.Width(70));
|
|
string s = GUILayout.TextField(value.ToString(), GUILayout.Width(60));
|
|
GUILayout.EndHorizontal();
|
|
return int.TryParse(s, out var v) ? v : value;
|
|
}
|
|
|
|
// One live-tuning row: shows the current value (from the readout) + step buttons. A nudge fires the
|
|
// authoritative server RPC AND an optimistic local apply (so the tuner's own predicted dash uses it now).
|
|
static void TuningRow(string label, byte knob, float step, string fmt)
|
|
{
|
|
float cur = ProjectM.Simulation.TuningConfig.Get(TuningReadout.Current, knob);
|
|
GUILayout.BeginHorizontal();
|
|
GUILayout.Label(label, GUILayout.Width(92));
|
|
GUILayout.Label(cur.ToString(fmt), GUILayout.Width(40));
|
|
if (GUILayout.Button("-", GUILayout.Width(26))) Nudge(knob, cur - step);
|
|
if (GUILayout.Button("+", GUILayout.Width(26))) Nudge(knob, cur + step);
|
|
GUILayout.EndHorizontal();
|
|
}
|
|
|
|
static void Nudge(byte knob, float value)
|
|
{
|
|
DebugCommandSendSystem.SetTuning(knob, value); // authoritative (server applies + broadcasts; clamped)
|
|
TuningReadout.SetLocal(knob, value); // optimistic local (instant feel for the tuner; clamped)
|
|
}
|
|
}
|
|
}
|
|
#endif
|