浏览代码

fix: username error

/main
当前提交
45f64de2
共有 6 个文件被更改,包括 14 次插入27 次删除
  1. 1
      Assets/Scripts/Gameplay/Lobby/MultiverseRoomAPI.cs
  2. 2
      Assets/Scripts/Gameplay/Lobby/MultiverseSDK.cs
  3. 6
      Assets/Scripts/Gameplay/Player/SetPlayerInfoSystem.cs
  4. 22
      Assets/Scripts/Gameplay/UI/ModeBootstrap.cs
  5. 1
      Assets/Scripts/Gameplay/Unity.MegaCity.Gameplay.asmdef
  6. 9
      Assets/Scripts/Utils/NetcodeExtensions/Components/PlayerName.cs

1
Assets/Scripts/Gameplay/Lobby/MultiverseRoomAPI.cs


RoomUUID = resp.roomInfo.roomUUID;
IP = resp.allocationInfo.ip;
Port = resp.allocationInfo.gameServerPorts.FirstOrDefault(port => port.protocol == "UDP").port;
await Task.Delay(1000); // wait 1 second
ConnectToServer();
return resp;
}

2
Assets/Scripts/Gameplay/Lobby/MultiverseSDK.cs


return;
}
await Task.Delay(3000); // wait 3 seconds for the server to be ready
// mark server as ready
bool ok = await m_Multiverse.Ready();
if (!ok)

6
Assets/Scripts/Gameplay/Player/SetPlayerInfoSystem.cs


m_ConnectedPlayers = state.GetEntityQuery(ComponentType.ReadOnly<GhostOwner>());
state.RequireForUpdate<ReceiveRpcCommandRequest>();
state.RequireForUpdate<SetPlayerInfoRequest>();
UnityEngine.Debug.Log("SetPlayerInfoSystem has been loaded and initialized!");
//UGS - Removed Burst compile from here to allow static access to the MultiplayGameServerManager
//TODO : Optimize for DOTS?
public void OnUpdate(ref SystemState state)
{

UnityEngine.Debug.Log($"Client: {name} ({playerID}) has joined the game! (Thin = {!info.IsClient})\nConnected Players: {m_ConnectedPlayers.CalculateEntityCount()}");
// If any players are connected, cancel the auto shutdown task
MultiverseSDKWrapper.Instance.CancelShutdown();
// GameHostingServerEvents.UserJoinedServer?.Invoke(playerID.ToString());
// TODO
break;
}
}

22
Assets/Scripts/Gameplay/UI/ModeBootstrap.cs


public bool QuitAfterFlyover { get; }
public bool IsThinClient => TargetThinClientWorldCount > 0;
public NetworkEndpoint UserSpecifiedEndpoint { get; }
public int UGSQueryPort { get; }
public int TargetThinClientWorldCount { get; }
public int MaxCarCount { get; }

private const string RunFlyoverAndExitSwitch = "--run-flyover-and-exit";
private const string ThinClientsEnabled = "--enable-thin-clients";
private const string MaxCars = "--max-cars";
private const string MultiplayPort = "-port";
private const string MultiplayServerIp = "0.0.0.0";
private const string MultiversePort = "-port";
private const string MultiverseServerIp = "0.0.0.0";
public static ExecutionOptions Options => m_Options ??= CreateOptions();
private static ExecutionOptions m_Options;

var isAutomatedFlyOver = commandLineArgs.Contains(RunFlyoverAndExitSwitch);
ParseThinClientArgs(commandLineArgs, out var userSpecifiedEndpoint, out var userSpecifiedNumThinClients);
ParseMaxCarCountArgs(commandLineArgs, out var maxCarCount);
//If we are running Multiplay UGS, it needs to set to endpoint specific to Multiplay
ParseMultiplayEndpoint(commandLineArgs, out userSpecifiedEndpoint);
ParseMultiverseEndpoint(commandLineArgs, out userSpecifiedEndpoint);
return new ExecutionOptions(isAutomatedFlyOver, isAutomatedFlyOver, userSpecifiedEndpoint,
userSpecifiedNumThinClients, maxCarCount);
}

$"Successfully parsed commandline arg {indexOfMaxCarCount} '{maxCarString}' as int '{maxCarCount}' (for arg '{MaxCars}')!");
}
private static void ParseMultiplayEndpoint(string[] commandlineArgs, out NetworkEndpoint multiplayEndpoint)
private static void ParseMultiverseEndpoint(string[] commandlineArgs, out NetworkEndpoint multiverseEndpoint)
multiplayEndpoint = hardcodedFallbackAddress;
multiverseEndpoint = hardcodedFallbackAddress;
var indexOfPort = Array.IndexOf(commandlineArgs, MultiplayPort);
var indexOfPort = Array.IndexOf(commandlineArgs, MultiversePort);
if (indexOfPort != -1 && indexOfPort < commandlineArgs.Length)
{

return;
}
if (!NetworkEndpoint.TryParse(MultiplayServerIp, portShort, out multiplayEndpoint, NetworkFamily.Ipv4))
if (!NetworkEndpoint.TryParse(MultiverseServerIp, portShort, out multiverseEndpoint, NetworkFamily.Ipv4))
$"Cannot parse ip : port - '{MultiplayServerIp}: {portShort}' as NetworkEndpoint (for arg '{MultiplayPort}')! Using hardcoded address '{hardcodedFallbackAddress}' instead!");
$"Cannot parse ip : port - '{MultiverseServerIp}: {portShort}' as NetworkEndpoint (for arg '{MultiversePort}')! Using hardcoded address '{hardcodedFallbackAddress}' instead!");
$"Using {MultiplayPort} arg. Starting server in Multiplay UGS Mode on {multiplayEndpoint.Address}");
$"Using {MultiversePort} arg. Starting server in Multiverse Mode on {multiverseEndpoint.Address}");
Debug.LogWarning($"Expecting a port after commandline arg '{MultiplayPort}' but there was none!");
Debug.LogWarning($"Expecting a port after commandline arg '{MultiversePort}' but there was none!");
#endif
}
}

1
Assets/Scripts/Gameplay/Unity.MegaCity.Gameplay.asmdef


"Unity.Netcode.Extensions",
"Unity.Pooling",
"Kino.Postprocessing",
"Unity.Services.Samples.UGS",
"Unity.Services.Core",
"Unity.Megacity.Utils.Graphics",
"Unity.Cn.Multiverse"

9
Assets/Scripts/Utils/NetcodeExtensions/Components/PlayerName.cs


public FixedString64Bytes Name;
}
/// <summary>
/// Allows for identification of the player's ID in the UGS service.
/// </summary>
/*public struct PlayerUASID : IComponentData
{
[GhostField] public FixedString64Bytes UASId;
}*/
public struct MultiversePlayerID : IComponentData
{
[GhostField] public FixedString64Bytes PlayerId;

正在加载...
取消
保存