Client LuaCsForBarotrauma
TutorialIconAction.cs
1 using System.Linq;
2 
3 namespace Barotrauma;
4 
8 class TutorialIconAction : EventAction
9 {
10  public enum ActionType { Add, Remove, RemoveTarget, RemoveIcon, Clear };
11 
12  [Serialize(ActionType.Add, IsPropertySaveable.Yes, description: "What to do with the icon. Add = add an icon, Remove = remove the icon that has the specific target and style, RemoveTarget = remove all icons assigned to the specific target, RemoveIcon = remove all icons with the specific style, Remove = remove all icons.")]
13  public ActionType Type { get; set; }
14 
15  [Serialize("", IsPropertySaveable.Yes, description: "Tag of the target to assign the icon to.")]
16  public Identifier TargetTag { get; set; }
17 
18  [Serialize("", IsPropertySaveable.Yes, description: "Style of the icon.")]
19  public Identifier IconStyle { get; set; }
20 
21  private bool isFinished;
22 
23  public TutorialIconAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element) { }
24 
25  public override void Update(float deltaTime)
26  {
27  if (isFinished) { return; }
28 #if CLIENT
29  if (GameMain.GameSession?.GameMode is TutorialMode tutorialMode)
30  {
31  if (ParentEvent.GetTargets(TargetTag).FirstOrDefault() is Entity target)
32  {
33  if (Type == ActionType.Add)
34  {
35  tutorialMode.Tutorial?.Icons.Add((target, IconStyle));
36  }
37  else if(Type == ActionType.Remove)
38  {
39  tutorialMode.Tutorial?.Icons.RemoveAll(i => i.entity == target && i.iconStyle == IconStyle);
40  }
41  else if (Type == ActionType.RemoveTarget)
42  {
43  tutorialMode.Tutorial?.Icons.RemoveAll(i => i.entity == target);
44  }
45  else if (Type == ActionType.RemoveIcon)
46  {
47  tutorialMode.Tutorial?.Icons.RemoveAll(i => i.iconStyle == IconStyle);
48  }
49  else if (Type == ActionType.Clear)
50  {
51  tutorialMode.Tutorial?.Icons.Clear();
52  }
53  }
54  }
55 #endif
56  isFinished = true;
57  }
58 
59  public override bool IsFinished(ref string goToLabel)
60  {
61  return isFinished;
62  }
63 
64  public override void Reset()
65  {
66  isFinished = false;
67  }
68 }
Displays a tutorial icon next to a specific target.
override bool IsFinished(ref string goToLabel)
TutorialIconAction(ScriptedEvent parentEvent, ContentXElement element)
override void Reset()
override void Update(float deltaTime)