Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_HelicopterCollimatorSightComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Misc", description: "")]
5
6class SCR_HelicopterCollimatorSightComponent : SCR_CollimatorSightsComponent
7{
8 [Attribute(defvalue: "SightDeployment", desc: "Animation signal name used to deploy the sight")]
9 protected string m_sDeploySignalName;
10
11 [Attribute(defvalue: "-1", desc: "Dictates where in hierarchy game will look for signals manager component in which value will be changed.\n-1 == Parent while 1 == First Child")]
12 protected int m_iSignalHierarchyLevel;
13
14 [Attribute(defvalue: "v_stow", desc: "Name of the bone from which sound will be played.")]
15 protected string m_sSoundEventBoneName;
16
17 [Attribute(defvalue: "SOUND_SIGHT_DEPLOY", desc: "Deploy Sound Event Name")]
18 protected string m_sDeploySoundEventName;
19
20 [Attribute(defvalue: "SOUND_SIGHT_UNDEPLOY", desc: "Stow Sound Event Name")]
21 protected string m_sStowSoundEventName;
22
23 [Attribute(defvalue: "-150", desc: "Min sight elevation angle")]
24 protected float m_fMinSightAngle;
25
26 [Attribute(defvalue: "150", desc: "Max sight elevation angle")]
27 protected float m_fMaxSightAngle;
28
29 [Attribute(defvalue: "10", desc: "Elevation angle step", params: "0 inf 0.01")]
30 protected float m_fElevationAngleStep;
31
32 [Attribute(defvalue: "1", desc: "Factor through which current elevation will be multiplied to get desired signal value", params: "0 inf 0.001")]
33 protected float m_fElevationToSignalFactor;
34
35 [Attribute(defvalue: "SightElevation", desc: "Animation signal name used to deploy the sight")]
36 protected string m_sElevationSignalName;
37
38 [Attribute(defvalue: "v_elevation_wheel", desc: "Name of the bone from which elevation change sound will be played")]
39 protected string m_sElevationSoundEventBoneName;
40
41 [RplProp(onRplName: "OnSightStateSynced")]
42 protected bool m_bIsDeployed;
43
44 protected const string DEPLOY_COLLIMATOR_ACTION_NAME = "HelicopterSightDeploy";
45 protected const string CHANGE_COLLIMATOR_ELEVATION_ACTION_NAME = "HelicopterSightZeroing";
46
47 //------------------------------------------------------------------------------------------------
48 override void OnSightADSActivate()
49 {
51 }
52
53 //------------------------------------------------------------------------------------------------
54 override void OnSightADSDeactivated()
55 {
57 }
58
59 //------------------------------------------------------------------------------------------------
64 protected void ToggleSightState(float value = 0.0, EActionTrigger reason = 0, string actionName = string.Empty)
65 {
67 if (!character)
68 return;
69
70 SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
71 if (!controller)
72 return;
73
74 RplComponent rplComp = SCR_EntityHelper.GetEntityRplComponent(GetOwner());
75 if (!rplComp)
76 return;
77
78 ChangeSightDeployedState(!m_bIsDeployed);//this wont cause too much of a desync thus it can be done locally to not wait for network delay
79 controller.ReplicateHelicopterSightState(m_bIsDeployed, rplComp.Id());
80 }
81
82 //------------------------------------------------------------------------------------------------
85 void OwnerSyncSightState(bool newState)
86 {
87 if (newState == m_bIsDeployed)
88 return;
89
91 Replication.BumpMe();
92 }
93
94 //------------------------------------------------------------------------------------------------
99
100 //------------------------------------------------------------------------------------------------
103 void OverrideSightState(bool newState)
104 {
105 m_bIsDeployed = newState;
106 }
107
108 //------------------------------------------------------------------------------------------------
111 {
112 IEntity signalManagerOwner = GetOwner();
113 for (int i, maxLevel = Math.AbsInt(m_iSignalHierarchyLevel); i < maxLevel; i++)
114 {
115 if (!signalManagerOwner)
116 return null;
117
118 if (m_iSignalHierarchyLevel < 0)
119 signalManagerOwner = signalManagerOwner.GetParent();
120 else
121 signalManagerOwner = signalManagerOwner.GetChildren();
122 }
123
124 if (!signalManagerOwner)
125 return null;
126
127 return SignalsManagerComponent.Cast(signalManagerOwner.FindComponent(SignalsManagerComponent));
128 }
129
130 //------------------------------------------------------------------------------------------------
133 protected void ChangeSightDeployedState(bool newState)
134 {
135 m_bIsDeployed = newState;
136
138 if (!signalMgr)
139 return;
140
141 int id = signalMgr.FindSignal(m_sDeploySignalName);
142 if (signalMgr.GetSignalValue(id) == newState)
143 return;
144
145 signalMgr.SetSignalValue(id, m_bIsDeployed);
146
147 SoundComponent soundComp = SoundComponent.Cast(GetOwner().FindComponent(SoundComponent));
148 if (!soundComp)
149 return;
150
151 if (m_bIsDeployed)
152 soundComp.SoundEventBone(m_sDeploySoundEventName, m_sSoundEventBoneName);
153 else
154 soundComp.SoundEventBone(m_sStowSoundEventName, m_sSoundEventBoneName);
155 }
156
157 //------------------------------------------------------------------------------------------------
162 protected void ChangeSightElevation(float value = 0.0, EActionTrigger reason = 0, string actionName = string.Empty)
163 {
164 if (value == 0)
165 return;
166
167 value /= Math.AbsFloat(value);
168 value *= m_fElevationAngleStep;
169 value = Math.Clamp(value + GetVerticalAngularCorrection(), m_fMinSightAngle, m_fMaxSightAngle);
170 SetVerticalAngularCorrection(value);
171
172 SoundComponent soundComp = SoundComponent.Cast(GetOwner().FindComponent(SoundComponent));
173 if (soundComp)
174 soundComp.SoundEventBone(SCR_SoundEvent.SOUND_SIGHT_ELEVATION, m_sElevationSoundEventBoneName);
175
176 if (m_fElevationToSignalFactor == 0 || m_sElevationSignalName.IsEmpty())
177 return;
178
180 if (!signalMgr)
181 return;
182
183 int id = signalMgr.FindSignal(m_sElevationSignalName);
184 signalMgr.SetSignalValue(id, value * m_fElevationToSignalFactor);
185 }
186
187 //------------------------------------------------------------------------------------------------
188 protected void SetUpActionListeners()
189 {
190 InputManager inputMgr = GetGame().GetInputManager();
191 if (!m_sDeploySignalName.IsEmpty())
192 inputMgr.AddActionListener(DEPLOY_COLLIMATOR_ACTION_NAME, EActionTrigger.DOWN, ToggleSightState);
193
194 if (m_fMinSightAngle < m_fMaxSightAngle)
195 inputMgr.AddActionListener(CHANGE_COLLIMATOR_ELEVATION_ACTION_NAME, EActionTrigger.VALUE, ChangeSightElevation);
196 }
197
198 //------------------------------------------------------------------------------------------------
199 protected void RemoveActionListeners()
200 {
201 InputManager inputMgr = GetGame().GetInputManager();
202 inputMgr.RemoveActionListener(DEPLOY_COLLIMATOR_ACTION_NAME, EActionTrigger.DOWN, ToggleSightState);
203 inputMgr.RemoveActionListener(CHANGE_COLLIMATOR_ELEVATION_ACTION_NAME, EActionTrigger.VALUE, ChangeSightElevation);
204 }
205}
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
void RemoveActionListeners()
SignalsManagerComponent FindSignalsManagerComponent()
Finds signals manager component that is responsible for animation playback.
void OverrideSightState(bool newState)
void ChangeSightElevation(float value=0.0, EActionTrigger reason=0, string actionName=string.Empty)
void ChangeSightDeployedState(bool newState)
void OwnerSyncSightState(bool newState)
void ToggleSightState(float value=0.0, EActionTrigger reason=0, string actionName=string.Empty)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
proto external IEntity GetChildren()
proto external IEntity GetParent()
Input management system for user interactions.
Definition Math.c:13
Main replication API.
Definition Replication.c:14
void ReplicateHelicopterSightState(bool newState, RplId sightId)
static RplComponent GetEntityRplComponent(notnull IEntity entity)
static IEntity GetLocalControlledEntity()
IEntity GetOwner()
Owner entity of the fuel tank.
SCR_FieldOfViewSettings Attribute
EActionTrigger