Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SupportStationGadgetComponent.c
Go to the documentation of this file.
5
6class SCR_SupportStationGadgetComponent : SCR_GadgetComponent
7{
8 [Attribute(desc: "Which support station this gadget belongs to", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(ESupportStationType), category: "Support Gadget")]
9 protected ref array<ESupportStationType> m_aSupportStationTypes;
10
11 [Attribute("1", desc: "If true then the animation target will be the gadget Offset in world position", category: "Support Gadget")]
13
15
16 //------------------------------------------------------------------------------------------------
19 int GetSupportStationTypes(out notnull array<ESupportStationType> types)
20 {
21 types.Copy(m_aSupportStationTypes);
22
23 return types.Count();
24 }
25
26 //------------------------------------------------------------------------------------------------
30 {
31 return m_aSupportStationTypes.Contains(type);
32 }
33
34 //------------------------------------------------------------------------------------------------
38 {
39 ChimeraCharacter chimeraCharacter = ChimeraCharacter.Cast(character);
40 if (!chimeraCharacter)
41 return false;
42
43 CharacterControllerComponent charController = chimeraCharacter.GetCharacterController();
44 if (!charController)
45 return false;
46
47 CharacterAnimationComponent animationComponent = charController.GetAnimationComponent();
48 if (!animationComponent)
49 return false;
50
52 return commandHandlerComponent && commandHandlerComponent.IsItemActionLoopTag();
53 }
54
55 //------------------------------------------------------------------------------------------------
60 void StartGadgetAnimation(notnull IEntity character, int animationCommand, notnull SCR_ScriptedUserAction action)
61 {
62 if (animationCommand < 0)
63 return;
64
66 AnimateCharacterWithGadget(character, animationCommand, action.GetWorldPositionAction());
67 else
68 AnimateCharacterWithGadget(character, animationCommand);
69 }
70
71 //------------------------------------------------------------------------------------------------
75 void StopGadgetAnimation(notnull IEntity character, int animationCommand)
76 {
77 if (animationCommand < 0)
78 return;
79
80 ChimeraCharacter chimeraCharacter = ChimeraCharacter.Cast(character);
81 if (!chimeraCharacter)
82 return;
83
84 CharacterControllerComponent charController = chimeraCharacter.GetCharacterController();
85 if (!charController)
86 return;
87
88 CharacterAnimationComponent animationComponent = charController.GetAnimationComponent();
89 if (!animationComponent)
90 return;
91
93 if (commandHandlerComponent)
94 commandHandlerComponent.FinishItemUse(true);
95 }
96
97 //------------------------------------------------------------------------------------------------
98 protected void AnimateCharacterWithGadget(notnull IEntity character, int animationCMD, vector animationTarget = vector.Zero)
99 {
100 ChimeraCharacter chimeraCharacter = ChimeraCharacter.Cast(character);
101 if (!chimeraCharacter)
102 return;
103
104 CharacterControllerComponent charController = chimeraCharacter.GetCharacterController();
105 if (!charController)
106 return;
107
108 CharacterAnimationComponent animationComponent = charController.GetAnimationComponent();
109 if (!animationComponent)
110 return;
111
112 PointInfo ptWS = null;
113
114 //~ Set target look position
115 if (animationTarget != vector.Zero)
116 {
117 vector charWorldMat[4];
118 character.GetWorldTransform(charWorldMat);
119 charWorldMat[3] = animationTarget;
120 ptWS = new PointInfo();
121 ptWS.Set(null, "", charWorldMat);
122 }
123
124 int itemActionId = animationComponent.BindCommand("CMD_Item_Action");
125
127 params.SetEntity(GetOwner());
128 params.SetAllowMovementDuringAction(false);
129 params.SetKeepInHandAfterSuccess(true);
130 params.SetCommandID(itemActionId);
131 params.SetCommandIntArg(animationCMD);
132 params.SetCommandFloatArg(2.0);
133 params.SetAlignmentPoint(ptWS);
134
135 charController.TryUseItemOverrideParams(params);
136 }
137
138 //------------------------------------------------------------------------------------------------
142 SCR_BaseSupportStationComponent GetSupportStation(ESupportStationType supportStationType)
143 {
144 SCR_BaseSupportStationComponent supportStation;
145 m_mSupportStations.Find(supportStationType, supportStation);
146
147 return supportStation;
148 }
149
150 //------------------------------------------------------------------------------------------------
155 static SCR_BaseSupportStationComponent GetHeldSupportStation(ESupportStationType supportStationType, notnull IEntity character)
156 {
157 SCR_SupportStationGadgetComponent gadgetComponent = GetHeldSupportStationGadget(supportStationType, character);
158 if (!gadgetComponent)
159 return null;
160
161 return gadgetComponent.GetSupportStation(supportStationType);
162 }
163
164 //------------------------------------------------------------------------------------------------
169 static SCR_SupportStationGadgetComponent GetHeldSupportStationGadget(ESupportStationType supportStationType, notnull IEntity character)
170 {
171 SCR_GadgetManagerComponent gadgetManager = SCR_GadgetManagerComponent.GetGadgetManager(character);
172 if (!gadgetManager)
173 return null;
174
175 SCR_SupportStationGadgetComponent gadgetComponent = SCR_SupportStationGadgetComponent.Cast(gadgetManager.GetHeldGadgetComponent());
176 if (!gadgetComponent)
177 return null;
178
179 if (!gadgetComponent.IsGadgetOfSupportStationType(supportStationType))
180 return null;
181
182 return gadgetComponent;
183 }
184
185 //------------------------------------------------------------------------------------------------
192 static bool GetHeldSupportStationAndGadget(ESupportStationType supportStationType, notnull IEntity character, out SCR_BaseSupportStationComponent supportStation, out SCR_SupportStationGadgetComponent supportStationGadget)
193 {
194 SCR_GadgetManagerComponent gadgetManager = SCR_GadgetManagerComponent.GetGadgetManager(character);
195 if (!gadgetManager)
196 return false;
197
198 supportStationGadget = SCR_SupportStationGadgetComponent.Cast(gadgetManager.GetHeldGadgetComponent());
199 if (!supportStationGadget)
200 return false;
201
202 if (!supportStationGadget.IsGadgetOfSupportStationType(supportStationType))
203 return false;
204
205 supportStation = supportStationGadget.GetSupportStation(supportStationType);
206 return supportStation;
207 }
208
209 //------------------------------------------------------------------------------------------------
210 override void EOnInit(IEntity owner)
211 {
212 super.EOnInit(owner);
213
214 array<Managed> supportStations = {};
215 GetOwner().FindComponents(SCR_BaseSupportStationComponent, supportStations);
216
217 //~ Cache support stations for optimization
218 SCR_BaseSupportStationComponent supportStation;
219 foreach (Managed supportStationManaged : supportStations)
220 {
221 supportStation = SCR_BaseSupportStationComponent.Cast(supportStationManaged);
222 if (!supportStation)
223 continue;
224
225 if (m_mSupportStations.Contains(supportStation.GetSupportStationType()))
226 {
227 Print("Support Station Gadget has two or more support stations of type: '" + typename.EnumToString(ESupportStationType, supportStation.GetSupportStationType()) + "' it can only have one of the same type!", LogLevel.WARNING);
228 continue;
229 }
230
231 m_mSupportStations.Insert(supportStation.GetSupportStationType(), supportStation);
232 }
233 }
234
235 //------------------------------------------------------------------------------------------------
236 override EGadgetType GetType()
237 {
238 return EGadgetType.SPECIALIST_ITEM;
239 }
240}
ESupportStationType
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
override EGadgetType GetType()
EDamageType type
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_BaseSupportStationComponent GetSupportStation(IEntity owner)
ref map< ESupportStationType, SCR_BaseSupportStationComponent > m_mSupportStations
bool InUseAnimationLoop(IEntity character)
bool IsGadgetOfSupportStationType(ESupportStationType type)
void StopGadgetAnimation(notnull IEntity character, int animationCommand)
int GetSupportStationTypes(out notnull array< ESupportStationType > types)
void StartGadgetAnimation(notnull IEntity character, int animationCommand, notnull SCR_ScriptedUserAction action)
void AnimateCharacterWithGadget(notnull IEntity character, int animationCMD, vector animationTarget=vector.Zero)
bool m_bUseActionAsAnimationTarget
enum EVehicleType IEntity
proto external GenericComponent FindComponent(typename typeName)
proto external int FindComponents(typename typeName, notnull array< Managed > outComponents)
PointInfo - allows to define position.
Definition PointInfo.c:9
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
override void EOnInit(IEntity owner)
SCR_GadgetComponent GetHeldGadgetComponent()
A scripted action class having optional logic to check if vehicle is valid.
Definition Types.c:486
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute