mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 20:13:02 +00:00
0445f29dfd
* Updated SyncDictionary usage in SyncedBag.cs - Removed the extra class that is no longer needed for SyncDictionary's - Removed OP codes (OP_DIRTY) switch case that no longer exists (superseded by OP_SET) Signed-off-by: Lukas Olson <lukasolson@greyblockgames.com> * Updated method names Signed-off-by: Lukas Olson <lukasolson@greyblockgames.com> * Updated more string sync dictionaries Ped_Networking.cs VehicleController.cs Player.cs SyncedServerData.cs Signed-off-by: Lukas Olson <lukasolson@greyblockgames.com> * Updated NetworkTime fields in NetStats.cs Signed-off-by: Lukas Olson <lukasolson@greyblockgames.com> * Updated syncData types Signed-off-by: Lukas Olson <lukasolson@greyblockgames.com> * Implemented conditional compilation to replace old isHeadless Signed-off-by: Lukas Olson <lukasolson@greyblockgames.com> * Updated hooks * A few more syncDictionary upgrades * Moved away from obsolete NetworkIdentity.spawned * Updated SetDirtyBit to SetSyncVarDirtyBit in DeadBody.cs * Updated ScriptingDefineSymbols for Mirror * Updated JoinGameWindow.cs * Use latest MirrorLite commit for submodule * Use latest MirrorLite commit for submodule * Reverted EditorSettings.asset to commitb1c9d38e3a
* Reverted JoinGameWindow.cs to commitb1c9d38e3a
* Changed method for headless mode in NetCmdLineHandler.cs Changed from compiler defs to SanAndreasUnity helpers for determining headless mode in NetCmdLineHandler.cs * Re-Added ConfigureHeadlessFrameRate override on CustomNetworkManager.cs * Started updating JoinGameWindow.cs - Commented out GUI errors - Updated type 'DiscoveryInfo' to 'ServerResponse' in method ConnectFromDiscovery() params. - Updated Connect() 'port' parameter to use type 'int' rather than 'ushort' as per Mirror conventions. Co-authored-by: Lukas Olson <lukasolson@greyblockgames.com>
80 lines
No EOL
2.2 KiB
C#
80 lines
No EOL
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Mirror;
|
|
using SanAndreasUnity.Utilities;
|
|
using SanAndreasUnity.Behaviours;
|
|
|
|
namespace SanAndreasUnity.Net
|
|
{
|
|
public class CustomNetworkManager : NetworkManager
|
|
{
|
|
public override void OnClientConnect()
|
|
{
|
|
if (NetStatus.IsServer)
|
|
{
|
|
// just do default action
|
|
base.OnClientConnect();
|
|
return;
|
|
}
|
|
|
|
// default method: if no scene was loaded, do Ready/AddPlayer
|
|
// we won't do this until loading process finishes
|
|
|
|
if (Loader.HasLoaded)
|
|
base.OnClientConnect();
|
|
}
|
|
|
|
public override void OnClientSceneChanged()
|
|
{
|
|
if (NetStatus.IsServer)
|
|
{
|
|
// just do default action
|
|
base.OnClientSceneChanged();
|
|
return;
|
|
}
|
|
|
|
// default method: do Ready/AddPlayer
|
|
// we won't do this until loading process finishes
|
|
|
|
if (Loader.HasLoaded)
|
|
base.OnClientSceneChanged();
|
|
}
|
|
|
|
void OnLoaderFinished()
|
|
{
|
|
if (F.IsAppInEditMode)
|
|
return;
|
|
|
|
if (NetStatus.IsServer) // don't do anything on server
|
|
return;
|
|
|
|
if (!NetworkClient.isConnected)
|
|
{
|
|
// client is not connected ? hmm... then loading process could not have started
|
|
Debug.LogErrorFormat("Loader finished, but client is not connected");
|
|
return;
|
|
}
|
|
|
|
|
|
// make client ready
|
|
if (NetworkClient.ready)
|
|
Debug.LogErrorFormat("Client was made ready before loader finished");
|
|
else
|
|
{
|
|
NetworkClient.Ready();
|
|
}
|
|
|
|
// add player if specified
|
|
if (autoCreatePlayer && NetworkClient.localPlayer == null)
|
|
{
|
|
NetworkClient.AddPlayer();
|
|
}
|
|
}
|
|
|
|
public override void ConfigureHeadlessFrameRate()
|
|
{
|
|
//Overriden so that other scripts can set the framerate without Mirror overriding it.
|
|
}
|
|
}
|
|
} |