Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
Vehicle.c
Go to the documentation of this file.
1//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
2// TODO: Separate file, also it should have SCR_ prefix
3enum EVehicleType // should be SCR_EVehicleType
4{
5 VEHICLE = 0,
6 CAR = 2,
7 TRUCK = 4,
8 APC = 8,
12 MORTAR = 128,
13 REPAIR = 256,
14 ARSENAL = 512,
15}
16//---- REFACTOR NOTE END ----
17
18class VehicleClass : BaseVehicleClass
19{
20}
21
22class Vehicle : BaseVehicle
23{
24 // Can be removed when EOnPhysicsActive is on components as well
26
27 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
28 // TODO: Attributes should be protected and use proper getter
29 [Attribute("0", UIWidgets.ComboBox, "Vehicle type:", "", ParamEnumArray.FromEnum(EVehicleType) )]
31 //---- REFACTOR NOTE END ----
32
33 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
34 // TODO: Module variable should be protected and have getter instead, also _p is wrong prefix
36 SCR_VehiclePerceivableComponent m_pPerceivableComponent;
37 //---- REFACTOR NOTE END ----
38 protected VehicleControllerComponent m_VehicleController;
39 protected SCR_ResourceComponent m_ResourceComponent;
40
41 //------------------------------------------------------------------------------------------------
50
51 //------------------------------------------------------------------------------------------------
52 override void EOnPhysicsActive(IEntity owner, bool activeState)
53 {
55 m_OnPhysicsActive.Invoke(owner, activeState);
56 }
57
58 //------------------------------------------------------------------------------------------------
61 {
63 return m_pFactionComponent.GetAffiliatedFaction();
64
65 return null;
66 }
67
68 //------------------------------------------------------------------------------------------------
74
75 //------------------------------------------------------------------------------------------------
78 {
80 return m_pFactionComponent.GetDefaultAffiliatedFaction();
81
82 return null;
83 }
84
85 //------------------------------------------------------------------------------------------------
88 {
90 return m_pFactionComponent.IsVehicleOccupied();
91
92 return false;
93 }
94
95 //------------------------------------------------------------------------------------------------
97 VehicleControllerComponent GetVehicleController()
98 {
100 }
101
102 //------------------------------------------------------------------------------------------------
105 {
107 return m_VehicleController.GetPilotCompartmentSlot();
108
109 return null;
110 }
111
112 //------------------------------------------------------------------------------------------------
115 {
117 if (slot)
118 return slot.GetOccupant();
119
120 return null;
121 }
122
123 //------------------------------------------------------------------------------------------------
125 SCR_ResourceComponent GetResourceComponent()
126 {
127 return m_ResourceComponent;
128 }
129
130 //------------------------------------------------------------------------------------------------
133 {
134 m_ResourceComponent = SCR_ResourceComponent.FindResourceComponent(this);
135 }
136
137#ifdef WORKBENCH
138 //------------------------------------------------------------------------------------------------
139 override array<ref WB_UIMenuItem> _WB_GetContextMenuItems()
140 {
141 array<ref WB_UIMenuItem> items = { new WB_UIMenuItem("Compute collision damage", 0) };
142
143 return items;
144 }
145
146 //------------------------------------------------------------------------------------------------
147 override void _WB_OnContextMenu(int id)
148 {
149 switch (id)
150 {
151 case 0:
152 {
153 WorldEditorAPI api = _WB_GetEditorAPI();
154 if (!api)
155 return;
156
158 if (!dmgManagerComp)
159 return;
160
161 float criticalFrontalDamage = dmgManagerComp.CalculateCriticalCollisionDamage();
162 if (criticalFrontalDamage <= 0)
163 {
164 Print("Error during critical collision damage callculation (returned value = " + criticalFrontalDamage + "). Check damage manager setup!", LogLevel.ERROR);
165 return;
166 }
167
168 api.BeginEntityAction();
169
170 IEntitySource ownerSource = api.EntityToSource(this);
171
172 int componentIndex = SCR_BaseContainerTools.FindComponentIndex(ownerSource, dmgManagerComp.Type());
173 array<ref ContainerIdPathEntry> path = {new ContainerIdPathEntry("components", componentIndex)};
174
175 if (api.SetVariableValue(ownerSource, path, "m_fVehicleDestroyDamage", criticalFrontalDamage.ToString()))
176 Print("Entity instance's m_fVehicleDestroyDamage set to " + criticalFrontalDamage + ". Apply this change to the prefab!", LogLevel.WARNING);
177 else
178 Print("Error setting m_fVehicleDestroyDamage set to " + criticalFrontalDamage, LogLevel.ERROR);
179
180 api.EndEntityAction();
181 }
182 }
183 }
184#endif
185
186 //------------------------------------------------------------------------------------------------
187 // constructor
190 void Vehicle(IEntitySource src, IEntity parent)
191 {
192 SetEventMask(EntityEvent.PHYSICSACTIVE);
193 }
194
195 //------------------------------------------------------------------------------------------------
196 override void EOnInit(IEntity owner)
197 {
198 m_VehicleController = VehicleControllerComponent.Cast(FindComponent(VehicleControllerComponent));
200 m_pPerceivableComponent = SCR_VehiclePerceivableComponent.Cast(FindComponent(SCR_VehiclePerceivableComponent));
202 }
203}
string path
void ContainerIdPathEntry(string propertyName, int index=-1)
Definition worldEditor.c:30
@ REPAIR
Job is fixing corrupted fragments.
SCR_ResourceComponent GetResourceComponent()
Caches and returns the resource component.
SCR_CampaignFaction GetFaction()
FactionAffiliationComponent m_pFactionComponent
SCR_CharacterPerceivableComponent m_pPerceivableComponent
SCR_CommunicationSoundComponentClass COMM_TRUCK
SCR_CommunicationSoundComponentClass APC
SCR_CommunicationSoundComponentClass FUEL_TRUCK
SCR_CommunicationSoundComponentClass TRUCK
SCR_CommunicationSoundComponentClass CAR
SCR_CommunicationSoundComponentClass MORTAR
SCR_CommunicationSoundComponentClass SUPPLY_TRUCK
bool IsOccupied()
Returns true, if slot is occupied.
SCR_ResourceComponent m_ResourceComponent
void SCR_VehicleDamageManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void EOnPhysicsActive(IEntity owner, bool activeState)
IEntity GetPilot()
Definition Vehicle.c:114
EVehicleType m_eVehicleType
Definition Vehicle.c:30
PilotCompartmentSlot GetPilotCompartmentSlot()
Get primary pilot compartment slot.
Definition Vehicle.c:104
void UpdateResourceComponent()
Definition Vehicle.c:132
EVehicleType
Definition Vehicle.c:4
@ ARSENAL
Definition Vehicle.c:14
enum EVehicleType m_OnPhysicsActive
VehicleControllerComponent m_VehicleController
Definition Vehicle.c:38
SCR_VehicleFactionAffiliationComponent GetFactionAffiliation()
Definition Vehicle.c:70
VehicleControllerComponent GetVehicleController()
Get vehicle controller.
Definition Vehicle.c:97
ScriptInvoker GetOnPhysicsActive()
Definition Vehicle.c:43
Faction GetDefaultFaction()
Definition Vehicle.c:77
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
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
EntityEvent
Various entity events.
Definition EntityEvent.c:14
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134