6 #define RESPAWN_TIMER_COMPONENT_DEBUG
11 [
Attribute(
"10", UIWidgets.EditBox,
"Default time in seconds that a player has to wait after dead to respawn.",
category:
"Respawn Timers")]
12 protected float m_fRespawnTime;
17 protected ref map<int, ref SCR_RespawnTimer>
m_mRespawnTimers =
new map<int, ref SCR_RespawnTimer>();
22 #ifdef RESPAWN_TIMER_COMPONENT_DEBUG
23 protected static bool s_DebugRegistered =
false;
30 override bool RplSave(ScriptBitWriter writer)
32 writer.WriteFloat(m_fRespawnTime);
36 writer.WriteInt(playerId);
37 timer.RplSave(writer);
47 override bool RplLoad(ScriptBitReader reader)
49 reader.ReadFloat(m_fRespawnTime);
52 reader.ReadInt(count);
54 for (
int i = 0; i < count; i++)
57 reader.ReadInt(playerId);
85 return world.GetServerTimestamp();
119 Print(
"Provided playerId: (" + playerID +
") in SCR_RespawnTimerComponent was invalid!", LogLevel.ERROR);
134 Print(
"Provided playerId: (" + playerID +
") in SCR_RespawnTimerComponent was invalid!", LogLevel.ERROR);
139 return Math.Ceil(remainingTime);
150 super.OnPlayerKilled(playerId, playerEntity, killerEntity, killer);
156 if (playerEntity.IsDeleted())
177 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
187 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
196 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
201 timer.SetDuration(duration);
209 super.OnPlayerRegistered(playerId);
215 respawnTimer.SetDuration(m_fRespawnTime);
216 WorldTimestamp startTime;
217 startTime = startTime.PlusSeconds(-m_fRespawnTime);
218 respawnTimer.Start(startTime);
230 m_fRespawnTime = respawnTime;
241 return m_fRespawnTime;
253 #ifdef RESPAWN_TIMER_COMPONENT_DEBUG
256 ArmaReforgerScripted game =
GetGame();
258 const string header =
"[PlayerID] [PlayerName] [Timer] [IsFinished] [TimerObject]";
259 const string tableFmt =
"%1 | %2 | %3 | %4 | %5";
263 PlayerController playerController = game.GetPlayerController();
264 if (playerController)
265 localId = playerController.GetPlayerId();
267 DbgUI.Begin(
"Respawn Timer Component Diag");
276 string isFinished =
"False";
277 if (timer.IsFinished(timeNow))
280 string playerIdentifier = playerId.ToString();
281 string playerName = playerManager.GetPlayerName(playerId);
282 string time = timer.GetRemainingTime(timeNow).ToString();
283 string obj = timer.ToString();
286 string text =
string.Format(tableFmt, playerIdentifier, playerName, time, isFinished, obj);
287 if (playerId == localId)
299 override void EOnDiag(IEntity owner,
float timeSlice)
301 super.EOnDiag(owner, timeSlice);
303 #ifdef RESPAWN_TIMER_COMPONENT_DEBUG
314 super.OnPostInit(owner);
315 ConnectToDiagSystem(owner);
317 m_RplComponent = RplComponent.Cast(owner.FindComponent(RplComponent));
323 DisconnectFromDiagSystem(owner);
325 super.OnDelete(owner);
335 #ifdef RESPAWN_TIMER_COMPONENT_DEBUG
336 if (!s_DebugRegistered)
338 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_RESPAWN_TIMER_COMPONENT,
"",
"Respawn Timer",
"GameMode");
339 s_DebugRegistered =
true;
348 #ifdef RESPAWN_TIMER_COMPONENT_DEBUG
349 if (s_DebugRegistered)
352 s_DebugRegistered =
false;