Null protection in multiplayer manager detach

This commit is contained in:
Westin Miller
2017-09-10 15:17:50 -07:00
parent a36e8a4065
commit aa784c121b

View File

@@ -69,7 +69,8 @@ namespace Torch.Managers
/// <inheritdoc /> /// <inheritdoc />
public override void Detach() public override void Detach()
{ {
MyMultiplayer.Static.ClientLeft -= OnClientLeft; if (MyMultiplayer.Static != null)
MyMultiplayer.Static.ClientLeft -= OnClientLeft;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -114,7 +115,7 @@ namespace Torch.Managers
protected void RaiseClientJoined(ulong steamId) protected void RaiseClientJoined(ulong steamId)
{ {
var vm = new PlayerViewModel(steamId){State=ConnectionState.Connected}; var vm = new PlayerViewModel(steamId) { State = ConnectionState.Connected };
_log.Info($"Player {vm.Name} joined ({vm.SteamId}"); _log.Info($"Player {vm.Name} joined ({vm.SteamId}");
Players.Add(steamId, vm); Players.Add(steamId, vm);
PlayerJoined?.Invoke(vm); PlayerJoined?.Invoke(vm);