12 protected ref map<int, RplId>
m_MainEntities =
new map<int, RplId>();
24 BaseGameMode gameMode =
GetGame().GetGameMode();
26 return SCR_PossessingManagerComponent.Cast(gameMode.FindComponent(SCR_PossessingManagerComponent));
62 RplComponent rplComponent = RplComponent.Cast(Replication.FindItem(rplId));
64 return rplComponent.GetEntity();
70 return GetGame().GetPlayerManager().GetPlayerControlledEntity(iPlayerId);
86 return GetRplId(
GetGame().GetPlayerManager().GetPlayerControlledEntity(iPlayerId));
96 return GetGame().GetPlayerManager().GetPlayerControlledEntity(iPlayerId);
108 return GetRplId(
GetGame().GetPlayerManager().GetPlayerControlledEntity(iPlayerId));
110 return RplId.Invalid();
119 array<int> players = {};
120 for (
int i = 0, count =
GetGame().GetPlayerManager().
GetPlayers(players); i < count; i++)
134 array<int> players = {};
135 for (
int i = 0, count =
GetGame().GetPlayerManager().
GetPlayers(players); i < count; i++)
149 int iPlayerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(entity);
162 int iPlayerId =
GetGame().GetPlayerManager().GetPlayerIdFromEntityRplId(rplId);
182 void SetMainEntity(
int playerID, IEntity controlledEntity, IEntity mainEntity,
bool isPossessing)
184 RplId mainEntityID = RplId.Invalid();
187 RplComponent rpl = RplComponent.Cast(mainEntity.FindComponent(RplComponent));
189 mainEntityID = rpl.Id();
204 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
226 static IEntity GetPlayerMainEntity(
int iPlayerId)
228 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
229 if (possessingManager)
230 return possessingManager.GetMainEntity(iPlayerId);
232 return GetGame().GetPlayerManager().GetPlayerControlledEntity(iPlayerId);
241 static RplId GetPlayerMainRplId(
int iPlayerId)
243 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
244 if (possessingManager)
245 return possessingManager.GetMainRplId(iPlayerId);
247 return possessingManager.GetRplId(
GetGame().GetPlayerManager().GetPlayerControlledEntity(iPlayerId));
254 static int GetPlayerIdFromMainEntity(IEntity entity)
256 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
257 if (possessingManager)
258 return possessingManager.GetIdFromMainEntity(entity);
260 return GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(entity);
267 static int GetPlayerIdFromMainRplId(RplId rplId)
269 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
270 if (possessingManager)
271 return possessingManager.GetIdFromMainRplId(rplId);
273 return GetGame().GetPlayerManager().GetPlayerIdFromEntityRplId(rplId);
280 static int GetPlayerIdFromControlledEntity(IEntity entity)
282 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
283 if (possessingManager)
284 return possessingManager.GetIdFromControlledEntity(entity);
286 return GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(entity);
293 static int GetPlayerIdFromControlledEntity(RplId rplId)
295 SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
296 if (possessingManager)
297 return possessingManager.GetIdFromControlledRplId(rplId);
299 return GetGame().GetPlayerManager().GetPlayerIdFromEntityRplId(rplId);
328 RplComponent rpl = RplComponent.Cast(entity.FindComponent(RplComponent));
333 return RplId.Invalid();
339 int pid = GetPlayerIdFromMainEntity(entity);
344 rc.NotifyReadyForSpawn_S();
358 if (playerController)
367 editorManager.Open();
374 playerController.SetPossessedEntity(
null);
382 return super.HandlePlayerKilled(playerId, playerEntity, killerEntity, killer);
394 super.OnPostInit(owner);
400 super.OnDelete(owner);
407 writer.WriteInt(mainEntityCount);
409 for (
int i = 0; i < mainEntityCount; i++)
422 reader.ReadInt(mainEntityCount);
426 for (
int i = 0; i < mainEntityCount; i++)
428 reader.ReadInt(playerID);
429 reader.ReadRplId(rplID);