Client LuaCsForBarotrauma
CheckTraitorEventStateAction.cs
1 #nullable enable
2 
3 namespace Barotrauma
4 {
9  {
10  [Serialize(TraitorEvent.State.Completed, IsPropertySaveable.Yes, description: "What does the state of the event need to be for the check to succeed?")]
11  public TraitorEvent.State State { get; set; }
12 
13  private readonly TraitorEvent? traitorEvent;
14 
15  public CheckTraitorEventStateAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
16  {
17  if (parentEvent is TraitorEvent traitorEvent)
18  {
19  this.traitorEvent = traitorEvent;
20  }
21  else
22  {
23  DebugConsole.ThrowError($"Cannot use the action {nameof(CheckTraitorEventStateAction)} in the event \"{parentEvent.Prefab.Identifier}\" because it's not a traitor event.",
24  contentPackage: element.ContentPackage);
25  }
26  }
27 
28  protected override bool? DetermineSuccess()
29  {
30  return traitorEvent?.CurrentState == State;
31  }
32 
33  public override string ToDebugString()
34  {
35  return $"{ToolBox.GetDebugSymbol(HasBeenDetermined())} {nameof(CheckTraitorEventStateAction)} -> " +
36  $"State: {State.ColorizeObject()}, Succeeded: {succeeded.ColorizeObject()})";
37  }
38  }
39 }
Check the state of the traitor event the action is defined in. Only valid for traitor events.
override string ToDebugString()
Rich test to display in debugdraw
CheckTraitorEventStateAction(ScriptedEvent parentEvent, ContentXElement element)
ContentPackage? ContentPackage