Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RefundPylonSupportStationAction.c
Go to the documentation of this file.
2{
3 [Attribute("1", params: "0")]
4 protected float m_fRefundMultiplier;
5
6 [Attribute("1", desc: "If true will disable the action if at least one of the barrels are occupied", params: "0")]
8
9 [Attribute(defvalue: "0", desc: "Id of the weapon slot from which this action should remove the pylon.", params: "0 inf")]
10 protected int m_iPylonIndex;
11
12 protected const LocalizedString INVALID_BARRELS_OCCUPIED = "#AR-SupportStation_ActionInvalid_PylonBarrelsOccupied";
13
16
19
20 protected SCR_EArsenalSupplyCostType m_eArsenalSupplyCostType = SCR_EArsenalSupplyCostType.DEFAULT;
21
22 protected SCR_BaseSupportStationComponent m_LastCheckedSupportStation;
23
24 //------------------------------------------------------------------------------------------------
26 {
27 return m_iPylonIndex;
28 }
29
30 //------------------------------------------------------------------------------------------------
35
36 //------------------------------------------------------------------------------------------------
38 {
39 //~ Get supply cost type if support station changed
41 {
43
45 if (arsenalComp)
47 }
48
49 //~ Get actual supply cost
50 if (m_ArsenalData)
51 return m_ArsenalData.GetSupplyCost(m_eArsenalSupplyCostType, false);
52 else if (m_NonArsenalData)
53 return m_NonArsenalData.GetSupplyCost(m_eArsenalSupplyCostType);
54
55 return 0;
56 }
57
58 //------------------------------------------------------------------------------------------------
59 override bool CanBeShownScript(IEntity user)
60 {
62 return false;
63
64 const IEntity pylon = m_ManagedWeaponSlot.GetWeaponEntity();
65 if (!pylon)
66 return false;
67
69 {
72 return false;
73 }
74
75 return super.CanBeShownScript(user);
76 }
77
78 //------------------------------------------------------------------------------------------------
79 override bool CanBePerformedScript(IEntity user)
80 {
81 if (!GetOwner() || GetOwner().IsDeleted())
82 return false;
83
85 {
86 const int count = m_RocketMuzzleComp.GetBarrelsCount();
87 for(int i = 0; i < count; i++)
88 {
89 if (!m_RocketMuzzleComp.CanReloadBarrel(i))
90 {
93 return false;
94 }
95 }
96 }
97
98 return super.CanBePerformedScript(user);
99 }
100
101 //------------------------------------------------------------------------------------------------
102 protected override void DelayedInit(IEntity owner)
103 {
104 if (!owner)
105 return;
106
107 super.DelayedInit(owner);
108
109 array<Managed> weaponSlots = {};
110 owner.FindComponents(WeaponSlotComponent, weaponSlots);
111
112 WeaponSlotComponent weaponSlot;
113 foreach (Managed slot : weaponSlots)
114 {
115 weaponSlot = WeaponSlotComponent.Cast(slot);
116 if (!weaponSlot)
117 continue;
118
119 if (weaponSlot.GetWeaponSlotIndex() != m_iPylonIndex)
120 continue;
121
122 m_ManagedWeaponSlot = weaponSlot;
123 }
124
126 {
127 Print("SCR_RefundPylonSupportStationAction was unable to find weapon slot with id = " + m_iPylonIndex + " in " + FilePath.StripPath(SCR_ResourceNameUtils.GetPrefabName(owner)), LogLevel.ERROR);
128 return;
129 }
130
131
132 SCR_EntityCatalogManagerComponent catalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
133 if (!catalogManager)
134 return;
135
136 EntityPrefabData prefabData = owner.GetPrefabData();
137 if (!prefabData || prefabData.GetPrefabName().IsEmpty())
138 {
139 Print("SCR_RefundPylonSupportStationAction action attached to non-prefab!", LogLevel.ERROR);
140 return;
141 }
142
143 SCR_EntityCatalogEntry entry = catalogManager.GetEntryWithPrefabFromAnyCatalog(EEntityCatalogType.ITEM, prefabData.GetPrefabName());
144 if (!entry)
145 {
146 Print("SCR_RefundPylonSupportStationAction could not find the prefab data in catalog.", LogLevel.WARNING);
147 return;
148 }
149
151 if (m_ArsenalData)
152 return;
153
155 {
157 return;
158 }
159
160 Print("SCR_RefundPylonSupportStationAction could not find the ArsenalItem nor the NonArsenalItemCost data on the catalog entry so could not get the supply cost", LogLevel.WARNING);
161 }
162
163 //------------------------------------------------------------------------------------------------
165 {
166 return ESupportStationType.VEHICLE_WEAPON;
167 }
168
169 //------------------------------------------------------------------------------------------------
170 override bool GetActionNameScript(out string outName)
171 {
172 UIInfo uiInfo = GetUIInfo();
173 if (!uiInfo)
174 return super.GetActionNameScript(outName);
175
176 string pylonName;
177
178 //~ Item to refund has no inventory component
180 {
181 pylonName = "MISSING NAME OR INVALID PREFAB";
182
183 InventoryItemComponent inventoryItem = InventoryItemComponent.Cast(m_RocketMuzzleComp.GetOwner().FindComponent(InventoryItemComponent));
184 if (inventoryItem)
185 {
186 UIInfo itemUIInfo = inventoryItem.GetUIInfo();
187
188 if (itemUIInfo)
189 pylonName = itemUIInfo.GetName();
190 }
191 }
192
193 outName = WidgetManager.Translate(uiInfo.GetName(), pylonName);
194
195 return super.GetActionNameScript(outName);
196 }
197}
EEntityCatalogType
ESupportStationType
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
string m_sCannotPerformReason
proto external Managed FindComponent(typename typeName)
proto external int FindComponents(typename typeName, notnull array< Managed > outComponents)
proto external EntityPrefabData GetPrefabData()
SCR_EArsenalSupplyCostType GetSupplyCostType()
SCR_BaseSupportStationComponent m_SupportStationComponent
void SetCanPerform(bool canPerform, ESupportStationReasonInvalid reasonInvalid)
Get prefab entity Data of type Ignores disabled Data s param dataType class of Data type you with to obtain return Entity Data of given type Null if not found *SCR_BaseEntityCatalogData GetEntityDataOfType(typename dataType)
Base Used for items and attachments which should not be shown in the arsenal but should have a cost t...
SCR_BaseSupportStationComponent m_LastCheckedSupportStation
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
IEntity GetOwner()
Owner entity of the fuel tank.
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