6 #define RESPAWN_TIMER_COMPONENT_DEBUG
14 protected ref array<ref SCR_RespawnTimer> m_aFactionRespawnTimers = {};
22 #ifdef RESPAWN_TIMER_COMPONENT_DEBUG
26 super.DrawDebugInfo();
28 DbgUI.Begin(
"Wave Respawn Diag");
31 DbgUI.Text(
"Allowed Players:");
35 string playerText =
string.Format(
"%1: %2", playerId, playerManager.GetPlayerName(playerId));
36 DbgUI.Text(playerText);
40 DbgUI.Text(
"Waiting Players:");
43 string playerText =
string.Format(
"%1: %2", playerId, playerManager.GetPlayerName(playerId));
44 DbgUI.Text(playerText);
53 DbgUI.Text(
"Faction Timers:");
57 Faction affiliatedFaction = factionManager.GetFactionByIndex(
index);
58 if (affiliatedFaction)
60 string factionText =
string.Format(
"%1: %2s (%3)",
index, respawnTimer.GetRemainingTime(timeNow), affiliatedFaction.GetFactionName());
61 DbgUI.Text(factionText);
91 Faction faction = factionManager.GetPlayerFaction(playerID);
92 int factionIndex = factionManager.GetFactionIndex(faction);
97 return m_aFactionRespawnTimers[factionIndex].GetRemainingTime(timeNow);
103 super.OnPlayerSpawned(playerId, controlledEntity);
106 if (allowedIndex != -1)
110 if (waitingIndex != -1)
113 Replication.BumpMe();
124 super.OnPlayerKilled(playerId, playerEntity, killerEntity, killer);
128 Replication.BumpMe();
144 Replication.BumpMe();
153 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
157 timer.Start(rplTime);
161 override void EOnFrame(IEntity owner,
float timeSlice)
169 int timersCount = m_aFactionRespawnTimers.Count();
175 for (
int i = 0; i < timersCount; i++)
181 if (timer.IsFinished(timeNow))
184 for (
int playerIndex =
m_aWaitingPlayers.Count() -1; playerIndex >= 0; playerIndex--)
187 playerFaction = factionManager.GetPlayerFaction(playerId);
190 int factionIndex = factionManager.GetFactionIndex(playerFaction);
191 if (factionIndex == i)
214 Replication.BumpMe();
221 super.OnPostInit(owner);
223 SetEventMask(owner, EntityEvent.INIT | EntityEvent.FRAME);
226 m_RplComponent = RplComponent.Cast(owner.FindComponent(RplComponent));
235 array<Faction> factions = {};
238 factionsCount = factionManager.GetFactionsList(factions);
243 for (
int i = 0; i < factionsCount; i++)
246 timer.SetDuration(m_fRespawnTime);
247 timer.Start(timeNow.PlusSeconds(-m_fRespawnTime));
248 m_aFactionRespawnTimers.Insert(timer);
251 Replication.BumpMe();