Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AnalyticsDataCollectionAiGroupCostModule.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(OnAIGroupSpawned);
12 }
13
14 //------------------------------------------------------------------------------------------------
15 protected override void Disable()
16 {
17 super.Disable();
18
19 SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
20 if (campaign)
21 campaign.GetOnEntityRequested().Remove(OnAIGroupSpawned);
22 }
23
24 //------------------------------------------------------------------------------------------------
28 protected void OnAIGroupSpawned(IEntity userEntity, IEntity spawnedEntity)
29 {
30 // Spawned entity is not an AI group
31 SCR_AIGroup aiGroup = SCR_AIGroup.Cast(spawnedEntity);
32 if (!aiGroup)
33 return;
34
35 // User is not a player
36 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(userEntity);
37 if (playerId == 0)
38 return;
39
40 string aiGroupName = SCR_AnalyticsDataCollectionHelper.GetEntityPrefabName(spawnedEntity);
41 int aiGroupCost = GetAiGroupCost(spawnedEntity);
42
43 AddSupplySpendingData(playerId, aiGroupName, aiGroupCost);
44 }
45
46 //------------------------------------------------------------------------------------------------
50 protected int GetAiGroupCost(IEntity groupEntity)
51 {
53 if (!editableGroupComponent)
54 return 0;
55
56 array<ref SCR_EntityBudgetValue> budgets = {};
57 editableGroupComponent.GetPrefabBudgetCost(budgets);
58
59 foreach (SCR_EntityBudgetValue budget : budgets)
60 {
61 // We only care about Conflict budget
62 if (budget.GetBudgetType() == EEditableEntityBudget.CAMPAIGN)
63 return budget.GetBudgetValue();
64 }
65
66 return 0;
67 }
68
69 //------------------------------------------------------------------------------------------------
74}
EEditableEntityBudget
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_EditableGroupComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
void OnAIGroupSpawned(IEntity userEntity, IEntity spawnedEntity)
static SCR_EditableEntityComponent GetEditableEntity(IEntity owner)