Fester Simulationstakt und Ansichten, die nur lesen; Nachweis, dass die Partie bei jeder Bildrate dieselbe ist. - LuneClock: Akkumulator, ganze Schritte zu 0,05 s, Alpha zum Interpolieren. - LuneMatchRunner: Host-Ablauf einer Bot-Partie (Planung über die Befehlsschnittstelle, Kampf im festen Takt, Abrechnung, nächste Runde); LuneMatchDriver reicht in Update nur Bildzeit weiter. - LuneTrace: Fingerabdruck der Partie (jeder Schritt, jede Abrechnung) und der reine Kernlauf zum Vergleich. - Ansichten: LuneMatchView, LuneUnitView (interpolierte Position, Blickrichtung, Clips aus Kampfereignissen, Teamring, Lebensbalken), LuneBuildingView mit Einsturz und Ruine aus den autoritativen HP, Turmblitze, LuneCameraRig wie lune_camera.gd, vorläufige Debug-Anzeige (kein HUD; U3 portiert das G3-HUD). - Einheitenbibliothek: Kohlenbeißer aus 131 Teilen zu einem Mesh, Animator- Controller mit den Blender-Clips, Ring- und Balkenmeshes, Markermaterialien. - Tests: EditMode (30/60/120 fps, unbegrenzt, Ruckler, 8x Tempo; Seed 2 und Seed 9 ab Runde 21) und PlayMode in der Szene bei echten Bildraten 30, 60, 120 und unbegrenzt: überall derselbe Fingerabdruck wie der Kern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using Luneraria.Core;
|
|
using UnityEngine;
|
|
|
|
namespace Luneraria.View
|
|
{
|
|
/// <summary>
|
|
/// Hosts a bot match in the scene (U2C/U2D). Update only hands frame time (times Speed) to the
|
|
/// runner's fixed clock; it never decides anything in combat. Seed, start round and extra gold
|
|
/// are the public fixtures of the golden scenarios.
|
|
/// </summary>
|
|
public sealed class LuneMatchDriver : MonoBehaviour
|
|
{
|
|
public int Seed = 2;
|
|
public int StartRound = 1;
|
|
public int ExtraGold;
|
|
public string Profile = "";
|
|
/// <summary>Match speed: simulated seconds per real second.</summary>
|
|
public float Speed = 1f;
|
|
public bool Paused;
|
|
public bool RecordTrace = true;
|
|
|
|
public LuneMatchRunner Runner { get; private set; }
|
|
/// <summary>Main-thread cost of the last frame's simulation (milliseconds).</summary>
|
|
public double LastAdvanceMs { get; private set; }
|
|
readonly System.Diagnostics.Stopwatch _clock = new System.Diagnostics.Stopwatch();
|
|
|
|
public void Restart()
|
|
{
|
|
Runner = new LuneMatchRunner(new MatchOptions { Seed = Seed, HumanSlot = -1 }, StartRound, ExtraGold, Profile);
|
|
if (RecordTrace)
|
|
Runner.Trace = new LuneTrace();
|
|
}
|
|
|
|
void Awake()
|
|
{
|
|
if (Runner == null)
|
|
Restart();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
_clock.Restart();
|
|
if (!Paused)
|
|
Runner.Advance(Time.deltaTime * Speed);
|
|
LastAdvanceMs = _clock.Elapsed.TotalMilliseconds;
|
|
}
|
|
}
|
|
}
|