rimworld-blax-laws/Source/BlaxLaws/Model/ActEvent.cs

62 lines
2.4 KiB
C#

using RimWorld;
using Verse;
using Verse.AI;
namespace BlaxLaws
{
/// <summary>
/// One act as a hook saw it, handed to CaseFiler.Report. Hooks build it only after their Watch flag and
/// Watch.MayMatch passed, so an empty lawbook allocates nothing. Never saved.
///
/// What each category puts in def: Break the MentalStateDef, Ate the eaten ThingDef, Used the used
/// ThingDef, Interaction the InteractionDef, RecordedAct the HistoryEventDef, Record the RecordDef, Bill
/// the RecipeDef, Special the ActDef.
/// </summary>
public sealed class ActEvent
{
/// <summary>The category id (ActCategories).</summary>
public string categoryId;
/// <summary>The def the act is about; see the class summary.</summary>
public Def def;
/// <summary>Who did it. Filtered by Offenders.IsCovered inside Report.</summary>
public Pawn offender;
/// <summary>Who it was done to, when there is someone (the insulted pawn, the provoker of a fight).</summary>
public Pawn victim;
/// <summary>The thing involved (the eaten stack, the used item, the corpse), when there is one. May be destroyed by now.</summary>
public Thing thing;
/// <summary>The drug's chemical (a dose), or the binge's chosen chemical (hook A on a drug binge).</summary>
public ChemicalDef chemical;
/// <summary>The drug's category (a dose), or the binge's (MentalState_BingingDrug.drugCategory).</summary>
public DrugCategory drugCategory;
/// <summary>What the hook read from the thing for thing-level groups (hook C's prefix).</summary>
public ActFacts facts;
/// <summary>Notes the case takes over (on a table, dug up).</summary>
public CaseNotes notes;
/// <summary>The live mental state: the new one for a Break report, else null (Report reads the offender's).</summary>
public MentalState mentalState;
public ActEvent()
{
}
public ActEvent(string categoryId, Def def, Pawn offender)
{
this.categoryId = categoryId;
this.def = def;
this.offender = offender;
}
public override string ToString() =>
categoryId + "/" + (def?.defName ?? "null") + " by " + (offender?.LabelShort ?? "nobody") + (victim != null ? " on " + victim.LabelShort : "");
}
}