Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BaseRocketPodsContextAction.c
Go to the documentation of this file.
3{
4 //------------------------------------------------------------------------------------------------
5 override bool CanBeShown(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
6 {
7 return selectedEntity.GetEntityType() == EEditableEntityType.VEHICLE;
8 }
9
10 //------------------------------------------------------------------------------------------------
11 override bool CanBePerformed(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
12 {
13 return true;
14 }
15
16 //------------------------------------------------------------------------------------------------
17 IEntity GetVehicleWeaponsRack(notnull IEntity vehicle, bool addIfAbsent = true)
18 {
19 SlotManagerComponent slotManager = SlotManagerComponent.Cast(vehicle.FindComponent(SlotManagerComponent));
20 if (!slotManager)
21 return null;
22
23 array<EntitySlotInfo> slots = {};
24 SCR_WeaponRackSlotInfo weaponRackSlot;
25 slotManager.GetSlotInfos(slots);
26 foreach (EntitySlotInfo slot : slots)
27 {
28 weaponRackSlot = SCR_WeaponRackSlotInfo.Cast(slot);
29 if (!weaponRackSlot)
30 continue;
31
32 if (weaponRackSlot.GetAttachedEntity())
33 return weaponRackSlot.GetAttachedEntity();
34
35 if (addIfAbsent)
36 return AddWeaponsRackToSlot(weaponRackSlot);
37 }
38
39 return null;
40 }
41
42 //------------------------------------------------------------------------------------------------
43 void GetVehicleWeapons(notnull IEntity weaponsRack, out array<IEntity> weapons)
44 {
45 array<Managed> weaponSlots = {};
46 WeaponSlotComponent weaponSlot;
47 weapons = {};
48 IEntity weapon;
49 weaponsRack.FindComponents(WeaponSlotComponent, weaponSlots);
50 foreach (Managed comp : weaponSlots)
51 {
52 weaponSlot = WeaponSlotComponent.Cast(comp);
53 if (!weaponSlot)
54 continue;
55
56 weapon = weaponSlot.GetWeaponEntity();
57 if (weapon)
58 weapons.Insert(weapon);
59 }
60 }
61
62 //------------------------------------------------------------------------------------------------
63 IEntity AddWeaponsRackToSlot(notnull SCR_WeaponRackSlotInfo weaponRackSlot)
64 {
65 ResourceName rackName = weaponRackSlot.GetDefaultWeaponRack();
66 if (rackName.IsEmpty())
67 return null;
68
69 Resource resource = Resource.Load(rackName);
70 if (!resource.IsValid())
71 return null;
72
73 IEntity weaponsRack = GetGame().SpawnEntityPrefab(resource);
74 if (!weaponsRack)
75 return null;
76
77 weaponRackSlot.AttachEntity(weaponsRack);
78 return weaponsRack;
79 }
80
81 //------------------------------------------------------------------------------------------------
82 bool CanReloadRocketPod(notnull IEntity rocketPod)
83 {
84 SCR_RocketEjectorMuzzleComponent rocketMuzzle = SCR_RocketEjectorMuzzleComponent.Cast(rocketPod.FindComponent(SCR_RocketEjectorMuzzleComponent));
85 if (!rocketMuzzle)
86 return false;
87
88 IEntity rocket;
89 for (int i, count = rocketMuzzle.GetBarrelsCount(); i < count; i++)
90 {
91 if (rocketMuzzle.CanReloadBarrel(i))
92 return true;
93 }
94
95 return false;
96 }
97
98 //------------------------------------------------------------------------------------------------
99 void ReloadRocketPod(notnull IEntity rocketPod)
100 {
101 SCR_RocketEjectorMuzzleComponent rocketMuzzle = SCR_RocketEjectorMuzzleComponent.Cast(rocketPod.FindComponent(SCR_RocketEjectorMuzzleComponent));
102 if (!rocketMuzzle)
103 return;
104
105 ResourceName defaultRocketName = rocketMuzzle.GetDefaultRocketPrefab();
106 if (defaultRocketName.IsEmpty())
107 return;
108
109 Resource resource = Resource.Load(defaultRocketName);
110 if (!resource.IsValid())
111 return;
112
113 IEntity rocket;
114 for (int i = 0, count = rocketMuzzle.GetBarrelsCount(); i < count; i++)
115 {
116 if (!rocketMuzzle.CanReloadBarrel(i))
117 continue;
118
119 rocket = GetGame().SpawnEntityPrefab(resource);
120 rocketMuzzle.ReloadBarrel(i, rocket);
121 }
122 }
123
124 //------------------------------------------------------------------------------------------------
125 void DisarmRocketPod(notnull IEntity rocketPod)
126 {
127 SCR_RocketEjectorMuzzleComponent rocketMuzzle = SCR_RocketEjectorMuzzleComponent.Cast(rocketPod.FindComponent(SCR_RocketEjectorMuzzleComponent));
128 if (!rocketMuzzle)
129 return;
130
131 ResourceName defaultRocketName = rocketMuzzle.GetDefaultRocketPrefab();
132 if (defaultRocketName.IsEmpty())
133 return;
134
135 Resource resource = Resource.Load(defaultRocketName);
136 if (!resource.IsValid())
137 return;
138
139 IEntity rocket;
140 for (int i, count = rocketMuzzle.GetBarrelsCount(); i < count; i++)
141 {
142 if (rocketMuzzle.CanReloadBarrel(i))
143 continue;
144
145 rocketMuzzle.UnloadBarrel(i);
146 }
147 }
148
149};
SCR_EAIThreatSectorFlags flags
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
class SCR_ArsenalGameModeUIDataHolder SCR_BaseContainerCustomTitleUIInfo("m_UIInfo")
Adds ability to attach an object to a slot.
proto external int FindComponents(typename typeName, notnull array< Managed > outComponents)
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
EEditableEntityType GetEntityType(IEntity owner=null)
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.