From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/XFightGroupDocument.cs | 251 +++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XFightGroupDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XFightGroupDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XFightGroupDocument.cs b/Client/Assets/Scripts/XMainClient/XFightGroupDocument.cs new file mode 100644 index 00000000..ae8fd393 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XFightGroupDocument.cs @@ -0,0 +1,251 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using KKSG; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XFightGroupDocument : XComponent + { + public override uint ID + { + get + { + return XFightGroupDocument.uuID; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("FightGroupDocument"); + + public static readonly uint _fightNeutral = (uint)XFastEnumIntEqualityComparer.ToInt(FightGroupType.FightNeutral); + + public static readonly List EmptyEntityList = new List(); + + public static bool[,] FightGroup = null; + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private static FightGroupTable _FightGroup = new FightGroupTable(); + + private static XFightGroupDocument.FightGroupDesc[] _fight_desc = null; + + private static Dictionary _fight_desc_map = new Dictionary(); + + private static Dictionary> _fight_groups = new Dictionary>(); + + public struct FightGroupDesc + { + public List ally; + + public List oppo; + } + + public static void Execute(OnLoadedCallback callback = null) + { + XFightGroupDocument.AsyncLoader.AddTask("Table/FightGroup", XFightGroupDocument._FightGroup, false); + XFightGroupDocument.AsyncLoader.Execute(callback); + } + + public static void OnTableLoaded() + { + int num = XFightGroupDocument._FightGroup.Table.Length - 1; + int num2 = XFastEnumIntEqualityComparer.ToInt(FightGroupType.FightNeutral); + XFightGroupDocument.FightGroup = new bool[num, num]; + Type typeFromHandle = typeof(FightGroupTable.RowData); + FieldInfo[] fields = typeFromHandle.GetFields(); + for (int i = 0; i < num; i++) + { + FightGroupTable.RowData obj = XFightGroupDocument._FightGroup.Table[i + 1]; + for (int j = 0; j < num; j++) + { + bool flag = i == num2 || j == num2 || i == j; + if (flag) + { + XFightGroupDocument.FightGroup[i, j] = false; + } + else + { + string a = fields[j + 1].GetValue(obj).ToString(); + XFightGroupDocument.FightGroup[i, j] = (a == "o"); + } + } + } + XFightGroupDocument._fight_desc = new XFightGroupDocument.FightGroupDesc[num]; + for (int k = 0; k < XFightGroupDocument._fight_desc.Length; k++) + { + XFightGroupDocument._fight_desc[k].ally = new List(); + XFightGroupDocument._fight_desc[k].oppo = new List(); + } + } + + public static void OnSceneLoaded() + { + for (int i = 0; i < XFightGroupDocument._fight_desc.Length; i++) + { + XFightGroupDocument._fight_desc[i].ally.Clear(); + XFightGroupDocument._fight_desc[i].oppo.Clear(); + } + XFightGroupDocument._fight_desc_map.Clear(); + XFightGroupDocument._fight_groups.Clear(); + for (int j = 0; j < 10; j++) + { + XFightGroupDocument.FightGroupDesc value = default(XFightGroupDocument.FightGroupDesc); + value.ally = new List(); + value.oppo = new List(); + XFightGroupDocument._fight_desc_map.Add((uint)(XFightGroupDocument._fight_desc.Length + j), value); + } + } + + public static void OnCalcFightGroup(XEntity e) + { + bool flag = XSingleton.singleton.IsNeutral(e); + if (flag) + { + XFightGroupDocument._fight_desc[(int)XFightGroupDocument._fightNeutral].ally.Add(e); + } + else + { + uint fightGroup = e.Attributes.FightGroup; + uint num = 0u; + while ((ulong)num < (ulong)((long)XFightGroupDocument._fight_desc.Length)) + { + bool flag2 = XSingleton.singleton.IsAlly(num, fightGroup); + if (flag2) + { + XFightGroupDocument._fight_desc[(int)num].ally.Add(e); + } + bool flag3 = XSingleton.singleton.IsOpponent(num, fightGroup); + if (flag3) + { + XFightGroupDocument._fight_desc[(int)num].oppo.Add(e); + } + num += 1u; + } + foreach (KeyValuePair keyValuePair in XFightGroupDocument._fight_desc_map) + { + bool flag4 = XSingleton.singleton.IsAlly(keyValuePair.Key, fightGroup); + if (flag4) + { + keyValuePair.Value.ally.Add(e); + } + bool flag5 = XSingleton.singleton.IsOpponent(keyValuePair.Key, fightGroup); + if (flag5) + { + keyValuePair.Value.oppo.Add(e); + } + } + } + uint key = XSingleton.singleton.IsNeutral(e) ? XFightGroupDocument._fightNeutral : e.Attributes.FightGroup; + bool flag6 = !XFightGroupDocument._fight_groups.ContainsKey(key); + if (flag6) + { + XFightGroupDocument._fight_groups[key] = new List(); + } + bool flag7 = !XFightGroupDocument._fight_groups[key].Contains(e); + if (flag7) + { + XFightGroupDocument._fight_groups[key].Add(e); + } + } + + public static void OnDecalcFightGroup(XEntity e) + { + bool flag = XSingleton.singleton.IsNeutral(e); + if (flag) + { + XFightGroupDocument._fight_desc[(int)XFightGroupDocument._fightNeutral].ally.Remove(e); + } + else + { + uint num = 0u; + while ((ulong)num < (ulong)((long)XFightGroupDocument._fight_desc.Length)) + { + XFightGroupDocument._fight_desc[(int)num].ally.Remove(e); + XFightGroupDocument._fight_desc[(int)num].oppo.Remove(e); + num += 1u; + } + foreach (KeyValuePair keyValuePair in XFightGroupDocument._fight_desc_map) + { + keyValuePair.Value.ally.Remove(e); + keyValuePair.Value.oppo.Remove(e); + } + } + foreach (KeyValuePair> keyValuePair2 in XFightGroupDocument._fight_groups) + { + keyValuePair2.Value.Remove(e); + } + } + + public static bool IsNeutral(uint e) + { + return e == XFightGroupDocument._fightNeutral; + } + + public static bool IsAlly(uint me, uint other) + { + return me != XFightGroupDocument._fightNeutral && other != XFightGroupDocument._fightNeutral && me == other && !XFightGroupDocument.LookUpTable(me, other); + } + + public static bool IsOpponent(uint me, uint other) + { + return me != XFightGroupDocument._fightNeutral && other != XFightGroupDocument._fightNeutral && XFightGroupDocument.LookUpTable(me, other); + } + + public static List GetOpponent(uint me) + { + return ((ulong)me < (ulong)((long)XFightGroupDocument._fight_desc.Length)) ? XFightGroupDocument._fight_desc[(int)me].oppo : (XFightGroupDocument._fight_desc_map.ContainsKey(me) ? XFightGroupDocument._fight_desc_map[me].oppo : XFightGroupDocument.EmptyEntityList); + } + + public static List GetAlly(uint me) + { + return ((ulong)me < (ulong)((long)XFightGroupDocument._fight_desc.Length)) ? XFightGroupDocument._fight_desc[(int)me].ally : (XFightGroupDocument._fight_desc_map.ContainsKey(me) ? XFightGroupDocument._fight_desc_map[me].ally : XFightGroupDocument.EmptyEntityList); + } + + public static List GetSpecificGroup(uint specific) + { + return XFightGroupDocument._fight_groups[specific]; + } + + public static List GetNeutral() + { + return XFightGroupDocument._fight_desc[(int)XFightGroupDocument._fightNeutral].ally; + } + + private static bool LookUpTable(uint me, uint other) + { + bool flag = XFightGroupDocument._fight_desc.Length == 0; + bool result; + if (flag) + { + result = false; + } + else + { + bool flag2 = (ulong)me >= (ulong)((long)XFightGroupDocument._fight_desc.Length) && (ulong)other >= (ulong)((long)XFightGroupDocument._fight_desc.Length); + if (flag2) + { + result = (me != other); + } + else + { + bool flag3 = (ulong)me >= (ulong)((long)XFightGroupDocument._fight_desc.Length); + if (flag3) + { + me = (uint)(XFightGroupDocument._fight_desc.Length - 1); + } + else + { + bool flag4 = (ulong)other >= (ulong)((long)XFightGroupDocument._fight_desc.Length); + if (flag4) + { + other = (uint)(XFightGroupDocument._fight_desc.Length - 1); + } + } + result = XFightGroupDocument.FightGroup[(int)me, (int)other]; + } + } + return result; + } + } +} -- cgit v1.1-26-g67d0