refactor(Core): Make more use of helpers. (#19835)

* Init.

* Reword.

* Update codestyle script.

Co-Authored-By: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Add gameobject type ID check, reorder checks.

* Add helper/codestyle check for unit type.

* `IsUnit()` -> `IsCreature()`

* Add `IsUnit()` method.

* Use type mask.

https: //github.com/TrinityCore/TrinityCore/commit/cc71da35b5dc74abf71f8691161525a23d870bb5
Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com>
Co-Authored-By: Ovahlord <18347559+Ovahlord@users.noreply.github.com>

* Replace instances of `isType` with `IsUnit`.

---------

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
Co-authored-by: Ovahlord <18347559+Ovahlord@users.noreply.github.com>
This commit is contained in:
Benjamin Jackson
2024-09-03 13:41:31 -04:00
committed by GitHub
parent e3e4133e88
commit 1edac37ac3
165 changed files with 725 additions and 719 deletions

View File

@@ -533,7 +533,7 @@ class DoorsGuidCheck
public:
bool operator()(WorldObject* object) const
{
if (object->GetTypeId() != TYPEID_UNIT)
if (!object->IsCreature())
return true;
Creature* cr = object->ToCreature();

View File

@@ -1088,7 +1088,7 @@ class spell_kiljaeden_sinister_reflection_clone : public SpellScript
WorldObject* target = targets.front();
targets.clear();
if (target && target->GetTypeId() == TYPEID_UNIT)
if (target && target->IsCreature())
{
target->ToCreature()->AI()->SetData(1, GetCaster()->getClass());
targets.push_back(target);
@@ -1133,7 +1133,7 @@ class spell_kiljaeden_darkness_aura : public AuraScript
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetUnitOwner()->GetTypeId() == TYPEID_UNIT)
if (GetUnitOwner()->IsCreature())
GetUnitOwner()->ToCreature()->AI()->DoAction(ACTION_NO_KILL_TALK);
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_DARKNESS_OF_A_THOUSAND_SOULS_DAMAGE, true);

View File

@@ -393,7 +393,7 @@ class spell_entropius_negative_energy : public SpellScript
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_UNIT;
return GetCaster()->IsCreature();
}
void FilterTargets(std::list<WorldObject*>& targets)