Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AnalyticsDataCollectionLoadoutCostModule.c
Go to the documentation of this file.
3{
4 //------------------------------------------------------------------------------------------------
5 protected override void Enable()
6 {
7 super.Enable();
8
10
12 if (supportStationManager)
14 }
15
16 //------------------------------------------------------------------------------------------------
17 protected override void Disable()
18 {
19 super.Disable();
20
22
24 if (supportStationManager)
26 }
27
28 //------------------------------------------------------------------------------------------------
34 protected override void OnPlayerSpawned(SCR_SpawnRequestComponent requestComponent, int playerId, SCR_SpawnData data, IEntity controlledEntity)
35 {
36 super.OnPlayerSpawned(requestComponent, playerId, data, controlledEntity);
37
39 if (!spawnPointData)
40 return;
41
42 SCR_PlayerLoadoutComponent loadoutComp = SCR_PlayerLoadoutComponent.Cast(requestComponent.GetPlayerController().FindComponent(SCR_PlayerLoadoutComponent));
43 if (!loadoutComp)
44 return;
45
46 // Get the supply cost of player loadout
48 SCR_ResourceComponent resourceComp;
49 int spawnSupplyCost = SCR_ArsenalManagerComponent.GetLoadoutCalculatedSupplyCost(loadoutComp.GetLoadout(), false, playerId, null, spawnPointData.GetSpawnPoint(), base, resourceComp);
50
51 // Player spawned on Main Base or the loadout has a cost of 0, no need to add to any data
52 if (spawnSupplyCost == 0)
53 return;
54
56 if (!loadout)
57 return;
58
59 string loadoutName = SCR_AnalyticsDataCollectionHelper.GetShortEntityPrefabName(loadout.GetLoadoutResource());
60
61 AddSupplySpendingData(playerId, loadoutName, spawnSupplyCost);
62 }
63
64 //------------------------------------------------------------------------------------------------
69 protected void OnPlayerItemRequested(SCR_ResourceComponent resourceComponent, ResourceName resourceName, IEntity requesterEntity, BaseInventoryStorageComponent inventoryStorageComponent, EResourceType resourceType, int resourceValue)
70 {
71 // Item is free, no need to add to collected data
72 if (resourceValue == 0)
73 return;
74
75 // In case the item is added to storage inside player inventory, we need to get player entity
76 IEntity ownerEntity = inventoryStorageComponent.GetOwner();
77 ownerEntity = ownerEntity.GetRootParent();
78
79 // User is not a player
80 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(ownerEntity);
81 if (playerId == 0)
82 return;
83
84 string itemName = SCR_AnalyticsDataCollectionHelper.GetShortEntityPrefabName(resourceName);
85
86 AddSupplySpendingData(playerId, itemName, resourceValue);
87 }
88
89 //------------------------------------------------------------------------------------------------
96 protected void OnSupportStationExecuted(SCR_BaseSupportStationComponent supportStation, ESupportStationType supportStationType, IEntity actionTarget, IEntity actionUser, SCR_BaseUseSupportStationAction action)
97 {
98 if (!action)
99 return;
100
101 // We only care about resupply ammo and resupply medical support stations
102 if (supportStationType != ESupportStationType.RESUPPLY_AMMO && supportStationType != ESupportStationType.RESUPPLY_MEDICAL)
103 return;
104
105 // User is not a player
106 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(actionUser);
107 if (playerId == 0)
108 return;
109
110 // The cost is 0, no need to add
111 int actionCost = action.GetSupportStationSuppliesOnUse();
112 if (actionCost == 0)
113 return;
114
116 if (!itemHolderAction)
117 return;
118
119 string itemName = SCR_AnalyticsDataCollectionHelper.GetShortEntityPrefabName(itemHolderAction.GetItemPrefab());
120
121 AddSupplySpendingData(playerId, itemName, actionCost);
122 }
123
124 //------------------------------------------------------------------------------------------------
126 {
127 Disable();
128 }
129}
ESupportStationType
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
ResourceName resourceName
Definition SCR_AIGroup.c:66
Get all prefabs that have the spawner data
proto external IEntity GetRootParent()
void OnPlayerItemRequested(SCR_ResourceComponent resourceComponent, ResourceName resourceName, IEntity requesterEntity, BaseInventoryStorageComponent inventoryStorageComponent, EResourceType resourceType, int resourceValue)
void OnSupportStationExecuted(SCR_BaseSupportStationComponent supportStation, ESupportStationType supportStationType, IEntity actionTarget, IEntity actionUser, SCR_BaseUseSupportStationAction action)
override void OnPlayerSpawned(SCR_SpawnRequestComponent requestComponent, int playerId, SCR_SpawnData data, IEntity controlledEntity)
ScriptInvokerBase< SupportStation_OnSupportStationExecuted > GetOnSupportStationExecutedSuccessfully()
static SCR_SupportStationManagerComponent GetInstance()