blob: e01b63745d186417f32fb08b92875ad1c6e51f88 (
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
using System;
using System.Collections.Generic;
using XUtliPoolLib;
namespace XMainClient
{
internal class XEnmityList
{
public bool IsInited
{
get
{
return this._inited;
}
}
public bool IsActive
{
get
{
return this._is_active;
}
}
private List<Enmity> _hatred_list = new List<Enmity>();
private List<XEntity> _targets = new List<XEntity>();
private XEntity _host = null;
private static readonly float OT_VALUE = float.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("OTValue"));
private bool _inited = false;
private bool _is_active = true;
private DateTime _last_refresh_time = DateTime.Today;
public void Init(XEntity host)
{
bool inited = this._inited;
if (!inited)
{
this._host = host;
this._hatred_list.Clear();
this._inited = true;
}
}
public void Reset()
{
this._hatred_list.Clear();
}
public void AddHateValue(XEntity entity, float value)
{
bool flag = false;
float enmityCoefficient = XSingleton<XProfessionSkillMgr>.singleton.GetEnmityCoefficient((int)entity.Attributes.Type);
float profFixedEnmity = XSingleton<XProfessionSkillMgr>.singleton.GetProfFixedEnmity((int)entity.Attributes.TypeID);
float num = profFixedEnmity + value * enmityCoefficient * (float)(entity.Attributes.GetAttr(XAttributeDefine.XATTR_ENMITY_Total) / XSingleton<XGlobalConfig>.singleton.GeneralCombatParam);
for (int i = 0; i < this._hatred_list.Count; i++)
{
bool flag2 = this._hatred_list[i].entity == entity;
if (flag2)
{
this._hatred_list[i].value += num;
this._hatred_list[i].value = Math.Max(this._hatred_list[i].value, 0f);
flag = true;
break;
}
}
bool flag3 = !flag;
if (flag3)
{
Enmity enmity = new Enmity();
enmity.value = Math.Max(num, 0f);
enmity.entity = entity;
this._hatred_list.Add(enmity);
}
this.UpdateHateList();
}
public int CompareHate(Enmity a, Enmity b)
{
return b.value.CompareTo(a.value);
}
public void UpdateHateList()
{
bool flag = this._hatred_list.Count == 0;
if (!flag)
{
float value = this._hatred_list[0].value;
int num = 0;
float num2 = 0f;
for (int i = 1; i < this._hatred_list.Count; i++)
{
bool flag2 = !XEntity.ValideEntity(this._hatred_list[i].entity);
if (flag2)
{
this._hatred_list.RemoveAt(i);
i--;
}
}
bool flag3 = !XEntity.ValideEntity(this._hatred_list[0].entity);
if (flag3)
{
this._hatred_list.RemoveAt(0);
this._hatred_list.Sort(new Comparison<Enmity>(this.CompareHate));
}
else
{
for (int j = 1; j < this._hatred_list.Count; j++)
{
bool flag4 = num == 0;
if (flag4)
{
bool flag5 = this._hatred_list[j].value > value * XEnmityList.OT_VALUE;
if (flag5)
{
num = j;
num2 = this._hatred_list[j].value;
}
}
else
{
bool flag6 = this._hatred_list[j].value > num2;
if (flag6)
{
num = j;
num2 = this._hatred_list[j].value;
}
}
}
bool flag7 = num != 0;
if (flag7)
{
Enmity value2 = this._hatred_list[0];
this._hatred_list[0] = this._hatred_list[num];
this._hatred_list[num] = value2;
}
Enmity item = this._hatred_list[0];
List<Enmity> hatred_list = this._hatred_list;
hatred_list.RemoveAt(0);
this._hatred_list.Sort(new Comparison<Enmity>(this.CompareHate));
this._hatred_list.Insert(0, item);
bool flag8 = (DateTime.Now - this._last_refresh_time).Seconds < 1;
if (!flag8)
{
this._last_refresh_time = DateTime.Now;
}
}
}
}
public void AddInitHateValue(XEntity entity)
{
bool flag = this._hatred_list.Count != 0;
if (!flag)
{
float value = float.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("InitEnmityValue"));
this.AddHateValue(entity, value);
}
}
public List<XEntity> GetHateEntity(bool filterImmortal = false)
{
this._targets.Clear();
this.UpdateHateList();
bool flag = this._hatred_list.Count == 0;
List<XEntity> targets;
if (flag)
{
targets = this._targets;
}
else
{
bool flag2 = !this._is_active;
if (flag2)
{
targets = this._targets;
}
else
{
if (filterImmortal)
{
float num = 0f;
for (int i = 0; i < this._hatred_list.Count; i++)
{
bool flag3 = this._hatred_list[i].entity.Buffs == null || !this._hatred_list[i].entity.Buffs.IsBuffStateOn(XBuffType.XBuffType_Immortal);
if (flag3)
{
bool flag4 = num == 0f;
if (flag4)
{
num = this._hatred_list[i].value;
this._targets.Add(this._hatred_list[i].entity);
}
else
{
bool flag5 = num == this._hatred_list[i].value;
if (flag5)
{
this._targets.Add(this._hatred_list[i].entity);
}
}
}
}
}
else
{
float num2 = 0f;
for (int j = 0; j < this._hatred_list.Count; j++)
{
bool flag6 = num2 == 0f;
if (flag6)
{
num2 = this._hatred_list[j].value;
this._targets.Add(this._hatred_list[j].entity);
}
else
{
bool flag7 = num2 == this._hatred_list[j].value;
if (flag7)
{
this._targets.Add(this._hatred_list[j].entity);
}
}
}
}
targets = this._targets;
}
}
return targets;
}
public void SetActive(bool active)
{
this._is_active = active;
}
}
}
|