mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-12 04:14:08 +00:00
Merge pull request #449 from misternebula/simpler-player
Simpler Player
This commit is contained in:
commit
690c391fc4
@ -41,9 +41,8 @@ namespace QSB.Animation.Player
|
||||
QSBSceneManager.OnUniverseSceneLoaded += OnUniverseSceneLoaded;
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
protected void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
Destroy(InvisibleAnimator);
|
||||
Destroy(NetworkAnimator);
|
||||
QSBSceneManager.OnUniverseSceneLoaded -= OnUniverseSceneLoaded;
|
||||
|
@ -7,26 +7,26 @@ namespace QSB.Animation.Player.Messages
|
||||
{
|
||||
internal class AnimationTriggerMessage : QSBMessage
|
||||
{
|
||||
private uint AttachedNetId;
|
||||
private uint PlayerId;
|
||||
private string Name;
|
||||
|
||||
public AnimationTriggerMessage(uint attachedNetId, string name)
|
||||
public AnimationTriggerMessage(uint playerId, string name)
|
||||
{
|
||||
AttachedNetId = attachedNetId;
|
||||
PlayerId = playerId;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public override void Serialize(QNetworkWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(AttachedNetId);
|
||||
writer.Write(PlayerId);
|
||||
writer.Write(Name);
|
||||
}
|
||||
|
||||
public override void Deserialize(QNetworkReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
AttachedNetId = reader.ReadUInt32();
|
||||
PlayerId = reader.ReadUInt32();
|
||||
Name = reader.ReadString();
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ namespace QSB.Animation.Player.Messages
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
var animationSync = QSBPlayerManager.GetSyncObject<AnimationSync>(AttachedNetId);
|
||||
var animationSync = QSBPlayerManager.GetPlayer(PlayerId).AnimationSync;
|
||||
if (animationSync == null)
|
||||
{
|
||||
return;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using QSB.Instruments;
|
||||
using QSB.Messaging;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.WorldSync;
|
||||
using QuantumUNET.Transport;
|
||||
@ -39,7 +38,7 @@ namespace QSB.Animation.Player.Messages
|
||||
}
|
||||
|
||||
player.AnimationSync.SetAnimationType(Value);
|
||||
QSBPlayerManager.GetSyncObject<InstrumentsManager>(PlayerId).CheckInstrumentProps(Value);
|
||||
player.InstrumentsManager.CheckInstrumentProps(Value);
|
||||
}
|
||||
}
|
||||
}
|
@ -62,16 +62,15 @@ namespace QSB.Animation.Player.Patches
|
||||
__instance._animator.SetBool("UsingJetpack", isInZeroG && PlayerState.IsWearingSuit());
|
||||
if (__instance._justBecameGrounded)
|
||||
{
|
||||
var playerAnimationSync = QSBPlayerManager.LocalPlayer.AnimationSync;
|
||||
if (__instance._justTookFallDamage)
|
||||
{
|
||||
__instance._animator.SetTrigger("LandHard");
|
||||
new AnimationTriggerMessage(playerAnimationSync.AttachedNetId, "LandHard").Send();
|
||||
new AnimationTriggerMessage(QSBPlayerManager.LocalPlayerId, "LandHard").Send();
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance._animator.SetTrigger("Land");
|
||||
new AnimationTriggerMessage(playerAnimationSync.AttachedNetId, "Land").Send();
|
||||
new AnimationTriggerMessage(QSBPlayerManager.LocalPlayerId, "Land").Send();
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,8 +127,7 @@ namespace QSB.Animation.Player.Patches
|
||||
}
|
||||
|
||||
__instance._animator.SetTrigger("Jump");
|
||||
var playerAnimationSync = QSBPlayerManager.LocalPlayer.AnimationSync;
|
||||
new AnimationTriggerMessage(playerAnimationSync.AttachedNetId, "Jump").Send();
|
||||
new AnimationTriggerMessage(QSBPlayerManager.LocalPlayerId, "Jump").Send();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,8 @@ namespace QSB.Instruments
|
||||
QSBCore.UnityEvents.RunWhen(() => Locator.GetPlayerBody() != null, SetupInstruments);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
protected void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
if (!IsLocalPlayer)
|
||||
{
|
||||
return;
|
||||
|
@ -4,6 +4,7 @@ using QSB.Animation.Player.Thrusters;
|
||||
using QSB.Audio;
|
||||
using QSB.CampfireSync.WorldObjects;
|
||||
using QSB.ClientServerStateSync;
|
||||
using QSB.Instruments;
|
||||
using QSB.ItemSync.WorldObjects.Items;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player.Messages;
|
||||
@ -22,10 +23,15 @@ namespace QSB.Player
|
||||
{
|
||||
public class PlayerInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// the player transform sync's net id
|
||||
/// </summary>
|
||||
public uint PlayerId { get; }
|
||||
public string Name { get; set; }
|
||||
public PlayerHUDMarker HudMarker { get; set; }
|
||||
public PlayerTransformSync TransformSync { get; set; }
|
||||
public PlayerTransformSync TransformSync { get; }
|
||||
public AnimationSync AnimationSync { get; }
|
||||
public InstrumentsManager InstrumentsManager { get; }
|
||||
public ClientState State { get; set; }
|
||||
public EyeState EyeState { get; set; }
|
||||
public bool IsDead { get; set; }
|
||||
@ -114,11 +120,10 @@ namespace QSB.Player
|
||||
public bool ProbeActive { get; set; }
|
||||
|
||||
// Conversation
|
||||
public int CurrentCharacterDialogueTreeId { get; set; }
|
||||
public int CurrentCharacterDialogueTreeId { get; set; } = -1;
|
||||
public GameObject CurrentDialogueBox { get; set; }
|
||||
|
||||
// Animation
|
||||
public AnimationSync AnimationSync => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId);
|
||||
public bool PlayingInstrument => AnimationSync.CurrentType
|
||||
is not AnimationType.PlayerSuited
|
||||
and not AnimationType.PlayerUnsuited;
|
||||
@ -181,10 +186,12 @@ namespace QSB.Player
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerInfo(uint id)
|
||||
public PlayerInfo(PlayerTransformSync transformSync)
|
||||
{
|
||||
PlayerId = id;
|
||||
CurrentCharacterDialogueTreeId = -1;
|
||||
PlayerId = transformSync.NetId.Value;
|
||||
TransformSync = transformSync;
|
||||
AnimationSync = transformSync.GetComponent<AnimationSync>();
|
||||
InstrumentsManager = transformSync.GetComponent<InstrumentsManager>();
|
||||
}
|
||||
|
||||
public void UpdateObjectsFromStates()
|
||||
@ -204,8 +211,7 @@ namespace QSB.Player
|
||||
Translator?.ChangeEquipState(TranslatorEquipped);
|
||||
ProbeLauncher?.ChangeEquipState(ProbeLauncherEquipped);
|
||||
Signalscope?.ChangeEquipState(SignalscopeEquipped);
|
||||
QSBCore.UnityEvents.RunWhen(() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId) != null,
|
||||
() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId).SetSuitState(SuitedUp));
|
||||
AnimationSync.SetSuitState(SuitedUp);
|
||||
}
|
||||
|
||||
public void UpdateStatesFromObjects()
|
||||
|
@ -4,11 +4,7 @@ namespace QSB.Player
|
||||
{
|
||||
public abstract class PlayerSyncObject : QNetworkBehaviour
|
||||
{
|
||||
public uint AttachedNetId => NetIdentity?.NetId.Value ?? uint.MaxValue;
|
||||
public uint PlayerId => NetIdentity.RootIdentity?.NetId.Value ?? NetIdentity.NetId.Value;
|
||||
public PlayerInfo Player => QSBPlayerManager.GetPlayer(PlayerId);
|
||||
|
||||
protected virtual void Start() => QSBPlayerManager.AddSyncObject(this);
|
||||
protected virtual void OnDestroy() => QSBPlayerManager.RemoveSyncObject(this);
|
||||
protected uint PlayerId => NetId.Value;
|
||||
protected PlayerInfo Player => QSBPlayerManager.GetPlayer(PlayerId);
|
||||
}
|
||||
}
|
@ -12,39 +12,37 @@ namespace QSB.Player
|
||||
{
|
||||
public static class QSBPlayerManager
|
||||
{
|
||||
public static uint LocalPlayerId
|
||||
public static PlayerInfo LocalPlayer
|
||||
{
|
||||
get
|
||||
{
|
||||
var localInstance = PlayerTransformSync.LocalInstance;
|
||||
if (localInstance == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Trying to get LocalPlayerId when the local PlayerTransformSync instance is null." +
|
||||
DebugLog.ToConsole("Error - Trying to get LocalPlayer when the local PlayerTransformSync instance is null." +
|
||||
$"{Environment.NewLine} Stacktrace : {Environment.StackTrace} ", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
return null;
|
||||
}
|
||||
|
||||
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;
|
||||
return localInstance.Player;
|
||||
}
|
||||
}
|
||||
public static uint LocalPlayerId => LocalPlayer.PlayerId;
|
||||
|
||||
public static Action<uint> OnRemovePlayer;
|
||||
/// <summary>
|
||||
/// called right after player is added
|
||||
/// </summary>
|
||||
public static Action<uint> OnAddPlayer;
|
||||
/// <summary>
|
||||
/// called right before player is removed
|
||||
/// </summary>
|
||||
public static Action<uint> OnRemovePlayer;
|
||||
|
||||
public static PlayerInfo LocalPlayer => GetPlayer(LocalPlayerId);
|
||||
public static List<PlayerInfo> PlayerList { get; } = new List<PlayerInfo>();
|
||||
|
||||
private static readonly List<PlayerSyncObject> PlayerSyncObjects = new();
|
||||
public static readonly List<PlayerInfo> PlayerList = new();
|
||||
|
||||
public static PlayerInfo GetPlayer(uint id)
|
||||
{
|
||||
if (id is uint.MaxValue or 0U)
|
||||
if (id is uint.MaxValue or 0)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
@ -59,39 +57,15 @@ namespace QSB.Player
|
||||
return player;
|
||||
}
|
||||
|
||||
public static void AddPlayer(uint id)
|
||||
{
|
||||
DebugLog.DebugWrite($"Create Player : id<{id}>", MessageType.Info);
|
||||
var player = new PlayerInfo(id);
|
||||
PlayerList.Add(player);
|
||||
OnAddPlayer?.Invoke(id);
|
||||
}
|
||||
|
||||
public static void RemovePlayer(uint id)
|
||||
{
|
||||
DebugLog.DebugWrite($"Remove Player : id<{id}>", MessageType.Info);
|
||||
PlayerList.RemoveAll(x => x.PlayerId == id);
|
||||
}
|
||||
|
||||
public static bool PlayerExists(uint id) =>
|
||||
id != uint.MaxValue && PlayerList.Any(x => x.PlayerId == id);
|
||||
|
||||
public static IEnumerable<T> GetSyncObjects<T>() where T : PlayerSyncObject =>
|
||||
PlayerSyncObjects.OfType<T>().Where(x => x != null);
|
||||
|
||||
public static T GetSyncObject<T>(uint id) where T : PlayerSyncObject =>
|
||||
GetSyncObjects<T>().FirstOrDefault(x => x != null && x.AttachedNetId == id);
|
||||
|
||||
public static void AddSyncObject(PlayerSyncObject obj) => PlayerSyncObjects.Add(obj);
|
||||
|
||||
public static void RemoveSyncObject(PlayerSyncObject obj) => PlayerSyncObjects.Remove(obj);
|
||||
id is not (uint.MaxValue or 0) && PlayerList.Any(x => x.PlayerId == id);
|
||||
|
||||
public static List<PlayerInfo> GetPlayersWithCameras(bool includeLocalCamera = true)
|
||||
{
|
||||
var cameraList = PlayerList.Where(x => x.Camera != null && x.PlayerId != LocalPlayerId).ToList();
|
||||
if (includeLocalCamera
|
||||
&& LocalPlayer != default
|
||||
&& LocalPlayer.Camera != null)
|
||||
&& LocalPlayer != default
|
||||
&& LocalPlayer.Camera != null)
|
||||
{
|
||||
cameraList.Add(LocalPlayer);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using QSB.Animation.Player;
|
||||
using OWML.Common;
|
||||
using QSB.Audio;
|
||||
using QSB.Instruments;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player.Messages;
|
||||
using QSB.RoastingSync;
|
||||
@ -48,9 +47,11 @@ namespace QSB.Player.TransformSync
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
var player = new PlayerInfo(this);
|
||||
QSBPlayerManager.PlayerList.SafeAdd(player);
|
||||
base.Start();
|
||||
QSBPlayerManager.AddPlayer(PlayerId);
|
||||
Player.TransformSync = this;
|
||||
QSBPlayerManager.OnAddPlayer?.Invoke(Player.PlayerId);
|
||||
DebugLog.DebugWrite($"Create Player : id<{Player.PlayerId}>", MessageType.Info);
|
||||
}
|
||||
|
||||
protected override void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isInUniverse)
|
||||
@ -86,13 +87,11 @@ namespace QSB.Player.TransformSync
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
// TODO : Maybe move this to a leave event...? Would ensure everything could finish up before removing the player
|
||||
QSBPlayerManager.OnRemovePlayer?.Invoke(PlayerId);
|
||||
QSBPlayerManager.OnRemovePlayer?.Invoke(Player.PlayerId);
|
||||
base.OnDestroy();
|
||||
if (QSBPlayerManager.PlayerExists(PlayerId))
|
||||
{
|
||||
Player.HudMarker?.Remove();
|
||||
QSBPlayerManager.RemovePlayer(PlayerId);
|
||||
}
|
||||
Player.HudMarker?.Remove();
|
||||
QSBPlayerManager.PlayerList.Remove(Player);
|
||||
DebugLog.DebugWrite($"Remove Player : id<{Player.PlayerId}>", MessageType.Info);
|
||||
}
|
||||
|
||||
protected override Transform InitLocalTransform()
|
||||
@ -102,8 +101,8 @@ namespace QSB.Player.TransformSync
|
||||
// player body
|
||||
var player = Locator.GetPlayerTransform();
|
||||
var playerModel = player.Find("Traveller_HEA_Player_v2");
|
||||
GetComponent<AnimationSync>().InitLocal(playerModel);
|
||||
GetComponent<InstrumentsManager>().InitLocal(player);
|
||||
Player.AnimationSync.InitLocal(playerModel);
|
||||
Player.InstrumentsManager.InitLocal(player);
|
||||
Player.Body = player.gameObject;
|
||||
|
||||
// camera
|
||||
@ -164,8 +163,8 @@ namespace QSB.Player.TransformSync
|
||||
|
||||
Player.Body = REMOTE_Player_Body;
|
||||
|
||||
GetComponent<AnimationSync>().InitRemote(REMOTE_Traveller_HEA_Player_v2);
|
||||
GetComponent<InstrumentsManager>().InitRemote(REMOTE_Player_Body.transform);
|
||||
Player.AnimationSync.InitRemote(REMOTE_Traveller_HEA_Player_v2);
|
||||
Player.InstrumentsManager.InitRemote(REMOTE_Player_Body.transform);
|
||||
|
||||
var marker = REMOTE_Player_Body.AddComponent<PlayerHUDMarker>();
|
||||
marker.Init(Player);
|
||||
|
@ -127,12 +127,7 @@ namespace QSB.Syncs.Sectored
|
||||
{
|
||||
if (IsPlayerObject)
|
||||
{
|
||||
if (!QSBPlayerManager.PlayerExists(PlayerId))
|
||||
{
|
||||
writer.Write(-1);
|
||||
return;
|
||||
}
|
||||
else if (!Player.IsReady)
|
||||
if (!Player.IsReady)
|
||||
{
|
||||
writer.Write(-1);
|
||||
return;
|
||||
|
@ -1,6 +1,5 @@
|
||||
using OWML.Common;
|
||||
using QSB.Player;
|
||||
using QSB.Player.TransformSync;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using QuantumUNET.Components;
|
||||
@ -17,48 +16,16 @@ namespace QSB.Syncs
|
||||
|
||||
public abstract class SyncBase<T> : QNetworkTransform where T : Component
|
||||
{
|
||||
public uint AttachedNetId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (NetIdentity == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Trying to get AttachedNetId with null NetIdentity! Type:{GetType().Name} GrandType:{GetType().GetType().Name}", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
return NetIdentity.NetId.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public uint PlayerId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsPlayerObject)
|
||||
{
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
if (NetIdentity == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Trying to get PlayerId with null NetIdentity! Type:{GetType().Name} GrandType:{GetType().GetType().Name}", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
return NetIdentity.RootIdentity != null
|
||||
? NetIdentity.RootIdentity.NetId.Value
|
||||
: AttachedNetId;
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerInfo Player => QSBPlayerManager.GetPlayer(PlayerId);
|
||||
/// <summary>
|
||||
/// valid if IsPlayerObject, otherwise null
|
||||
/// </summary>
|
||||
public PlayerInfo Player { get; private set; }
|
||||
|
||||
private bool _baseIsReady
|
||||
{
|
||||
get
|
||||
{
|
||||
if (NetId.Value is uint.MaxValue or 0U)
|
||||
if (NetId.Value is uint.MaxValue or 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -70,16 +37,6 @@ namespace QSB.Syncs
|
||||
|
||||
if (IsPlayerObject)
|
||||
{
|
||||
if (!QSBPlayerManager.PlayerExists(PlayerId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Player.IsReady && !IsLocalPlayer)
|
||||
{
|
||||
return false;
|
||||
@ -100,7 +57,7 @@ namespace QSB.Syncs
|
||||
public T AttachedObject { get; set; }
|
||||
public Transform ReferenceTransform { get; set; }
|
||||
|
||||
public string LogName => $"{PlayerId}.{NetId.Value}:{GetType().Name}";
|
||||
public string LogName => $"{(IsPlayerObject ? Player.PlayerId : "<non player object>")}.{NetId.Value}:{GetType().Name}";
|
||||
protected virtual float DistanceLeeway { get; } = 5f;
|
||||
private float _previousDistance;
|
||||
protected const float SmoothTime = 0.1f;
|
||||
@ -117,9 +74,11 @@ namespace QSB.Syncs
|
||||
{
|
||||
if (IsPlayerObject)
|
||||
{
|
||||
var lowestBound = QSBWorldSync.GetUnityObjects<PlayerTransformSync>()
|
||||
.Where(x => x.NetId.Value <= NetId.Value).OrderBy(x => x.NetId.Value).Last();
|
||||
NetIdentity.SetRootIdentity(lowestBound.NetIdentity);
|
||||
// get player objects spawned before this object (or is this one)
|
||||
// and use the closest one
|
||||
Player = QSBPlayerManager.PlayerList
|
||||
.Where(x => x.PlayerId <= NetId.Value)
|
||||
.OrderBy(x => x.PlayerId).Last();
|
||||
}
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
@ -137,12 +137,6 @@ namespace QSB.Utility
|
||||
WriteLine(2, $"Player data :");
|
||||
foreach (var player in QSBPlayerManager.PlayerList)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
WriteLine(2, $"NULL PLAYER", Color.red);
|
||||
continue;
|
||||
}
|
||||
|
||||
WriteLine(2, $"{player.PlayerId}.{player.Name}");
|
||||
WriteLine(2, $"State : {player.State}");
|
||||
WriteLine(2, $"Eye State : {player.EyeState}");
|
||||
@ -227,12 +221,6 @@ namespace QSB.Utility
|
||||
|
||||
foreach (var player in QSBPlayerManager.PlayerList)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
WriteLine(4, $"- NULL PLAYER", Color.red);
|
||||
continue;
|
||||
}
|
||||
|
||||
WriteLine(4, $"- {player.PlayerId}.{player.Name}");
|
||||
var allQuantumObjects = QSBWorldSync.GetWorldObjects<IQSBQuantumObject>();
|
||||
var ownedQuantumObjects = allQuantumObjects.Where(x => x.ControllingPlayer == player.PlayerId);
|
||||
|
@ -1,6 +1,4 @@
|
||||
using OWML.Common;
|
||||
using QSB.Player;
|
||||
using QSB.Player.TransformSync;
|
||||
using QuantumUNET;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -41,28 +39,14 @@ namespace QSB.Utility
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
var playerController = connection.PlayerControllers[0];
|
||||
var playerController = connection.PlayerControllers.FirstOrDefault();
|
||||
if (playerController == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Player Controller of {connection.address} is null.", MessageType.Error);
|
||||
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)
|
||||
|
@ -21,8 +21,6 @@ namespace QuantumUNET.Components
|
||||
public short PlayerControllerId { get; private set; } = -1;
|
||||
public QNetworkConnection ConnectionToServer { get; private set; }
|
||||
public QNetworkConnection ConnectionToClient { get; private set; }
|
||||
public QNetworkIdentity RootIdentity { get; private set; }
|
||||
public List<QNetworkIdentity> SubIdentities { get; private set; } = new List<QNetworkIdentity>();
|
||||
|
||||
public bool ServerOnly
|
||||
{
|
||||
@ -39,23 +37,6 @@ namespace QuantumUNET.Components
|
||||
public QNetworkBehaviour[] GetNetworkBehaviours()
|
||||
=> m_NetworkBehaviours;
|
||||
|
||||
public void SetRootIdentity(QNetworkIdentity newRoot)
|
||||
{
|
||||
if (RootIdentity != null)
|
||||
{
|
||||
RootIdentity.RemoveSubIdentity(this);
|
||||
}
|
||||
|
||||
RootIdentity = newRoot;
|
||||
RootIdentity.AddSubIndentity(this);
|
||||
}
|
||||
|
||||
internal void AddSubIndentity(QNetworkIdentity identityToAdd)
|
||||
=> SubIdentities.Add(identityToAdd);
|
||||
|
||||
internal void RemoveSubIdentity(QNetworkIdentity identityToRemove)
|
||||
=> SubIdentities.Remove(identityToRemove);
|
||||
|
||||
internal void SetDynamicAssetId(int newAssetId)
|
||||
{
|
||||
if (m_AssetId == 0 || m_AssetId.Equals(newAssetId))
|
||||
|
Loading…
x
Reference in New Issue
Block a user