summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/Buff/XBuffStateInfo.cs
blob: 13e522a5d0f694b1c1f83e676fb79597a87525fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XBuffStateInfo
	{
		protected short[] _BuffState;

		protected int[] _StateParam;

		public XBuffStateInfo()
		{
			this._BuffState = new short[XFastEnumIntEqualityComparer<XBuffType>.ToInt(XBuffType.XBuffType_Max)];
			this._StateParam = new int[XFastEnumIntEqualityComparer<XBuffType>.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<XDebug>.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<XBuffType>.ToInt(state)] = count;
		}

		public void IncBuffState(XBuffType state, int param = 0)
		{
			short[] buffState = this._BuffState;
			int num = XFastEnumIntEqualityComparer<XBuffType>.ToInt(state);
			buffState[num] += 1;
			if (state != XBuffType.XBuffType_Transform && state != XBuffType.XBuffType_Scale)
			{
				this._StateParam[XFastEnumIntEqualityComparer<XBuffType>.ToInt(state)] += param;
			}
			else
			{
				this._StateParam[XFastEnumIntEqualityComparer<XBuffType>.ToInt(state)] = param;
			}
		}

		public void DecBuffState(XBuffType state, int param = 0)
		{
			int num = XFastEnumIntEqualityComparer<XBuffType>.ToInt(state);
			short[] buffState = this._BuffState;
			int num2 = num;
			buffState[num2] -= 1;
			if (state != XBuffType.XBuffType_Transform && state != XBuffType.XBuffType_Scale)
			{
				this._StateParam[XFastEnumIntEqualityComparer<XBuffType>.ToInt(state)] -= param;
			}
			else
			{
				bool flag = this._StateParam[XFastEnumIntEqualityComparer<XBuffType>.ToInt(state)] == param;
				if (flag)
				{
					this._StateParam[XFastEnumIntEqualityComparer<XBuffType>.ToInt(state)] = 0;
				}
			}
			bool flag2 = this._BuffState[num] < 0;
			if (flag2)
			{
			}
		}

		public bool IsBuffStateOn(XBuffType state)
		{
			return this._BuffState[XFastEnumIntEqualityComparer<XBuffType>.ToInt(state)] != 0;
		}

		public short GetBuffStateCounter(XBuffType state)
		{
			return this._BuffState[XFastEnumIntEqualityComparer<XBuffType>.ToInt(state)];
		}

		public int GetStateParam(XBuffType state)
		{
			return this._StateParam[XFastEnumIntEqualityComparer<XBuffType>.ToInt(state)];
		}

		public void SetStateParam(XBuffType state, int v)
		{
			this._StateParam[XFastEnumIntEqualityComparer<XBuffType>.ToInt(state)] = v;
		}
	}
}