Move to shared pointer

This commit is contained in:
David Markowitz
2023-06-07 00:23:50 -07:00
parent ea9d0d8592
commit 9e9e4dc087
219 changed files with 743 additions and 748 deletions

View File

@@ -8,7 +8,7 @@
void DamagingPets::OnStartup(Entity* self) {
// Make the pet hostile or non-hostile based on whether or not it is tamed
const auto* petComponent = self->GetComponent<PetComponent>();
const auto petComponent = self->GetComponent<PetComponent>();
if (petComponent != nullptr && petComponent->GetOwner() == nullptr) {
self->AddTimer("GoEvil", 0.5f);
}
@@ -19,9 +19,9 @@ void DamagingPets::OnPlayerLoaded(Entity* self, Entity* player) {
// Makes it so that new players also see the effect
self->AddCallbackTimer(2.5f, [self]() {
if (self != nullptr) {
const auto* petComponent = self->GetComponent<PetComponent>();
const auto petComponent = self->GetComponent<PetComponent>();
if (petComponent != nullptr && petComponent->GetOwner() == nullptr && self->GetVar<bool>(u"IsEvil")) {
auto* renderComponent = self->GetComponent<RenderComponent>();
auto renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent != nullptr) {
auto counter = 1;
for (const auto petEffect : GetPetInfo(self).effect) {
@@ -58,7 +58,7 @@ void DamagingPets::OnSkillEventFired(Entity* self, Entity* caster, const std::st
if (infoForPet.skill == message) {
// Only make pets tamable that aren't tamed yet
const auto* petComponent = self->GetComponent<PetComponent>();
const auto petComponent = self->GetComponent<PetComponent>();
if (petComponent != nullptr && petComponent->GetOwner() == nullptr && self->GetVar<bool>(u"IsEvil")) {
ClearEffects(self);
self->AddTimer("GoEvil", 30.0f);
@@ -74,7 +74,7 @@ void DamagingPets::OnTimerDone(Entity* self, std::string message) {
}
void DamagingPets::MakeUntamable(Entity* self) {
auto* petComponent = self->GetComponent<PetComponent>();
auto petComponent = self->GetComponent<PetComponent>();
// If the pet is currently not being tamed, make it hostile
if (petComponent != nullptr && petComponent->GetStatus() != 5) {
@@ -82,19 +82,19 @@ void DamagingPets::MakeUntamable(Entity* self) {
self->SetVar<bool>(u"IsEvil", true);
petComponent->SetStatus(1);
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(false);
}
// Special faction that can attack the player but the player can't attack
auto* destroyableComponent = self->GetComponent<DestroyableComponent>();
auto destroyableComponent = self->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) {
destroyableComponent->SetFaction(114);
destroyableComponent->SetHealth(5);
}
auto* renderComponent = self->GetComponent<RenderComponent>();
auto renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent != nullptr) {
auto counter = 1;
for (const auto petEffect : GetPetInfo(self).effect) {
@@ -108,22 +108,22 @@ void DamagingPets::MakeUntamable(Entity* self) {
void DamagingPets::ClearEffects(Entity* self) {
self->SetVar<bool>(u"IsEvil", false);
auto* petComponent = self->GetComponent<PetComponent>();
auto petComponent = self->GetComponent<PetComponent>();
if (petComponent != nullptr) {
petComponent->SetStatus(67108866);
}
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(true);
}
auto* destroyableComponent = self->GetComponent<DestroyableComponent>();
auto destroyableComponent = self->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) {
destroyableComponent->SetFaction(99);
}
auto* renderComponent = self->GetComponent<RenderComponent>();
auto renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent != nullptr) {
auto counter = 1;
for (const auto petEffect : GetPetInfo(self).effect) {

View File

@@ -3,7 +3,7 @@
#include "ePetTamingNotifyType.h"
void PetFromDigServer::OnStartup(Entity* self) {
auto* petComponent = self->GetComponent<PetComponent>();
auto petComponent = self->GetComponent<PetComponent>();
if (petComponent == nullptr || petComponent->GetOwner() != nullptr)
return;
@@ -21,7 +21,7 @@ void PetFromDigServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "killself") {
// Don't accidentally kill a pet that is already owned
auto* petComponent = self->GetComponent<PetComponent>();
auto petComponent = self->GetComponent<PetComponent>();
if (petComponent == nullptr || petComponent->GetOwner() != nullptr)
return;
@@ -35,7 +35,7 @@ void PetFromDigServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eP
} else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) {
self->Smash(self->GetObjectID(), eKillType::SILENT);
} else if (type == ePetTamingNotifyType::SUCCESS) {
auto* petComponent = self->GetComponent<PetComponent>();
auto petComponent = self->GetComponent<PetComponent>();
if (petComponent == nullptr)
return;
// TODO: Remove custom group?

View File

@@ -9,7 +9,7 @@ void PetFromObjectServer::OnStartup(Entity* self) {
void PetFromObjectServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "killSelf") {
const auto* petComponent = self->GetComponent<PetComponent>();
const auto petComponent = self->GetComponent<PetComponent>();
if (petComponent == nullptr || petComponent->GetOwner() != nullptr)
return;
self->Smash(self->GetObjectID(), eKillType::SILENT);