mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-10 12:39:53 +00:00
nre fixes (#177)
Co-authored-by: Mister_Nebula <41904486+misternebula@users.noreply.github.com>
This commit is contained in:
parent
f434ed027b
commit
42cb791c5d
@ -22,7 +22,7 @@ namespace QSB.Animation
|
||||
public override void OnReceiveRemote(ToggleMessage message)
|
||||
{
|
||||
var player = PlayerRegistry.GetPlayer(message.SenderId);
|
||||
player.UpdateState(State.Suit, message.ToggleValue);
|
||||
player?.UpdateState(State.Suit, message.ToggleValue);
|
||||
}
|
||||
|
||||
public override void OnReceiveLocal(ToggleMessage message)
|
||||
|
@ -45,11 +45,11 @@ namespace QSB
|
||||
{
|
||||
return;
|
||||
}
|
||||
FlashLight.UpdateState(FlagsHelper.IsSet(State, State.Flashlight));
|
||||
Translator.ChangeEquipState(FlagsHelper.IsSet(State, State.Translator));
|
||||
ProbeLauncher.ChangeEquipState(FlagsHelper.IsSet(State, State.ProbeLauncher));
|
||||
Signalscope.ChangeEquipState(FlagsHelper.IsSet(State, State.Signalscope));
|
||||
PlayerRegistry.GetAnimationSync(NetId).SetSuitState(FlagsHelper.IsSet(State, State.Suit));
|
||||
FlashLight?.UpdateState(FlagsHelper.IsSet(State, State.Flashlight));
|
||||
Translator?.ChangeEquipState(FlagsHelper.IsSet(State, State.Translator));
|
||||
ProbeLauncher?.ChangeEquipState(FlagsHelper.IsSet(State, State.ProbeLauncher));
|
||||
Signalscope?.ChangeEquipState(FlagsHelper.IsSet(State, State.Signalscope));
|
||||
PlayerRegistry.GetAnimationSync(NetId)?.SetSuitState(FlagsHelper.IsSet(State, State.Suit));
|
||||
}
|
||||
|
||||
public bool GetState(State state)
|
||||
|
@ -143,7 +143,6 @@ namespace QSB
|
||||
|
||||
public override void OnStopClient() // Called on the client when closing connection
|
||||
{
|
||||
DebugLog.ToScreen("OnStopClient");
|
||||
Destroy(GetComponent<SectorSync>());
|
||||
Destroy(GetComponent<RespawnOnDeath>());
|
||||
Destroy(GetComponent<PreventShipDestruction>());
|
||||
@ -156,8 +155,6 @@ namespace QSB
|
||||
|
||||
public override void OnServerDisconnect(NetworkConnection connection) // Called on the server when any client disconnects
|
||||
{
|
||||
DebugLog.ToScreen("OnServerDisconnect");
|
||||
|
||||
var playerId = connection.playerControllers[0].gameObject.GetComponent<PlayerTransformSync>().netId.Value;
|
||||
var objectIds = connection.clientOwnedObjects.Select(x => x.Value).ToArray();
|
||||
GlobalMessenger<uint, uint[]>.FireEvent(EventNames.QSBPlayerLeave, playerId, objectIds);
|
||||
|
13
QSB/State.cs
13
QSB/State.cs
@ -5,12 +5,13 @@ namespace QSB
|
||||
[Flags]
|
||||
public enum State
|
||||
{
|
||||
Flashlight = 0,
|
||||
Suit = 1,
|
||||
ProbeLauncher = 2,
|
||||
Signalscope = 4,
|
||||
Translator = 8,
|
||||
ProbeActive = 16
|
||||
None = 0,
|
||||
Flashlight = 1,
|
||||
Suit = 2,
|
||||
ProbeLauncher = 4,
|
||||
Signalscope = 8,
|
||||
Translator = 16,
|
||||
ProbeActive = 32
|
||||
//Increment these in binary to add more states
|
||||
}
|
||||
}
|
@ -30,12 +30,12 @@ namespace QSB.TransformSync
|
||||
|
||||
if (sector == null)
|
||||
{
|
||||
DebugLog.ToScreen($"Sector with order id {message.ObjectId} not found!");
|
||||
DebugLog.ToConsole($"Sector with order id {message.ObjectId} not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
var transformSync = PlayerRegistry.GetTransformSync(message.SenderId);
|
||||
DebugLog.ToScreen($"{transformSync.GetType().Name} of ID {message.SenderId} set to {sector.Name}");
|
||||
//DebugLog.ToConsole($"{transformSync.GetType().Name} of ID {message.SenderId} set to {sector.Name}");
|
||||
UnityHelper.Instance.RunWhen(() => transformSync.SyncedTransform != null,
|
||||
() => transformSync.SetReferenceSector(sector));
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace QSB.TransformSync
|
||||
public QSBSector GetClosestSector(Transform trans)
|
||||
{
|
||||
return WorldRegistry.GetObjects<QSBSector>()
|
||||
.Where(sector => !_sectorBlacklist.Contains(sector.Type))
|
||||
.Where(sector => sector.Sector != null && !_sectorBlacklist.Contains(sector.Type))
|
||||
.OrderBy(sector => Vector3.Distance(sector.Position, trans.position))
|
||||
.First();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using UnityEngine;
|
||||
using QSB.Events;
|
||||
using QSB.Utility;
|
||||
|
||||
namespace QSB.TransformSync
|
||||
{
|
||||
@ -42,7 +41,7 @@ namespace QSB.TransformSync
|
||||
|
||||
private void SendSector(uint id, QSBSector sector)
|
||||
{
|
||||
DebugLog.ToScreen($"Sending sector {sector.Name} for id {id}");
|
||||
//DebugLog.ToConsole($"Sending sector {sector.Name} for id {id}");
|
||||
GlobalMessenger<uint, QSBSector>.FireEvent(EventNames.QSBSectorChange, id, sector);
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using OWML.Common;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace QSB.Utility
|
||||
{
|
||||
public class DebugLog : MonoBehaviour
|
||||
{
|
||||
private const int ScreenLinesMax = 6;
|
||||
|
||||
private static Text _screenText;
|
||||
private static List<string> _lines;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
var assetBundle = QSB.Helper.Assets.LoadBundle("assets/debug");
|
||||
var logCanvas = Instantiate(assetBundle.LoadAsset<GameObject>("assets/logcanvas.prefab"));
|
||||
DontDestroyOnLoad(logCanvas);
|
||||
DontDestroyOnLoad(this);
|
||||
logCanvas.GetComponent<Canvas>().sortingOrder = 9999;
|
||||
_screenText = logCanvas.GetComponentInChildren<Text>();
|
||||
|
||||
_lines = new List<string>(ScreenLinesMax);
|
||||
for (var i = 0; i < ScreenLinesMax; i++)
|
||||
{
|
||||
_lines.Add(".");
|
||||
}
|
||||
}
|
||||
|
||||
private static string JoinAll(params object[] logObjects)
|
||||
{
|
||||
return string.Join(" ", logObjects.Select(o => o.ToString()).ToArray());
|
||||
@ -44,18 +21,6 @@ namespace QSB.Utility
|
||||
QSB.Helper.Console.WriteLine(message, type);
|
||||
}
|
||||
|
||||
public static void ToScreen(params object[] logObjects)
|
||||
{
|
||||
/*
|
||||
for (var i = 1; i < ScreenLinesMax; i++)
|
||||
{
|
||||
_lines[i - 1] = _lines[i];
|
||||
}
|
||||
_lines.Insert(ScreenLinesMax - 1, JoinAll(logObjects));
|
||||
_screenText.text = string.Join("\n", _lines.ToArray());
|
||||
*/
|
||||
}
|
||||
|
||||
public static void ToHud(params object[] logObjects)
|
||||
{
|
||||
if (Locator.GetPlayerBody() == null)
|
||||
@ -69,7 +34,6 @@ namespace QSB.Utility
|
||||
public static void ToAll(MessageType type, params object[] logObjects)
|
||||
{
|
||||
ToConsole(JoinAll(logObjects), type);
|
||||
ToScreen(logObjects);
|
||||
ToHud(logObjects);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user