Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_VehicleSalvageSupportStationUserAction.c
Go to the documentation of this file.
2{
4 protected SCR_DamageManagerComponent m_DamageManager;
5 protected bool m_bSupplyCostObtained;
6 protected int m_iSupplyCost;
7
8 //------------------------------------------------------------------------------------------------
10 {
11 return ESupportStationType.LOAD_WRECK;
12 }
13
14 //------------------------------------------------------------------------------------------------
18 {
20 return m_iSupplyCost;
21
23
24 if (!m_VehicleParent)
25 {
26 Print("'SCR_VehicleSalvageSupportStationUserAction': Vehicle is null!", LogLevel.WARNING);
27 return 0;
28 }
29
30 // Get prefab data of vehicle
31 EntityPrefabData prefabData = m_VehicleParent.GetPrefabData();
32 if (!prefabData)
33 {
34 Print("'SCR_VehicleSalvageSupportStationUserAction': Vehicle does not have prefab data!", LogLevel.WARNING);
35 return 0;
36 }
37
38 // Get prefab name of vehicle
39 ResourceName prefab = prefabData.GetPrefabName();
40 if (prefab.IsEmpty())
41 {
42 Print("'SCR_VehicleSalvageSupportStationUserAction': Prefab does not have a name!", LogLevel.WARNING);
43 return 0;
44 }
45
46 // Get vehicle faction
47 SCR_Faction faction;
48 FactionAffiliationComponent factionAff = FactionAffiliationComponent.Cast(m_VehicleParent.FindComponent(FactionAffiliationComponent));
49 if (factionAff)
50 faction = SCR_Faction.Cast(factionAff.GetDefaultAffiliatedFaction());
51
52 // Get entity catalog so we can obtain the vehicle's value
53 SCR_EntityCatalogManagerComponent catalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
54 if (!catalogManager)
55 {
56 Print("'SCR_VehicleSalvageSupportStationUserAction': Catalog Manager is null!", LogLevel.WARNING);
57 return 0;
58 }
59
60 SCR_EntityCatalogEntry catalogEntry = catalogManager.GetEntryWithPrefabFromAnyCatalog(EEntityCatalogType.VEHICLE, prefab, faction);
61 if (!catalogEntry)
62 {
63 Print("'SCR_VehicleSalvageSupportStationUserAction': Catalog entry is null!", LogLevel.WARNING);
64 return 0;
65 }
66
67 SCR_EditableEntityUIInfo editableUIInfo = SCR_EditableEntityUIInfo.Cast(catalogEntry.GetEntityUiInfo());
68 if (!editableUIInfo)
69 {
70 Print("'SCR_VehicleSalvageSupportStationUserAction': Editable UI Info of catalog entry is null!", LogLevel.WARNING);
71 return 0;
72 }
73
74 array<ref SCR_EntityBudgetValue> budgets = {};
75 editableUIInfo.GetEntityAndChildrenBudgetCost(budgets);
76
77 // Loop through budgets to find the one of target vehicle
78 foreach (SCR_EntityBudgetValue budget : budgets)
79 {
80 if (!budget)
81 continue;
82
83 if (budget.GetBudgetType() != EEditableEntityBudget.CAMPAIGN)
84 continue;
85
86 m_iSupplyCost = budget.GetBudgetValue();
87 break;
88 }
89
90 return m_iSupplyCost;
91 }
92
93 //------------------------------------------------------------------------------------------------
94 protected override void DelayedInit(IEntity owner)
95 {
96 if (!owner)
97 return;
98
99 super.DelayedInit(owner);
100
101 m_VehicleParent = Vehicle.Cast(owner);
102 if (!m_VehicleParent)
103 m_VehicleParent = Vehicle.Cast(owner.GetParent());
104
105 if (!m_VehicleParent)
106 {
107 Print("'SCR_VehicleSalvageSupportStationComponent': Vehicle Parent is null!", LogLevel.ERROR);
108 return;
109 }
110
111 m_DamageManager = m_VehicleParent.GetDamageManager();
112
113 if (!m_DamageManager)
114 {
115 Print("'SCR_VehicleSalvageSupportStationComponent': Damage Manager is null!", LogLevel.ERROR);
116 return;
117 }
118 }
119
120 //------------------------------------------------------------------------------------------------
121 override bool CanBeShownScript(IEntity user)
122 {
124
125 // Check if setting is enabled
127 if (!additionalGameSettings)
128 {
129 additionalGameSettings.SetEnableVehicleSalvage_S(false);
130 return false;
131 }
132
133 if (!additionalGameSettings.IsVehicleSalvageEnabled())
134 return false;
135
136 // Check if the vehicle exists and is destroyed
138 return false;
139
140 if (!m_DamageManager.IsDestroyed())
141 return false;
142
143 return super.CanBeShownScript(user);
144 }
145}
EEditableEntityBudget
EEntityCatalogType
ESupportStationType
void SCR_AdditionalGameModeSettingsComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
proto external IEntity GetParent()
void GetEntityAndChildrenBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
Get Entity and its children budgets.
Get UI info Prefab needs to be an editable entity or have a custom UI info logic Note that if UIInfo is NULL then the autotest will fail return Ui info *SCR_UIInfo GetEntityUiInfo()
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
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