Revert "LightSensorAuthorityMessage"

This reverts commit 7ed6fed50c.
This commit is contained in:
JohnCorby 2022-05-27 15:03:30 -07:00
parent c1df1ce3d4
commit b3709b8cdc
2 changed files with 2 additions and 43 deletions

View File

@ -1,36 +0,0 @@
using QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
using QSB.Messaging;
using QSB.Player;
namespace QSB.EchoesOfTheEye.LightSensorSync.Messages;
internal class LightSensorAuthorityMessage : QSBWorldObjectMessage<QSBLightSensor, uint>
{
public LightSensorAuthorityMessage(uint authorityOwner) : base(authorityOwner) { }
public override bool ShouldReceive
{
get
{
if (!base.ShouldReceive)
{
return false;
}
return (WorldObject.AuthorityOwner == 0 || Data == 0)
&& WorldObject.AuthorityOwner != Data;
}
}
public override void OnReceiveLocal() => WorldObject.AuthorityOwner = Data;
public override void OnReceiveRemote()
{
WorldObject.AuthorityOwner = Data;
if (WorldObject.AuthorityOwner == 0 && WorldObject.AttachedObject.enabled)
{
// object has no owner, but is still active for this player. request ownership
WorldObject.SendMessage(new LightSensorAuthorityMessage(QSBPlayerManager.LocalPlayerId));
}
}
}

View File

@ -1,19 +1,14 @@
using QSB.EchoesOfTheEye.LightSensorSync.Messages;
using QSB.Messaging;
using QSB.WorldSync;
using QSB.WorldSync;
using System;
namespace QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
internal class QSBLightSensor : WorldObject<SingleLightSensor>
{
public uint AuthorityOwner;
public bool LocallyIlluminated;
public Action OnDetectLocalLight;
public Action OnDetectLocalDarkness;
public override void SendInitialState(uint to) =>
this.SendMessage(new LightSensorAuthorityMessage(AuthorityOwner) { To = to });
public override void SendInitialState(uint to) { }
}