worldbox-observer-mod/IdleSpectator/Events/LiveSceneStickyState.cs
2026-07-17 01:54:59 -05:00

92 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
namespace IdleSpectator;
/// <summary>
/// Durable sticky scoreboard for a multi-actor live scene (combat first; war/plot/family later).
/// Locks opposing side identity once, tracks member ids, and holds peak scale across dips.
/// Owned by <see cref="InterestCandidate"/>; cleared when the scene goes cold.
/// </summary>
public sealed class LiveSceneStickyState
{
public EnsembleKind Kind = EnsembleKind.Combat;
public EnsembleFrame Frame = EnsembleFrame.CountOnly;
public int PeakParticipants;
public float ScaleDropSince = -999f;
public string SideAKey = "";
public string SideADisplay = "";
public string SideAKingdom = "";
public int SideACount;
public readonly List<long> SideAIds = new List<long>(8);
public string SideBKey = "";
public string SideBDisplay = "";
public string SideBKingdom = "";
public int SideBCount;
public readonly List<long> SideBIds = new List<long>(8);
/// <summary>
/// True when sticky identity is locked. Opposing camps need A+B; FamilyPack locks Side A only.
/// </summary>
public bool HasOpposingSides =>
!string.IsNullOrEmpty(SideAKey)
&& (
Kind == EnsembleKind.FamilyPack
|| Kind == EnsembleKind.StatusOutbreak
|| (!string.IsNullOrEmpty(SideBKey)
&& (Frame == EnsembleFrame.SpeciesVsSpecies
|| Frame == EnsembleFrame.KingdomVsKingdom)));
public int TotalCount => Math.Max(0, SideACount) + Math.Max(0, SideBCount);
public void Clear()
{
Kind = EnsembleKind.Combat;
Frame = EnsembleFrame.CountOnly;
PeakParticipants = 0;
ScaleDropSince = -999f;
SideAKey = "";
SideADisplay = "";
SideAKingdom = "";
SideACount = 0;
SideAIds.Clear();
SideBKey = "";
SideBDisplay = "";
SideBKingdom = "";
SideBCount = 0;
SideBIds.Clear();
}
public void CopyTo(LiveSceneStickyState other)
{
if (other == null)
{
return;
}
other.Clear();
other.Kind = Kind;
other.Frame = Frame;
other.PeakParticipants = PeakParticipants;
other.ScaleDropSince = ScaleDropSince;
other.SideAKey = SideAKey;
other.SideADisplay = SideADisplay;
other.SideAKingdom = SideAKingdom;
other.SideACount = SideACount;
other.SideBKey = SideBKey;
other.SideBDisplay = SideBDisplay;
other.SideBKingdom = SideBKingdom;
other.SideBCount = SideBCount;
for (int i = 0; i < SideAIds.Count; i++)
{
other.SideAIds.Add(SideAIds[i]);
}
for (int i = 0; i < SideBIds.Count; i++)
{
other.SideBIds.Add(SideBIds[i]);
}
}
}