summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/Buff/XBuffSkillsReplace.cs
blob: 19f7caf9a48bef9ca83a9c99a8a51fbf081fc6da (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
using System;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XBuffSkillsReplace : BuffEffect
	{
		private XBuff m_Buff;

		private XEntity m_Entity;

		public static bool TryCreate(BuffTable.RowData rowData, XBuff buff)
		{
			bool flag = rowData.SkillsReplace.Count == 0;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				buff.AddEffect(new XBuffSkillsReplace(buff));
				result = true;
			}
			return result;
		}

		public XBuffSkillsReplace(XBuff _Buff)
		{
			this.m_Buff = _Buff;
		}

		public override void OnAdd(XEntity entity, CombatEffectHelper pEffectHelper)
		{
			this.m_Entity = entity;
			XBuffSkillsReplace.DoAdd(entity, ref this.m_Buff.BuffInfo.SkillsReplace);
		}

		public override void OnRemove(XEntity entity, bool IsReplaced)
		{
			XBuffSkillsReplace.DoRemove(entity, ref this.m_Buff.BuffInfo.SkillsReplace);
		}

		public static void TrySkillsReplace(XEntity entity, UIBuffInfo uibuffInfo, bool bOpen)
		{
			bool flag = uibuffInfo == null || uibuffInfo.buffInfo == null || uibuffInfo.buffInfo.SkillsReplace.Count == 0;
			if (!flag)
			{
				if (bOpen)
				{
					XBuffSkillsReplace.DoAdd(entity, ref uibuffInfo.buffInfo.SkillsReplace);
				}
				else
				{
					XBuffSkillsReplace.DoRemove(entity, ref uibuffInfo.buffInfo.SkillsReplace);
				}
			}
		}

		public static void DoAdd(XEntity entity, ref SeqListRef<string> list)
		{
			bool flag = entity == null || entity.Skill == null;
			if (!flag)
			{
				for (int i = 0; i < list.Count; i++)
				{
					entity.Skill.SetSkillReplace(XSingleton<XCommon>.singleton.XHash(list[i, 0]), XSingleton<XCommon>.singleton.XHash(list[i, 1]));
				}
			}
		}

		public static void DoRemove(XEntity entity, ref SeqListRef<string> list)
		{
			bool flag = entity == null || entity.Skill == null;
			if (!flag)
			{
				for (int i = 0; i < list.Count; i++)
				{
					entity.Skill.SetSkillReplace(XSingleton<XCommon>.singleton.XHash(list[i, 0]), 0u);
				}
			}
		}
	}
}