Merge pull request #182 from Raicuparta/alek/dc-dev-merge

dc dev merge
This commit is contained in:
Mister_Nebula 2020-08-17 18:33:41 +01:00 committed by GitHub
commit 5bf088f609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 23 additions and 57 deletions

View File

@ -28,10 +28,6 @@ namespace QSB.ElevatorSync
public override void OnReceiveRemote(ElevatorMessage message)
{
if (!QSBSceneManager.IsInUniverse)
{
return;
}
var elevator = WorldRegistry.GetObject<QSBElevator>(message.ObjectId);
elevator?.RemoteCall(message.Direction);
}

View File

@ -1,5 +1,4 @@
using QSB.Messaging;
using QSB.TransformSync;
using QSB.Utility;
namespace QSB.Events
@ -28,7 +27,7 @@ namespace QSB.Events
public override void OnReceiveRemote(PlayerJoinMessage message)
{
var player = PlayerRegistry.CreatePlayer(message.AboutId);
var player = PlayerRegistry.GetPlayer(message.AboutId);
player.Name = message.PlayerName;
var text = $"{player.Name} joined!";
DebugLog.ToAll(OWML.Common.MessageType.Info, text);
@ -36,7 +35,7 @@ namespace QSB.Events
public override void OnReceiveLocal(PlayerJoinMessage message)
{
var player = PlayerRegistry.CreatePlayer(PlayerTransformSync.LocalInstance.netId.Value);
var player = PlayerRegistry.GetPlayer(PlayerRegistry.LocalPlayerId);
player.Name = message.PlayerName;
var text = $"Connected to server as {player.Name}.";
DebugLog.ToAll(OWML.Common.MessageType.Info, text);

View File

@ -1,5 +1,4 @@
using QSB.Messaging;
using QSB.TransformSync;
using QSB.Utility;
using UnityEngine.Networking;
@ -21,7 +20,7 @@ namespace QSB.Events
private void OnClientReceiveMessage(PlayerStateMessage message)
{
if (message.FromId == PlayerTransformSync.LocalInstance.netId.Value)
if (message.FromId == PlayerRegistry.LocalPlayerId)
{
return;
}

View File

@ -29,10 +29,6 @@ namespace QSB.GeyserSync
public override void OnReceiveRemote(GeyserMessage message)
{
if (!QSBSceneManager.IsInUniverse)
{
return;
}
var geyser = WorldRegistry.GetObject<QSBGeyser>(message.ObjectId);
geyser?.SetState(message.State);
}

View File

@ -59,7 +59,8 @@ namespace QSB
private QSBTool GetToolByType(ToolType type)
{
return Camera.GetComponentsInChildren<QSBTool>().First(x => x.Type == type);
return Camera?.GetComponentsInChildren<QSBTool>()
.FirstOrDefault(x => x.Type == type);
}
}
}

View File

@ -18,25 +18,16 @@ namespace QSB
public static List<AnimationSync> AnimationSyncs { get; } = new List<AnimationSync>();
public static List<PlayerHUDMarker> PlayerHudMarkers { get; } = new List<PlayerHUDMarker>();
public static PlayerInfo CreatePlayer(uint id)
{
if (PlayerExists(id))
{
return null;
}
var player = new PlayerInfo(id);
PlayerList.Add(player);
return player;
}
public static PlayerInfo GetPlayer(uint id)
{
return PlayerList.FirstOrDefault(x => x.NetId == id);
}
public static bool PlayerExists(uint id)
{
return GetPlayer(id) != null;
var player = PlayerList.FirstOrDefault(x => x.NetId == id);
if (player != null)
{
return player;
}
player = new PlayerInfo(id);
PlayerList.Add(player);
return player;
}
public static void RemovePlayer(uint id)
@ -47,7 +38,7 @@ namespace QSB
public static void HandleFullStateMessage(PlayerStateMessage message)
{
var player = GetPlayer(message.AboutId) ?? CreatePlayer(message.AboutId);
var player = GetPlayer(message.AboutId);
player.Name = message.PlayerName;
player.IsReady = message.PlayerReady;
player.State = message.PlayerState;

View File

@ -31,12 +31,8 @@ namespace QSB.Tools
public override void OnReceiveRemote(ToggleMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
player?.UpdateState(State.Flashlight, message.ToggleValue);
if (!QSBSceneManager.IsInUniverse)
{
return;
}
player?.FlashLight?.UpdateState(message.ToggleValue);
player.UpdateState(State.Flashlight, message.ToggleValue);
player.FlashLight?.UpdateState(message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)

View File

@ -32,7 +32,7 @@ namespace QSB.Tools
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
player.UpdateState(State.ProbeActive, message.ToggleValue);
player.Probe.SetState(message.ToggleValue);
player.Probe?.SetState(message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)

View File

@ -31,12 +31,8 @@ namespace QSB.Tools
public override void OnReceiveRemote(ToggleMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
player?.UpdateState(State.ProbeLauncher, message.ToggleValue);
if (!QSBSceneManager.IsInUniverse)
{
return;
}
player?.ProbeLauncher?.ChangeEquipState(message.ToggleValue);
player.UpdateState(State.ProbeLauncher, message.ToggleValue);
player.ProbeLauncher?.ChangeEquipState(message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)

View File

@ -31,12 +31,8 @@ namespace QSB.Tools
public override void OnReceiveRemote(ToggleMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
player?.UpdateState(State.Signalscope, message.ToggleValue);
if (!QSBSceneManager.IsInUniverse)
{
return;
}
player?.Signalscope?.ChangeEquipState(message.ToggleValue);
player.UpdateState(State.Signalscope, message.ToggleValue);
player.Signalscope?.ChangeEquipState(message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)

View File

@ -31,12 +31,8 @@ namespace QSB.Tools
public override void OnReceiveRemote(ToggleMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
player?.UpdateState(State.Translator, message.ToggleValue);
if (!QSBSceneManager.IsInUniverse)
{
return;
}
player?.Translator?.ChangeEquipState(message.ToggleValue);
player.UpdateState(State.Translator, message.ToggleValue);
player.Translator?.ChangeEquipState(message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)