public void SyncCooldownToPlayer(ulong steamId) { int currentTime = MySandboxGame.TotalGamePlayTimeInMilliseconds; m_tmpRespawnTimes.Clear(); foreach (var entry in m_globalRespawnTimesMs) { // Send only those respawn times that concern the given steam player if (entry.Key.ControllerId.SteamId != steamId) { continue; } RespawnCooldownEntry syncEntry = new RespawnCooldownEntry(); syncEntry.ControllerId = entry.Key.ControllerId.SerialId; syncEntry.ShipId = entry.Key.RespawnShipId; syncEntry.RelativeRespawnTime = entry.Value - currentTime; m_tmpRespawnTimes.Add(syncEntry); } SyncCooldownResponseMessage response = new SyncCooldownResponseMessage(); response.RespawnTimes = m_tmpRespawnTimes.ToArray(); Sync.Layer.SendMessage(response, steamId); m_tmpRespawnTimes.Clear(); }
public void SyncCooldownToPlayer(ulong steamId, bool isLocal) { int currentTime = MySandboxGame.TotalTimeInMilliseconds; m_tmpRespawnTimes.Clear(); foreach (var entry in m_globalRespawnTimesMs) { // Send only those respawn times that concern the given steam player if (entry.Key.ControllerId.SteamId != steamId) { continue; } RespawnCooldownEntry syncEntry = new RespawnCooldownEntry(); syncEntry.ControllerId = entry.Key.ControllerId.SerialId; syncEntry.ShipId = entry.Key.RespawnShipId; syncEntry.RelativeRespawnTime = entry.Value - currentTime; m_tmpRespawnTimes.Add(syncEntry); } if (isLocal) { OnSyncCooldownResponse(m_tmpRespawnTimes); } else { MyMultiplayer.RaiseStaticEvent(s => OnSyncCooldownResponse, m_tmpRespawnTimes, new EndpointId(steamId)); } m_tmpRespawnTimes.Clear(); }