Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RefillMagazineContextAction.c
Go to the documentation of this file.
3{
4 //------------------------------------------------------------------------------------------------
5 override bool CanBeShown(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
6 {
7 if (selectedEntity.GetEntityType() != EEditableEntityType.VEHICLE)
8 return false;
9
10 return FindTurrets(selectedEntity);
11 }
12
13 //------------------------------------------------------------------------------------------------
14 override bool CanBePerformed(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
15 {
16 array<BaseMagazineComponent> mags = {};
17
18 GetMagazines(selectedEntity, mags);
19
20 foreach (BaseMagazineComponent mag : mags)
21 {
22 if (mag.GetAmmoCount() < mag.GetMaxAmmoCount())
23 return true;
24 }
25
26 return false;
27 }
28
29 //------------------------------------------------------------------------------------------------
30 bool FindTurrets(notnull SCR_EditableEntityComponent selectedEntity, out array<Turret> turrets = null)
31 {
32 SlotManagerComponent slotManager = SlotManagerComponent.Cast(selectedEntity.GetOwner().FindComponent(SlotManagerComponent));
33 if (!slotManager)
34 return false;
35
36 array<EntitySlotInfo> slots = {};
37 SCR_WeaponRackSlotInfo weaponRackSlot;
38 slotManager.GetSlotInfos(slots);
39 Turret localTurret;
40 turrets = {};
41
42 foreach (EntitySlotInfo slot : slots)
43 {
44 localTurret = Turret.Cast(slot.GetAttachedEntity());
45 if (localTurret)
46 turrets.Insert(localTurret);
47 }
48
49 if (turrets.IsEmpty())
50 return false;
51
52 return true;
53 }
54
55 //------------------------------------------------------------------------------------------------
56 void GetMagazines(notnull SCR_EditableEntityComponent selectedEntity, out array<BaseMagazineComponent> magazines)
57 {
58 array<Turret> turrets;
59 if (!FindTurrets(selectedEntity, turrets))
60 return;
61
62 array<Managed> weaponComps = {};
63 IEntity weaponEntity;
64 MuzzleComponent muzzle;
65 WeaponSlotComponent weaponSlot;
67
68 foreach (Turret turret : turrets)
69 {
70 turret.FindComponents(WeaponSlotComponent, weaponComps);
71
72 foreach (Managed slot : weaponComps)
73 {
74 weaponSlot = WeaponSlotComponent.Cast(slot);
75 if (!weaponSlot)
76 continue;
77 weaponEntity = weaponSlot.GetWeaponEntity();
78 if (!weaponEntity)
79 continue;
80 muzzle = MuzzleComponent.Cast(weaponEntity.FindComponent(MuzzleComponent));
81 if (!muzzle)
82 continue;
83
84 mag = muzzle.GetMagazine();
85 if (mag)
86 magazines.Insert(mag);
87 }
88 }
89 }
90
91 //------------------------------------------------------------------------------------------------
92 override void Perform(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition)
93 {
94 array<BaseMagazineComponent> mags = {};
95
96 GetMagazines(selectedEntity, mags);
97
98 foreach (BaseMagazineComponent mag : mags)
99 {
100 mag.SetAmmoCount(mag.GetMaxAmmoCount());
101 }
102 }
103};
SCR_EAIThreatSectorFlags flags
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 Managed FindComponent(typename typeName)
EEditableEntityType GetEntityType(IEntity owner=null)
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.