mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-27 03:35:20 +00:00
35 lines
868 B
C#
35 lines
868 B
C#
using QSB.Messaging;
|
|
using QSB.Player;
|
|
using QSB.Player.TransformSync;
|
|
|
|
namespace QSB.Tools.FlashlightTool.Messages
|
|
{
|
|
public class PlayerFlashlightMessage : QSBBoolMessage
|
|
{
|
|
static PlayerFlashlightMessage()
|
|
{
|
|
GlobalMessenger.AddListener(OWEvents.TurnOnFlashlight, () => Handle(true));
|
|
GlobalMessenger.AddListener(OWEvents.TurnOffFlashlight, () => Handle(false));
|
|
}
|
|
|
|
private static void Handle(bool on)
|
|
{
|
|
if (PlayerTransformSync.LocalInstance)
|
|
{
|
|
new PlayerFlashlightMessage(on).Send();
|
|
}
|
|
}
|
|
|
|
private PlayerFlashlightMessage(bool on) => Value = on;
|
|
|
|
public override void OnReceiveRemote()
|
|
{
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
player.FlashlightActive = Value;
|
|
player.FlashLight?.UpdateState(Value);
|
|
}
|
|
|
|
public override void OnReceiveLocal() =>
|
|
QSBPlayerManager.LocalPlayer.FlashlightActive = Value;
|
|
}
|
|
} |