From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/XJadeInfo.cs | 116 +++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XJadeInfo.cs (limited to 'Client/Assets/Scripts/XMainClient/XJadeInfo.cs') diff --git a/Client/Assets/Scripts/XMainClient/XJadeInfo.cs b/Client/Assets/Scripts/XMainClient/XJadeInfo.cs new file mode 100644 index 00000000..46335c93 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XJadeInfo.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; + +namespace XMainClient +{ + internal struct XJadeInfo + { + public uint slotCount + { + get + { + return this._slotCount; + } + } + + public uint slots + { + set + { + this._slots = value; + this._slotCount = 0u; + for (uint num = 0u; num < XJadeInfo.slot_max; num += 1u) + { + uint slot = this.GetSlot((int)num); + bool flag = XJadeInfo.SlotExists(slot); + if (flag) + { + this._slotCount += 1u; + } + } + } + } + + private static readonly uint slot_mask = 15u; + + private static readonly uint slot_step = 4u; + + private static readonly uint slot_max = 32u / XJadeInfo.slot_step; + + private uint _slots; + + private uint _slotCount; + + public XJadeItem[] jades; + + public static readonly uint SLOT_NOTEXIST = 0u; + + public static readonly uint SLOT_NOTOPEN = 15u; + + public void Init() + { + bool flag = this.jades == null; + if (flag) + { + this.jades = new XJadeItem[XJadeInfo.slot_max]; + } + else + { + int num = 0; + while ((long)num < (long)((ulong)XJadeInfo.slot_max)) + { + bool flag2 = this.jades[num] != null; + if (flag2) + { + this.jades[num].Recycle(); + this.jades[num] = null; + } + num++; + } + } + this._slotCount = 0u; + this._slots = 0u; + } + + public uint GetSlot(int index) + { + return this._slots >> (int)((long)index * (long)((ulong)XJadeInfo.slot_step)) & XJadeInfo.slot_mask; + } + + public IEnumerable AllSlots() + { + uint num; + for (uint i = 0u; i < this._slotCount; i = num) + { + yield return this.GetSlot((int)i); + num = i + 1u; + } + yield break; + } + + public static bool SlotExists(uint slot) + { + return slot != XJadeInfo.SLOT_NOTEXIST; + } + + public static bool SlotNotOpen(uint slot) + { + return slot == XJadeInfo.SLOT_NOTOPEN; + } + + public static bool SlotOpened(uint slot) + { + return XJadeInfo.SlotExists(slot) && !XJadeInfo.SlotNotOpen(slot); + } + + public static bool SlotEmpty(int slotIndex, XJadeInfo jadeInfo) + { + return XJadeInfo.SlotOpened(jadeInfo.GetSlot(slotIndex)) && jadeInfo.jades[slotIndex] == null; + } + + public static bool SlotHasJade(int slotIndex, XJadeInfo jadeInfo) + { + return XJadeInfo.SlotOpened(jadeInfo.GetSlot(slotIndex)) && jadeInfo.jades[slotIndex] != null; + } + } +} -- cgit v1.1-26-g67d0