Core/Refactor: Part 2

This commit is contained in:
hondacrx
2018-05-07 22:07:35 -04:00
parent 216db1c23a
commit 9b40067017
93 changed files with 321 additions and 388 deletions
@@ -302,10 +302,7 @@ namespace Game.Entities
AxisAlignedBox box = new AxisAlignedBox(new Vector3(minX, minY, minZ), new Vector3(maxX, maxY, maxZ));
targetList.RemoveAll(unit =>
{
return !box.contains(new Vector3(unit.GetPositionX(), unit.GetPositionY(), unit.GetPositionZ()));
});
targetList.RemoveAll(unit => !box.contains(new Vector3(unit.GetPositionX(), unit.GetPositionY(), unit.GetPositionZ())));
}
void SearchUnitInPolygon(List<Unit> targetList)
@@ -319,11 +316,7 @@ namespace Game.Entities
float maxZ = GetPositionZ() + height;
targetList.RemoveAll(unit =>
{
return !CheckIsInPolygon2D(unit)
|| unit.GetPositionZ() < minZ
|| unit.GetPositionZ() > maxZ;
});
!CheckIsInPolygon2D(unit) || unit.GetPositionZ() < minZ || unit.GetPositionZ() > maxZ);
}
void SearchUnitInCylinder(List<Unit> targetList)
@@ -336,11 +329,8 @@ namespace Game.Entities
float minZ = GetPositionZ() - height;
float maxZ = GetPositionZ() + height;
targetList.RemoveAll(unit =>
{
return unit.GetPositionZ() < minZ
|| unit.GetPositionZ() > maxZ;
});
targetList.RemoveAll(unit => unit.GetPositionZ() < minZ
|| unit.GetPositionZ() > maxZ);
}
void HandleUnitEnterExit(List<Unit> newTargetList)
+1 -1
View File
@@ -3052,7 +3052,7 @@ namespace Game.Entities
// The last taunt aura caster is alive an we are happy to attack him
if (caster != null && caster.IsAlive())
return GetVictim();
else if (tauntAuras.Count() > 1)
else if (tauntAuras.Count > 1)
{
// We do not have last taunt aura caster but we have more taunt auras,
// so find first available target
+1 -1
View File
@@ -793,7 +793,7 @@ namespace Game.Misc
public int GetMenuItemCount()
{
return _questMenuItems.Count();
return _questMenuItems.Count;
}
public bool IsEmpty()
+1 -1
View File
@@ -108,7 +108,7 @@ namespace Game.Entities
TrainerSpellState GetSpellState(Player player, TrainerSpell trainerSpell)
{
if (player.HasSpell(trainerSpell.SpellId))
if (player.HasSpell(trainerSpell.IsCastable() ? trainerSpell.LearnedSpellId : trainerSpell.SpellId))
return TrainerSpellState.Known;
// check race/class requirement
+3 -6
View File
@@ -265,7 +265,7 @@ namespace Game.Entities
stmt.AddValue(0, GetGUID().GetCounter());
trans.Append(stmt);
if (transmogMods.Any(modifier => { return GetModifier(modifier) != 0; }))
if (transmogMods.Any(modifier => GetModifier(modifier) != 0))
{
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_ITEM_INSTANCE_TRANSMOG);
stmt.AddValue(0, GetGUID().GetCounter());
@@ -318,7 +318,7 @@ namespace Game.Entities
stmt.AddValue(0, GetGUID().GetCounter());
trans.Append(stmt);
if (modifiersTable.Any(modifier => { return GetModifier(modifier) != 0; }))
if (modifiersTable.Any(modifier => GetModifier(modifier) != 0))
{
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_ITEM_INSTANCE_MODIFIERS);
stmt.AddValue(0, GetGUID().GetCounter());
@@ -1115,10 +1115,7 @@ namespace Game.Entities
public byte GetGemCountWithID(uint GemID)
{
return (byte)GetGems().Count(gemData =>
{
return gemData.ItemId == GemID;
});
return (byte)GetGems().Count(gemData => gemData.ItemId == GemID);
}
public byte GetGemCountWithLimitCategory(uint limitCategory)
+1 -1
View File
@@ -170,7 +170,7 @@ namespace Game.Entities
public override string ToString()
{
string str = string.Format("GUID Full: 0x{0}, Type: {1}", _high + _low, GetHigh());
string str = $"GUID Full: 0x{_high + _low}, Type: {GetHigh()}";
if (HasEntry())
str += (IsPet() ? " Pet number: " : " Entry: ") + GetEntry() + " ";
+2 -2
View File
@@ -311,7 +311,7 @@ namespace Game.Entities
public override string ToString()
{
return string.Format("X: {0} Y: {1} Z: {2} O: {3}", posX, posY, posZ, Orientation);
return $"X: {posX} Y: {posY} Z: {posZ} O: {Orientation}";
}
public float posX;
@@ -356,7 +356,7 @@ namespace Game.Entities
}
public uint GetMapId() { return _mapId; }
public void SetMapId(uint _mapId) { this._mapId = _mapId; }
public void SetMapId(uint mapId) { _mapId = mapId; }
public Cell GetCurrentCell()
{
+2 -2
View File
@@ -1526,7 +1526,7 @@ namespace Game.Entities
SetDynamicValue(index, (ushort)((offset + 1) * BlockCount - 1), 0); // reserve space
for (ushort i = 0; i < BlockCount; ++i)
SetDynamicValue(index, (ushort)(offset * BlockCount + i), Extensions.SerializeObject(value)[i]);
SetDynamicValue(index, (ushort)(offset * BlockCount + i), value.SerializeObject()[i]);
}
public void AddDynamicStructuredValue<T>(object index, T value)
@@ -1535,7 +1535,7 @@ namespace Game.Entities
ushort offset = (ushort)(_dynamicValues[(int)index].Length / BlockCount);
SetDynamicValue(index, (ushort)((offset + 1) * BlockCount - 1), 0); // reserve space
for (ushort i = 0; i < BlockCount; ++i)
SetDynamicValue(index, (ushort)(offset * BlockCount + i), Extensions.SerializeObject(value)[i]);
SetDynamicValue(index, (ushort)(offset * BlockCount + i), value.SerializeObject()[i]);
}
bool PrintIndexError(object index, bool set)
@@ -816,7 +816,7 @@ namespace Game.Entities
if (transmogSlot < 0 || knownPieces[transmogSlot] == 1)
continue;
(var hasAppearance, var isTemporary) = HasItemAppearance(transmogSetItem.ItemModifiedAppearanceID);
(var hasAppearance, bool isTemporary) = HasItemAppearance(transmogSetItem.ItemModifiedAppearanceID);
knownPieces[transmogSlot] = (hasAppearance && !isTemporary) ? 1 : 0;
}
+1 -1
View File
@@ -740,7 +740,7 @@ namespace Game.Entities
{
byte objectiveIndex = result.Read<byte>(1);
var objectiveItr = quest.Objectives.FirstOrDefault(objective => { return objective.StorageIndex == objectiveIndex; });
var objectiveItr = quest.Objectives.FirstOrDefault(objective => objective.StorageIndex == objectiveIndex);
if (objectiveIndex < questStatusData.ObjectiveData.Length && objectiveItr != null)
{
int data = result.Read<int>(2);
+2 -5
View File
@@ -1213,7 +1213,7 @@ namespace Game.Entities
ushort pos = itemPosCount.pos;
uint count = itemPosCount.count;
if (i == dest.Count() - 1)
if (i == dest.Count - 1)
{
lastItem = _StoreItem(pos, pItem, count, false, update);
break;
@@ -4489,10 +4489,7 @@ namespace Game.Entities
public bool HasLootWorldObjectGUID(ObjectGuid lootWorldObjectGuid)
{
return m_AELootView.Any(lootView =>
{
return lootView.Value == lootWorldObjectGuid;
});
return m_AELootView.Any(lootView => lootView.Value == lootWorldObjectGuid);
}
//Inventory
+2 -8
View File
@@ -2778,15 +2778,9 @@ namespace Game.Entities
pctMod.ModifierData.Add(pctData);
}
flatMod.ModifierData.RemoveAll(mod =>
{
return MathFunctions.fuzzyEq(mod.ModifierValue, 0.0f);
});
flatMod.ModifierData.RemoveAll(mod => MathFunctions.fuzzyEq(mod.ModifierValue, 0.0f));
pctMod.ModifierData.RemoveAll(mod =>
{
return MathFunctions.fuzzyEq(mod.ModifierValue, 1.0f);
});
pctMod.ModifierData.RemoveAll(mod => MathFunctions.fuzzyEq(mod.ModifierValue, 1.0f));
flatMods.Modifiers.Add(flatMod);
pctMods.Modifiers.Add(pctMod);
+3 -3
View File
@@ -5284,7 +5284,7 @@ namespace Game.Entities
packet.HealthDelta = 0;
/// @todo find some better solution
packet.PowerDelta[0] = basemana - GetCreateMana();
packet.PowerDelta[0] = (int)basemana - (int)GetCreateMana();
packet.PowerDelta[1] = 0;
packet.PowerDelta[2] = 0;
packet.PowerDelta[3] = 0;
@@ -5292,7 +5292,7 @@ namespace Game.Entities
packet.PowerDelta[5] = 0;
for (Stats i = Stats.Strength; i < Stats.Max; ++i)
packet.StatDelta[(int)i] = info.stats[(int)i] - (uint)GetCreateStat(i);
packet.StatDelta[(int)i] = info.stats[(int)i] - (int)GetCreateStat(i);
uint[] rowLevels = (GetClass() != Class.Deathknight) ? PlayerConst.DefaultTalentRowLevels : PlayerConst.DKTalentRowLevels;
@@ -6301,7 +6301,7 @@ namespace Game.Entities
int count = 0;
string result = System.Text.RegularExpressions.Regex.Replace(input, pattern, m =>
{
return String.Concat("{", count++, "}");
return string.Concat("{", count++, "}");
});
SendSysMessage(result, args);
+1 -4
View File
@@ -1514,10 +1514,7 @@ namespace Game.Entities
Item weapon = GetWeaponForAttack(attack, true);
expertise += GetTotalAuraModifier(AuraType.ModExpertise, aurEff =>
{
return aurEff.GetSpellInfo().IsItemFitToSpellRequirements(weapon);
});
expertise += GetTotalAuraModifier(AuraType.ModExpertise, aurEff => aurEff.GetSpellInfo().IsItemFitToSpellRequirements(weapon));
if (expertise < 0)
expertise = 0;
+2 -2
View File
@@ -342,7 +342,7 @@ namespace Game.Entities
/// </returns>
public override string ToString()
{
return string.Format("From: {0}, To: {1}, Weight: {2}", From, To, Weight);
return $"From: {From}, To: {To}, Weight: {Weight}";
}
}
@@ -374,7 +374,7 @@ namespace Game.Entities
{
if (edge.Weight < 0)
{
throw new ArgumentOutOfRangeException(string.Format("Edge: '{0}' has negative weight", edge));
throw new ArgumentOutOfRangeException($"Edge: '{edge}' has negative weight");
}
}
+1 -1
View File
@@ -290,7 +290,7 @@ namespace Game.Entities
public void addHatedBy(HostileReference pHostileReference)
{
m_HostileRefManager.insertFirst(pHostileReference);
m_HostileRefManager.InsertFirst(pHostileReference);
}
public void removeHatedBy(HostileReference pHostileReference) { } //nothing to do yet
+4 -4
View File
@@ -4295,7 +4295,7 @@ namespace Game.Entities
public int GetTotalAuraModifier(AuraType auratype)
{
return GetTotalAuraModifier(auratype, aurEff => { return true; });
return GetTotalAuraModifier(auratype, aurEff => true);
}
public int GetTotalAuraModifier(AuraType auratype, Func<AuraEffect, bool> predicate)
@@ -4324,7 +4324,7 @@ namespace Game.Entities
public float GetTotalAuraMultiplier(AuraType auratype)
{
return GetTotalAuraMultiplier(auratype, aurEff => { return true; });
return GetTotalAuraMultiplier(auratype, aurEff => true);
}
public float GetTotalAuraMultiplier(AuraType auratype, Func<AuraEffect, bool> predicate)
@@ -4356,7 +4356,7 @@ namespace Game.Entities
public int GetMaxPositiveAuraModifier(AuraType auratype)
{
return GetMaxPositiveAuraModifier(auratype, aurEff => { return true; });
return GetMaxPositiveAuraModifier(auratype, aurEff => true);
}
public int GetMaxPositiveAuraModifier(AuraType auratype, Func<AuraEffect, bool> predicate)
@@ -4377,7 +4377,7 @@ namespace Game.Entities
public int GetMaxNegativeAuraModifier(AuraType auratype)
{
return GetMaxNegativeAuraModifier(auratype, aurEff => { return true; });
return GetMaxNegativeAuraModifier(auratype, aurEff => true);
}
public int GetMaxNegativeAuraModifier(AuraType auratype, Func<AuraEffect, bool> predicate)
+2 -2
View File
@@ -150,7 +150,7 @@ namespace Game.Entities
// Check UNIT_STATE_MELEE_ATTACKING or UNIT_STATE_CHASE (without UNIT_STATE_FOLLOW in this case) so pets can reach far away
// targets without stopping half way there and running off.
// These flags are reset after target dies or another command is given.
if (m_HostileRefManager.isEmpty())
if (m_HostileRefManager.IsEmpty())
{
// m_CombatTimer set at aura start and it will be freeze until aura removing
if (m_CombatTimer <= diff)
@@ -1931,7 +1931,7 @@ namespace Game.Entities
public void addFollower(FollowerReference pRef)
{
m_FollowingRefManager.insertFirst(pRef);
m_FollowingRefManager.InsertFirst(pRef);
}
public void removeFollower(FollowerReference pRef) { } //nothing to do yet