2 using System.Collections.Generic;
4 using System.Reflection;
20 private int currentSubAction = 0;
26 if (currentSubAction >= 0 &&
Actions.Count > currentSubAction)
28 return Actions[currentSubAction];
37 Actions =
new List<EventAction>();
39 foreach (var e
in elem.Elements())
41 if (e.Name.ToString().Equals(
"statuseffect", StringComparison.OrdinalIgnoreCase))
43 DebugConsole.ThrowError($
"Error in event prefab \"{scriptedEvent.Prefab.Identifier}\". Status effect configured as a sub action (text: \"{Text}\"). Please configure status effects as child elements of a StatusEffectAction.",
44 contentPackage: elem.ContentPackage);
48 if (action !=
null) {
Actions.Add(action); }
54 if (currentSubAction <
Actions.Count)
56 string innerGoTo =
null;
59 if (
string.IsNullOrEmpty(innerGoTo))
70 if (currentSubAction >=
Actions.Count)
80 for (
int i = 0; i <
Actions.Count; i++)
93 Actions.ForEach(a => a.Reset());
99 if (currentSubAction <
Actions.Count)
101 Actions[currentSubAction].Update(deltaTime);
138 public virtual void Update(
float deltaTime) { }
145 Identifier typeName = element.
Name.ToString().ToIdentifier();
146 if (typeName ==
"TutorialSegmentAction")
150 else if (typeName ==
"TutorialHighlightAction")
154 actionType = Type.GetType(
"Barotrauma." + typeName, throwOnError:
true, ignoreCase:
true);
155 if (actionType ==
null) {
throw new NullReferenceException(); }
159 DebugConsole.ThrowError($
"Could not find an {nameof(EventAction)} class of the type \"{element.Name}\".",
167 if (constructor ==
null)
169 throw new Exception($
"Error in scripted event \"{scriptedEvent.Prefab.Identifier}\" - could not find a constructor for the EventAction \"{actionType}\".");
171 return constructor.Invoke(
new object[] { scriptedEvent, element }) as
EventAction;
175 DebugConsole.ThrowError(ex.InnerException !=
null ? ex.InnerException.ToString() : ex.ToString(),
183 var currentHull = entity
switch
189 if (currentHull ==
null) {
return; }
191 if (!hullTag.IsEmpty)
195 if (!linkedHullTag.IsEmpty)
198 foreach (var linkedHull
in currentHull.GetLinkedEntities<
Hull>())
225 return $
"[?] {GetType().Name}";
ContentPackage? ContentPackage
bool GetAttributeBool(string key, bool def)
XAttribute? GetAttribute(string name)
bool SetGoToTarget(string goTo)
void Update(float deltaTime)
SubactionGroup(ScriptedEvent scriptedEvent, ContentXElement elem)
List< EventAction > Actions
EventAction CurrentSubAction
bool EndConversation
Should this option end the conversation (closing the conversation prompt?). By default,...
bool IsFinished(ref string goTo)
virtual bool CanBeFinished()
virtual IEnumerable< EventAction > GetSubActions()
readonly ScriptedEvent ParentEvent
string GetEventDebugName()
EventAction(ScriptedEvent parentEvent, ContentXElement element)
virtual bool SetGoToTarget(string goTo)
static EventAction Instantiate(ScriptedEvent scriptedEvent, ContentXElement element)
abstract bool IsFinished(ref string goToLabel)
Has the action finished.
void ApplyTagsToHulls(Entity entity, Identifier hullTag, Identifier linkedHullTag)
virtual void Update(float deltaTime)
virtual string ToDebugString()
Rich test to display in debugdraw
Displays an objective in the top-right corner of the screen, or modifies an existing objective in som...
readonly Identifier Identifier
void AddTarget(Identifier tag, Entity target)
static Dictionary< Identifier, SerializableProperty > DeserializeProperties(object obj, XElement element=null)
Highlights a specific entity.