2020-12-24 10:06:17 +00:00
|
|
|
|
using OWML.Utils;
|
2020-12-24 15:57:25 +00:00
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using UnityEngine.UI;
|
2020-12-23 22:43:05 +00:00
|
|
|
|
|
2020-12-31 12:10:55 +00:00
|
|
|
|
namespace QSB.QuantumSync.WorldObjects
|
2020-12-23 11:26:47 +00:00
|
|
|
|
{
|
2021-01-26 14:07:17 +00:00
|
|
|
|
internal class QSBMultiStateQuantumObject : QSBQuantumObject<MultiStateQuantumObject>
|
2020-12-23 11:26:47 +00:00
|
|
|
|
{
|
2020-12-24 10:06:17 +00:00
|
|
|
|
public QuantumState[] QuantumStates { get; private set; }
|
2020-12-24 15:57:25 +00:00
|
|
|
|
public Text DebugBoxText;
|
2020-12-24 10:06:17 +00:00
|
|
|
|
|
2021-02-10 20:37:42 +00:00
|
|
|
|
public override void OnRemoval()
|
|
|
|
|
{
|
|
|
|
|
base.OnRemoval();
|
2021-02-19 21:25:17 +00:00
|
|
|
|
if (DebugBoxText != null)
|
|
|
|
|
{
|
|
|
|
|
UnityEngine.Object.Destroy(DebugBoxText.gameObject);
|
|
|
|
|
}
|
2021-02-10 20:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-23 22:43:05 +00:00
|
|
|
|
public override void Init(MultiStateQuantumObject attachedObject, int id)
|
|
|
|
|
{
|
|
|
|
|
ObjectId = id;
|
|
|
|
|
AttachedObject = attachedObject;
|
2020-12-24 10:06:17 +00:00
|
|
|
|
QuantumStates = AttachedObject.GetValue<QuantumState[]>("_states");
|
2020-12-24 15:57:25 +00:00
|
|
|
|
if (QSBCore.DebugMode)
|
|
|
|
|
{
|
|
|
|
|
DebugBoxText = DebugBoxManager.CreateBox(AttachedObject.transform, 0, AttachedObject.GetValue<int>("_stateIndex").ToString()).GetComponent<Text>();
|
|
|
|
|
}
|
2021-01-26 17:08:02 +00:00
|
|
|
|
base.Init(attachedObject, id);
|
2021-01-26 14:07:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ChangeState(int stateIndex)
|
|
|
|
|
{
|
|
|
|
|
var currentStateIndex = AttachedObject.GetValue<int>("_stateIndex");
|
|
|
|
|
if (currentStateIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
QuantumStates[currentStateIndex].SetVisible(false);
|
|
|
|
|
}
|
|
|
|
|
QuantumStates[stateIndex].SetVisible(true);
|
|
|
|
|
AttachedObject.SetValue("_stateIndex", stateIndex);
|
|
|
|
|
if (QSBCore.DebugMode)
|
|
|
|
|
{
|
|
|
|
|
DebugBoxText.text = stateIndex.ToString();
|
|
|
|
|
}
|
2020-12-23 22:43:05 +00:00
|
|
|
|
}
|
2020-12-23 11:26:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|