mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-09 18:40:36 +00:00
43 lines
979 B
C#
43 lines
979 B
C#
using OWML.ModHelper.Events;
|
|
using QSB.EventsCore;
|
|
using QSB.WorldSync;
|
|
|
|
namespace QSB.OrbSync
|
|
{
|
|
public class QSBOrbSlot : WorldObject
|
|
{
|
|
public NomaiInterfaceSlot InterfaceSlot { get; private set; }
|
|
public bool Activated { get; private set; }
|
|
|
|
private bool _initialized;
|
|
|
|
public void Init(NomaiInterfaceSlot slot, int id)
|
|
{
|
|
ObjectId = id;
|
|
InterfaceSlot = slot;
|
|
_initialized = true;
|
|
WorldRegistry.AddObject(this);
|
|
}
|
|
|
|
public void HandleEvent(bool state, int orbId)
|
|
{
|
|
if (QSB.HasWokenUp)
|
|
{
|
|
GlobalMessenger<int, int, bool>.FireEvent(EventNames.QSBOrbSlot, ObjectId, orbId, state);
|
|
}
|
|
}
|
|
|
|
public void SetState(bool state, int orbId)
|
|
{
|
|
if (!_initialized)
|
|
{
|
|
return;
|
|
}
|
|
var occOrb = state ? WorldRegistry.OldOrbList[orbId] : null;
|
|
InterfaceSlot.SetValue("_occupyingOrb", occOrb);
|
|
var ev = state ? "OnSlotActivated" : "OnSlotDeactivated";
|
|
WorldRegistry.RaiseEvent(InterfaceSlot, ev);
|
|
Activated = state;
|
|
}
|
|
}
|
|
} |