worldbox-observer-mod/IdleSpectator/Events/DiscreteEventEntry.cs
DazedAnon ba58a9ff38 feat(saga): deepen session cast stakes and cut idle hitch spikes
- Keep LifeSagaSession across Clear; wipe on map load/clear with bind key
- Soft-bias Prefer/cross-MC/cast and prefer roster MCs in aftermath/recover/park
- Resolve war/plot principals plus discrete/WorldLog labels from live libraries
- Amortize roster world scans, gate Relayout, and add hitch probe/save-slot helpers
2026-07-22 14:37:36 -05:00

79 lines
2.7 KiB
C#

namespace IdleSpectator;
/// <summary>
/// Shared catalog row for discrete / library-backed spectator events.
/// Lives in <c>Events/</c> with <see cref="EventReason"/> - catalogs own dials; director only ranks.
/// </summary>
public sealed class DiscreteEventEntry
{
public string Id = "";
public float EventStrength = 50f;
public string Category = "Event";
public bool CreatesInterest = true;
public string LabelTemplate = "{a}";
/// <summary>
/// Optional infinitive clause for decision-style reasons
/// (e.g. <c>change the kingdom's culture</c> → <c>{a} decides to …</c>).
/// </summary>
public string ActionPhrase = "";
/// <summary>
/// When set, <c>{id}</c> resolves via <see cref="LibraryAssetNames"/> for this domain.
/// </summary>
public string LibraryKind = "";
public bool IsFallback;
public string MakeLabel(Actor a, Actor b = null)
{
string template = LabelTemplate ?? "";
if (template.IndexOf("casts {id}", System.StringComparison.OrdinalIgnoreCase) >= 0
|| template.IndexOf("casts {ID}", System.StringComparison.OrdinalIgnoreCase) >= 0)
{
string an = EventFeedUtil.SafeName(a);
string obj = EventReason.SpellCastObject(Id);
return (string.IsNullOrEmpty(an) ? "Someone" : an) + " casts " + obj;
}
string displayId = ResolveIdDisplay();
string t = string.IsNullOrEmpty(template) ? "{a}" : template;
return t
.Replace("{id}", displayId)
.Replace("{a}", EventFeedUtil.SafeName(a) ?? "")
.Replace("{b}", EventFeedUtil.SafeName(b) ?? "");
}
public string MakeLabel(string a, string b)
{
string template = string.IsNullOrEmpty(LabelTemplate) ? "{id}" : LabelTemplate;
if (template.IndexOf("casts {id}", System.StringComparison.OrdinalIgnoreCase) >= 0)
{
string an = string.IsNullOrEmpty(a) ? "Someone" : a;
return an + " casts " + EventReason.SpellCastObject(Id);
}
string displayId = ResolveIdDisplay();
return template
.Replace("{id}", displayId)
.Replace("{a}", a ?? "")
.Replace("{b}", b ?? "");
}
/// <summary>Localized library name when <see cref="LibraryKind"/> is set; else humanized id.</summary>
public string ResolveIdDisplay()
{
if (string.IsNullOrEmpty(Id))
{
return "";
}
if (!string.IsNullOrEmpty(LibraryKind))
{
string named = LibraryAssetNames.DisplayName(LibraryKind, Id);
if (!string.IsNullOrEmpty(named))
{
return named;
}
}
return EventReason.HumanizeId(Id);
}
}