Client LuaCsForBarotrauma
SetTraitorEventStateAction.cs
1 #nullable enable
2 
3 namespace Barotrauma
4 {
9  {
10  private readonly TraitorEvent? traitorEvent;
11 
12  public SetTraitorEventStateAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
13  {
14  if (parentEvent is TraitorEvent traitorEvent)
15  {
16  this.traitorEvent = traitorEvent;
17  }
18  else
19  {
20  DebugConsole.ThrowError($"Cannot use the action {nameof(SetTraitorEventStateAction)} in the event \"{parentEvent.Prefab.Identifier}\" because it's not a traitor event.",
21  contentPackage: element.ContentPackage);
22  }
23  }
24 
25  [Serialize(TraitorEvent.State.Completed, IsPropertySaveable.Yes, description: "The state to set the traitor event to (Incomplete, Completed or Failed).")]
26  public TraitorEvent.State State { get; set; }
27 
28  private bool isFinished;
29 
30  public override bool IsFinished(ref string goTo)
31  {
32  return isFinished;
33  }
34 
35  public override void Reset()
36  {
37  isFinished = false;
38  }
39 
40  public override void Update(float deltaTime)
41  {
42  if (isFinished || traitorEvent == null) { return; }
43  traitorEvent.CurrentState = State;
44  isFinished = true;
45  }
46 
47  public override string ToDebugString()
48  {
49  return $"{ToolBox.GetDebugSymbol(isFinished)} {nameof(SetTraitorEventStateAction)} -> (State: {State})";
50  }
51  }
52 }
ContentPackage? ContentPackage
Sets the state of the traitor event. Only valid in traitor events.
override bool IsFinished(ref string goTo)
Has the action finished.
SetTraitorEventStateAction(ScriptedEvent parentEvent, ContentXElement element)
override string ToDebugString()
Rich test to display in debugdraw