mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-12 04:14:08 +00:00
passing player object around (#127)
This commit is contained in:
parent
465074b176
commit
209b8dad76
@ -41,12 +41,12 @@ namespace QSB.Tools
|
||||
}
|
||||
}
|
||||
|
||||
public static void CreateProbe(Transform body, uint id)
|
||||
public static void CreateProbe(Transform body, PlayerInfo player)
|
||||
{
|
||||
var newProbe = body.gameObject.AddComponent<QSBProbe>();
|
||||
newProbe.Init(id);
|
||||
newProbe.Init(player);
|
||||
|
||||
PlayerRegistry.GetPlayer(id).Probe = newProbe;
|
||||
player.Probe = newProbe;
|
||||
}
|
||||
|
||||
private static void CreateStowTransforms()
|
||||
|
@ -6,27 +6,22 @@ namespace QSB.Tools
|
||||
{
|
||||
public class QSBProbe : MonoBehaviour
|
||||
{
|
||||
private uint _attachedNetId;
|
||||
private PlayerInfo _player;
|
||||
|
||||
public void Init(uint netid)
|
||||
public void Init(PlayerInfo player)
|
||||
{
|
||||
_attachedNetId = netid;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
DebugLog.ToConsole($"Activating player {_attachedNetId}'s probe.", MessageType.Info);
|
||||
DebugLog.ToConsole($"Activating {_player.Name}'s probe.", MessageType.Info);
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
DebugLog.ToConsole($"Deactivating player {_attachedNetId}'s probe.", MessageType.Info);
|
||||
DebugLog.ToConsole($"Deactivating {_player.Name}'s probe.", MessageType.Info);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace QSB.TransformSync
|
||||
{
|
||||
public class PlayerHUDMarker : HUDDistanceMarker
|
||||
{
|
||||
private uint _netId = uint.MaxValue;
|
||||
private PlayerInfo _player;
|
||||
private bool _isReady;
|
||||
|
||||
protected override void InitCanvasMarker()
|
||||
@ -17,9 +17,9 @@ namespace QSB.TransformSync
|
||||
_markerTarget.localPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
public void SetId(uint netId)
|
||||
public void Init(PlayerInfo player)
|
||||
{
|
||||
_netId = netId;
|
||||
_player = player;
|
||||
_isReady = true;
|
||||
}
|
||||
|
||||
@ -33,11 +33,11 @@ namespace QSB.TransformSync
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!_isReady || !PlayerRegistry.GetPlayer(_netId).IsReady)
|
||||
if (!_isReady || !_player.IsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_markerLabel = PlayerRegistry.GetPlayer(_netId).Name;
|
||||
_markerLabel = _player.Name;
|
||||
_isReady = false;
|
||||
|
||||
base.InitCanvasMarker();
|
||||
|
@ -42,7 +42,7 @@ namespace QSB.TransformSync
|
||||
|
||||
Destroy(body.GetComponentInChildren<ProbeAnimatorController>());
|
||||
|
||||
PlayerToolsManager.CreateProbe(body, PlayerId);
|
||||
PlayerToolsManager.CreateProbe(body, Player);
|
||||
|
||||
bodyTransform = body;
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace QSB.TransformSync
|
||||
GetComponent<AnimationSync>().InitRemote(body);
|
||||
|
||||
var marker = body.gameObject.AddComponent<PlayerHUDMarker>();
|
||||
marker.SetId(PlayerId);
|
||||
marker.Init(Player);
|
||||
|
||||
Player.Body = body.gameObject;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user