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;
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);
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();
98 RpcDo_SetDuration_BC(playerID, respawnTime);
99 Rpc(RpcDo_SetDuration_BC, playerID, respawnTime);
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(instigatorContextData);
152 int playerId = instigatorContextData.GetVictimPlayerID();
158 if (instigatorContextData.GetVictimEntity().IsDeleted())
165 RpcDo_StartTimer_BC(playerId, rplTime);
166 Rpc(RpcDo_StartTimer_BC, playerId, rplTime);
180 private void RpcDo_StartTimer_BC(
int playerId, WorldTimestamp rplTime)
190 private void RpcDo_SetDuration_BC(
int playerId,
float duration)
199 private void RpcDo_SetDurationAll_BC(
float duration)
203 timer.SetDuration(duration);
211 super.OnPlayerRegistered(playerId);
214 SCR_RespawnTimer respawnTimer =
new SCR_RespawnTimer();
218 WorldTimestamp startTime;
219 startTime = startTime.PlusSeconds(-m_fRespawnTime);
220 respawnTimer.
Start(startTime);
232 m_fRespawnTime = respawnTime;
235 RpcDo_SetDurationAll_BC(respawnTime);
236 Rpc(RpcDo_SetDurationAll_BC, respawnTime);
241 float GetRespawnTime()
243 return m_fRespawnTime;
255 #ifdef RESPAWN_TIMER_COMPONENT_DEBUG
260 const string header =
"[PlayerID] [PlayerName] [Timer] [IsFinished] [TimerObject]";
261 const string tableFmt =
"%1 | %2 | %3 | %4 | %5";
265 PlayerController playerController =
game.GetPlayerController();
266 if (playerController)
267 localId = playerController.GetPlayerId();
269 DbgUI.Begin(
"Respawn Timer Component Diag");
278 string isFinished =
"False";
279 if (timer.IsFinished(timeNow))
282 string playerIdentifier = playerId.ToString();
284 string time = timer.GetRemainingTime(timeNow).ToString();
285 string obj = timer.ToString();
288 string text =
string.Format(tableFmt, playerIdentifier, playerName, time, isFinished, obj);
289 if (playerId == localId)
303 super.EOnDiag(owner, timeSlice);
305 #ifdef RESPAWN_TIMER_COMPONENT_DEBUG
316 super.OnPostInit(owner);
317 ConnectToDiagSystem(owner);
325 DisconnectFromDiagSystem(owner);
327 super.OnDelete(owner);
337 #ifdef RESPAWN_TIMER_COMPONENT_DEBUG
338 if (!s_DebugRegistered)
341 s_DebugRegistered =
true;
350 #ifdef RESPAWN_TIMER_COMPONENT_DEBUG
351 if (s_DebugRegistered)
354 s_DebugRegistered =
false;
ArmaReforgerScripted GetGame()
override bool RplLoad(ScriptBitReader reader)
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
override bool RplSave(ScriptBitWriter writer)
RplComponent m_RplComponent
void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
void OnPlayerDeleted(int playerId, IEntity player)
ref map< int, ref SCR_RespawnTimer > m_mRespawnTimers
void SetRespawnTime(int playerID, float respawnTime)
WorldTimestamp GetCurrentTime()
void SCR_RespawnTimerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
bool GetCanPlayerSpawn(int playerID, float additionalTime=0)
void ~SCR_RespawnTimerComponent()
int GetPlayerRemainingTime(int playerID, float additionalTime=0)
bool IsPlayerEnqueued(int playerID)
proto external Managed FindComponent(typename typeName)
void Start(WorldTimestamp timeNow)
void SetDuration(float duration)
override void EOnDiag(IEntity owner, float timeSlice)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
override void OnPlayerRegistered(int playerId)
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.