using OWML.Utils; using QSB.Utility; using UnityEngine.UI; namespace QSB.QuantumSync.WorldObjects { internal class QSBMultiStateQuantumObject : QSBQuantumObject { public QuantumState[] QuantumStates { get; private set; } public Text DebugBoxText; public override void OnRemoval() { base.OnRemoval(); if (DebugBoxText != null) { UnityEngine.Object.Destroy(DebugBoxText.gameObject); } } public override void Init(MultiStateQuantumObject attachedObject, int id) { ObjectId = id; AttachedObject = attachedObject; QuantumStates = AttachedObject.GetValue("_states"); if (QSBCore.DebugMode) { DebugBoxText = DebugBoxManager.CreateBox(AttachedObject.transform, 0, AttachedObject.GetValue("_stateIndex").ToString()).GetComponent(); } base.Init(attachedObject, id); } public void ChangeState(int stateIndex) { var currentStateIndex = AttachedObject.GetValue("_stateIndex"); if (currentStateIndex != -1) { QuantumStates[currentStateIndex].SetVisible(false); } QuantumStates[stateIndex].SetVisible(true); AttachedObject.SetValue("_stateIndex", stateIndex); if (QSBCore.DebugMode) { DebugBoxText.text = stateIndex.ToString(); } } } }