mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-06 18:40:47 +00:00
36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using QSB.ItemSync.WorldObjects.Items;
|
|
using QSB.Messaging;
|
|
using QSB.Player;
|
|
using QSB.Utility;
|
|
|
|
namespace QSB.EchoesOfTheEye.DreamLantern.Messages;
|
|
|
|
internal class DreamLanternStateMessage : QSBMessage<(DreamLanternActionType Type, bool BoolValue, float FloatValue)>
|
|
{
|
|
public DreamLanternStateMessage(DreamLanternActionType actionType, bool boolValue = false, float floatValue = 0f)
|
|
: base((actionType, boolValue, floatValue)) { }
|
|
|
|
public override void OnReceiveRemote()
|
|
{
|
|
var heldItem = QSBPlayerManager.GetPlayer(From).HeldItem;
|
|
|
|
if (heldItem is not QSBDreamLanternItem lantern)
|
|
{
|
|
DebugLog.ToConsole($"Error - Got DreamLanternStateMessage from player {From}, but they are not holding a QSBDreamLanternItem!");
|
|
return;
|
|
}
|
|
|
|
var controller = lantern.AttachedObject._lanternController;
|
|
|
|
switch (Data.Type)
|
|
{
|
|
case DreamLanternActionType.CONCEAL:
|
|
controller.SetConcealed(Data.BoolValue);
|
|
break;
|
|
case DreamLanternActionType.FOCUS:
|
|
controller.SetFocus(Data.FloatValue);
|
|
break;
|
|
}
|
|
}
|
|
}
|