public override void OnServerDisconnect(NetworkConnection conn) { DebugLog.Screen("OnServerDisconnect"); var playerId = conn.playerControllers[0].gameObject.GetComponent <PlayerTransformSync>().netId.Value; var objectIds = conn.clientOwnedObjects.Select(x => x.Value).ToArray(); GetComponent <PlayerLeave>().Leave(playerId, objectIds); base.OnServerDisconnect(conn); }
public override void OnStopClient() { // Stop client without errors DebugLog.Screen("OnStopClient"); var sectorSync = GetComponent <SectorSync>(); if (sectorSync != null) { Destroy(sectorSync); } var playerJoin = GetComponent <PlayerJoin>(); if (playerJoin != null) { Destroy(playerJoin); } var playerLeave = GetComponent <PlayerLeave>(); if (playerLeave != null) { Destroy(playerLeave); } var respawnOnDeath = GetComponent <RespawnOnDeath>(); if (respawnOnDeath != null) { Destroy(respawnOnDeath); } var preventShipDestruction = GetComponent <PreventShipDestruction>(); if (preventShipDestruction != null) { Destroy(preventShipDestruction); } if (PlayerTransformSync.LocalInstance != null) { var animationSync = PlayerTransformSync.LocalInstance.gameObject.GetComponent <AnimationSync>(); if (animationSync != null) { animationSync.Reset(); } } _canEditName = true; }
public override void OnClientConnect(NetworkConnection conn) { base.OnClientConnect(conn); DebugLog.Screen("OnClientConnect"); gameObject.AddComponent <SectorSync>(); gameObject.AddComponent <PlayerJoin>().Join(_playerName); gameObject.AddComponent <PlayerLeave>(); gameObject.AddComponent <RespawnOnDeath>(); gameObject.AddComponent <PreventShipDestruction>(); _canEditName = false; OnNetworkManagerReady.Invoke(); IsReady = true; }