Files
TeslaSuite/Console/TeslaConsole.BattleTech/BTMissionRecorder.cs
T
CydandClaude Fable 5 36166a95b0 BTGame pane + shell de-hardcode for multi-game pods (BT port phase 3)
BTGame mirrors RPGame - same GameStateData/state-machine/NetworkScan engine
driving each pod's MungaGame (take ownership, stream egg on WaitingForEgg,
Run/Abort/Stop, countdown) - with the BT differences: ApplicationID.BTL4, a
pilots grid carrying Mech/Camo/Patch/Badge/Experience, an Advanced Damage
checkbox in place of RP's Score Compression, and the Mech* in-match messages
recorded via BTMissionRecorder into BTMissionResults (.btm, gzip +
BinaryFormatter like .rpm; scores are 1000-based like RP). Free For All and
No Return share the pane; the mode selects the pilots' role. BTDefaults
persists per-mode operator defaults to BTDefaults.btd (no dialog yet).
RPGame's dead decompile members (sStopToIdleStates, IsAllPodsAppState) were
not carried over.

TeslaConsoleForm no longer assumes RP: the "AppID != 0 -> Pod Not Running RP"
check becomes a GameTag map (RPL4 -> RP, BTL4 -> BT, otherwise Unknown Pod
Application) feeding the per-game status strings, and the Games menu gains
BattleTech: Free For All / No Return.

Deferred to phase 4: mech/arena art, BT defaults dialog, BT score-sheet
print document, Apps.xml BT411 product, live-pod verification.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 22:29:20 -05:00

100 lines
2.8 KiB
C#

using System;
namespace TeslaConsole.BattleTech;
/// <summary>
/// Records the in-match Munga event messages of one BattleTech mission into a
/// <see cref="BTMissionResults" />. Mirrors <c>RPMissionRecorder</c>; the event
/// set follows the BT messages in Munga Net.dll (Mech* / EndMission).
/// </summary>
internal class BTMissionRecorder
{
private BTMissionResults mMissionResults;
private bool mStartSet;
public BTMissionRecorder(BTMission mission)
{
mMissionResults = new BTMissionResults(mission);
}
public void SetMissionStart()
{
if (mStartSet)
{
throw new InvalidOperationException();
}
mMissionResults.mMissionStart = DateTime.Now;
mStartSet = true;
}
private void ValidatePlayer(BTPlayer player, string param)
{
if (player == null)
{
throw new ArgumentNullException(param);
}
foreach (BTPlayer player2 in mMissionResults.Mission.Players)
{
if (player2 == player)
{
return;
}
}
throw new ArgumentException(param);
}
private TimeSpan GetMissionTime()
{
if (!mStartSet)
{
return TimeSpan.Zero;
}
return DateTime.Now - mMissionResults.mMissionStart;
}
public void PlayerKilled(BTPlayer reportingPlayer, BTPlayer killer)
{
ValidatePlayer(reportingPlayer, "reportingPlayer");
ValidatePlayer(killer, "killer");
TimeSpan missionTime = GetMissionTime();
mMissionResults.mEvents.Add(new BTKilledEvent(reportingPlayer, missionTime, killer));
}
public void PlayerDeathWithoutHonor(BTPlayer reportingPlayer)
{
ValidatePlayer(reportingPlayer, "reportingPlayer");
TimeSpan missionTime = GetMissionTime();
mMissionResults.mEvents.Add(new BTDeathWithoutHonorEvent(reportingPlayer, missionTime));
}
public void PlayerScoreUpdate(BTPlayer reportingPlayer, int score)
{
ValidatePlayer(reportingPlayer, "reportingPlayer");
TimeSpan missionTime = GetMissionTime();
mMissionResults.mEvents.Add(new BTScoreUpdateEvent(reportingPlayer, missionTime, score));
}
public void PlayerDamaged(BTPlayer reportingPlayer, BTPlayer damager, int damageLoss, int pointsTransfered, int damageZoneIndex, bool damageZoneDestroyed, int weaponIndex)
{
ValidatePlayer(reportingPlayer, "reportingPlayer");
ValidatePlayer(damager, "damager");
TimeSpan missionTime = GetMissionTime();
mMissionResults.mEvents.Add(new BTDamagedEvent(reportingPlayer, missionTime, damager, damageLoss, pointsTransfered, damageZoneIndex, damageZoneDestroyed, weaponIndex));
}
public void PlayerFinalScore(BTPlayer reportingPlayer, int finalScore)
{
ValidatePlayer(reportingPlayer, "reportingPlayer");
mMissionResults.mFinalScores.Add(reportingPlayer, finalScore);
}
public BTMissionResults EndMission(TimeSpan missionLength)
{
mMissionResults.mActuallMissionTime = missionLength;
BTMissionResults result = mMissionResults;
mMissionResults = null;
return result;
}
}