Misc Fixes

This commit is contained in:
hondacrx
2021-06-07 13:13:58 -04:00
parent 1941148d8f
commit cb7640e3c6
2 changed files with 8 additions and 12 deletions
+6 -10
View File
@@ -28,7 +28,6 @@ namespace Game.Combat
public class ThreatManager public class ThreatManager
{ {
public static uint CLIENT_THREAT_UPDATE_INTERVAL = 1000u; public static uint CLIENT_THREAT_UPDATE_INTERVAL = 1000u;
static CompareThreatLessThan CompareThreat = new();
public Unit _owner; public Unit _owner;
bool _ownerCanHaveThreatList; bool _ownerCanHaveThreatList;
@@ -632,7 +631,7 @@ namespace Game.Combat
Cypher.Assert(!_myThreatListEntries.ContainsKey(guid), $"Duplicate threat reference being inserted on {_owner.GetGUID()} for {guid.ToString()}!"); Cypher.Assert(!_myThreatListEntries.ContainsKey(guid), $"Duplicate threat reference being inserted on {_owner.GetGUID()} for {guid.ToString()}!");
_myThreatListEntries[guid] = refe; _myThreatListEntries[guid] = refe;
_sortedThreatList.Add(refe); _sortedThreatList.Add(refe);
_sortedThreatList.Sort(CompareThreat); _sortedThreatList.Sort();
} }
public void PurgeThreatListRef(ObjectGuid guid, bool sendRemove) public void PurgeThreatListRef(ObjectGuid guid, bool sendRemove)
@@ -647,7 +646,7 @@ namespace Game.Combat
_currentVictimRef = null; _currentVictimRef = null;
_sortedThreatList.Remove(refe); _sortedThreatList.Remove(refe);
_sortedThreatList.Sort(CompareThreat); _sortedThreatList.Sort();
if (sendRemove && refe.IsOnline()) if (sendRemove && refe.IsOnline())
SendRemoveToClients(refe.GetVictim()); SendRemoveToClients(refe.GetVictim());
} }
@@ -700,7 +699,7 @@ namespace Game.Combat
public void ListNotifyChanged() public void ListNotifyChanged()
{ {
_sortedThreatList.Sort(CompareThreat); _sortedThreatList.Sort();
} }
public Dictionary<ObjectGuid, ThreatReference> GetThreatenedByMeList() { return _threatenedByMe; } public Dictionary<ObjectGuid, ThreatReference> GetThreatenedByMeList() { return _threatenedByMe; }
@@ -729,7 +728,7 @@ namespace Game.Combat
Offline = 0 Offline = 0
} }
public class ThreatReference public class ThreatReference : IComparable<ThreatReference>
{ {
Unit _owner; Unit _owner;
ThreatManager _mgr; ThreatManager _mgr;
@@ -878,13 +877,10 @@ namespace Game.Combat
ScaleThreat(0.01f * (100f + percent)); } ScaleThreat(0.01f * (100f + percent)); }
public void ListNotifyChanged() { _mgr.ListNotifyChanged(); } public void ListNotifyChanged() { _mgr.ListNotifyChanged(); }
}
public class CompareThreatLessThan : IComparer<ThreatReference> public int CompareTo(ThreatReference other)
{
public int Compare(ThreatReference a, ThreatReference b)
{ {
return ThreatManager.CompareReferencesLT(a, b, 1.0f) ? 1 : -1; return ThreatManager.CompareReferencesLT(this, other, 1.0f) ? 1 : -1;
} }
} }
} }
@@ -158,9 +158,9 @@ namespace Game.Entities
return _values.IndexOf(value); return _values.IndexOf(value);
} }
public int FindIndexIf(Predicate<T> blah) public int FindIndexIf(Predicate<T> predicate)
{ {
return _values.FindIndex(blah); return _values.FindIndex(predicate);
} }
public bool HasChanged(int index) public bool HasChanged(int index)