Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_HintSequenceComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Misc", description: "")]
2 class SCR_HintSequenceComponentClass : ScriptComponentClass
3 {
4  [Attribute()]
5  protected ref SCR_HintSequenceList m_Sequence;
6 
7  //------------------------------------------------------------------------------------------------
9  SCR_HintSequenceList GetSequence()
10  {
11  return m_Sequence;
12  }
13 }
14 
15 class SCR_HintSequenceComponent : ScriptComponent
16 {
17  protected bool m_bIsActive;
18  protected ref ScriptInvoker m_OnSequenceChange = new ScriptInvoker;
19 
21  //--- Public functions
23 
24  //------------------------------------------------------------------------------------------------
28  {
29  SCR_HintSequenceComponentClass prefabData = SCR_HintSequenceComponentClass.Cast(GetComponentData(GetOwner()));
30  if (!prefabData.GetSequence())
31  {
32  Debug.Error("No sequence defined!");
33  return false;
34  }
35 
36  SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
37  if (!hintManager.Show(prefabData.GetSequence().GetHint(0), ignoreShown: true))
38  return false;
39 
40  m_bIsActive = true;
41 
42  hintManager.GetOnHintShow().Insert(OnHintShow);
43  hintManager.GetOnHintHide().Insert(OnHintHide);
44  m_OnSequenceChange.Invoke(true);
45  return true;
46  }
47 
48  //------------------------------------------------------------------------------------------------
51  void StopSequence()
52  {
53  SCR_HintSequenceComponentClass prefabData = SCR_HintSequenceComponentClass.Cast(GetComponentData(GetOwner()));
54  SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
55  if (hintManager && prefabData.GetSequence().FindHint(hintManager.GetCurrentHint()) != -1)
56  {
57  Clear();
58  hintManager.Hide();
59  }
60  }
61 
62  //------------------------------------------------------------------------------------------------
66  {
67  if (IsSequenceActive())
68  StopSequence();
69  else
70  StartSequence();
71  }
72 
73  //------------------------------------------------------------------------------------------------
77  {
78  return m_bIsActive;
79  }
80 
81  //------------------------------------------------------------------------------------------------
84  ScriptInvoker GetOnSequenceChange()
85  {
86  return m_OnSequenceChange;
87  }
88 
90  //--- Protected functions
92 
93  //------------------------------------------------------------------------------------------------
94  protected void OnHintShow(SCR_HintUIInfo info, bool isSilent)
95  {
96  //--- Interrupted by unrelated hint
97  SCR_HintSequenceComponentClass prefabData = SCR_HintSequenceComponentClass.Cast(GetComponentData(GetOwner()));
98  if (prefabData.GetSequence().FindHint(info) == -1)
99  Clear();
100  }
101 
102  //------------------------------------------------------------------------------------------------
103  protected void OnHintHide(SCR_HintUIInfo info, bool isSilent)
104  {
105  SCR_HintSequenceComponentClass prefabData = SCR_HintSequenceComponentClass.Cast(GetComponentData(GetOwner()));
106  int index = prefabData.GetSequence().FindHint(info);
107  if (index >= 0 && index < prefabData.GetSequence().CountHints() - 1)
108  {
109  SCR_HintManagerComponent.ShowHint(prefabData.GetSequence().GetHint(index + 1), ignoreShown: true);
110  }
111  else
112  {
113  //--- Last hint, terminate
114  Clear();
115  }
116  }
117 
118  //------------------------------------------------------------------------------------------------
119  protected void Clear()
120  {
121  m_bIsActive = false;
122 
123  SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
124  hintManager.GetOnHintShow().Remove(OnHintShow);
125  hintManager.GetOnHintHide().Remove(OnHintHide);
126 
127  m_OnSequenceChange.Invoke(false);
128  }
129 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
IsSequenceActive
bool IsSequenceActive()
Definition: SCR_HintSequenceComponent.c:76
ToggleSequence
void ToggleSequence()
Definition: SCR_HintSequenceComponent.c:65
SCR_HintSequenceComponentClass
Definition: SCR_HintSequenceComponent.c:2
SCR_HintSequenceList
Definition: SCR_HintSequenceList.c:2
OnHintShow
protected void OnHintShow(SCR_HintUIInfo info, bool isSilent)
Definition: SCR_HintSequenceComponent.c:94
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
StartSequence
bool StartSequence()
Definition: SCR_HintSequenceComponent.c:27
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_HintUIInfo
Definition: SCR_HintUIInfo.c:2
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
m_OnSequenceChange
protected ref ScriptInvoker m_OnSequenceChange
Definition: SCR_HintSequenceComponent.c:18
GetOnSequenceChange
ScriptInvoker GetOnSequenceChange()
Definition: SCR_HintSequenceComponent.c:84
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
Clear
protected void Clear()
Definition: SCR_HintSequenceComponent.c:119
StopSequence
void StopSequence()
Definition: SCR_HintSequenceComponent.c:51
m_bIsActive
SCR_HintSequenceComponentClass m_bIsActive
OnHintHide
protected void OnHintHide(SCR_HintUIInfo info, bool isSilent)
Definition: SCR_HintSequenceComponent.c:103
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180