4 protected ref map<int, IEntity> m_mTrackedPlayers =
new map<int, IEntity>();
5 const int LIMIT_WALKING_SPEED_PER_SECOND = 5;
6 protected int m_iMaxWalkingDistancePerSecond = LIMIT_WALKING_SPEED_PER_SECOND * m_fUpdatePeriod;
9 protected override void AddInvokers(IEntity player)
11 super.AddInvokers(player);
16 SCR_ChimeraCharacter chimeraPlayer = SCR_ChimeraCharacter.Cast(player);
21 if (!compartmentAccessComponent)
24 compartmentAccessComponent.GetOnCompartmentEntered().Insert(OnCompartmentEntered);
25 compartmentAccessComponent.GetOnCompartmentLeft().Insert(OnCompartmentLeft);
29 protected override void RemoveInvokers(IEntity player)
31 super.RemoveInvokers(player);
36 SCR_ChimeraCharacter chimeraPlayer = SCR_ChimeraCharacter.Cast(player);
41 if (!compartmentAccessComponent)
44 compartmentAccessComponent.GetOnCompartmentEntered().Remove(OnCompartmentEntered);
45 compartmentAccessComponent.GetOnCompartmentLeft().Remove(OnCompartmentLeft);
49 protected void OnCompartmentEntered(IEntity targetEntity, BaseCompartmentManagerComponent manager,
int mgrID,
int slotID,
bool move)
51 BaseCompartmentSlot compartment = manager.FindCompartment(slotID, mgrID);
60 int playerID = playerManager.GetPlayerIdFromControlledEntity(compartment.GetOccupant());
64 m_mTrackedPlayers.Remove(playerID);
68 protected void OnCompartmentLeft(IEntity targetEntity, BaseCompartmentManagerComponent manager,
int mgrID,
int slotID,
bool move)
70 BaseCompartmentSlot compartment = manager.FindCompartment(slotID, mgrID);
74 IEntity playerEntity = compartment.GetOccupant();
81 int playerID = playerManager.GetPlayerIdFromControlledEntity(playerEntity);
85 m_mTrackedPlayers.Insert(playerID, playerEntity);
89 override void OnPlayerDisconnected(
int playerID, IEntity controlledEntity =
null)
91 controlledEntity = m_mTrackedPlayers.Get(playerID);
92 super.OnPlayerDisconnected(playerID, controlledEntity);
94 m_mTrackedPlayers.Remove(playerID);
98 override void OnPlayerSpawned(
int playerID, IEntity controlledEntity)
100 super.OnPlayerSpawned(playerID, controlledEntity);
101 m_mTrackedPlayers.Insert(playerID, controlledEntity);
108 super.OnControlledEntityChanged(from, to);
112 int playerID =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(to);
113 m_mTrackedPlayers.Insert(playerID, to);
117 int playerID =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(from);
118 m_mTrackedPlayers.Remove(playerID);
124 override void OnPlayerKilled(
int playerId, IEntity playerEntity, IEntity killerEntity, notnull
Instigator killer)
126 super.OnPlayerKilled(playerId, playerEntity, killerEntity, killer);
127 m_mTrackedPlayers.Remove(playerId);
131 override void Update(
float timeTick)
139 float distanceTraveled;
142 IEntity currentEntity;
144 for (
int i = m_mTrackedPlayers.Count() - 1; i >= 0; i--)
146 currentEntity = m_mTrackedPlayers.GetElement(i);
150 physics = currentEntity.GetPhysics();
154 playerId = m_mTrackedPlayers.GetKey(i);
155 playerData =
GetGame().GetDataCollector().GetPlayerData(playerId);
161 if (distanceTraveled > m_iMaxWalkingDistancePerSecond)
162 distanceTraveled = m_iMaxWalkingDistancePerSecond;
164 playerData.AddStat(
SCR_EDataStats.DISTANCE_WALKED, distanceTraveled);
169 if (m_StatsVisualization)
170 m_StatsVisualization.Get(EBasicActionsModuleStats.DistanceWalked).SetText(playerData.GetStat(
SCR_EDataStats.DISTANCE_WALKED).ToString());
178 override void CreateVisualization()
180 super.CreateVisualization();
181 if (!m_StatsVisualization)
184 CreateEntry(
"Distance Walked: ", 0, EBasicActionsModuleStats.DistanceWalked);
191 enum EBasicActionsModuleStats