Client LuaCsForBarotrauma
BarotraumaClient/ClientSource/Events/EventActions/EventObjectiveAction.cs
1 #nullable enable
2 
3 namespace Barotrauma;
4 
5 partial class EventObjectiveAction : EventAction
6 {
7  public static void Trigger(
8  SegmentActionType Type,
9  Identifier Identifier,
10  Identifier ObjectiveTag,
11  Identifier ParentObjectiveId,
12  Identifier TextTag,
13  bool CanBeCompleted,
14  bool autoPlayVideo = false,
15  string videoFile = "",
16  int width = 450,
17  int height = 80)
18  {
19  if (Type == SegmentActionType.AddIfNotFound)
20  {
21  if (ObjectiveManager.IsSegmentActive(Identifier)) { return; }
22  }
23 
24  ObjectiveManager.Segment? segment = null;
25  // Only need to create the segment when it's being triggered (otherwise the tutorial already has the segment instance)
26  if (Type == SegmentActionType.Trigger)
27  {
28  segment = ObjectiveManager.Segment.CreateInfoBoxSegment(Identifier, ObjectiveTag, autoPlayVideo ? Tutorials.AutoPlayVideo.Yes : Tutorials.AutoPlayVideo.No,
29  new ObjectiveManager.Segment.Text(TextTag, width, height, Anchor.Center),
30  new ObjectiveManager.Segment.Video(videoFile, TextTag, width, height));
31  }
32  else if (Type == SegmentActionType.Add ||
33  Type == SegmentActionType.AddIfNotFound)
34  {
35  segment = ObjectiveManager.Segment.CreateObjectiveSegment(Identifier, !ObjectiveTag.IsEmpty ? ObjectiveTag : Identifier);
36  }
37  if (segment is not null)
38  {
39  segment.CanBeCompleted = CanBeCompleted;
40  segment.ParentId = ParentObjectiveId;
41  }
42 
43  switch (Type)
44  {
45  case SegmentActionType.Trigger:
46  case SegmentActionType.Add:
47  case SegmentActionType.AddIfNotFound:
48  ObjectiveManager.TriggerSegment(segment);
49  break;
50  case SegmentActionType.Complete:
51  ObjectiveManager.CompleteSegment(Identifier);
52  break;
53  case SegmentActionType.Remove:
54  ObjectiveManager.RemoveSegment(Identifier);
55  break;
56  case SegmentActionType.CompleteAndRemove:
57  ObjectiveManager.CompleteSegment(Identifier);
58  ObjectiveManager.RemoveSegment(Identifier);
59  break;
60  case SegmentActionType.Fail:
61  ObjectiveManager.FailSegment(Identifier);
62  break;
63  case SegmentActionType.FailAndRemove:
64  ObjectiveManager.FailSegment(Identifier);
65  ObjectiveManager.RemoveSegment(Identifier);
66  break;
67  }
68  }
69 
70  partial void UpdateProjSpecific()
71  {
72  Trigger(Type, Identifier, ObjectiveTag, ParentObjectiveId, TextTag, CanBeCompleted, AutoPlayVideo, VideoFile, Width, Height);
73  }
74 }
static void Trigger(SegmentActionType Type, Identifier Identifier, Identifier ObjectiveTag, Identifier ParentObjectiveId, Identifier TextTag, bool CanBeCompleted, bool autoPlayVideo=false, string videoFile="", int width=450, int height=80)