diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatedByMessage.cs b/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatedByMessage.cs
deleted file mode 100644
index 1cbc1bd1..00000000
--- a/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatedByMessage.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using QSB.Messaging;
-using QSB.Player;
-using System.Linq;
-
-namespace QSB.EchoesOfTheEye.LightSensorSync.Messages;
-
-///
-/// always sent by host
-///
-internal class PlayerIlluminatedByMessage : QSBMessage<(uint playerId, uint[] illuminatedBy)>
-{
- public PlayerIlluminatedByMessage(uint playerId, uint[] illuminatedBy) : base((playerId, illuminatedBy)) { }
-
- public override void OnReceiveRemote()
- {
- var qsbPlayerLightSensor = QSBPlayerManager.GetPlayer(Data.playerId).QSBPlayerLightSensor;
-
- foreach (var added in Data.illuminatedBy.Except(qsbPlayerLightSensor._illuminatedBy).ToList())
- {
- qsbPlayerLightSensor.SetIlluminated(added, true);
- }
-
- foreach (var removed in qsbPlayerLightSensor._illuminatedBy.Except(Data.illuminatedBy).ToList())
- {
- qsbPlayerLightSensor.SetIlluminated(removed, false);
- }
- }
-}
diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatingLanternsMessage.cs b/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatingLanternsMessage.cs
index 6e6a7d5a..4cc78e69 100644
--- a/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatingLanternsMessage.cs
+++ b/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatingLanternsMessage.cs
@@ -19,12 +19,6 @@ internal class PlayerIlluminatingLanternsMessage : QSBMessage<(uint playerId, in
{
var lightSensor = (SingleLightSensor)QSBPlayerManager.GetPlayer(Data.playerId).LightSensor;
- if (lightSensor.enabled)
- {
- // sensor is enabled, so this will already be synced
- return;
- }
-
lightSensor._illuminatingDreamLanternList.Clear();
lightSensor._illuminatingDreamLanternList.AddRange(
Data.lanterns.Select(x => x.GetWorldObject().AttachedObject));
diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerSetIlluminatedMessage.cs b/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerSetIlluminatedMessage.cs
index acd6abfe..09e3f171 100644
--- a/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerSetIlluminatedMessage.cs
+++ b/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerSetIlluminatedMessage.cs
@@ -6,8 +6,24 @@ namespace QSB.EchoesOfTheEye.LightSensorSync.Messages;
internal class PlayerSetIlluminatedMessage : QSBMessage<(uint playerId, bool illuminated)>
{
public PlayerSetIlluminatedMessage(uint playerId, bool illuminated) : base((playerId, illuminated)) { }
- public override void OnReceiveLocal() => OnReceiveRemote();
- public override void OnReceiveRemote() =>
- QSBPlayerManager.GetPlayer(Data.playerId).QSBPlayerLightSensor.SetIlluminated(From, Data.illuminated);
+ public override void OnReceiveRemote()
+ {
+ var lightSensor = (SingleLightSensor)QSBPlayerManager.GetPlayer(Data.playerId).LightSensor;
+
+ if (lightSensor._illuminated == Data.illuminated)
+ {
+ return;
+ }
+
+ lightSensor._illuminated = Data.illuminated;
+ if (Data.illuminated)
+ {
+ lightSensor.OnDetectLight.Invoke();
+ }
+ else
+ {
+ lightSensor.OnDetectDarkness.Invoke();
+ }
+ }
}
diff --git a/QSB/EchoesOfTheEye/LightSensorSync/QSBPlayerLightSensor.cs b/QSB/EchoesOfTheEye/LightSensorSync/QSBPlayerLightSensor.cs
deleted file mode 100644
index f3891529..00000000
--- a/QSB/EchoesOfTheEye/LightSensorSync/QSBPlayerLightSensor.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using QSB.EchoesOfTheEye.LightSensorSync.Messages;
-using QSB.Messaging;
-using QSB.Player;
-using QSB.WorldSync;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using UnityEngine;
-
-/*
- * For those who come here,
- * leave while you still can.
- */
-
-namespace QSB.EchoesOfTheEye.LightSensorSync;
-
-///
-/// stores a bit of extra data needed for player light sensor sync
-///
-/// 2 uses:
-/// - AlarmTotem.CheckPlayerVisible
-/// GhostSensors.FixedUpdate_Sensors
-///
-/// TODO: this can probably be massively simplified to work with these uses only
-///
-/// we don't have to worry about start illuminated or sectors
-///
-[RequireComponent(typeof(SingleLightSensor))]
-public class QSBPlayerLightSensor : MonoBehaviour
-{
- private SingleLightSensor _lightSensor;
- [NonSerialized]
- public uint PlayerId;
-
- internal bool _locallyIlluminated;
- internal readonly List _illuminatedBy = new();
-
- private void Awake()
- {
- _lightSensor = GetComponent();
- PlayerId = QSBPlayerManager.PlayerList.First(x => x.LightSensor == _lightSensor).PlayerId;
-
- RequestInitialStatesMessage.SendInitialState += SendInitialState;
- QSBPlayerManager.OnRemovePlayer += OnPlayerLeave;
- }
-
- private void OnDestroy()
- {
- RequestInitialStatesMessage.SendInitialState -= SendInitialState;
- QSBPlayerManager.OnRemovePlayer -= OnPlayerLeave;
- }
-
- private void SendInitialState(uint to)
- {
- new PlayerIlluminatedByMessage(PlayerId, _illuminatedBy.ToArray()) { To = to }.Send();
- if (_lightSensor._illuminatingDreamLanternList != null)
- {
- new PlayerIlluminatingLanternsMessage(PlayerId, _lightSensor._illuminatingDreamLanternList) { To = to }.Send();
- }
- }
-
- private void OnPlayerLeave(PlayerInfo player) => SetIlluminated(player.PlayerId, false);
-
- public void SetIlluminated(uint playerId, bool locallyIlluminated)
- {
- var illuminated = _illuminatedBy.Count > 0;
- if (locallyIlluminated)
- {
- _illuminatedBy.SafeAdd(playerId);
- }
- else
- {
- _illuminatedBy.QuickRemove(playerId);
- }
-
- if (!illuminated && _illuminatedBy.Count > 0)
- {
- _lightSensor._illuminated = true;
- _lightSensor.OnDetectLight.Invoke();
- }
- else if (illuminated && _illuminatedBy.Count == 0)
- {
- _lightSensor._illuminated = false;
- _lightSensor.OnDetectDarkness.Invoke();
- }
- }
-}
diff --git a/QSB/Player/PlayerInfoParts/Body.cs b/QSB/Player/PlayerInfoParts/Body.cs
index 7bfba9a8..bee6ba69 100644
--- a/QSB/Player/PlayerInfoParts/Body.cs
+++ b/QSB/Player/PlayerInfoParts/Body.cs
@@ -1,5 +1,4 @@
using OWML.Common;
-using QSB.EchoesOfTheEye.LightSensorSync;
using QSB.Utility;
using UnityEngine;
@@ -74,8 +73,6 @@ public partial class PlayerInfo
}
}
- public QSBPlayerLightSensor QSBPlayerLightSensor;
-
public Vector3 Velocity
{
get
diff --git a/QSB/PlayerBodySetup/Local/LocalPlayerCreation.cs b/QSB/PlayerBodySetup/Local/LocalPlayerCreation.cs
index 512755ed..eb502f49 100644
--- a/QSB/PlayerBodySetup/Local/LocalPlayerCreation.cs
+++ b/QSB/PlayerBodySetup/Local/LocalPlayerCreation.cs
@@ -1,12 +1,10 @@
-using QSB.EchoesOfTheEye.LightSensorSync;
-using QSB.Messaging;
+using QSB.Messaging;
using QSB.Player;
using QSB.Player.Messages;
using QSB.SectorSync;
using QSB.Tools;
using QSB.Utility;
using QSB.WorldSync;
-using System.Linq;
using UnityEngine;
namespace QSB.PlayerBodySetup.Local;
@@ -21,7 +19,7 @@ public static class LocalPlayerCreation
out Transform visibleStickPivot,
out Transform visibleStickTip)
{
- DebugLog.DebugWrite($"CREATE PLAYER");
+ DebugLog.DebugWrite("CREATE PLAYER");
sectorDetector.Init(Locator.GetPlayerSectorDetector());
@@ -38,8 +36,6 @@ public static class LocalPlayerCreation
player.CameraBody = cameraBody.gameObject;
visibleCameraRoot = cameraBody;
- player.QSBPlayerLightSensor = player.LightSensor.gameObject.GetAddComponent();
-
PlayerToolsManager.InitLocal();
// stick
@@ -56,4 +52,4 @@ public static class LocalPlayerCreation
return playerBody;
}
-}
\ No newline at end of file
+}
diff --git a/QSB/PlayerBodySetup/Remote/RemotePlayerCreation.cs b/QSB/PlayerBodySetup/Remote/RemotePlayerCreation.cs
index a12ec7e6..68d06a61 100644
--- a/QSB/PlayerBodySetup/Remote/RemotePlayerCreation.cs
+++ b/QSB/PlayerBodySetup/Remote/RemotePlayerCreation.cs
@@ -1,5 +1,4 @@
using QSB.Audio;
-using QSB.EchoesOfTheEye.LightSensorSync;
using QSB.Player;
using QSB.RoastingSync;
using QSB.Tools;
@@ -33,13 +32,13 @@ public static class RemotePlayerCreation
out Transform visibleStickPivot,
out Transform visibleStickTip)
{
- DebugLog.DebugWrite($"CREATE PLAYER");
+ DebugLog.DebugWrite("CREATE PLAYER");
/*
* CREATE PLAYER STRUCTURE
*/
- DebugLog.DebugWrite($"CREATE PLAYER STRUCTURE");
+ DebugLog.DebugWrite("CREATE PLAYER STRUCTURE");
// Variable naming convention is broken here to reflect OW unity project (with REMOTE_ prefixed) for readability
@@ -54,7 +53,7 @@ public static class RemotePlayerCreation
* SET UP PLAYER BODY
*/
- DebugLog.DebugWrite($"SET UP PLAYER BODY");
+ DebugLog.DebugWrite("SET UP PLAYER BODY");
player.Body = REMOTE_Player_Body;
player.ThrusterLightTracker = player.Body.GetComponentInChildren();
@@ -72,7 +71,7 @@ public static class RemotePlayerCreation
* SET UP PLAYER CAMERA
*/
- DebugLog.DebugWrite($"SET UP PLAYER CAMERA");
+ DebugLog.DebugWrite("SET UP PLAYER CAMERA");
REMOTE_PlayerCamera.GetComponent().enabled = false;
var owcamera = REMOTE_PlayerCamera.GetComponent();
@@ -80,15 +79,13 @@ public static class RemotePlayerCreation
player.CameraBody = REMOTE_PlayerCamera;
visibleCameraRoot = REMOTE_PlayerCamera.transform;
- player.QSBPlayerLightSensor = player.LightSensor.gameObject.GetAddComponent();
-
PlayerToolsManager.InitRemote(player);
/*
* SET UP ROASTING STICK
*/
- DebugLog.DebugWrite($"SET UP ROASTING STICK");
+ DebugLog.DebugWrite("SET UP ROASTING STICK");
var REMOTE_Stick_Pivot = REMOTE_Stick_Root.transform.GetChild(0);
var mallowRoot = REMOTE_Stick_Pivot.Find("REMOTE_Stick_Tip/Mallow_Root");
@@ -104,4 +101,4 @@ public static class RemotePlayerCreation
return REMOTE_Player_Body.transform;
}
-}
\ No newline at end of file
+}