Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_FlareAnimationComponent.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameScripted/Flares"
, description:
"Base component for handling animation."
)]
2
class
SCR_FlareAnimationComponentClass
:
WeaponAnimationComponentClass
3
{
4
}
5
6
class
SCR_FlareAnimationComponent
:
WeaponAnimationComponent
7
{
8
protected
SCR_CharacterControllerComponent
m_UserController
;
9
10
protected
AnimationEventID
m_iFireFlare
= -1;
11
protected
AnimationEventID
m_iHideFlare
= -1;
12
13
protected
bool
m_bStartedProne
;
14
15
protected
static
const
string
CHARACTER_FIRE_INPUT_NAME =
"CharacterFire"
;
16
protected
static
const
string
ANIMATION_EVENT_FIRE =
"Fire"
;
17
protected
static
const
string
ANIMATION_EVENT_HIDE =
"Weapon_Hide"
;
18
19
protected
static
const
int
GARBAGE_COLLECTION_TIME = 30;
20
21
//------------------------------------------------------------------------------------------------
22
// constructor
26
void
SCR_FlareAnimationComponent
(
IEntityComponentSource
src,
IEntity
ent,
IEntity
parent)
27
{
28
SCR_WeaponComponent
weaponComp =
SCR_WeaponComponent
.Cast(ent.
FindComponent
(
SCR_WeaponComponent
));
29
if
(weaponComp)
30
weaponComp.
GetOnWeaponStateChanged
().Insert(
OnWeaponStateChanged
);
31
}
32
33
//------------------------------------------------------------------------------------------------
35
protected
bool
CanContinueTheAnimation
()
36
{
37
if
(!
m_UserController
.IsWeaponRaised())
38
return
false
;
39
40
if
(
m_UserController
.IsPartiallyLowered())
41
return
false
;
42
43
if
(!
m_UserController
.GetCanFireWeapon())
44
return
false
;
45
46
bool
isProne =
m_UserController
.GetStance() ==
ECharacterStance
.PRONE;
47
return
m_bStartedProne
== isProne;
48
}
49
50
//------------------------------------------------------------------------------------------------
51
override
protected
event
void
OnAnimationEvent
(
AnimationEventID
animEventType,
AnimationEventID
animUserString,
int
intParam,
float
timeFromStart,
float
timeToEnd)
52
{
53
super.OnAnimationEvent(animEventType, animUserString, intParam, timeFromStart, timeToEnd);
54
55
if
(animEventType ==
m_iHideFlare
&&
Replication
.IsServer())
56
{
57
IEntity
owner =
GetOwner
();
58
SCR_GarbageSystem
garbageSystem =
SCR_GarbageSystem
.
GetByEntityWorld
(owner);
59
if
(garbageSystem)
60
garbageSystem.Insert(owner, GARBAGE_COLLECTION_TIME);
61
}
62
63
if
(!
m_UserController
)
64
return
;
65
66
if
(!
CanContinueTheAnimation
())
67
{
68
CharacterAnimationComponent
animationComponent =
m_UserController
.GetAnimationComponent();
69
if
(!animationComponent)
70
return
;
71
72
CharacterCommandHandlerComponent
commandHandler = animationComponent.GetCommandHandler();
73
if
(commandHandler)
74
commandHandler.CancelItemUse();
75
76
return
;
77
}
78
79
if
(animEventType !=
m_iHideFlare
&& animEventType !=
m_iFireFlare
)
80
return
;
81
82
CharacterInputContext
inputContext =
m_UserController
.GetInputContext();
83
if
(!inputContext)
84
return
;
85
86
if
(animEventType ==
m_iFireFlare
)
87
{
88
inputContext.SetWeaponPullTrigger(
true
);
89
LockItem
();
90
// Observe the player in case he does something that would prevent the animation from reaching the point at which we discard this item
91
// As in such case it could cause problems due to the fact that the item is now locked
92
m_UserController
.m_OnItemUseEndedInvoker.Insert(
OnItemUseEnded
);
93
return
;
94
}
95
96
if
(animEventType !=
m_iHideFlare
)
97
return
;
98
99
inputContext.SetWeaponPullTrigger(
false
);
100
DisposeOfFlare
();
101
OnWeaponStateChanged
(null,
false
);
102
}
103
104
//------------------------------------------------------------------------------------------------
106
protected
void
FireFlare
()
107
{
108
if
(!
m_UserController
)
109
return
;
110
111
if
(
m_UserController
.GetCharacter() !=
SCR_PlayerController
.
GetLocalControlledEntity
())
112
return
;
113
114
if
(
m_UserController
.IsUsingItem())
115
return
;
116
117
m_UserController
.SetPartialLower(
false
);
118
m_bStartedProne
=
m_UserController
.GetStance() ==
ECharacterStance
.PRONE;
119
if
(!
CanContinueTheAnimation
())
120
return
;
121
122
m_UserController
.TryUseItem(
GetOwner
(),
true
,
false
);
123
}
124
125
//------------------------------------------------------------------------------------------------
130
protected
void
OnItemUseEnded
(
IEntity
item,
bool
successful,
ItemUseParameters
animParams)
131
{
132
IEntity
owner =
GetOwner
();
133
if
(item != owner)
134
return
;
135
136
WeaponComponent
wpnComp =
WeaponComponent
.Cast(owner.
FindComponent
(
WeaponComponent
));
137
if
(!wpnComp)
138
return
;
139
140
BaseMagazineComponent
currentMag = wpnComp.GetCurrentMagazine();
141
if
(currentMag)
142
return
;
143
144
LockItem
();
145
DisposeOfFlare
();
146
}
147
148
//------------------------------------------------------------------------------------------------
152
protected
void
OnWeaponStateChanged
(
WeaponComponent
weapon,
bool
active)
153
{
154
if
(!active)
155
{
156
GetGame
().GetInputManager().RemoveActionListener(CHARACTER_FIRE_INPUT_NAME,
EActionTrigger
.DOWN,
FireFlare
);
157
m_iFireFlare
= -1;
158
m_iHideFlare
= -1;
159
if
(!
m_UserController
)
160
return
;
161
162
m_UserController
.m_OnItemUseEndedInvoker.Remove(
OnItemUseEnded
);
163
if
(weapon)
164
{
165
BaseMagazineComponent
currentMag = weapon.GetCurrentMagazine();
166
if
(!currentMag)
// If player was somehow able to equip used flare, then we should make sure that he will get rid of it
167
DisposeOfFlare
();
168
}
169
170
m_UserController
= null;
171
return
;
172
}
173
174
m_UserController
= null;
175
ChimeraCharacter
character;
176
IEntity
parent =
GetOwner
().
GetParent
();
177
while
(parent)
178
{
179
character = SCR_ChimeraCharacter.Cast(parent);
180
if
(character)
181
break
;
182
183
parent = parent.
GetParent
();
184
}
185
186
if
(!character)
187
return
;
188
189
m_iHideFlare
=
GameAnimationUtils
.RegisterAnimationEvent(ANIMATION_EVENT_HIDE);
190
191
bool
isAi;
192
if
(
SCR_CharacterHelper
.IsPlayerOrAIOwner(character, isAi))
193
m_UserController
=
SCR_CharacterControllerComponent
.Cast(character.GetCharacterController());
194
195
if
(!
m_UserController
)
196
return
;
197
198
BaseMagazineComponent
currentMag = weapon.GetCurrentMagazine();
199
if
(!currentMag)
200
{
201
LockItem
();
202
DisposeOfFlare
();
203
return
;
204
}
205
206
m_iFireFlare
=
GameAnimationUtils
.RegisterAnimationEvent(ANIMATION_EVENT_FIRE);
207
208
if
(!isAi)
209
GetGame
().GetInputManager().AddActionListener(CHARACTER_FIRE_INPUT_NAME,
EActionTrigger
.DOWN,
FireFlare
);
210
}
211
212
//------------------------------------------------------------------------------------------------
214
protected
void
LockItem
()
215
{
216
SCR_WeaponAttachmentsStorageComponent weaponStorage = SCR_WeaponAttachmentsStorageComponent.Cast(
GetOwner
().FindComponent(SCR_WeaponAttachmentsStorageComponent));
217
if
(!weaponStorage)
218
return
;
219
220
weaponStorage.RequestUserLock(
m_UserController
.GetCharacter(),
true
);
221
}
222
223
//------------------------------------------------------------------------------------------------
225
protected
void
DisposeOfFlare
(
bool
doEquipNextFlare =
true
)
226
{
227
if
(!
m_UserController
)
228
return
;
229
230
SCR_ChimeraCharacter character =
m_UserController
.GetCharacter();
231
if
(!character)
232
return
;
233
234
CharacterWeaponManagerComponent weaponManager = CharacterWeaponManagerComponent.Cast(character.GetWeaponManager());
235
if
(!weaponManager)
236
return
;
237
238
WeaponSlotComponent
currentSlot = weaponManager.GetCurrentSlot();
239
if
(!currentSlot)
240
return
;
241
242
GetGame
().GetInputManager().RemoveActionListener(CHARACTER_FIRE_INPUT_NAME,
EActionTrigger
.DOWN,
FireFlare
);
243
m_UserController
.m_OnItemUseEndedInvoker.Remove(
OnItemUseEnded
);
244
m_UserController
.DropWeapon(currentSlot);
245
246
CharacterAnimationComponent
animationComponent =
m_UserController
.GetAnimationComponent();
247
if
(!animationComponent)
248
return
;
249
250
if
(doEquipNextFlare)
251
EquipNextFlare
();
252
253
CharacterCommandHandlerComponent
commandHandler = animationComponent.GetCommandHandler();
254
if
(commandHandler)
255
commandHandler.FinishItemUse(
true
);
256
}
257
258
//------------------------------------------------------------------------------------------------
260
protected
void
EquipNextFlare
()
261
{
262
if
(!
m_UserController
)
263
return
;
264
265
SCR_ChimeraCharacter character =
m_UserController
.GetCharacter();
266
if
(!character)
267
return
;
268
269
CharacterWeaponManagerComponent weaponManager = CharacterWeaponManagerComponent.Cast(character.GetWeaponManager());
270
if
(!weaponManager)
271
return
;
272
273
WeaponSlotComponent
currentSlot = weaponManager.GetCurrentSlot();
274
if
(!currentSlot)
275
return
;
276
277
SCR_InventoryStorageManagerComponent storageManager = SCR_InventoryStorageManagerComponent.Cast(
m_UserController
.GetInventoryStorageManager());
278
if
(!storageManager)
279
return
;
280
281
storageManager.TryAssigningNextItemToQuickSlot(
GetOwner
(), currentSlot.GetWeaponSlotIndex(),
false
);
282
}
283
}
AnimationEventID
int AnimationEventID
Definition
AnimationStringTypes.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
OnItemUseEnded
func OnItemUseEnded
Definition
SCR_CharacterControllerComponent.c:27
EntityEditorProps
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Definition
SCR_CompassComponent.c:10
EquipNextFlare
void EquipNextFlare()
Method used to attempt to cycle to the next flare.
Definition
SCR_FlareAnimationComponent.c:260
m_bStartedProne
bool m_bStartedProne
Definition
SCR_FlareAnimationComponent.c:13
FireFlare
void FireFlare()
Method used to start flare firing procedure.
Definition
SCR_FlareAnimationComponent.c:106
OnWeaponStateChanged
void OnWeaponStateChanged(WeaponComponent weapon, bool active)
Definition
SCR_FlareAnimationComponent.c:152
CanContinueTheAnimation
bool CanContinueTheAnimation()
Definition
SCR_FlareAnimationComponent.c:35
m_iHideFlare
AnimationEventID m_iHideFlare
Definition
SCR_FlareAnimationComponent.c:11
LockItem
void LockItem()
Method used to ensure that players wont be able to interact with this item.
Definition
SCR_FlareAnimationComponent.c:214
SCR_FlareAnimationComponent
void SCR_FlareAnimationComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition
SCR_FlareAnimationComponent.c:26
m_iFireFlare
AnimationEventID m_iFireFlare
Definition
SCR_FlareAnimationComponent.c:10
DisposeOfFlare
void DisposeOfFlare(bool doEquipNextFlare=true)
Method used to drop the item on the ground.
Definition
SCR_FlareAnimationComponent.c:225
m_UserController
SCR_FlareAnimationComponentClass m_UserController
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
BaseItemAnimationComponent::OnAnimationEvent
void OnAnimationEvent(AnimationEventID animEventType, AnimationEventID animUserString, int intParam, float timeFromStart, float timeToEnd)
BaseMagazineComponent
Definition
BaseMagazineComponent.c:13
CharacterAnimationComponent
Definition
CharacterAnimationComponent.c:13
CharacterCommandHandlerComponent
Definition
CharacterCommandHandlerComponent.c:13
CharacterInputContext
Definition
CharacterInputContext.c:13
ChimeraCharacter
Definition
ChimeraCharacter.c:13
GameAnimationUtils
Definition
GameAnimationUtils.c:8
IEntityComponentSource
Definition
IEntityComponentSource.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetParent
proto external IEntity GetParent()
ItemUseParameters
Definition
ItemUseParameters.c:16
Replication
Main replication API.
Definition
Replication.c:14
SCR_CharacterControllerComponent
Definition
SCR_CharacterControllerComponent.c:36
SCR_CharacterHelper
Definition
SCR_CharacterHelper.c:2
SCR_FlareAnimationComponentClass
Definition
SCR_FlareAnimationComponent.c:3
SCR_GarbageSystem
Script entry for garbage system modding.
Definition
SCR_GarbageSystem.c:3
SCR_GarbageSystem::GetByEntityWorld
static SCR_GarbageSystem GetByEntityWorld(IEntity entity)
Definition
SCR_GarbageSystem.c:70
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalControlledEntity
static IEntity GetLocalControlledEntity()
Definition
SCR_PlayerController.c:495
SCR_WeaponComponent
Definition
SCR_WeaponComponent.c:10
SCR_WeaponComponent::GetOnWeaponStateChanged
ScriptInvokerWeaponState GetOnWeaponStateChanged()
Definition
SCR_WeaponComponent.c:14
WeaponAnimationComponentClass
Definition
WeaponAnimationComponentClass.c:13
WeaponAnimationComponent
Definition
WeaponAnimationComponent.c:13
WeaponComponent
Definition
WeaponComponent.c:13
WeaponSlotComponent
Definition
WeaponSlotComponent.c:13
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition
SCR_FuelNode.c:128
ECharacterStance
ECharacterStance
Definition
ECharacterStance.c:13
EActionTrigger
EActionTrigger
Definition
EActionTrigger.c:13
scripts
Game
Components
Flares
SCR_FlareAnimationComponent.c
Generated by
1.17.0