More refactoring of code.

This commit is contained in:
hondacrx
2019-09-23 21:41:13 -04:00
parent 2418715800
commit 570aebce26
176 changed files with 2261 additions and 2265 deletions
+9 -9
View File
@@ -25,16 +25,16 @@ namespace Game.Combat
{
iType = pType;
}
public UnitEventTypes getType()
public UnitEventTypes GetEventType()
{
return iType;
}
bool matchesTypeMask(uint pMask)
bool MatchesTypeMask(uint pMask)
{
return Convert.ToBoolean((uint)iType & pMask);
}
void setType(UnitEventTypes pType)
void SetEventType(UnitEventTypes pType)
{
iType = pType;
}
@@ -67,32 +67,32 @@ namespace Game.Combat
iBValue = pValue;
}
public float getFValue()
public float GetFValue()
{
return iFValue;
}
bool getBValue()
bool GetBValue()
{
return iBValue;
}
void setBValue(bool pValue)
void SetBValue(bool pValue)
{
iBValue = pValue;
}
public HostileReference getReference()
public HostileReference GetReference()
{
return iHostileReference;
}
public void setThreatManager(ThreatManager pThreatManager)
public void SetThreatManager(ThreatManager pThreatManager)
{
iThreatManager = pThreatManager;
}
ThreatManager getThreatManager()
ThreatManager GetThreatManager()
{
return iThreatManager;
}
+107 -107
View File
@@ -31,130 +31,130 @@ namespace Game.Combat
Owner = owner;
}
Unit getOwner() { return Owner; }
Unit GetOwner() { return Owner; }
// send threat to all my haters for the victim
// The victim is then hated by them as well
// use for buffs and healing threat functionality
public void threatAssist(Unit victim, float baseThreat, SpellInfo threatSpell = null)
public void ThreatAssist(Unit victim, float baseThreat, SpellInfo threatSpell = null)
{
float threat = ThreatManager.calcThreat(victim, Owner, baseThreat, (threatSpell != null ? threatSpell.GetSchoolMask() : SpellSchoolMask.Normal), threatSpell);
float threat = ThreatManager.CalcThreat(victim, Owner, baseThreat, (threatSpell != null ? threatSpell.GetSchoolMask() : SpellSchoolMask.Normal), threatSpell);
threat /= GetSize();
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
while (refe != null)
{
if (ThreatManager.isValidProcess(victim, refe.GetSource().GetOwner(), threatSpell))
refe.GetSource().doAddThreat(victim, threat);
if (ThreatManager.IsValidProcess(victim, refe.GetSource().GetOwner(), threatSpell))
refe.GetSource().DoAddThreat(victim, threat);
refe = refe.next();
refe = refe.Next();
}
}
public void addTempThreat(float threat, bool apply)
public void AddTempThreat(float threat, bool apply)
{
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
while (refe != null)
{
if (apply)
{
if (refe.getTempThreatModifier() == 0.0f)
refe.addTempThreat(threat);
if (refe.GetTempThreatModifier() == 0.0f)
refe.AddTempThreat(threat);
}
else
refe.resetTempThreat();
refe.ResetTempThreat();
refe = refe.next();
refe = refe.Next();
}
}
void addThreatPercent(int percent)
void AddThreatPercent(int percent)
{
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
while (refe != null)
{
refe.addThreatPercent(percent);
refe = refe.next();
refe.AddThreatPercent(percent);
refe = refe.Next();
}
}
// The references are not needed anymore
// tell the source to remove them from the list and free the mem
public void deleteReferences()
public void DeleteReferences()
{
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
while (refe != null)
{
HostileReference nextRef = refe.next();
refe.removeReference();
HostileReference nextRef = refe.Next();
refe.RemoveReference();
refe = nextRef;
}
}
// Remove specific faction references
public void deleteReferencesForFaction(uint faction)
public void DeleteReferencesForFaction(uint faction)
{
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
while (refe != null)
{
HostileReference nextRef = refe.next();
HostileReference nextRef = refe.Next();
if (refe.GetSource().GetOwner().GetFactionTemplateEntry().Faction == faction)
{
refe.removeReference();
refe.RemoveReference();
}
refe = nextRef;
}
}
// delete all references out of specified range
public void deleteReferencesOutOfRange(float range)
public void DeleteReferencesOutOfRange(float range)
{
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
range = range * range;
while (refe != null)
{
HostileReference nextRef = refe.next();
HostileReference nextRef = refe.Next();
Unit owner = refe.GetSource().GetOwner();
if (!owner.IsActiveObject() && owner.GetExactDist2dSq(getOwner()) > range)
if (!owner.IsActiveObject() && owner.GetExactDist2dSq(GetOwner()) > range)
{
refe.removeReference();
refe.RemoveReference();
}
refe = nextRef;
}
}
public new HostileReference getFirst() { return ((HostileReference)base.getFirst()); }
public new HostileReference GetFirst() { return (HostileReference)base.GetFirst(); }
public void updateThreatTables()
public void UpdateThreatTables()
{
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
while (refe != null)
{
refe.updateOnlineStatus();
refe = refe.next();
refe.UpdateOnlineStatus();
refe = refe.Next();
}
}
public void setOnlineOfflineState(bool isOnline)
public void SetOnlineOfflineState(bool isOnline)
{
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
while (refe != null)
{
refe.setOnlineOfflineState(isOnline);
refe = refe.next();
refe.SetOnlineOfflineState(isOnline);
refe = refe.Next();
}
}
// set state for one reference, defined by Unit
public void setOnlineOfflineState(Unit creature, bool isOnline)
public void SetOnlineOfflineState(Unit creature, bool isOnline)
{
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
while (refe != null)
{
HostileReference nextRef = refe.next();
HostileReference nextRef = refe.Next();
if (refe.GetSource().GetOwner() == creature)
{
refe.setOnlineOfflineState(isOnline);
refe.SetOnlineOfflineState(isOnline);
break;
}
refe = nextRef;
@@ -162,15 +162,15 @@ namespace Game.Combat
}
// delete one reference, defined by Unit
public void deleteReference(Unit creature)
public void DeleteReference(Unit creature)
{
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
while (refe != null)
{
HostileReference nextRef = refe.next();
HostileReference nextRef = refe.Next();
if (refe.GetSource().GetOwner() == creature)
{
refe.removeReference();
refe.RemoveReference();
break;
}
refe = nextRef;
@@ -179,14 +179,14 @@ namespace Game.Combat
public void UpdateVisibility()
{
HostileReference refe = getFirst();
HostileReference refe = GetFirst();
while (refe != null)
{
HostileReference nextRef = refe.next();
if (!refe.GetSource().GetOwner().CanSeeOrDetect(getOwner()))
HostileReference nextRef = refe.Next();
if (!refe.GetSource().GetOwner().CanSeeOrDetect(GetOwner()))
{
nextRef = refe.next();
refe.removeReference();
nextRef = refe.Next();
refe.RemoveReference();
}
refe = nextRef;
}
@@ -199,32 +199,32 @@ namespace Game.Combat
{
iThreat = threat;
iTempThreatModifier = 0.0f;
link(refUnit, threatManager);
Link(refUnit, threatManager);
iUnitGuid = refUnit.GetGUID();
iOnline = true;
iAccessible = true;
}
public override void targetObjectBuildLink()
public override void TargetObjectBuildLink()
{
getTarget().AddHatedBy(this);
GetTarget().AddHatedBy(this);
}
public override void targetObjectDestroyLink()
public override void TargetObjectDestroyLink()
{
getTarget().RemoveHatedBy(this);
GetTarget().RemoveHatedBy(this);
}
public override void sourceObjectDestroyLink()
public override void SourceObjectDestroyLink()
{
setOnlineOfflineState(false);
SetOnlineOfflineState(false);
}
void fireStatusChanged(ThreatRefStatusChangeEvent threatRefStatusChangeEvent)
void FireStatusChanged(ThreatRefStatusChangeEvent threatRefStatusChangeEvent)
{
if (GetSource() != null)
GetSource().processThreatEvent(threatRefStatusChangeEvent);
GetSource().ProcessThreatEvent(threatRefStatusChangeEvent);
}
public void addThreat(float modThreat)
public void AddThreat(float modThreat)
{
if (modThreat == 0.0f)
return;
@@ -233,131 +233,131 @@ namespace Game.Combat
// the threat is changed. Source and target unit have to be available
// if the link was cut before relink it again
if (!isOnline())
updateOnlineStatus();
if (!IsOnline())
UpdateOnlineStatus();
ThreatRefStatusChangeEvent Event = new ThreatRefStatusChangeEvent(UnitEventTypes.ThreatRefThreatChange, this, modThreat);
fireStatusChanged(Event);
FireStatusChanged(Event);
if (isValid() && modThreat > 0.0f)
if (IsValid() && modThreat > 0.0f)
{
Unit victimOwner = getTarget().GetCharmerOrOwner();
Unit victimOwner = GetTarget().GetCharmerOrOwner();
if (victimOwner != null && victimOwner.IsAlive())
GetSource().addThreat(victimOwner, 0.0f); // create a threat to the owner of a pet, if the pet attacks
GetSource().AddThreat(victimOwner, 0.0f); // create a threat to the owner of a pet, if the pet attacks
}
}
public void addThreatPercent(int percent)
public void AddThreatPercent(int percent)
{
addThreat(MathFunctions.CalculatePct(iThreat, percent));
AddThreat(MathFunctions.CalculatePct(iThreat, percent));
}
// check, if source can reach target and set the status
public void updateOnlineStatus()
public void UpdateOnlineStatus()
{
bool online = false;
bool accessible = false;
if (!isValid())
if (!IsValid())
{
Unit target = Global.ObjAccessor.GetUnit(getSourceUnit(), getUnitGuid());
Unit target = Global.ObjAccessor.GetUnit(GetSourceUnit(), GetUnitGuid());
if (target != null)
link(target, GetSource());
Link(target, GetSource());
}
// only check for online status if
// ref is valid
// target is no player or not gamemaster
// target is not in flight
if (isValid()
&& (getTarget().IsTypeId(TypeId.Player) || !getTarget().ToPlayer().IsGameMaster())
&& !getTarget().HasUnitState(UnitState.InFlight)
&& getTarget().IsInMap(getSourceUnit())
&& getTarget().IsInPhase(getSourceUnit())
if (IsValid()
&& (GetTarget().IsTypeId(TypeId.Player) || !GetTarget().ToPlayer().IsGameMaster())
&& !GetTarget().HasUnitState(UnitState.InFlight)
&& GetTarget().IsInMap(GetSourceUnit())
&& GetTarget().IsInPhase(GetSourceUnit())
)
{
Creature creature = getSourceUnit().ToCreature();
online = getTarget().IsInAccessiblePlaceFor(creature);
Creature creature = GetSourceUnit().ToCreature();
online = GetTarget().IsInAccessiblePlaceFor(creature);
if (!online)
{
if (creature.IsWithinCombatRange(getTarget(), creature.m_CombatDistance))
if (creature.IsWithinCombatRange(GetTarget(), creature.m_CombatDistance))
online = true; // not accessible but stays online
}
else
accessible = true;
}
setAccessibleState(accessible);
setOnlineOfflineState(online);
SetAccessibleState(accessible);
SetOnlineOfflineState(online);
}
public void setOnlineOfflineState(bool isOnline)
public void SetOnlineOfflineState(bool isOnline)
{
if (iOnline != isOnline)
{
iOnline = isOnline;
if (!iOnline)
setAccessibleState(false); // if not online that not accessable as well
SetAccessibleState(false); // if not online that not accessable as well
ThreatRefStatusChangeEvent Event = new ThreatRefStatusChangeEvent(UnitEventTypes.ThreatRefOnlineStatus, this);
fireStatusChanged(Event);
FireStatusChanged(Event);
}
}
void setAccessibleState(bool isAccessible)
void SetAccessibleState(bool isAccessible)
{
if (iAccessible != isAccessible)
{
iAccessible = isAccessible;
ThreatRefStatusChangeEvent Event = new ThreatRefStatusChangeEvent(UnitEventTypes.ThreatRefAccessibleStatus, this);
fireStatusChanged(Event);
FireStatusChanged(Event);
}
}
// reference is not needed anymore. realy delete it !
public void removeReference()
public void RemoveReference()
{
invalidate();
Invalidate();
ThreatRefStatusChangeEvent Event = new ThreatRefStatusChangeEvent(UnitEventTypes.ThreatRefRemoveFromList, this);
fireStatusChanged(Event);
FireStatusChanged(Event);
}
Unit getSourceUnit()
Unit GetSourceUnit()
{
return GetSource().GetOwner();
}
public void setThreat(float threat)
public void SetThreat(float threat)
{
addThreat(threat - iThreat);
AddThreat(threat - iThreat);
}
public float getThreat()
public float GetThreat()
{
return iThreat + iTempThreatModifier;
}
public bool isOnline()
public bool IsOnline()
{
return iOnline;
}
// The Unit might be in water and the creature can not enter the water, but has range attack
// in this case online = true, but accessible = false
bool isAccessible()
bool IsAccessible()
{
return iAccessible;
}
// used for temporary setting a threat and reducing it later again.
// the threat modification is stored
public void setTempThreat(float threat)
public void SetTempThreat(float threat)
{
addTempThreat(threat - iTempThreatModifier);
AddTempThreat(threat - iTempThreatModifier);
}
public void addTempThreat(float threat)
public void AddTempThreat(float threat)
{
if (threat == 0.0f)
return;
@@ -365,25 +365,25 @@ namespace Game.Combat
iTempThreatModifier += threat;
ThreatRefStatusChangeEvent Event = new ThreatRefStatusChangeEvent(UnitEventTypes.ThreatRefThreatChange, this, threat);
fireStatusChanged(Event);
FireStatusChanged(Event);
}
public void resetTempThreat()
public void ResetTempThreat()
{
addTempThreat(-iTempThreatModifier);
AddTempThreat(-iTempThreatModifier);
}
public float getTempThreatModifier()
public float GetTempThreatModifier()
{
return iTempThreatModifier;
}
public ObjectGuid getUnitGuid()
public ObjectGuid GetUnitGuid()
{
return iUnitGuid;
}
public new HostileReference next() { return (HostileReference)base.next(); }
public new HostileReference Next() { return (HostileReference)base.Next(); }
float iThreat;
float iTempThreatModifier; // used for SPELL_AURA_MOD_TOTAL_THREAT
+103 -103
View File
@@ -36,23 +36,23 @@ namespace Game.Combat
const int ThreatUpdateInternal = 1 * Time.InMilliseconds;
public void clearReferences()
public void ClearReferences()
{
threatContainer.clearReferences();
threatOfflineContainer.clearReferences();
threatContainer.ClearReferences();
threatOfflineContainer.ClearReferences();
currentVictim = null;
updateTimer = ThreatUpdateInternal;
}
public void addThreat(Unit victim, float threat, SpellSchoolMask schoolMask = SpellSchoolMask.Normal, SpellInfo threatSpell = null)
public void AddThreat(Unit victim, float threat, SpellSchoolMask schoolMask = SpellSchoolMask.Normal, SpellInfo threatSpell = null)
{
if (!isValidProcess(victim, Owner, threatSpell))
if (!IsValidProcess(victim, Owner, threatSpell))
return;
doAddThreat(victim, calcThreat(victim, Owner, threat, schoolMask, threatSpell));
DoAddThreat(victim, CalcThreat(victim, Owner, threat, schoolMask, threatSpell));
}
public void doAddThreat(Unit victim, float threat)
public void DoAddThreat(Unit victim, float threat)
{
uint redirectThreadPct = victim.GetRedirectThreatPercent();
Unit redirectTarget = victim.GetRedirectThreatTarget();
@@ -81,78 +81,78 @@ namespace Game.Combat
{
float redirectThreat = MathFunctions.CalculatePct(threat, redirectThreadPct);
threat -= redirectThreat;
if (isValidProcess(redirectTarget, GetOwner()))
_addThreat(redirectTarget, redirectThreat);
if (IsValidProcess(redirectTarget, GetOwner()))
AddThreat(redirectTarget, redirectThreat);
}
}
_addThreat(victim, threat);
AddThreat(victim, threat);
}
void _addThreat(Unit victim, float threat)
void AddThreat(Unit victim, float threat)
{
var reff = threatContainer.addThreat(victim, threat);
var reff = threatContainer.AddThreat(victim, threat);
// Ref is not in the online refs, search the offline refs next
if (reff == null)
reff = threatOfflineContainer.addThreat(victim, threat);
reff = threatOfflineContainer.AddThreat(victim, threat);
if (reff == null) // there was no ref => create a new one
{
bool isFirst = threatContainer.empty();
bool isFirst = threatContainer.Empty();
// threat has to be 0 here
var hostileRef = new HostileReference(victim, this, 0);
threatContainer.addReference(hostileRef);
hostileRef.addThreat(threat); // now we add the real threat
threatContainer.AddReference(hostileRef);
hostileRef.AddThreat(threat); // now we add the real threat
if (victim.IsTypeId(TypeId.Player) && victim.ToPlayer().IsGameMaster())
hostileRef.setOnlineOfflineState(false); // GM is always offline
hostileRef.SetOnlineOfflineState(false); // GM is always offline
else if (isFirst)
setCurrentVictim(hostileRef);
SetCurrentVictim(hostileRef);
}
}
public void modifyThreatPercent(Unit victim, int percent)
public void ModifyThreatPercent(Unit victim, int percent)
{
threatContainer.modifyThreatPercent(victim, percent);
threatContainer.ModifyThreatPercent(victim, percent);
}
public Unit getHostilTarget()
public Unit GetHostilTarget()
{
threatContainer.update();
HostileReference nextVictim = threatContainer.selectNextVictim(GetOwner().ToCreature(), getCurrentVictim());
setCurrentVictim(nextVictim);
return getCurrentVictim() != null ? getCurrentVictim().getTarget() : null;
threatContainer.Update();
HostileReference nextVictim = threatContainer.SelectNextVictim(GetOwner().ToCreature(), GetCurrentVictim());
SetCurrentVictim(nextVictim);
return GetCurrentVictim() != null ? GetCurrentVictim().GetTarget() : null;
}
public float getThreat(Unit victim, bool alsoSearchOfflineList = false)
public float GetThreat(Unit victim, bool alsoSearchOfflineList = false)
{
float threat = 0.0f;
HostileReference refe = threatContainer.getReferenceByTarget(victim);
HostileReference refe = threatContainer.GetReferenceByTarget(victim);
if (refe == null && alsoSearchOfflineList)
refe = threatOfflineContainer.getReferenceByTarget(victim);
refe = threatOfflineContainer.GetReferenceByTarget(victim);
if (refe != null)
threat = refe.getThreat();
threat = refe.GetThreat();
return threat;
}
void tauntApply(Unit taunter)
void TauntApply(Unit taunter)
{
HostileReference refe = threatContainer.getReferenceByTarget(taunter);
if (getCurrentVictim() != null && refe != null && (refe.getThreat() < getCurrentVictim().getThreat()))
HostileReference refe = threatContainer.GetReferenceByTarget(taunter);
if (GetCurrentVictim() != null && refe != null && (refe.GetThreat() < GetCurrentVictim().GetThreat()))
{
if (refe.getTempThreatModifier() == 0.0f) // Ok, temp threat is unused
refe.setTempThreat(getCurrentVictim().getThreat());
if (refe.GetTempThreatModifier() == 0.0f) // Ok, temp threat is unused
refe.SetTempThreat(GetCurrentVictim().GetThreat());
}
}
void tauntFadeOut(Unit taunter)
void TauntFadeOut(Unit taunter)
{
HostileReference refe = threatContainer.getReferenceByTarget(taunter);
HostileReference refe = threatContainer.GetReferenceByTarget(taunter);
if (refe != null)
refe.resetTempThreat();
refe.ResetTempThreat();
}
public void setCurrentVictim(HostileReference pHostileReference)
public void SetCurrentVictim(HostileReference pHostileReference)
{
if (pHostileReference != null && pHostileReference != currentVictim)
{
@@ -161,58 +161,58 @@ namespace Game.Combat
currentVictim = pHostileReference;
}
public void processThreatEvent(ThreatRefStatusChangeEvent threatRefStatusChangeEvent)
public void ProcessThreatEvent(ThreatRefStatusChangeEvent threatRefStatusChangeEvent)
{
threatRefStatusChangeEvent.setThreatManager(this); // now we can set the threat manager
threatRefStatusChangeEvent.SetThreatManager(this); // now we can set the threat manager
HostileReference hostilRef = threatRefStatusChangeEvent.getReference();
HostileReference hostilRef = threatRefStatusChangeEvent.GetReference();
switch (threatRefStatusChangeEvent.getType())
switch (threatRefStatusChangeEvent.GetEventType())
{
case UnitEventTypes.ThreatRefThreatChange:
if ((getCurrentVictim() == hostilRef && threatRefStatusChangeEvent.getFValue() < 0.0f) ||
(getCurrentVictim() != hostilRef && threatRefStatusChangeEvent.getFValue() > 0.0f))
setDirty(true); // the order in the threat list might have changed
if ((GetCurrentVictim() == hostilRef && threatRefStatusChangeEvent.GetFValue() < 0.0f) ||
(GetCurrentVictim() != hostilRef && threatRefStatusChangeEvent.GetFValue() > 0.0f))
SetDirty(true); // the order in the threat list might have changed
break;
case UnitEventTypes.ThreatRefOnlineStatus:
if (!hostilRef.isOnline())
if (!hostilRef.IsOnline())
{
if (hostilRef == getCurrentVictim())
if (hostilRef == GetCurrentVictim())
{
setCurrentVictim(null);
setDirty(true);
SetCurrentVictim(null);
SetDirty(true);
}
Owner.SendRemoveFromThreatList(hostilRef);
threatContainer.remove(hostilRef);
threatOfflineContainer.addReference(hostilRef);
threatContainer.Remove(hostilRef);
threatOfflineContainer.AddReference(hostilRef);
}
else
{
if (getCurrentVictim() != null && hostilRef.getThreat() > (1.1f * getCurrentVictim().getThreat()))
setDirty(true);
threatContainer.addReference(hostilRef);
threatOfflineContainer.remove(hostilRef);
if (GetCurrentVictim() != null && hostilRef.GetThreat() > (1.1f * GetCurrentVictim().GetThreat()))
SetDirty(true);
threatContainer.AddReference(hostilRef);
threatOfflineContainer.Remove(hostilRef);
}
break;
case UnitEventTypes.ThreatRefRemoveFromList:
if (hostilRef == getCurrentVictim())
if (hostilRef == GetCurrentVictim())
{
setCurrentVictim(null);
setDirty(true);
SetCurrentVictim(null);
SetDirty(true);
}
Owner.SendRemoveFromThreatList(hostilRef);
if (hostilRef.isOnline())
threatContainer.remove(hostilRef);
if (hostilRef.IsOnline())
threatContainer.Remove(hostilRef);
else
threatOfflineContainer.remove(hostilRef);
threatOfflineContainer.Remove(hostilRef);
break;
}
}
public bool isNeedUpdateToClient(uint time)
public bool IsNeedUpdateToClient(uint time)
{
if (isThreatListEmpty())
if (IsThreatListEmpty())
return false;
if (time >= updateTimer)
@@ -225,27 +225,27 @@ namespace Game.Combat
}
// Reset all aggro without modifying the threatlist.
void resetAllAggro()
void ResetAllAggro()
{
var threatList = threatContainer.threatList;
if (threatList.Empty())
return;
foreach (var refe in threatList)
refe.setThreat(0);
refe.SetThreat(0);
setDirty(true);
SetDirty(true);
}
public bool isThreatListEmpty()
public bool IsThreatListEmpty()
{
return threatContainer.empty();
return threatContainer.Empty();
}
public bool areThreatListsEmpty()
public bool IsThreatListsEmpty()
{
return threatContainer.empty() && threatOfflineContainer.empty();
return threatContainer.Empty() && threatOfflineContainer.Empty();
}
public HostileReference getCurrentVictim()
public HostileReference GetCurrentVictim()
{
return currentVictim;
}
@@ -255,17 +255,17 @@ namespace Game.Combat
return Owner;
}
void setDirty(bool isDirty)
void SetDirty(bool isDirty)
{
threatContainer.setDirty(isDirty);
threatContainer.SetDirty(isDirty);
}
public List<HostileReference> getThreatList() { return threatContainer.getThreatList(); }
public List<HostileReference> getOfflineThreatList() { return threatOfflineContainer.getThreatList(); }
public ThreatContainer getOnlineContainer() { return threatContainer; }
public List<HostileReference> GetThreatList() { return threatContainer.GetThreatList(); }
public List<HostileReference> GetOfflineThreatList() { return threatOfflineContainer.GetThreatList(); }
public ThreatContainer GetOnlineContainer() { return threatContainer; }
// The hatingUnit is not used yet
public static float calcThreat(Unit hatedUnit, Unit hatingUnit, float threat, SpellSchoolMask schoolMask = SpellSchoolMask.Normal, SpellInfo threatSpell = null)
public static float CalcThreat(Unit hatedUnit, Unit hatingUnit, float threat, SpellSchoolMask schoolMask = SpellSchoolMask.Normal, SpellInfo threatSpell = null)
{
if (threatSpell != null)
{
@@ -287,7 +287,7 @@ namespace Game.Combat
return hatedUnit.ApplyTotalThreatModifier(threat, schoolMask);
}
public static bool isValidProcess(Unit hatedUnit, Unit hatingUnit, SpellInfo threatSpell = null)
public static bool IsValidProcess(Unit hatedUnit, Unit hatingUnit, SpellInfo threatSpell = null)
{
//function deals with adding threat and adding players and pets into ThreatList
//mobs, NPCs, guards have ThreatList and HateOfflineList
@@ -337,17 +337,17 @@ namespace Game.Combat
iDirty = false;
}
public void clearReferences()
public void ClearReferences()
{
foreach (var reff in threatList)
{
reff.unlink();
reff.Unlink();
}
threatList.Clear();
}
public HostileReference getReferenceByTarget(Unit victim)
public HostileReference GetReferenceByTarget(Unit victim)
{
if (victim == null)
return null;
@@ -355,37 +355,37 @@ namespace Game.Combat
ObjectGuid guid = victim.GetGUID();
foreach (var reff in threatList)
{
if (reff != null && reff.getUnitGuid() == guid)
if (reff != null && reff.GetUnitGuid() == guid)
return reff;
}
return null;
}
public HostileReference addThreat(Unit victim, float threat)
public HostileReference AddThreat(Unit victim, float threat)
{
var reff = getReferenceByTarget(victim);
var reff = GetReferenceByTarget(victim);
if (reff != null)
reff.addThreat(threat);
reff.AddThreat(threat);
return reff;
}
public void modifyThreatPercent(Unit victim, int percent)
public void ModifyThreatPercent(Unit victim, int percent)
{
HostileReference refe = getReferenceByTarget(victim);
HostileReference refe = GetReferenceByTarget(victim);
if (refe != null)
refe.addThreatPercent(percent);
refe.AddThreatPercent(percent);
}
public void update()
public void Update()
{
if (iDirty && threatList.Count > 1)
threatList = threatList.OrderByDescending(p => p.getThreat()).ToList();
threatList = threatList.OrderByDescending(p => p.GetThreat()).ToList();
iDirty = false;
}
public HostileReference selectNextVictim(Creature attacker, HostileReference currentVictim)
public HostileReference SelectNextVictim(Creature attacker, HostileReference currentVictim)
{
HostileReference currentRef = null;
bool found = false;
@@ -398,7 +398,7 @@ namespace Game.Combat
currentRef = threatList[i];
Unit target = currentRef.getTarget();
Unit target = currentRef.GetTarget();
Cypher.Assert(target); // if the ref has status online the target must be there !
// some units are prefered in comparison to others
@@ -425,17 +425,17 @@ namespace Game.Combat
if (currentVictim != null) // select 1.3/1.1 better target in comparison current target
{
// list sorted and and we check current target, then this is best case
if (currentVictim == currentRef || currentRef.getThreat() <= 1.1f * currentVictim.getThreat())
if (currentVictim == currentRef || currentRef.GetThreat() <= 1.1f * currentVictim.GetThreat())
{
if (currentVictim != currentRef && attacker.CanCreatureAttack(currentVictim.getTarget()))
if (currentVictim != currentRef && attacker.CanCreatureAttack(currentVictim.GetTarget()))
currentRef = currentVictim; // for second case, if currentvictim is attackable
found = true;
break;
}
if (currentRef.getThreat() > 1.3f * currentVictim.getThreat() ||
(currentRef.getThreat() > 1.1f * currentVictim.getThreat() &&
if (currentRef.GetThreat() > 1.3f * currentVictim.GetThreat() ||
(currentRef.GetThreat() > 1.1f * currentVictim.GetThreat() &&
attacker.IsWithinMeleeRange(target)))
{ //implement 110% threat rule for targets in melee range
found = true; //and 130% rule for targets in ranged distances
@@ -455,35 +455,35 @@ namespace Game.Combat
return currentRef;
}
public void setDirty(bool isDirty)
public void SetDirty(bool isDirty)
{
iDirty = isDirty;
}
bool isDirty()
bool IsDirty()
{
return iDirty;
}
public bool empty()
public bool Empty()
{
return threatList.Empty();
}
public HostileReference getMostHated()
public HostileReference GetMostHated()
{
return threatList.Count == 0 ? null : threatList[0];
}
public void remove(HostileReference hostileRef)
public void Remove(HostileReference hostileRef)
{
threatList.Remove(hostileRef);
}
public void addReference(HostileReference hostileRef)
public void AddReference(HostileReference hostileRef)
{
threatList.Add(hostileRef);
}
public List<HostileReference> getThreatList() { return threatList; }
public List<HostileReference> GetThreatList() { return threatList; }
public List<HostileReference> threatList { get; set; }
bool iDirty;