From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/Buff/XBuffStateInfo.cs | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/Buff/XBuffStateInfo.cs (limited to 'Client/Assets/Scripts/XMainClient/Buff/XBuffStateInfo.cs') diff --git a/Client/Assets/Scripts/XMainClient/Buff/XBuffStateInfo.cs b/Client/Assets/Scripts/XMainClient/Buff/XBuffStateInfo.cs new file mode 100644 index 00000000..13e522a5 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Buff/XBuffStateInfo.cs @@ -0,0 +1,103 @@ +using System; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XBuffStateInfo + { + protected short[] _BuffState; + + protected int[] _StateParam; + + public XBuffStateInfo() + { + this._BuffState = new short[XFastEnumIntEqualityComparer.ToInt(XBuffType.XBuffType_Max)]; + this._StateParam = new int[XFastEnumIntEqualityComparer.ToInt(XBuffType.XBuffType_Max)]; + } + + public void CheckBuffState() + { + for (int i = 0; i < this._BuffState.Length; i++) + { + bool flag = this._BuffState[i] != 0; + if (flag) + { + XSingleton.singleton.AddErrorLog(string.Format("Clear buff, state {0} is {1}", i, this._BuffState[i]), null, null, null, null, null); + } + } + } + + public void Reset() + { + for (int i = 0; i < this._BuffState.Length; i++) + { + this._BuffState[i] = 0; + this._StateParam[i] = 0; + } + } + + public void SetBuffState(XBuffType state, short count) + { + this._BuffState[XFastEnumIntEqualityComparer.ToInt(state)] = count; + } + + public void IncBuffState(XBuffType state, int param = 0) + { + short[] buffState = this._BuffState; + int num = XFastEnumIntEqualityComparer.ToInt(state); + buffState[num] += 1; + if (state != XBuffType.XBuffType_Transform && state != XBuffType.XBuffType_Scale) + { + this._StateParam[XFastEnumIntEqualityComparer.ToInt(state)] += param; + } + else + { + this._StateParam[XFastEnumIntEqualityComparer.ToInt(state)] = param; + } + } + + public void DecBuffState(XBuffType state, int param = 0) + { + int num = XFastEnumIntEqualityComparer.ToInt(state); + short[] buffState = this._BuffState; + int num2 = num; + buffState[num2] -= 1; + if (state != XBuffType.XBuffType_Transform && state != XBuffType.XBuffType_Scale) + { + this._StateParam[XFastEnumIntEqualityComparer.ToInt(state)] -= param; + } + else + { + bool flag = this._StateParam[XFastEnumIntEqualityComparer.ToInt(state)] == param; + if (flag) + { + this._StateParam[XFastEnumIntEqualityComparer.ToInt(state)] = 0; + } + } + bool flag2 = this._BuffState[num] < 0; + if (flag2) + { + } + } + + public bool IsBuffStateOn(XBuffType state) + { + return this._BuffState[XFastEnumIntEqualityComparer.ToInt(state)] != 0; + } + + public short GetBuffStateCounter(XBuffType state) + { + return this._BuffState[XFastEnumIntEqualityComparer.ToInt(state)]; + } + + public int GetStateParam(XBuffType state) + { + return this._StateParam[XFastEnumIntEqualityComparer.ToInt(state)]; + } + + public void SetStateParam(XBuffType state, int v) + { + this._StateParam[XFastEnumIntEqualityComparer.ToInt(state)] = v; + } + } +} -- cgit v1.1-26-g67d0