Client LuaCsForBarotrauma
BarotraumaShared/SharedSource/Events/EventActions/EventObjectiveAction.cs
1 using System;
2 
3 namespace Barotrauma
4 {
5 
10  {
11  public enum SegmentActionType
12  {
16  [Obsolete]
17  Trigger,
21  Add,
25  AddIfNotFound,
29  Complete,
33  CompleteAndRemove,
37  Remove,
41  Fail,
45  FailAndRemove
46  };
47 
48  [Serialize(SegmentActionType.Add, IsPropertySaveable.Yes, description: "Should the action add a new objective, or do something to an existing objective?")]
49  public SegmentActionType Type { get; set; }
50 
51  [Serialize("", IsPropertySaveable.Yes, description: "Arbitrary identifier given to the objective. Can be used to complete/remove/fail the objective later. Also used to fetch the text from the text files.")]
52  public Identifier Identifier { get; set; }
53 
54  [Obsolete, Serialize("", IsPropertySaveable.Yes, description: "Legacy support. Tag of the text to display as an objective in info box segments.")]
55  public Identifier ObjectiveTag { get; set; }
56 
57  [Obsolete, Serialize(true, IsPropertySaveable.Yes, description: "Legacy support. Is this objective possible to complete if it's used in an info box segment.")]
58  public bool CanBeCompleted { get; set; }
59 
60  [Serialize("", IsPropertySaveable.Yes, description: "Identifier of a parent objective. If set, this objective is displayed as a subobjective under the parent objective.")]
61  public Identifier ParentObjectiveId { get; set; }
62 
63  [Obsolete, Serialize(false, IsPropertySaveable.Yes, description: "Legacy support. Should the video defined by VideoFile play automatically, or wait for the user to play it.")]
64  public bool AutoPlayVideo { get; set; }
65 
66  [Obsolete, Serialize("", IsPropertySaveable.Yes, description: "Legacy support. Tag of the main text to display in info box segments.")]
67  public Identifier TextTag { get; set; }
68 
69  [Obsolete, Serialize("", IsPropertySaveable.Yes, description: "Legacy support. Path of a video file to display in info box segments.")]
70  public string VideoFile { get; set; }
71 
72  [Obsolete, Serialize(450, IsPropertySaveable.Yes, description: "Legacy support. Width of the info box segment.")]
73  public int Width { get; set; }
74 
75  [Obsolete, Serialize(80, IsPropertySaveable.Yes, description: "Legacy support. Height of the info box segment.")]
76  public int Height { get; set; }
77 
78  [Serialize("", IsPropertySaveable.Yes, description: "Tag of the character(s) to show the objective to.")]
79  public Identifier TargetTag { get; set; }
80 
81  private bool isFinished;
82 
83  public EventObjectiveAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
84  {
85  if (Identifier.IsEmpty)
86  {
87  Identifier = element.GetAttributeIdentifier("id", Identifier.Empty);
88  }
89  if (Type != SegmentActionType.Trigger && !TextTag.IsEmpty)
90  {
91  DebugConsole.ThrowError(
92  $"Error in {nameof(EventObjectiveAction)} in the event \"{parentEvent.Prefab.Identifier}\""+
93  $" - {nameof(TextTag)} will do nothing unless the action triggers a message box or a video.",
94  contentPackage: element.ContentPackage);
95  }
96  if (element.GetChildElement("Replace") != null)
97  {
98  DebugConsole.ThrowError(
99  $"Error in {nameof(EventObjectiveAction)} in the event \"{parentEvent.Prefab.Identifier}\"" +
100  $" - unrecognized child element \"Replace\".",
101  contentPackage: element.ContentPackage);
102  }
103  }
104 
105  public override void Update(float deltaTime)
106  {
107  if (isFinished) { return; }
108  UpdateProjSpecific();
109  isFinished = true;
110  }
111 
112  partial void UpdateProjSpecific();
113 
114  public override bool IsFinished(ref string goToLabel) => isFinished;
115 
116  public override void Reset() => isFinished = false;
117  }
118 }
ContentPackage? ContentPackage
ContentXElement? GetChildElement(string name)
Identifier GetAttributeIdentifier(string key, string def)
Displays an objective in the top-right corner of the screen, or modifies an existing objective in som...
override bool IsFinished(ref string goToLabel)
Has the action finished.