43 lines
981 B
C#
Raw Normal View History

2020-12-07 18:49:51 +00:00
using OWML.ModHelper.Events;
2020-12-14 16:24:52 +00:00
using QSB.Events;
using QSB.WorldSync;
namespace QSB.OrbSync
{
2020-12-02 21:23:01 +00:00
public class QSBOrbSlot : WorldObject
{
public NomaiInterfaceSlot InterfaceSlot { get; private set; }
2020-12-05 18:41:38 +00:00
public bool Activated { get; private set; }
2020-09-07 20:27:56 +02:00
2020-12-02 21:23:01 +00:00
private bool _initialized;
2020-12-02 21:23:01 +00:00
public void Init(NomaiInterfaceSlot slot, int id)
{
ObjectId = id;
InterfaceSlot = slot;
_initialized = true;
2020-12-11 13:14:58 +00:00
QSBWorldSync.AddWorldObject(this);
2020-12-02 21:23:01 +00:00
}
2020-12-07 18:49:51 +00:00
public void HandleEvent(bool state, int orbId)
2020-12-02 21:23:01 +00:00
{
2020-12-14 16:24:52 +00:00
if (QSBCore.HasWokenUp)
2020-12-02 21:23:01 +00:00
{
2020-12-07 18:49:51 +00:00
GlobalMessenger<int, int, bool>.FireEvent(EventNames.QSBOrbSlot, ObjectId, orbId, state);
2020-12-02 21:23:01 +00:00
}
}
2020-12-07 18:49:51 +00:00
public void SetState(bool state, int orbId)
2020-12-02 21:23:01 +00:00
{
if (!_initialized)
{
return;
}
2020-12-11 13:14:58 +00:00
var occOrb = state ? QSBWorldSync.OldOrbList[orbId] : null;
2020-12-07 18:49:51 +00:00
InterfaceSlot.SetValue("_occupyingOrb", occOrb);
2020-12-02 21:23:01 +00:00
var ev = state ? "OnSlotActivated" : "OnSlotDeactivated";
2020-12-11 13:14:58 +00:00
QSBWorldSync.RaiseEvent(InterfaceSlot, ev);
2020-12-05 18:41:38 +00:00
Activated = state;
2020-12-02 21:23:01 +00:00
}
}
2020-12-03 08:28:05 +00:00
}