Client LuaCsForBarotrauma
TriggerEventAction.cs
1 namespace Barotrauma
2 {
7  {
8  [Serialize("", IsPropertySaveable.Yes, description: "Identifier of the event to trigger.")]
9  public Identifier Identifier { get; set; }
10 
11  [Serialize(false, IsPropertySaveable.Yes, description: "If set to true, the event will trigger at the beginning of the next round. Useful for e.g. triggering some scripted event in the outpost after you finish a mission.")]
12  public bool NextRound { get; set; }
13 
14  private bool isFinished;
15 
16  public TriggerEventAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element) { }
17 
18  public override bool IsFinished(ref string goTo)
19  {
20  return isFinished;
21  }
22  public override void Reset()
23  {
24  isFinished = false;
25  }
26 
27  public override void Update(float deltaTime)
28  {
29  if (isFinished) { return; }
30 
31  if (GameMain.GameSession?.EventManager != null)
32  {
33  if (NextRound)
34  {
36  }
37  else
38  {
39  var eventPrefab = EventSet.GetEventPrefab(Identifier);
40  if (eventPrefab == null)
41  {
42  DebugConsole.ThrowError($"Error in TriggerEventAction - could not find an event with the identifier {Identifier}.",
43  contentPackage: ParentEvent.Prefab.ContentPackage);
44  }
45  else
46  {
48  if (ev != null)
49  {
51  }
52  }
53  }
54  }
55 
56  isFinished = true;
57  }
58 
59  public override string ToDebugString()
60  {
61  return $"{ToolBox.GetDebugSymbol(isFinished)} {nameof(TriggerEventAction)} -> (EventPrefab: {Identifier.ColorizeObject()})";
62  }
63  }
64 }
readonly ScriptedEvent ParentEvent
Definition: EventAction.cs:102
EventPrefab Prefab
Definition: Event.cs:16
Event CreateInstance(int seed)
Definition: EventPrefab.cs:115
Event sets are sets of random events that occur within a level (most commonly, monster spawns and scr...
Definition: EventSet.cs:31
static EventPrefab GetEventPrefab(Identifier identifier)
Definition: EventSet.cs:80
static GameSession?? GameSession
Definition: GameMain.cs:88
ContentPackage? ContentPackage
Definition: Prefab.cs:37
Triggers another scripted event.
override void Update(float deltaTime)
TriggerEventAction(ScriptedEvent parentEvent, ContentXElement element)
override bool IsFinished(ref string goTo)
Has the action finished.
override string ToDebugString()
Rich test to display in debugdraw