summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XPet.cs
blob: 735158b21d7aca1ff76ce7aff99e51bd6c69b811 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
using System;
using System.Collections.Generic;
using KKSG;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XPet
	{
		public bool Canpairride { get; set; }

		public List<XPet.Skill> SkillList
		{
			get
			{
				return this.m_SkillList;
			}
		}

		public List<XPet.Skill> ShowSkillList
		{
			get
			{
				return this.m_ShowSkillList;
			}
		}

		public XPet.Skill ActiveSkill
		{
			get
			{
				return this.m_ActiveSkill;
			}
		}

		public static readonly uint FIX_SKILL_COUNT_MAX = 3u;

		public ulong UID;

		public uint ID;

		public int Level;

		public string Name;

		public PetSex Sex;

		public uint PPT;

		public int Exp;

		public uint FullDegree;

		public uint Mood;

		public int HistoryLevelMAX;

		public int showExp;

		public int showLevel;

		public uint showFullDegree;

		private List<XPet.Skill> m_SkillList = new List<XPet.Skill>();

		private List<XPet.Skill> m_ShowSkillList = new List<XPet.Skill>();

		private XPet.Skill m_ActiveSkill = new XPet.Skill();

		public class Skill
		{
			public uint id;

			public bool open;

			public void Init(uint Id, bool IsOpen = true)
			{
				this.id = Id;
				this.open = IsOpen;
			}
		}

		public XPet.Skill FindSkill(uint id)
		{
			for (int i = 0; i < this.m_SkillList.Count; i++)
			{
				bool flag = this.m_SkillList[i].id == id;
				if (flag)
				{
					return this.m_SkillList[i];
				}
			}
			return null;
		}

		public void Init(PetSingle data, PetChange change = PetChange.None)
		{
			this.UID = data.uid;
			this.ID = data.petid;
			this.Level = (int)data.level;
			this.Exp = (int)data.exp;
			this.Sex = (PetSex)data.sex;
			this.PPT = data.power;
			this.FullDegree = data.hungry;
			this.Mood = data.mood;
			this.HistoryLevelMAX = (int)data.max_level;
			this.Canpairride = data.canpairride;
			PetInfoTable.RowData petInfo = XPetDocument.GetPetInfo(this.ID);
			bool flag = petInfo != null;
			if (flag)
			{
				this.Name = petInfo.name;
			}
			this.m_SkillList.Clear();
			bool flag2 = data.fixedskills != null;
			if (flag2)
			{
				int num = 0;
				while ((long)num < (long)((ulong)XPet.FIX_SKILL_COUNT_MAX))
				{
					XPet.Skill skill = new XPet.Skill();
					bool flag3 = num < data.fixedskills.Count;
					if (flag3)
					{
						skill.Init(data.fixedskills[num], true);
					}
					else
					{
						PetInfoTable.RowData petInfo2 = XPetDocument.GetPetInfo(this.ID);
						bool flag4 = petInfo2 == null;
						if (flag4)
						{
							XSingleton<XDebug>.singleton.AddErrorLog("PetId:" + this.ID + " No Find", null, null, null, null, null);
						}
						skill.Init(XPetDocument.GetFixSkill(this.ID, num + 1), false);
					}
					this.m_SkillList.Add(skill);
					num++;
				}
			}
			bool flag5 = data.randskills != null;
			if (flag5)
			{
				for (int i = 0; i < data.randskills.Count; i++)
				{
					bool flag6 = (long)i >= (long)((ulong)(XPetSkillHandler.SKILL_MAX - XPet.FIX_SKILL_COUNT_MAX));
					if (flag6)
					{
						XSingleton<XDebug>.singleton.AddErrorLog("Random Skill List Count is" + data.randskills.Count, null, null, null, null, null);
						break;
					}
					XPet.Skill skill2 = new XPet.Skill();
					skill2.Init(data.randskills[i], true);
					this.m_SkillList.Add(skill2);
				}
			}
			bool flag7 = change > PetChange.None;
			if (flag7)
			{
				XPetDocument specificDocument = XDocuments.GetSpecificDocument<XPetDocument>(XPetDocument.uuID);
				bool flag8 = change == PetChange.All || change == PetChange.Exp;
				if (flag8)
				{
					bool flag9 = this.showExp != this.Exp || this.showLevel != this.Level;
					if (flag9)
					{
						bool flag10 = this.showLevel != 0 && !specificDocument.IsMaxLevel(this.ID, this.showLevel);
						if (flag10)
						{
							specificDocument.ChangeExp = true;
						}
					}
				}
				bool flag11 = change == PetChange.All || change == PetChange.ExpTransfer;
				if (flag11)
				{
					bool flag12 = this.showFullDegree != this.FullDegree;
					if (flag12)
					{
						bool flag13 = this.showFullDegree < this.FullDegree;
						if (flag13)
						{
							specificDocument.ChangeFullDegree = true;
						}
						else
						{
							this.showFullDegree = this.FullDegree;
						}
					}
				}
				bool flag14 = change == PetChange.ExpTransfer;
				if (flag14)
				{
				}
			}
			else
			{
				this.showExp = this.Exp;
				this.showLevel = this.Level;
				this.showFullDegree = this.FullDegree;
				this.m_ShowSkillList.Clear();
				for (int j = 0; j < this.m_SkillList.Count; j++)
				{
					this.m_ShowSkillList.Add(this.m_SkillList[j]);
				}
			}
		}

		public void Refresh()
		{
			this.showExp = this.Exp;
			this.showLevel = this.Level;
			this.showFullDegree = this.FullDegree;
			this.m_ShowSkillList.Clear();
			for (int i = 0; i < this.m_SkillList.Count; i++)
			{
				this.m_ShowSkillList.Add(this.m_SkillList[i]);
			}
		}
	}
}