Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SupportStationGadgetComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Gadgets", description: "")]
3 {
4 }
5 
6 class 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 
14  protected ref map<ESupportStationType, SCR_BaseSupportStationComponent> m_mSupportStations = new map<ESupportStationType, SCR_BaseSupportStationComponent>();
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  //------------------------------------------------------------------------------------------------
37  bool InUseAnimationLoop(IEntity character)
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 
51  CharacterCommandHandlerComponent commandHandlerComponent = CharacterCommandHandlerComponent.Cast(animationComponent.FindComponent(CharacterCommandHandlerComponent));
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 
92  CharacterCommandHandlerComponent commandHandlerComponent = CharacterCommandHandlerComponent.Cast(animationComponent.FindComponent(CharacterCommandHandlerComponent));
93  if (commandHandlerComponent)
94  commandHandlerComponent.FinishItemUse();
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 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
AnimateCharacterWithGadget
protected void AnimateCharacterWithGadget(notnull IEntity character, int animationCMD, vector animationTarget=vector.Zero)
Definition: SCR_SupportStationGadgetComponent.c:98
SCR_SupportStationGadgetComponentClass
Definition: SCR_SupportStationGadgetComponent.c:2
SCR_ScriptedUserAction
A scripted action class having optional logic to check if vehicle is valid.
Definition: SCR_ScriptedUserAction.c:2
SCR_GadgetManagerComponent
Definition: SCR_GadgetManagerComponent.c:138
ItemUseParameters
Definition: ItemUseParameters.c:15
SCR_GadgetComponentClass
Definition: SCR_GadgetComponent.c:2
m_mSupportStations
protected ref map< ESupportStationType, SCR_BaseSupportStationComponent > m_mSupportStations
Definition: SCR_SupportStationGadgetComponent.c:14
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GetSupportStation
SCR_BaseSupportStationComponent GetSupportStation(ESupportStationType supportStationType)
Definition: SCR_SupportStationGadgetComponent.c:142
StopGadgetAnimation
void StopGadgetAnimation(notnull IEntity character, int animationCommand)
Definition: SCR_SupportStationGadgetComponent.c:75
InUseAnimationLoop
bool InUseAnimationLoop(IEntity character)
Definition: SCR_SupportStationGadgetComponent.c:37
ESupportStationType
ESupportStationType
Definition: ESupportStationType.c:2
Attribute
SCR_SupportStationGadgetComponentClass SCR_GadgetComponentClass Attribute(desc:"Which support station this gadget belongs to", uiwidget:UIWidgets.SearchComboBox, enums:ParamEnumArray.FromEnum(ESupportStationType), category:"Support Gadget")] protected ref array< ESupportStationType > m_aSupportStationTypes
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
GetType
override EGadgetType GetType()
Definition: SCR_SupportStationGadgetComponent.c:236
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_SupportStationGadgetComponent.c:210
StartGadgetAnimation
void StartGadgetAnimation(notnull IEntity character, int animationCommand, notnull SCR_ScriptedUserAction action)
Definition: SCR_SupportStationGadgetComponent.c:60
GetSupportStationTypes
int GetSupportStationTypes(out notnull array< ESupportStationType > types)
Definition: SCR_SupportStationGadgetComponent.c:19
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
m_bUseActionAsAnimationTarget
protected bool m_bUseActionAsAnimationTarget
Definition: SCR_SupportStationGadgetComponent.c:12
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
IsGadgetOfSupportStationType
bool IsGadgetOfSupportStationType(ESupportStationType type)
Definition: SCR_SupportStationGadgetComponent.c:29
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180