mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-03 17:53:57 +00:00
slightly optimize
This commit is contained in:
parent
23421993d2
commit
3d386e00f7
@ -24,12 +24,6 @@ namespace QSB.Player
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
if (localInstance.NetIdentity == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Trying to get LocalPlayerId when the local PlayerTransformSync instance's QNetworkIdentity is null.", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
return localInstance.NetIdentity.NetId.Value;
|
||||
}
|
||||
}
|
||||
@ -38,13 +32,13 @@ namespace QSB.Player
|
||||
public static Action<uint> OnAddPlayer;
|
||||
|
||||
public static PlayerInfo LocalPlayer => GetPlayer(LocalPlayerId);
|
||||
public static List<PlayerInfo> PlayerList { get; } = new List<PlayerInfo>();
|
||||
public static List<PlayerInfo> PlayerList { get; } = new();
|
||||
|
||||
private static readonly List<PlayerSyncObject> PlayerSyncObjects = new();
|
||||
|
||||
public static PlayerInfo GetPlayer(uint id)
|
||||
{
|
||||
if (id is uint.MaxValue or 0U)
|
||||
if (id is uint.MaxValue or 0)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
@ -74,7 +68,7 @@ namespace QSB.Player
|
||||
}
|
||||
|
||||
public static bool PlayerExists(uint id) =>
|
||||
id != uint.MaxValue && PlayerList.Any(x => x.PlayerId == id);
|
||||
id is not (uint.MaxValue or 0) && PlayerList.Any(x => x.PlayerId == id);
|
||||
|
||||
public static IEnumerable<T> GetSyncObjects<T>() where T : PlayerSyncObject =>
|
||||
PlayerSyncObjects.OfType<T>().Where(x => x != null);
|
||||
|
@ -1,6 +1,5 @@
|
||||
using OWML.Common;
|
||||
using QSB.Player;
|
||||
using QSB.Player.TransformSync;
|
||||
using QuantumUNET;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -48,21 +47,7 @@ namespace QSB.Utility
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
var go = playerController.Gameobject;
|
||||
if (go == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - GameObject of {playerController.UnetView.NetId.Value} is null.", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
var controller = go.GetComponent<PlayerTransformSync>();
|
||||
if (controller == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - No PlayerTransformSync found on {go.name}", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
return controller.NetId.Value;
|
||||
return playerController.UnetView.NetId.Value;
|
||||
}
|
||||
|
||||
public static void SpawnWithServerAuthority(this GameObject go)
|
||||
|
Loading…
x
Reference in New Issue
Block a user