5 protected ref map<int, IEntity> m_mTrackedPossibleShooters =
new map<int, IEntity>();
8 protected override void AddInvokers(IEntity player)
10 super.AddInvokers(player);
16 if (!compartmentAccessComponent)
19 compartmentAccessComponent.GetOnCompartmentEntered().Insert(OnCompartmentEntered);
20 compartmentAccessComponent.GetOnCompartmentLeft().Insert(OnCompartmentLeft);
22 EventHandlerManagerComponent eventHandlerManager = EventHandlerManagerComponent.Cast(player.FindComponent(EventHandlerManagerComponent));
23 if (!eventHandlerManager)
26 eventHandlerManager.RegisterScriptHandler(
"OnProjectileShot",
this, OnWeaponFired);
27 eventHandlerManager.RegisterScriptHandler(
"OnGrenadeThrown",
this, OnGrenadeThrown);
49 if (weapon.GetWeaponType() ==
EWeaponType.WT_SMOKEGRENADE)
56 protected override void RemoveInvokers(IEntity player)
58 super.RemoveInvokers(player);
64 if (!compartmentAccessComponent)
67 compartmentAccessComponent.GetOnCompartmentEntered().Remove(OnCompartmentEntered);
68 compartmentAccessComponent.GetOnCompartmentLeft().Remove(OnCompartmentLeft);
70 EventHandlerManagerComponent eventHandlerManager = EventHandlerManagerComponent.Cast(player.FindComponent(EventHandlerManagerComponent));
71 if (!eventHandlerManager)
74 eventHandlerManager.RemoveScriptHandler(
"OnProjectileShot",
this, OnWeaponFired);
75 eventHandlerManager.RemoveScriptHandler(
"OnGrenadeThrown",
this, OnGrenadeThrown);
80 protected void OnCompartmentEntered(IEntity targetEntity, BaseCompartmentManagerComponent manager,
int mgrID,
int slotID,
bool move)
82 BaseCompartmentSlot compartment = manager.FindCompartment(slotID, mgrID);
85 if (!compartment || !compartment.GetOccupant() || compartment.GetType() ==
ECompartmentType.Turret)
90 int playerID = playerManager.GetPlayerIdFromControlledEntity(compartment.GetOccupant());
92 m_mTrackedPossibleShooters.Remove(playerID);
97 protected void OnCompartmentLeft(IEntity targetEntity, BaseCompartmentManagerComponent manager,
int mgrID,
int slotID,
bool move)
99 BaseCompartmentSlot compartment = manager.FindCompartment(slotID, mgrID);
103 if (!compartment.GetOccupant())
108 int playerID = playerManager.GetPlayerIdFromControlledEntity(compartment.GetOccupant());
112 m_mTrackedPossibleShooters.Insert(playerID, compartment.GetOccupant());
116 override void OnPlayerDisconnected(
int playerID, IEntity controlledEntity =
null)
118 controlledEntity = m_mTrackedPossibleShooters.Get(playerID);
119 super.OnPlayerDisconnected(playerID, controlledEntity);
121 m_mTrackedPossibleShooters.Remove(playerID);
125 override void OnPlayerSpawned(
int playerID, IEntity controlledEntity)
127 super.OnPlayerSpawned(playerID, controlledEntity);
128 m_mTrackedPossibleShooters.Insert(playerID, controlledEntity);
135 super.OnControlledEntityChanged(from, to);
139 int playerID =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(to);
140 m_mTrackedPossibleShooters.Insert(playerID, to);
144 int playerID =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(from);
145 m_mTrackedPossibleShooters.Remove(playerID);
151 override void OnAIKilled(IEntity AIEntity, IEntity killerEntity, notnull
Instigator killer)
153 super.OnAIKilled(AIEntity, killerEntity, killer);
157 if (killer.GetInstigatorType() !=
InstigatorType.INSTIGATOR_PLAYER)
160 SCR_ChimeraCharacter AIEntityChar = SCR_ChimeraCharacter.Cast(AIEntity);
164 int killerId = killer.GetInstigatorPlayerID();
170 Faction factionKiller =
Faction.Cast(factionManager.GetPlayerFaction(killerId));
177 if (factionKiller.IsFactionFriendly(AIEntityChar.GetFaction()))
184 override void OnPlayerKilled(
int playerId, IEntity playerEntity, IEntity killerEntity, notnull
Instigator killer)
186 super.OnPlayerKilled(playerId, playerEntity, killerEntity, killer);
187 m_mTrackedPossibleShooters.Remove(playerId);
192 if (killer.GetInstigatorType() !=
InstigatorType.INSTIGATOR_PLAYER)
195 SCR_ChimeraCharacter playerEntityChar = SCR_ChimeraCharacter.Cast(playerEntity);
196 if (!playerEntityChar)
199 int killerId = killer.GetInstigatorPlayerID();
202 if (playerId == killerId)
211 Faction factionKiller =
Faction.Cast(factionManager.GetPlayerFaction(killerId));
216 if (factionKiller.IsFactionFriendly(playerEntityChar.GetFaction()))
223 override void Update(
float timeTick)
237 for (
int i = m_mTrackedPossibleShooters.Count() - 1; i >= 0; i--)
240 playerId = m_mTrackedPossibleShooters.GetKey(i);
241 playerData =
GetGame().GetDataCollector().GetPlayerData(playerId);
245 if (m_StatsVisualization)
247 m_StatsVisualization.Get(SCR_EShootingModuleStats.DEATHS).SetText((playerData.GetStat(
SCR_EDataStats.DEATHS) - playerData.GetStat(
SCR_EDataStats.DEATHS,
false)).ToString());
248 m_StatsVisualization.Get(SCR_EShootingModuleStats.PLAYERKILLS).SetText((playerData.GetStat(
SCR_EDataStats.KILLS) - playerData.GetStat(
SCR_EDataStats.KILLS,
false)).ToString());
249 m_StatsVisualization.Get(SCR_EShootingModuleStats.AIKILLS).SetText((playerData.GetStat(
SCR_EDataStats.AI_KILLS) - playerData.GetStat(
SCR_EDataStats.AI_KILLS,
false)).ToString());
250 m_StatsVisualization.Get(SCR_EShootingModuleStats.FRIENDLYPLAYERKILLS).SetText((playerData.GetStat(
SCR_EDataStats.FRIENDLY_KILLS) - playerData.GetStat(
SCR_EDataStats.FRIENDLY_KILLS,
false)).ToString());
251 m_StatsVisualization.Get(SCR_EShootingModuleStats.FRIENDLYAIKILLS).SetText((playerData.GetStat(
SCR_EDataStats.FRIENDLY_AI_KILLS) - playerData.GetStat(
SCR_EDataStats.FRIENDLY_AI_KILLS,
false)).ToString());
252 m_StatsVisualization.Get(SCR_EShootingModuleStats.BULLETSSHOT).SetText((playerData.GetStat(
SCR_EDataStats.SHOTS) - playerData.GetStat(
SCR_EDataStats.SHOTS,
false)).ToString());
253 m_StatsVisualization.Get(SCR_EShootingModuleStats.GRENADESTHROWN).SetText((playerData.GetStat(
SCR_EDataStats.GRENADES_THROWN) - playerData.GetStat(
SCR_EDataStats.GRENADES_THROWN,
false)).ToString());
262 override void CreateVisualization()
264 super.CreateVisualization();
265 if (!m_StatsVisualization)
268 CreateEntry(
"Deaths: ", 0, SCR_EShootingModuleStats.DEATHS);
269 CreateEntry(
"Player Kills: ", 0, SCR_EShootingModuleStats.PLAYERKILLS);
270 CreateEntry(
"AI Kills: ", 0, SCR_EShootingModuleStats.AIKILLS);
271 CreateEntry(
"Friendly Player Kills: ", 0, SCR_EShootingModuleStats.FRIENDLYPLAYERKILLS);
272 CreateEntry(
"Friendly AI Kills: ", 0, SCR_EShootingModuleStats.FRIENDLYAIKILLS);
273 CreateEntry(
"Bullets Shot: ", 0, SCR_EShootingModuleStats.BULLETSSHOT);
274 CreateEntry(
"Grenades Thrown: ", 0, SCR_EShootingModuleStats.GRENADESTHROWN);
280 enum SCR_EShootingModuleStats