mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-08 09:41:07 +00:00
parent
c1df1ce3d4
commit
b3709b8cdc
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +1,14 @@
|
|||||||
using QSB.EchoesOfTheEye.LightSensorSync.Messages;
|
using QSB.WorldSync;
|
||||||
using QSB.Messaging;
|
|
||||||
using QSB.WorldSync;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
|
namespace QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
|
||||||
|
|
||||||
internal class QSBLightSensor : WorldObject<SingleLightSensor>
|
internal class QSBLightSensor : WorldObject<SingleLightSensor>
|
||||||
{
|
{
|
||||||
public uint AuthorityOwner;
|
|
||||||
|
|
||||||
public bool LocallyIlluminated;
|
public bool LocallyIlluminated;
|
||||||
|
|
||||||
public Action OnDetectLocalLight;
|
public Action OnDetectLocalLight;
|
||||||
public Action OnDetectLocalDarkness;
|
public Action OnDetectLocalDarkness;
|
||||||
|
|
||||||
public override void SendInitialState(uint to) =>
|
public override void SendInitialState(uint to) { }
|
||||||
this.SendMessage(new LightSensorAuthorityMessage(AuthorityOwner) { To = to });
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user