2020-12-20 10:56:15 +00:00
|
|
|
|
using OWML.Utils;
|
2020-12-14 16:24:52 +00:00
|
|
|
|
using QSB.Events;
|
2020-12-24 15:57:25 +00:00
|
|
|
|
using QSB.Utility;
|
2020-09-04 19:54:34 +00:00
|
|
|
|
using QSB.WorldSync;
|
2020-12-24 15:57:25 +00:00
|
|
|
|
using UnityEngine.UI;
|
2020-09-04 19:54:34 +00:00
|
|
|
|
|
2020-12-31 12:10:55 +00:00
|
|
|
|
namespace QSB.OrbSync.WorldObjects
|
2020-09-04 19:54:34 +00:00
|
|
|
|
{
|
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-24 15:57:25 +00:00
|
|
|
|
private Text _debugBoxText;
|
2020-09-04 19:54:34 +00:00
|
|
|
|
|
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-24 15:57:25 +00:00
|
|
|
|
if (QSBCore.DebugMode)
|
|
|
|
|
{
|
|
|
|
|
_debugBoxText = DebugBoxManager.CreateBox(AttachedObject.transform, 0, AttachedObject.IsActivated().ToString()).GetComponent<Text>();
|
|
|
|
|
}
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2020-09-04 19:54:34 +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-24 15:57:25 +00:00
|
|
|
|
if (!QSBCore.HasWokenUp)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
2020-12-24 15:57:25 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-02-10 19:34:41 +00:00
|
|
|
|
QSBEventManager.FireEvent(EventNames.QSBOrbSlot, ObjectId, orbId, state);
|
2020-12-24 15:57:25 +00:00
|
|
|
|
if (QSBCore.DebugMode)
|
|
|
|
|
{
|
|
|
|
|
_debugBoxText.text = state.ToString();
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-04 19:54:34 +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-23 22:43:05 +00:00
|
|
|
|
AttachedObject.SetValue("_occupyingOrb", occOrb);
|
2020-12-02 21:23:01 +00:00
|
|
|
|
var ev = state ? "OnSlotActivated" : "OnSlotDeactivated";
|
2020-12-23 22:43:05 +00:00
|
|
|
|
QSBWorldSync.RaiseEvent(AttachedObject, ev);
|
2020-12-05 18:41:38 +00:00
|
|
|
|
Activated = state;
|
2020-12-24 15:57:25 +00:00
|
|
|
|
if (QSBCore.DebugMode)
|
|
|
|
|
{
|
|
|
|
|
_debugBoxText.text = state.ToString();
|
|
|
|
|
}
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|