quantum-space-buddies/QSB/OrbSync/WorldObjects/QSBOrbSlot.cs

45 lines
948 B
C#
Raw Normal View History

2020-12-20 10:56:15 +00:00
using OWML.Utils;
2020-12-14 16:24:52 +00:00
using QSB.Events;
using QSB.Utility;
2021-07-07 08:02:23 +00:00
using QSB.WorldSync;
namespace QSB.OrbSync.WorldObjects
{
2020-12-23 22:43:05 +00:00
public class QSBOrbSlot : WorldObject<NomaiInterfaceSlot>
2020-12-02 21:23:01 +00:00
{
2020-12-05 18:41:38 +00:00
public bool Activated { get; private set; }
2020-09-07 18:27:56 +00:00
2020-12-02 21:23:01 +00:00
private bool _initialized;
2020-12-23 22:43:05 +00:00
public override void Init(NomaiInterfaceSlot slot, int id)
2020-12-02 21:23:01 +00:00
{
ObjectId = id;
2020-12-23 22:43:05 +00:00
AttachedObject = slot;
2020-12-02 21:23:01 +00:00
_initialized = true;
}
2020-12-07 18:49:51 +00:00
public void HandleEvent(bool state, int orbId)
2020-12-02 21:23:01 +00:00
{
if (!WorldObjectManager.AllObjectsReady)
2020-12-02 21:23:01 +00:00
{
2020-12-24 15:57:25 +00:00
return;
}
2021-06-18 21:38:32 +00:00
QSBEventManager.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;
}
2021-06-18 21:38:32 +00:00
2020-12-11 13:14:58 +00:00
var occOrb = state ? QSBWorldSync.OldOrbList[orbId] : null;
2020-12-23 22:43:05 +00:00
AttachedObject.SetValue("_occupyingOrb", occOrb);
2020-12-02 21:23:01 +00:00
var ev = state ? "OnSlotActivated" : "OnSlotDeactivated";
2021-07-07 08:02:23 +00:00
AttachedObject.RaiseEvent(ev, AttachedObject);
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
}