!I integrate from //ce/main...
[CRYENGINE.git] / Code / CryEngine / CryAction / Analyst.h
blob142aff6c5536a475e964d639130f30f6869b5999
1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
3 #ifndef __ANALYST_H__
4 #define __ANALYST_H__
6 #pragma once
8 #include "IGameplayRecorder.h"
10 class CGameplayAnalyst : public IGameplayListener
12 public:
13 CGameplayAnalyst();
14 virtual ~CGameplayAnalyst();
16 // IGameplayListener
17 virtual void OnGameplayEvent(IEntity* pEntity, const GameplayEvent& event);
18 //~IGameplayListener
20 void ProcessPlayerEvent(EntityId id, const GameplayEvent& event);
22 // Feel free to add
23 void GetMemoryStatistics(ICrySizer* s) {}
25 typedef struct WeaponAnalysis
27 WeaponAnalysis() : usage(0), timeUsed(0.0f), zoomUsage(0), timeZoomed(0.0f), firemodes(0), melee(0), shots(0), hits(0), reloads(0), kills(0), deaths(0), damage(0) {}
29 int usage; // number of times this weapon was selected
30 CTimeValue timeUsed; // total time this weapon was used
32 int zoomUsage; // number of zoom ins
33 CTimeValue timeZoomed; // total times zoomed with this weapon
35 int firemodes; // total number of firemode changes
37 int melee; // total number of melee attacks with this weapon
38 int shots; // total number of shots fired with this weapon
39 int hits; // total number of hits with this weapon
40 int reloads;// total number of reloads with this weapon
41 int kills; // kills with this weapon
42 int deaths; // deaths while carrying this weapon
43 int damage; // total damage dealt with this weapon
44 }WeaponAnalysis;
46 typedef struct PurchaseDetail
48 PurchaseDetail() : totalAmount(0), totalSpent(0) {}
50 int totalAmount; // total amount of times purchased
51 int totalSpent; // total amount of currency spent
52 }PurchaseDetail;
54 typedef struct CurrencyAnalysis
56 CurrencyAnalysis() : totalEarned(0), totalSpent(0), nMin(0), nMax(0) {}
58 int totalEarned; // total number of currency earned
59 int totalSpent; // total number of currency spent
60 int nMin; // lowest ever currency value
61 int nMax; // max ever currency value
63 std::map<string, PurchaseDetail> spentDetail; // total currency spent on each item
64 } CurrencyAnalysis;
66 typedef struct SuitAnalysis
68 SuitAnalysis()
69 : mode(3)
71 for (int i = 0; i < 4; i++)
73 timeUsed[i] = 0.0f;
74 usage[i] = 0;
75 kills[i] = 0;
76 deaths[i] = 0;
80 CTimeValue usageStart;
81 CTimeValue timeUsed[4]; // total time using each suit mode
82 int usage[4]; // number of times this suit mode was selected
84 int kills[4]; // number of kills using each suit mode
85 int deaths[4]; // number of deaths using each suit mode
86 int mode;
87 } SuitAnalysis;
89 typedef std::map<string, WeaponAnalysis> Weapons;
91 typedef struct PlayerAnalysis
93 PlayerAnalysis()
94 : promotions(0),
95 demotions(0),
96 rank(0),
97 rankStart(0.0f),
98 maxRank(0),
99 zoomUsage(0),
100 itemUsage(0),
101 firemodes(0),
102 melee(0),
103 shots(0),
104 hits(0),
105 reloads(0),
106 damage(0),
107 kills(0),
108 deaths(0),
109 deathStart(0.0f),
110 timeDead(0.0f),
111 timeAlive(0.0f),
112 timeStart(0.0f),
113 alive(false)
115 memset(rankTime, 0, sizeof(rankTime));
118 string name; // player name
120 int promotions;
121 int demotions;
122 int rank;
123 CTimeValue rankStart;
125 int maxRank; // max rank achieved
126 CTimeValue rankTime[10];// total time spent in each rank
128 int zoomUsage; // total number of times zoomed
129 int itemUsage; // total number of item selections
130 int firemodes; // total number of firemode changes
132 int melee; // total number of melee attacks
133 int shots; // total number of shots
134 int hits; // total number of hits
135 int reloads; // total number of reloads
136 int damage; // total damage dealt
137 int kills; // total number of kills
138 int deaths; // total number of deaths
139 bool alive;
141 CTimeValue deathStart;
142 CTimeValue timeDead; // time dead / waiting to respawn
143 CTimeValue timeAlive; // time alive
144 CTimeValue timeStart; // total time played
146 Weapons weapons; // weapon analysis
147 SuitAnalysis suit;
148 CurrencyAnalysis currency; // currency analysis
149 } PlayerAnalysis;
151 typedef std::map<EntityId, PlayerAnalysis> Players;
153 typedef struct
155 Players players;
156 } GameAnalysis;
158 void Release() { delete this; };
160 void Reset();
161 void DumpToTXT();
163 void DumpWeapon(EntityId playerId, string& lines);
164 void DumpRank(string& lines);
165 void DumpSuit(string& lines);
166 void DumpCurrency(string& lines);
168 private:
169 void NewPlayer(IEntity* pEntity);
170 bool IsPlayer(EntityId entityId) const;
172 PlayerAnalysis& GetPlayer(EntityId playerId);
174 WeaponAnalysis& GetWeapon(EntityId playerId, EntityId weaponId);
175 WeaponAnalysis& GetWeapon(EntityId playerId, const char* weapon);
176 WeaponAnalysis& GetCurrentWeapon(EntityId playerId);
178 GameAnalysis m_gameanalysis;
180 #endif