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
+26 -26
View File
@@ -43,10 +43,10 @@ namespace Game.Entities
// Search in threat list
ObjectGuid guid = who.GetGUID();
foreach (var refe in GetThreatManager().getThreatList())
foreach (var refe in GetThreatManager().GetThreatList())
{
// Return true if the unit matches
if (refe != null && refe.getUnitGuid() == guid)
if (refe != null && refe.GetUnitGuid() == guid)
return true;
}
@@ -60,18 +60,18 @@ namespace Game.Entities
public void SendChangeCurrentVictim(HostileReference pHostileReference)
{
if (!GetThreatManager().isThreatListEmpty())
if (!GetThreatManager().IsThreatListEmpty())
{
HighestThreatUpdate packet = new HighestThreatUpdate();
packet.UnitGUID = GetGUID();
packet.HighestThreatGUID = pHostileReference.getUnitGuid();
packet.HighestThreatGUID = pHostileReference.GetUnitGuid();
var refeList = GetThreatManager().getThreatList();
var refeList = GetThreatManager().GetThreatList();
foreach (var refe in refeList)
{
ThreatInfo info = new ThreatInfo();
info.UnitGUID = refe.getUnitGuid();
info.Threat = (long)refe.getThreat() * 100;
info.UnitGUID = refe.GetUnitGuid();
info.Threat = (long)refe.GetThreat() * 100;
packet.ThreatList.Add(info);
}
SendMessageToSet(packet, false);
@@ -108,7 +108,7 @@ namespace Game.Entities
++i;
}
GetHostileRefManager().deleteReferencesForFaction(factionId);
GetHostileRefManager().DeleteReferencesForFaction(factionId);
foreach (var control in m_Controlled)
control.StopAttackFaction(factionId);
@@ -136,22 +136,22 @@ namespace Game.Entities
{
ThreatRemove packet = new ThreatRemove();
packet.UnitGUID = GetGUID();
packet.AboutGUID = pHostileReference.getUnitGuid();
packet.AboutGUID = pHostileReference.GetUnitGuid();
SendMessageToSet(packet, false);
}
void SendThreatListUpdate()
{
if (!GetThreatManager().isThreatListEmpty())
if (!GetThreatManager().IsThreatListEmpty())
{
ThreatUpdate packet = new ThreatUpdate();
packet.UnitGUID = GetGUID();
var tlist = GetThreatManager().getThreatList();
var tlist = GetThreatManager().GetThreatList();
foreach (var refe in tlist)
{
ThreatInfo info = new ThreatInfo();
info.UnitGUID = refe.getUnitGuid();
info.Threat = (long)refe.getThreat() * 100;
info.UnitGUID = refe.GetUnitGuid();
info.Threat = (long)refe.GetThreat() * 100;
packet.ThreatList.Add(info);
}
SendMessageToSet(packet, false);
@@ -160,9 +160,9 @@ namespace Game.Entities
public void DeleteThreatList()
{
if (CanHaveThreatList(true) && !threatManager.isThreatListEmpty())
if (CanHaveThreatList(true) && !threatManager.IsThreatListEmpty())
SendClearThreatList();
threatManager.clearReferences();
threatManager.ClearReferences();
}
public void TauntApply(Unit taunter)
@@ -208,7 +208,7 @@ namespace Game.Entities
if (!target || target != taunter)
return;
if (threatManager.isThreatListEmpty())
if (threatManager.IsThreatListEmpty())
{
if (creature.IsAIEnabled)
creature.GetAI().EnterEvadeMode(EvadeReason.NoHostiles);
@@ -326,7 +326,7 @@ namespace Game.Entities
{
// Only mobs can manage threat lists
if (CanHaveThreatList() && !HasUnitState(UnitState.Evade))
threatManager.addThreat(victim, fThreat, schoolMask, threatSpell);
threatManager.AddThreat(victim, fThreat, schoolMask, threatSpell);
}
public float ApplyTotalThreatModifier(float fThreat, SpellSchoolMask schoolMask = SpellSchoolMask.Normal)
{
@@ -601,7 +601,7 @@ namespace Game.Entities
// melee attack spell casted at main hand attack only - no normal melee dmg dealt
if (attType == WeaponAttackType.BaseAttack && GetCurrentSpell(CurrentSpellTypes.Melee) != null && !extra)
m_currentSpells[CurrentSpellTypes.Melee].cast();
m_currentSpells[CurrentSpellTypes.Melee].Cast();
else
{
// attack can be redirected to another target
@@ -975,7 +975,7 @@ namespace Game.Entities
Spell spell = victim.GetCurrentSpell(CurrentSpellTypes.Generic);
if (spell)
{
if (spell.getState() == SpellState.Preparing)
if (spell.GetState() == SpellState.Preparing)
{
SpellInterruptFlags interruptFlags = spell.m_spellInfo.InterruptFlags;
if (interruptFlags.HasAnyFlag(SpellInterruptFlags.AbortOnDmg))
@@ -1143,7 +1143,7 @@ namespace Game.Entities
{
Spell spell = victim.GetCurrentSpell(CurrentSpellTypes.Generic);
if (spell != null)
if (spell.getState() == SpellState.Preparing)
if (spell.GetState() == SpellState.Preparing)
{
var interruptFlags = spell.m_spellInfo.InterruptFlags;
if (interruptFlags.HasAnyFlag(SpellInterruptFlags.AbortOnDmg))
@@ -1154,7 +1154,7 @@ namespace Game.Entities
}
Spell spell1 = victim.GetCurrentSpell(CurrentSpellTypes.Channeled);
if (spell1 != null)
if (spell1.getState() == SpellState.Casting && spell1.m_spellInfo.HasChannelInterruptFlag(SpellChannelInterruptFlags.Delay) && damagetype != DamageEffectType.DOT)
if (spell1.GetState() == SpellState.Casting && spell1.m_spellInfo.HasChannelInterruptFlag(SpellChannelInterruptFlags.Delay) && damagetype != DamageEffectType.DOT)
spell1.DelayedChannel();
}
}
@@ -1474,13 +1474,13 @@ namespace Game.Entities
{
Loot loot = creature.loot;
loot.clear();
loot.Clear();
uint lootid = creature.GetCreatureTemplate().LootId;
if (lootid != 0)
loot.FillLoot(lootid, LootStorage.Creature, looter, false, false, creature.GetLootMode());
if (creature.GetLootMode() > 0)
loot.generateMoneyLoot(creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold);
loot.GenerateMoneyLoot(creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold);
if (group)
{
@@ -1490,7 +1490,7 @@ namespace Game.Entities
group.SendLooter(creature, null);
// Update round robin looter only if the creature had loot
if (!loot.empty())
if (!loot.Empty())
group.UpdateLooterGuid(creature);
}
}
@@ -1572,7 +1572,7 @@ namespace Game.Entities
creature.DeleteThreatList();
// must be after setDeathState which resets dynamic flags
if (!creature.loot.isLooted())
if (!creature.loot.IsLooted())
creature.AddDynamicFlag(UnitDynFlags.Lootable);
else
creature.AllLootRemovedFromCorpse();
@@ -1798,7 +1798,7 @@ namespace Game.Entities
List<Unit> nearMembers = new List<Unit>();
// reserve place for players and pets because resizing vector every unit push is unefficient (vector is reallocated then)
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.next())
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.Next())
{
Player target = refe.GetSource();
if (target)
+1 -1
View File
@@ -40,7 +40,7 @@ namespace Game.Entities
//Movement
protected float[] m_speed_rate = new float[(int)UnitMoveType.Max];
RefManager<Unit, TargetedMovementGeneratorBase> m_FollowingRefManager;
RefManager<Unit, ITargetedMovementGeneratorBase> m_FollowingRefManager;
public MoveSpline MoveSpline { get; set; }
MotionMaster i_motionMaster;
public uint m_movementCounter; //< Incrementing counter used in movement packets
+6 -6
View File
@@ -46,7 +46,7 @@ namespace Game.Entities
public bool IsFlying() { return m_movementInfo.HasMovementFlag(MovementFlag.Flying | MovementFlag.DisableGravity); }
public bool IsFalling()
{
return m_movementInfo.HasMovementFlag(MovementFlag.Falling | MovementFlag.FallingFar) || MoveSpline.isFalling();
return m_movementInfo.HasMovementFlag(MovementFlag.Falling | MovementFlag.FallingFar) || MoveSpline.IsFalling();
}
public virtual bool CanSwim()
{
@@ -68,7 +68,7 @@ namespace Game.Entities
return GetMap().IsUnderWater(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ());
}
void PropagateSpeedChange() { GetMotionMaster().propagateSpeedChange(); }
void PropagateSpeedChange() { GetMotionMaster().PropagateSpeedChange(); }
public float GetSpeed(UnitMoveType mtype)
{
@@ -679,7 +679,7 @@ namespace Game.Entities
}
LiquidData liquid;
ZLiquidStatus liquidStatus = GetMap().getLiquidStatus(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), MapConst.MapAllLiquidTypes, out liquid);
ZLiquidStatus liquidStatus = GetMap().GetLiquidStatus(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), MapConst.MapAllLiquidTypes, out liquid);
isSubmerged = liquidStatus.HasAnyFlag(ZLiquidStatus.UnderWater) || HasUnitMovementFlag(MovementFlag.Swimming);
isInWater = liquidStatus.HasAnyFlag(ZLiquidStatus.InWater | ZLiquidStatus.UnderWater);
@@ -759,7 +759,7 @@ namespace Game.Entities
return;
LiquidData liquid_status;
ZLiquidStatus res = m.getLiquidStatus(GetPhaseShift(), x, y, z, MapConst.MapAllLiquidTypes, out liquid_status);
ZLiquidStatus res = m.GetLiquidStatus(GetPhaseShift(), x, y, z, MapConst.MapAllLiquidTypes, out liquid_status);
if (res == 0)
{
if (_lastLiquid != null && _lastLiquid.SpellID != 0)
@@ -1295,7 +1295,7 @@ namespace Game.Entities
{
Battleground bg = ToPlayer().GetBattleground();
// don't unsummon pet in arena but SetFlag UNIT_FLAG_STUNNED to disable pet's interface
if (bg && bg.isArena())
if (bg && bg.IsArena())
pet.AddUnitFlag(UnitFlags.Stunned);
else
player.UnsummonPetTemporaryIfAny();
@@ -1636,7 +1636,7 @@ namespace Game.Entities
if (MoveSpline.Finalized())
return;
MoveSpline.updateState((int)diff);
MoveSpline.UpdateState((int)diff);
bool arrived = MoveSpline.Finalized();
if (arrived)
+1 -1
View File
@@ -477,7 +477,7 @@ namespace Game.Entities
CastStop();
CombatStop(); // @todo CombatStop(true) may cause crash (interrupt spells)
GetHostileRefManager().deleteReferences();
GetHostileRefManager().DeleteReferences();
DeleteThreatList();
if (_oldFactionId != 0)
+13 -13
View File
@@ -1034,7 +1034,7 @@ namespace Game.Entities
spell.SetSpellValue(pair.Key, pair.Value);
spell.m_CastItem = castItem;
spell.prepare(targets, triggeredByAura);
spell.Prepare(targets, triggeredByAura);
}
public void CastSpell(Unit victim, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
@@ -1134,7 +1134,7 @@ namespace Game.Entities
if (spellType == CurrentSpellTypes.Channeled)
spell.SendChannelUpdate(0);
spell.finish(ok);
spell.Finish(ok);
}
uint GetCastingTimeForBonus(SpellInfo spellProto, DamageEffectType damagetype, uint CastingTime)
@@ -1385,7 +1385,7 @@ namespace Game.Entities
// channeled spells during channel stage (after the initial cast timer) allow movement with a specific spell attribute
Spell spell = m_currentSpells.LookupByKey(CurrentSpellTypes.Channeled);
if (spell)
if (spell.getState() != SpellState.Finished && spell.IsChannelActive())
if (spell.GetState() != SpellState.Finished && spell.IsChannelActive())
if (spell.GetSpellInfo().IsMoveAllowedChannel())
return false;
@@ -1501,7 +1501,7 @@ namespace Game.Entities
int overEnergize = damage - gain;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
victim.GetHostileRefManager().threatAssist(this, damage * 0.5f, spellInfo);
victim.GetHostileRefManager().ThreatAssist(this, damage * 0.5f, spellInfo);
SendEnergizeSpellLog(victim, spellId, damage, overEnergize, powerType);
}
@@ -2100,8 +2100,8 @@ namespace Game.Entities
// generic spells are cast when they are not finished and not delayed
var currentSpell = GetCurrentSpell(CurrentSpellTypes.Generic);
if (currentSpell &&
(currentSpell.getState() != SpellState.Finished) &&
(withDelayed || currentSpell.getState() != SpellState.Delayed))
(currentSpell.GetState() != SpellState.Finished) &&
(withDelayed || currentSpell.GetState() != SpellState.Delayed))
{
if (!skipInstant || currentSpell.GetCastTime() != 0)
{
@@ -2112,7 +2112,7 @@ namespace Game.Entities
currentSpell = GetCurrentSpell(CurrentSpellTypes.Channeled);
// channeled spells may be delayed, but they are still considered cast
if (!skipChanneled && currentSpell &&
(currentSpell.getState() != SpellState.Finished))
(currentSpell.GetState() != SpellState.Finished))
{
if (!isAutoshoot || !currentSpell.m_spellInfo.HasAttribute(SpellAttr2.NotResetAutoActions))
return true;
@@ -2833,8 +2833,8 @@ namespace Game.Entities
Log.outDebug(LogFilter.Unit, "Interrupt spell for unit {0}", GetEntry());
Spell spell = m_currentSpells.LookupByKey(spellType);
if (spell != null
&& (withDelayed || spell.getState() != SpellState.Delayed)
&& (withInstant || spell.GetCastTime() > 0 || spell.getState() == SpellState.Casting))
&& (withDelayed || spell.GetState() != SpellState.Delayed)
&& (withInstant || spell.GetCastTime() > 0 || spell.GetState() == SpellState.Casting))
{
// for example, do not let self-stun aura interrupt itself
if (!spell.IsInterruptable())
@@ -2845,8 +2845,8 @@ namespace Game.Entities
if (IsTypeId(TypeId.Player))
ToPlayer().SendAutoRepeatCancel(this);
if (spell.getState() != SpellState.Finished)
spell.cancel();
if (spell.GetState() != SpellState.Finished)
spell.Cancel();
if (IsCreature() && IsAIEnabled)
ToCreature().GetAI().OnSpellCastInterrupt(spell.GetSpellInfo());
@@ -2867,7 +2867,7 @@ namespace Game.Entities
Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled);
if (spell != null)
{
if (spell.getState() == SpellState.Casting)
if (spell.GetState() == SpellState.Casting)
{
for (var i = 0; i < m_interruptMask.Length; ++i)
m_interruptMask[i] |= spell.m_spellInfo.ChannelInterruptFlags[i];
@@ -3243,7 +3243,7 @@ namespace Game.Entities
Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled);
if (spell != null)
{
if (spell.getState() == SpellState.Casting
if (spell.GetState() == SpellState.Casting
&& Convert.ToBoolean(spell.GetSpellInfo().ChannelInterruptFlags[index] & flag)
&& spell.GetSpellInfo().Id != except
&& !(Convert.ToBoolean(flag & (uint)SpellAuraInterruptFlags.Move) && HasAuraTypeWithAffectMask(AuraType.CastWhileWalking, spell.GetSpellInfo())))
+14 -14
View File
@@ -44,7 +44,7 @@ namespace Game.Entities
UnitTypeMask = UnitTypeMask.None;
hostileRefManager = new HostileRefManager(this);
_spellHistory = new SpellHistory(this);
m_FollowingRefManager = new RefManager<Unit, TargetedMovementGeneratorBase>();
m_FollowingRefManager = new RefManager<Unit, ITargetedMovementGeneratorBase>();
ObjectTypeId = TypeId.Unit;
ObjectTypeMask |= TypeMask.Unit;
@@ -142,7 +142,7 @@ namespace Game.Entities
// Having this would prevent spells from being proced, so let's crash
Cypher.Assert(m_procDeep == 0);
if (CanHaveThreatList() && GetThreatManager().isNeedUpdateToClient(diff))
if (CanHaveThreatList() && GetThreatManager().IsNeedUpdateToClient(diff))
SendThreatListUpdate();
// update combat timer only for players and pets (only pets with PetAI)
@@ -191,7 +191,7 @@ namespace Game.Entities
for (CurrentSpellTypes i = 0; i < CurrentSpellTypes.Max; ++i)
{
if (GetCurrentSpell(i) != null && m_currentSpells[i].getState() == SpellState.Finished)
if (GetCurrentSpell(i) != null && m_currentSpells[i].GetState() == SpellState.Finished)
{
m_currentSpells[i].SetReferencedFromCurrent(false);
m_currentSpells[i] = null;
@@ -484,7 +484,7 @@ namespace Game.Entities
m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map.RemoveAllObjectsInRemoveList
CombatStop();
DeleteThreatList();
GetHostileRefManager().deleteReferences();
GetHostileRefManager().DeleteReferences();
GetMotionMaster().Clear(false); // remove different non-standard movement generators.
}
public override void CleanupsBeforeDelete(bool finalCleanup = true)
@@ -1118,7 +1118,7 @@ namespace Game.Entities
if (IsTypeId(TypeId.Unit) || !ToPlayer().GetSession().PlayerLogout())
{
HostileRefManager refManager = GetHostileRefManager();
HostileReference refe = refManager.getFirst();
HostileReference refe = refManager.GetFirst();
while (refe != null)
{
@@ -1127,17 +1127,17 @@ namespace Game.Entities
{
Creature creature = unit.ToCreature();
if (creature != null)
refManager.setOnlineOfflineState(creature, creature.IsInPhase(this));
refManager.SetOnlineOfflineState(creature, creature.IsInPhase(this));
}
refe = refe.next();
refe = refe.Next();
}
// modify threat lists for new phasemask
if (!IsTypeId(TypeId.Player))
{
List<HostileReference> threatList = GetThreatManager().getThreatList();
List<HostileReference> offlineThreatList = GetThreatManager().getOfflineThreatList();
List<HostileReference> threatList = GetThreatManager().GetThreatList();
List<HostileReference> offlineThreatList = GetThreatManager().GetOfflineThreatList();
// merge expects sorted lists
threatList.Sort();
@@ -1146,9 +1146,9 @@ namespace Game.Entities
foreach (var host in threatList)
{
Unit unit = host.getTarget();
Unit unit = host.GetTarget();
if (unit != null)
unit.GetHostileRefManager().setOnlineOfflineState(ToCreature(), unit.IsInPhase(this));
unit.GetHostileRefManager().SetOnlineOfflineState(ToCreature(), unit.IsInPhase(this));
}
}
}
@@ -1603,7 +1603,7 @@ namespace Game.Entities
{
CombatStop();
DeleteThreatList();
GetHostileRefManager().deleteReferences();
GetHostileRefManager().DeleteReferences();
if (IsNonMeleeSpellCast(false))
InterruptNonMeleeSpells(false);
@@ -1860,7 +1860,7 @@ namespace Game.Entities
// we want to shoot
Spell spell = new Spell(this, autoRepeatSpellInfo, TriggerCastFlags.FullMask);
spell.prepare(m_currentSpells[CurrentSpellTypes.AutoRepeat].m_targets);
spell.Prepare(m_currentSpells[CurrentSpellTypes.AutoRepeat].m_targets);
// all went good, reset attack
ResetAttackTimer(WeaponAttackType.RangedAttack);
@@ -2753,7 +2753,7 @@ namespace Game.Entities
Battleground bg = target.GetBattleground();
if (bg != null)
{
if (bg.isArena())
if (bg.IsArena())
{
DestroyArenaUnit destroyArenaUnit = new DestroyArenaUnit();
destroyArenaUnit.Guid = GetGUID();