diff --git a/QSB/AuthoritySync/IAuthWorldObject.cs b/QSB/AuthoritySync/IAuthWorldObject.cs index 323f4849..7d706feb 100644 --- a/QSB/AuthoritySync/IAuthWorldObject.cs +++ b/QSB/AuthoritySync/IAuthWorldObject.cs @@ -7,6 +7,9 @@ namespace QSB.AuthoritySync; /// public interface IAuthWorldObject : IWorldObject { + /// + /// 0 = owned by no one + /// public uint Owner { get; set; } /// /// can the world object have authority diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Messages/IlluminatedByMessage.cs b/QSB/EchoesOfTheEye/LightSensorSync/Messages/IlluminatedByMessage.cs deleted file mode 100644 index f8e63cc7..00000000 --- a/QSB/EchoesOfTheEye/LightSensorSync/Messages/IlluminatedByMessage.cs +++ /dev/null @@ -1,26 +0,0 @@ -using QSB.EchoesOfTheEye.LightSensorSync.WorldObjects; -using QSB.Messaging; -using System.Linq; - -namespace QSB.EchoesOfTheEye.LightSensorSync.Messages; - -/// -/// always sent by host -/// -internal class IlluminatedByMessage : QSBWorldObjectMessage -{ - public IlluminatedByMessage(uint[] illuminatedBy) : base(illuminatedBy) { } - - public override void OnReceiveRemote() - { - foreach (var added in Data.Except(WorldObject._illuminatedBy).ToList()) - { - WorldObject.SetIlluminated(added, true); - } - - foreach (var removed in WorldObject._illuminatedBy.Except(Data).ToList()) - { - WorldObject.SetIlluminated(removed, false); - } - } -} diff --git a/QSB/EchoesOfTheEye/LightSensorSync/WorldObjects/QSBLightSensor.cs b/QSB/EchoesOfTheEye/LightSensorSync/WorldObjects/QSBLightSensor.cs index e5558338..0c11cc45 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/WorldObjects/QSBLightSensor.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/WorldObjects/QSBLightSensor.cs @@ -1,4 +1,5 @@ using Cysharp.Threading.Tasks; +using QSB.AuthoritySync; using QSB.EchoesOfTheEye.LightSensorSync.Messages; using QSB.Messaging; using QSB.Player; @@ -24,21 +25,20 @@ namespace QSB.EchoesOfTheEye.LightSensorSync.WorldObjects; /// the sector it's enabled in is bigger than the sector the zone2 walls are enabled in :( /// maybe this can be fixed by making the collision group use the same sector. /// -internal class QSBLightSensor : WorldObject +internal class QSBLightSensor : WorldObject, IAuthWorldObject { internal bool _locallyIlluminated; public Action OnDetectLocalLight; public Action OnDetectLocalDarkness; - internal readonly List _illuminatedBy = new(); + + public uint Owner { get; set; } + public bool CanOwn => AttachedObject.enabled; + public override void SendInitialState(uint to) { - this.SendMessage(new IlluminatedByMessage(_illuminatedBy.ToArray()) { To = to }); - if (AttachedObject._illuminatingDreamLanternList != null) - { - this.SendMessage(new IlluminatingLanternsMessage(AttachedObject._illuminatingDreamLanternList) { To = to }); - } + // todo initial state } public override async UniTask Init(CancellationToken ct) @@ -64,25 +64,6 @@ internal class QSBLightSensor : WorldObject 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) - { - AttachedObject._illuminated = true; - AttachedObject.OnDetectLight.Invoke(); - } - else if (illuminated && _illuminatedBy.Count == 0) - { - AttachedObject._illuminated = false; - AttachedObject.OnDetectDarkness.Invoke(); - } + // todo remove } }