Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AnalyticsDataCollectionVehicleCostModule.c
Go to the documentation of this file.
3{
4 //------------------------------------------------------------------------------------------------
5 protected override void Enable()
6 {
7 super.Enable();
8
9 SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
10 if (campaign)
11 campaign.GetOnEntityRequested().Insert(OnVehicleSpawned);
12
14 if (supportStationManager)
16 }
17
18 //------------------------------------------------------------------------------------------------
19 protected override void Disable()
20 {
21 super.Disable();
22
23 SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
24 if (campaign)
25 campaign.GetOnEntityRequested().Remove(OnVehicleSpawned);
26
28 if (supportStationManager)
30 }
31
32 //------------------------------------------------------------------------------------------------
36 protected void OnVehicleSpawned(IEntity userEntity, IEntity spawnedEntity)
37 {
38 // Spawned entity is not a vehicle
39 if (!spawnedEntity.IsInherited(Vehicle))
40 return;
41
42 // User is not a player
43 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(userEntity);
44 if (playerId == 0)
45 return;
46
47 string vehicleName = SCR_AnalyticsDataCollectionHelper.GetEntityPrefabName(spawnedEntity);
48 int vehicleCost = SCR_AnalyticsDataCollectionHelper.GetEntitySupplyCost(spawnedEntity);
49
50 AddSupplySpendingData(playerId, vehicleName, vehicleCost);
51 }
52
53 //------------------------------------------------------------------------------------------------
60 protected void OnSupportStationExecuted(SCR_BaseSupportStationComponent supportStation, ESupportStationType supportStationType, IEntity actionTarget, IEntity actionUser, SCR_BaseUseSupportStationAction action)
61 {
62 if (!action)
63 return;
64
65 // We only care about repair and vehicle weapon support station types
66 if (supportStationType != ESupportStationType.REPAIR && supportStationType != ESupportStationType.VEHICLE_WEAPON)
67 return;
68
69 // User is not a player
70 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(actionUser);
71 if (playerId == 0)
72 return;
73
74 // The cost is 0, no need to add
75 int actionCost = action.GetSupportStationSuppliesOnUse();
76 if (actionCost == 0)
77 return;
78
79 // Refund action does not cost supplies
81 return;
82
83 IEntity vehiclePrefab = actionTarget.GetRootParent();
84 string vehicleName = SCR_AnalyticsDataCollectionHelper.GetEntityPrefabName(vehiclePrefab);
85
86 AddSupplySpendingData(playerId, vehicleName, actionCost);
87 }
88
89 //------------------------------------------------------------------------------------------------
94}
ESupportStationType
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
proto external IEntity GetRootParent()
void OnSupportStationExecuted(SCR_BaseSupportStationComponent supportStation, ESupportStationType supportStationType, IEntity actionTarget, IEntity actionUser, SCR_BaseUseSupportStationAction action)
void OnVehicleSpawned(IEntity userEntity, IEntity spawnedEntity)
ScriptInvokerBase< SupportStation_OnSupportStationExecuted > GetOnSupportStationExecutedSuccessfully()
static SCR_SupportStationManagerComponent GetInstance()
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24