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

@ -136,7 +136,7 @@ void Entity::Initialize() {
for (const auto& [componentTemplate, componentId] : components) { for (const auto& [componentTemplate, componentId] : components) {
switch (componentTemplate) { switch (componentTemplate) {
case eReplicaComponentType::CONTROLLABLE_PHYSICS: case eReplicaComponentType::CONTROLLABLE_PHYSICS:
AddComponent<ControllablePhysicsComponent>(this); AddComponent<ControllablePhysicsComponent>();
break; break;
case eReplicaComponentType::RENDER: case eReplicaComponentType::RENDER:
break; break;
@ -432,12 +432,12 @@ void Entity::Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationNa
} }
void Entity::SetProximityRadius(float proxRadius, std::string name) { void Entity::SetProximityRadius(float proxRadius, std::string name) {
auto proximityMonitorComponent = AddComponent<ProximityMonitorComponent>(this); auto proximityMonitorComponent = AddComponent<ProximityMonitorComponent>();
if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(proxRadius, name); if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(proxRadius, name);
} }
void Entity::SetProximityRadius(dpEntity* entity, std::string name) { void Entity::SetProximityRadius(dpEntity* entity, std::string name) {
auto proximityMonitorComponent = AddComponent<ProximityMonitorComponent>(this); auto proximityMonitorComponent = AddComponent<ProximityMonitorComponent>();
if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(entity, name); if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(entity, name);
} }

View File

@ -1,4 +1,5 @@
#pragma once #ifndef __ENTITY__H__
#define __ENTITY__H__
#include <map> #include <map>
#include <functional> #include <functional>
@ -146,8 +147,8 @@ public:
bool HasComponent(eReplicaComponentType componentId) const; bool HasComponent(eReplicaComponentType componentId) const;
template<typename ComponentType, typename...ConstructorValues> template<typename Cmpt, typename...ConstructorValues>
std::shared_ptr<ComponentType> AddComponent(ConstructorValues... arguments); std::shared_ptr<Cmpt> AddComponent(ConstructorValues... arguments);
std::vector<std::shared_ptr<ScriptComponent>> GetScriptComponents(); std::vector<std::shared_ptr<ScriptComponent>> GetScriptComponents();
@ -290,6 +291,8 @@ public:
Entity* GetScheduledKiller() { return m_ScheduleKiller; } Entity* GetScheduledKiller() { return m_ScheduleKiller; }
std::unordered_map<eReplicaComponentType, ComponentPtr>& GetComponents() { return m_Components; }
protected: protected:
LWOOBJID m_ObjectID; LWOOBJID m_ObjectID;
@ -481,9 +484,14 @@ T Entity::GetNetworkVar(const std::u16string& name) {
return LDFData<T>::Default; return LDFData<T>::Default;
} }
template<typename ComponentType, typename...ConstructorValues> template<typename Cmpt, typename...ConstructorValues>
std::shared_ptr<ComponentType> Entity::AddComponent(ConstructorValues...arguments) { std::shared_ptr<Cmpt> Entity::AddComponent(ConstructorValues...arguments) {
if (GetComponent<ComponentType>()) return nullptr; auto component = GetComponent<Cmpt>();
if (component) return component;
m_Components.insert_or_assign(ComponentType::ComponentType, std::make_shared<ComponentType>(arguments...)); auto insertedComponent = m_Components.insert_or_assign(Cmpt::ComponentType,
std::make_shared<Cmpt>(this, std::forward<ConstructorValues>(arguments)...)).first->second;
return std::dynamic_pointer_cast<Cmpt>(insertedComponent);
} }
#endif //!__ENTITY__H__

View File

@ -630,8 +630,8 @@ no_ghosting:
TriggerEvent(eTriggerEventType::CREATE, this); TriggerEvent(eTriggerEventType::CREATE, this);
if (m_Character) { if (m_Character) {
auto* controllablePhysicsComponent = GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = GetComponent<ControllablePhysicsComponent>();
auto* levelComponent = GetComponent<LevelProgressionComponent>(); auto levelComponent = GetComponent<LevelProgressionComponent>();
if (controllablePhysicsComponent && levelComponent) { if (controllablePhysicsComponent && levelComponent) {
controllablePhysicsComponent->SetSpeedMultiplier(levelComponent->GetSpeedBase() / 500.0f); controllablePhysicsComponent->SetSpeedMultiplier(levelComponent->GetSpeedBase() / 500.0f);

View File

@ -42,7 +42,7 @@ void DamageAbsorptionBehavior::Timer(BehaviorContext* context, BehaviorBranchCon
return; return;
} }
auto* destroyable = target->GetComponent<DestroyableComponent>(); auto destroyable = target->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) { if (destroyable == nullptr) {
return; return;

View File

@ -16,7 +16,7 @@ void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream
return; return;
} }
auto* destroyable = target->GetComponent<DestroyableComponent>(); auto destroyable = target->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) { if (destroyable == nullptr) {
return; return;
@ -40,7 +40,7 @@ void DamageReductionBehavior::Timer(BehaviorContext* context, BehaviorBranchCont
return; return;
} }
auto* destroyable = target->GetComponent<DestroyableComponent>(); auto destroyable = target->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) { if (destroyable == nullptr) {
return; return;

View File

@ -14,7 +14,7 @@ void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream
return; return;
} }
auto* destroyableComponent = target->GetComponent<DestroyableComponent>(); auto destroyableComponent = target->GetComponent<DestroyableComponent>();
if (destroyableComponent == nullptr) { if (destroyableComponent == nullptr) {
return; return;
@ -34,7 +34,7 @@ void DarkInspirationBehavior::Calculate(BehaviorContext* context, RakNet::BitStr
return; return;
} }
auto* destroyableComponent = target->GetComponent<DestroyableComponent>(); auto destroyableComponent = target->GetComponent<DestroyableComponent>();
if (destroyableComponent == nullptr) { if (destroyableComponent == nullptr) {
return; return;

View File

@ -11,7 +11,7 @@ void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
auto* target = EntityManager::Instance()->GetEntity(branch.target); auto* target = EntityManager::Instance()->GetEntity(branch.target);
if (!target) return; if (!target) return;
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
if (!controllablePhysicsComponent) return; if (!controllablePhysicsComponent) return;
controllablePhysicsComponent->SetGravityScale(m_PercentSlowed); controllablePhysicsComponent->SetGravityScale(m_PercentSlowed);
EntityManager::Instance()->SerializeEntity(target); EntityManager::Instance()->SerializeEntity(target);
@ -39,7 +39,7 @@ void FallSpeedBehavior::End(BehaviorContext* context, BehaviorBranchContext bran
auto* target = EntityManager::Instance()->GetEntity(branch.target); auto* target = EntityManager::Instance()->GetEntity(branch.target);
if (!target) return; if (!target) return;
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
if (!controllablePhysicsComponent) return; if (!controllablePhysicsComponent) return;
controllablePhysicsComponent->SetGravityScale(1); controllablePhysicsComponent->SetGravityScale(1);
EntityManager::Instance()->SerializeEntity(target); EntityManager::Instance()->SerializeEntity(target);

View File

@ -44,7 +44,7 @@ void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStrea
auto* casterEntity = EntityManager::Instance()->GetEntity(context->caster); auto* casterEntity = EntityManager::Instance()->GetEntity(context->caster);
if (casterEntity != nullptr) { if (casterEntity != nullptr) {
auto* controllablePhysicsComponent = casterEntity->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = casterEntity->GetComponent<ControllablePhysicsComponent>();
if (controllablePhysicsComponent != nullptr) { if (controllablePhysicsComponent != nullptr) {
if (m_Forward == 1) { if (m_Forward == 1) {
@ -74,7 +74,7 @@ void ForceMovementBehavior::Load() {
void ForceMovementBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { void ForceMovementBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
auto* casterEntity = EntityManager::Instance()->GetEntity(context->caster); auto* casterEntity = EntityManager::Instance()->GetEntity(context->caster);
if (casterEntity != nullptr) { if (casterEntity != nullptr) {
auto* controllablePhysicsComponent = casterEntity->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = casterEntity->GetComponent<ControllablePhysicsComponent>();
if (controllablePhysicsComponent != nullptr) { if (controllablePhysicsComponent != nullptr) {
controllablePhysicsComponent->SetPosition(controllablePhysicsComponent->GetPosition() + controllablePhysicsComponent->GetVelocity() * m_Duration); controllablePhysicsComponent->SetPosition(controllablePhysicsComponent->GetPosition() + controllablePhysicsComponent->GetVelocity() * m_Duration);

View File

@ -16,7 +16,7 @@ void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_strea
return; return;
} }
auto* destroyable = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); auto destroyable = entity->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) { if (destroyable == nullptr) {
Game::logger->Log("HealBehavior", "Failed to find destroyable component for %(llu)!", branch.target); Game::logger->Log("HealBehavior", "Failed to find destroyable component for %(llu)!", branch.target);

View File

@ -13,7 +13,7 @@ void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
return; return;
} }
auto* destroyable = entity->GetComponent<DestroyableComponent>(); auto destroyable = entity->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) { if (destroyable == nullptr) {
return; return;

View File

@ -17,7 +17,7 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
return; return;
} }
auto* destroyableComponent = target->GetComponent<DestroyableComponent>(); auto destroyableComponent = target->GetComponent<DestroyableComponent>();
if (destroyableComponent) { if (destroyableComponent) {
destroyableComponent->SetStatusImmunity( destroyableComponent->SetStatusImmunity(
eStateChangeType::PUSH, eStateChangeType::PUSH,
@ -33,7 +33,7 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
); );
} }
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
if (controllablePhysicsComponent) { if (controllablePhysicsComponent) {
controllablePhysicsComponent->SetStunImmunity( controllablePhysicsComponent->SetStunImmunity(
eStateChangeType::PUSH, eStateChangeType::PUSH,
@ -63,7 +63,7 @@ void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext bra
return; return;
} }
auto* destroyableComponent = target->GetComponent<DestroyableComponent>(); auto destroyableComponent = target->GetComponent<DestroyableComponent>();
if (destroyableComponent) { if (destroyableComponent) {
destroyableComponent->SetStatusImmunity( destroyableComponent->SetStatusImmunity(
eStateChangeType::POP, eStateChangeType::POP,
@ -79,7 +79,7 @@ void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext bra
); );
} }
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
if (controllablePhysicsComponent) { if (controllablePhysicsComponent) {
controllablePhysicsComponent->SetStunImmunity( controllablePhysicsComponent->SetStunImmunity(
eStateChangeType::POP, eStateChangeType::POP,

View File

@ -46,7 +46,7 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
if (target == nullptr) return; if (target == nullptr) return;
auto* skillComponent = target->GetComponent<SkillComponent>(); auto skillComponent = target->GetComponent<SkillComponent>();
if (skillComponent == nullptr) return; if (skillComponent == nullptr) return;
@ -71,7 +71,7 @@ void InterruptBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* b
if (target == nullptr) return; if (target == nullptr) return;
auto* skillComponent = target->GetComponent<SkillComponent>(); auto skillComponent = target->GetComponent<SkillComponent>();
if (skillComponent == nullptr) return; if (skillComponent == nullptr) return;

View File

@ -24,7 +24,7 @@ void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* b
auto* target = EntityManager::Instance()->GetEntity(branch.target); auto* target = EntityManager::Instance()->GetEntity(branch.target);
if (target != nullptr) { if (target != nullptr) {
auto* destroyableComponent = target->GetComponent<DestroyableComponent>(); auto destroyableComponent = target->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
blocked = destroyableComponent->IsKnockbackImmune(); blocked = destroyableComponent->IsKnockbackImmune();

View File

@ -24,7 +24,7 @@ void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
if (entity == nullptr) return; if (entity == nullptr) return;
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto skillComponent = entity->GetComponent<SkillComponent>();
if (skillComponent == nullptr) return; if (skillComponent == nullptr) return;

View File

@ -24,7 +24,7 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
return; return;
} }
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto skillComponent = entity->GetComponent<SkillComponent>();
if (skillComponent == nullptr) { if (skillComponent == nullptr) {
Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", -context->originator); Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", -context->originator);
@ -69,7 +69,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
return; return;
} }
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto skillComponent = entity->GetComponent<SkillComponent>();
if (skillComponent == nullptr) { if (skillComponent == nullptr) {
Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", context->originator); Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", context->originator);

View File

@ -14,7 +14,7 @@ void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
return; return;
} }
auto* movement = target->GetComponent<MovementAIComponent>(); auto movement = target->GetComponent<MovementAIComponent>();
if (movement == nullptr) { if (movement == nullptr) {
return; return;

View File

@ -9,7 +9,7 @@ void RemoveBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit
auto* entity = EntityManager::Instance()->GetEntity(context->caster); auto* entity = EntityManager::Instance()->GetEntity(context->caster);
if (!entity) return; if (!entity) return;
auto* buffComponent = entity->GetComponent<BuffComponent>(); auto buffComponent = entity->GetComponent<BuffComponent>();
if (!buffComponent) return; if (!buffComponent) return;
buffComponent->RemoveBuff(m_BuffId, false, m_RemoveImmunity); buffComponent->RemoveBuff(m_BuffId, false, m_RemoveImmunity);

View File

@ -16,7 +16,7 @@ void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_str
return; return;
} }
auto* destroyable = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); auto destroyable = entity->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) { if (destroyable == nullptr) {
Game::logger->Log("RepairBehavior", "Failed to find destroyable component for %(llu)!", branch.target); Game::logger->Log("RepairBehavior", "Failed to find destroyable component for %(llu)!", branch.target);

View File

@ -53,7 +53,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
entity->SetOwnerOverride(context->originator); entity->SetOwnerOverride(context->originator);
// Unset the flag to reposition the player, this makes it harder to glitch out of the map // Unset the flag to reposition the player, this makes it harder to glitch out of the map
auto* rebuildComponent = entity->GetComponent<RebuildComponent>(); auto rebuildComponent = entity->GetComponent<RebuildComponent>();
if (rebuildComponent != nullptr) { if (rebuildComponent != nullptr) {
rebuildComponent->SetRepositionPlayer(false); rebuildComponent->SetRepositionPlayer(false);
@ -87,9 +87,9 @@ void SpawnBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext
return; return;
} }
auto* destroyable = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); auto destroyable = entity->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) { if (!destroyable) {
entity->Smash(context->originator); entity->Smash(context->originator);
return; return;

View File

@ -12,7 +12,7 @@ void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
auto* target = EntityManager::Instance()->GetEntity(branch.target); auto* target = EntityManager::Instance()->GetEntity(branch.target);
if (!target) return; if (!target) return;
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
if (!controllablePhysicsComponent) return; if (!controllablePhysicsComponent) return;
controllablePhysicsComponent->AddSpeedboost(m_RunSpeed); controllablePhysicsComponent->AddSpeedboost(m_RunSpeed);
@ -41,7 +41,7 @@ void SpeedBehavior::End(BehaviorContext* context, BehaviorBranchContext branch,
auto* target = EntityManager::Instance()->GetEntity(branch.target); auto* target = EntityManager::Instance()->GetEntity(branch.target);
if (!target) return; if (!target) return;
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
if (!controllablePhysicsComponent) return; if (!controllablePhysicsComponent) return;
controllablePhysicsComponent->RemoveSpeedboost(m_RunSpeed); controllablePhysicsComponent->RemoveSpeedboost(m_RunSpeed);

View File

@ -33,7 +33,7 @@ void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream
* If our target is an enemy we can go ahead and stun it. * If our target is an enemy we can go ahead and stun it.
*/ */
auto* combatAiComponent = static_cast<BaseCombatAIComponent*>(target->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); auto combatAiComponent = target->GetComponent<BaseCombatAIComponent>();
if (combatAiComponent == nullptr) { if (combatAiComponent == nullptr) {
return; return;
@ -56,7 +56,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr
* See if we can stun ourselves * See if we can stun ourselves
*/ */
auto* combatAiComponent = static_cast<BaseCombatAIComponent*>(self->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); auto combatAiComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAiComponent == nullptr) { if (combatAiComponent == nullptr) {
return; return;
@ -72,7 +72,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr
auto* target = EntityManager::Instance()->GetEntity(branch.target); auto* target = EntityManager::Instance()->GetEntity(branch.target);
if (target != nullptr) { if (target != nullptr) {
auto* destroyableComponent = target->GetComponent<DestroyableComponent>(); auto destroyableComponent = target->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
blocked = destroyableComponent->IsKnockbackImmune(); blocked = destroyableComponent->IsKnockbackImmune();
@ -91,7 +91,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr
* If our target is an enemy we can go ahead and stun it. * If our target is an enemy we can go ahead and stun it.
*/ */
auto* combatAiComponent = static_cast<BaseCombatAIComponent*>(target->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); auto combatAiComponent = target->GetComponent<BaseCombatAIComponent>();
if (combatAiComponent == nullptr) { if (combatAiComponent == nullptr) {
return; return;

View File

@ -22,7 +22,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
return; return;
} }
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>(); auto destroyableComponent = entity->GetComponent<DestroyableComponent>();
if (destroyableComponent == nullptr) { if (destroyableComponent == nullptr) {
return; return;
@ -46,7 +46,7 @@ void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
state = entity != nullptr; state = entity != nullptr;
if (state && m_targetHasBuff != 0) { if (state && m_targetHasBuff != 0) {
auto* buffComponent = entity->GetComponent<BuffComponent>(); auto buffComponent = entity->GetComponent<BuffComponent>();
if (buffComponent != nullptr && !buffComponent->HasBuff(m_targetHasBuff)) { if (buffComponent != nullptr && !buffComponent->HasBuff(m_targetHasBuff)) {
state = false; state = false;

View File

@ -82,7 +82,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
return; return;
} }
const auto* destroyableComponent = self->GetComponent<DestroyableComponent>(); const auto destroyableComponent = self->GetComponent<DestroyableComponent>();
if ((this->m_usePickedTarget || context->clientInitalized) && branch.target > 0) { if ((this->m_usePickedTarget || context->clientInitalized) && branch.target > 0) {
const auto* target = EntityManager::Instance()->GetEntity(branch.target); const auto* target = EntityManager::Instance()->GetEntity(branch.target);
@ -101,7 +101,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
return; return;
} }
auto* combatAi = self->GetComponent<BaseCombatAIComponent>(); auto combatAi = self->GetComponent<BaseCombatAIComponent>();
const auto casterPosition = self->GetPosition(); const auto casterPosition = self->GetPosition();

View File

@ -15,7 +15,7 @@ void TauntBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
return; return;
} }
auto* combatComponent = target->GetComponent<BaseCombatAIComponent>(); auto combatComponent = target->GetComponent<BaseCombatAIComponent>();
if (combatComponent != nullptr) { if (combatComponent != nullptr) {
combatComponent->Taunt(context->originator, m_threatToAdd); combatComponent->Taunt(context->originator, m_threatToAdd);
@ -31,7 +31,7 @@ void TauntBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitSt
return; return;
} }
auto* combatComponent = target->GetComponent<BaseCombatAIComponent>(); auto combatComponent = target->GetComponent<BaseCombatAIComponent>();
if (combatComponent != nullptr) { if (combatComponent != nullptr) {
combatComponent->Taunt(context->originator, m_threatToAdd); combatComponent->Taunt(context->originator, m_threatToAdd);

View File

@ -189,11 +189,12 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
m_StartPosition = m_OwningEntity->GetPosition(); m_StartPosition = m_OwningEntity->GetPosition();
} }
if (m_MovementAI == nullptr) {
m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>(); m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
if (m_MovementAI == nullptr) { if (m_MovementAI == nullptr) {
return; return;
} }
}
if (stunnedThisFrame) { if (stunnedThisFrame) {
m_MovementAI->Stop(); m_MovementAI->Stop();
@ -243,7 +244,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
bool hadRemainingDowntime = m_SkillTime > 0.0f; bool hadRemainingDowntime = m_SkillTime > 0.0f;
if (m_SkillTime > 0.0f) m_SkillTime -= deltaTime; if (m_SkillTime > 0.0f) m_SkillTime -= deltaTime;
auto* rebuild = m_OwningEntity->GetComponent<RebuildComponent>(); auto rebuild = m_OwningEntity->GetComponent<RebuildComponent>();
if (rebuild != nullptr) { if (rebuild != nullptr) {
const auto state = rebuild->GetState(); const auto state = rebuild->GetState();
@ -253,7 +254,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
} }
} }
auto* skillComponent = m_OwningEntity->GetComponent<SkillComponent>(); auto skillComponent = m_OwningEntity->GetComponent<SkillComponent>();
if (skillComponent == nullptr) { if (skillComponent == nullptr) {
return; return;
@ -287,7 +288,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
} }
if (!m_TetherEffectActive && m_OutOfCombat && (m_OutOfCombatTime -= deltaTime) <= 0) { if (!m_TetherEffectActive && m_OutOfCombat && (m_OutOfCombatTime -= deltaTime) <= 0) {
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>(); auto destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr && destroyableComponent->HasFaction(4)) { if (destroyableComponent != nullptr && destroyableComponent->HasFaction(4)) {
auto serilizationRequired = false; auto serilizationRequired = false;
@ -547,13 +548,13 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
return false; return false;
} }
auto* destroyable = entity->GetComponent<DestroyableComponent>(); auto destroyable = entity->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) { if (destroyable == nullptr) {
return false; return false;
} }
auto* referenceDestroyable = m_OwningEntity->GetComponent<DestroyableComponent>(); auto referenceDestroyable = m_OwningEntity->GetComponent<DestroyableComponent>();
if (referenceDestroyable == nullptr) { if (referenceDestroyable == nullptr) {
Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_OwningEntity->GetObjectID()); Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_OwningEntity->GetObjectID());
@ -561,7 +562,7 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
return false; return false;
} }
auto* quickbuild = entity->GetComponent<RebuildComponent>(); auto quickbuild = entity->GetComponent<RebuildComponent>();
if (quickbuild != nullptr) { if (quickbuild != nullptr) {
const auto state = quickbuild->GetState(); const auto state = quickbuild->GetState();

View File

@ -10,6 +10,7 @@
#include "Component.h" #include "Component.h"
#include "eReplicaComponentType.h" #include "eReplicaComponentType.h"
#include <memory>
#include <vector> #include <vector>
#include <map> #include <map>
@ -319,7 +320,7 @@ private:
/** /**
* The component that handles movement AI, also owned by this entity * The component that handles movement AI, also owned by this entity
*/ */
MovementAIComponent* m_MovementAI; std::shared_ptr<MovementAIComponent> m_MovementAI;
/** /**
* The position at which this entity spawned * The position at which this entity spawned

View File

@ -71,7 +71,7 @@ void BouncerComponent::LookupPetSwitch() {
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup(group); const auto& entities = EntityManager::Instance()->GetEntitiesInGroup(group);
for (auto* entity : entities) { for (auto* entity : entities) {
auto* switchComponent = entity->GetComponent<SwitchComponent>(); auto switchComponent = entity->GetComponent<SwitchComponent>();
if (switchComponent != nullptr) { if (switchComponent != nullptr) {
switchComponent->SetPetBouncer(this); switchComponent->SetPetBouncer(this);

View File

@ -149,7 +149,7 @@ void BuffComponent::ApplyBuffEffect(int32_t id) {
if (parameter.name == "max_health") { if (parameter.name == "max_health") {
const auto maxHealth = parameter.value; const auto maxHealth = parameter.value;
auto* destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>(); auto destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) return; if (destroyable == nullptr) return;
@ -157,7 +157,7 @@ void BuffComponent::ApplyBuffEffect(int32_t id) {
} else if (parameter.name == "max_armor") { } else if (parameter.name == "max_armor") {
const auto maxArmor = parameter.value; const auto maxArmor = parameter.value;
auto* destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>(); auto destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) return; if (destroyable == nullptr) return;
@ -165,13 +165,13 @@ void BuffComponent::ApplyBuffEffect(int32_t id) {
} else if (parameter.name == "max_imagination") { } else if (parameter.name == "max_imagination") {
const auto maxImagination = parameter.value; const auto maxImagination = parameter.value;
auto* destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>(); auto destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) return; if (destroyable == nullptr) return;
destroyable->SetMaxImagination(destroyable->GetMaxImagination() + maxImagination); destroyable->SetMaxImagination(destroyable->GetMaxImagination() + maxImagination);
} else if (parameter.name == "speed") { } else if (parameter.name == "speed") {
auto* controllablePhysicsComponent = this->GetOwningEntity()->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = this->GetOwningEntity()->GetComponent<ControllablePhysicsComponent>();
if (!controllablePhysicsComponent) return; if (!controllablePhysicsComponent) return;
const auto speed = parameter.value; const auto speed = parameter.value;
controllablePhysicsComponent->AddSpeedboost(speed); controllablePhysicsComponent->AddSpeedboost(speed);
@ -185,7 +185,7 @@ void BuffComponent::RemoveBuffEffect(int32_t id) {
if (parameter.name == "max_health") { if (parameter.name == "max_health") {
const auto maxHealth = parameter.value; const auto maxHealth = parameter.value;
auto* destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>(); auto destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) return; if (destroyable == nullptr) return;
@ -193,7 +193,7 @@ void BuffComponent::RemoveBuffEffect(int32_t id) {
} else if (parameter.name == "max_armor") { } else if (parameter.name == "max_armor") {
const auto maxArmor = parameter.value; const auto maxArmor = parameter.value;
auto* destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>(); auto destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) return; if (destroyable == nullptr) return;
@ -201,13 +201,13 @@ void BuffComponent::RemoveBuffEffect(int32_t id) {
} else if (parameter.name == "max_imagination") { } else if (parameter.name == "max_imagination") {
const auto maxImagination = parameter.value; const auto maxImagination = parameter.value;
auto* destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>(); auto destroyable = this->GetOwningEntity()->GetComponent<DestroyableComponent>();
if (destroyable == nullptr) return; if (destroyable == nullptr) return;
destroyable->SetMaxImagination(destroyable->GetMaxImagination() - maxImagination); destroyable->SetMaxImagination(destroyable->GetMaxImagination() - maxImagination);
} else if (parameter.name == "speed") { } else if (parameter.name == "speed") {
auto* controllablePhysicsComponent = this->GetOwningEntity()->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = this->GetOwningEntity()->GetComponent<ControllablePhysicsComponent>();
if (!controllablePhysicsComponent) return; if (!controllablePhysicsComponent) return;
const auto speed = parameter.value; const auto speed = parameter.value;
controllablePhysicsComponent->RemoveSpeedboost(speed); controllablePhysicsComponent->RemoveSpeedboost(speed);

View File

@ -27,7 +27,7 @@ void BuildBorderComponent::OnUse(Entity* originator) {
Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque"); Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque");
} }
auto* inventoryComponent = originator->GetComponent<InventoryComponent>(); auto inventoryComponent = originator->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) { if (inventoryComponent == nullptr) {
return; return;
@ -63,7 +63,7 @@ void BuildBorderComponent::OnUse(Entity* originator) {
GameMessages::SendStartArrangingWithItem(originator, originator->GetSystemAddress(), true, buildArea, originator->GetPosition()); GameMessages::SendStartArrangingWithItem(originator, originator->GetSystemAddress(), true, buildArea, originator->GetPosition());
} }
InventoryComponent* inv = m_OwningEntity->GetComponent<InventoryComponent>(); auto inv = m_OwningEntity->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
inv->PushEquippedItems(); // technically this is supposed to happen automatically... but it doesnt? so just keep this here inv->PushEquippedItems(); // technically this is supposed to happen automatically... but it doesnt? so just keep this here
} }

View File

@ -367,7 +367,7 @@ void CharacterComponent::SetLastRocketConfig(std::u16string config) {
Item* CharacterComponent::GetRocket(Entity* player) { Item* CharacterComponent::GetRocket(Entity* player) {
Item* rocket = nullptr; Item* rocket = nullptr;
auto* inventoryComponent = player->GetComponent<InventoryComponent>(); auto inventoryComponent = player->GetComponent<InventoryComponent>();
if (!inventoryComponent) return rocket; if (!inventoryComponent) return rocket;

View File

@ -38,6 +38,6 @@ void Component::LoadTemplateData() {
} }
void Component::Serialize(RakNet::BitStream* bitStream, bool isConstruction = false) { void Component::Serialize(RakNet::BitStream* bitStream, bool isConstruction) {
} }

View File

@ -321,7 +321,7 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) {
// Recalculate speedboost since we removed one // Recalculate speedboost since we removed one
m_SpeedBoost = 0.0f; m_SpeedBoost = 0.0f;
if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed
auto* levelProgressionComponent = m_OwningEntity->GetComponent<LevelProgressionComponent>(); auto levelProgressionComponent = m_OwningEntity->GetComponent<LevelProgressionComponent>();
if (levelProgressionComponent) m_SpeedBoost = levelProgressionComponent->GetSpeedBase(); if (levelProgressionComponent) m_SpeedBoost = levelProgressionComponent->GetSpeedBase();
} else { // Used the last applied speedboost } else { // Used the last applied speedboost
m_SpeedBoost = m_ActiveSpeedBoosts.back(); m_SpeedBoost = m_ActiveSpeedBoosts.back();

View File

@ -185,7 +185,7 @@ void DestroyableComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
return; return;
} }
auto* buffComponent = m_OwningEntity->GetComponent<BuffComponent>(); auto buffComponent = m_OwningEntity->GetComponent<BuffComponent>();
if (buffComponent != nullptr) { if (buffComponent != nullptr) {
buffComponent->LoadFromXml(doc); buffComponent->LoadFromXml(doc);
@ -207,7 +207,7 @@ void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
return; return;
} }
auto* buffComponent = m_OwningEntity->GetComponent<BuffComponent>(); auto buffComponent = m_OwningEntity->GetComponent<BuffComponent>();
if (buffComponent != nullptr) { if (buffComponent != nullptr) {
buffComponent->UpdateXml(doc); buffComponent->UpdateXml(doc);
@ -224,7 +224,7 @@ void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
void DestroyableComponent::SetHealth(int32_t value) { void DestroyableComponent::SetHealth(int32_t value) {
m_DirtyHealth = true; m_DirtyHealth = true;
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>(); auto characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->TrackHealthDelta(value - m_iHealth); characterComponent->TrackHealthDelta(value - m_iHealth);
} }
@ -262,14 +262,14 @@ void DestroyableComponent::SetArmor(int32_t value) {
// If Destroyable Component already has zero armor do not trigger the passive ability again. // If Destroyable Component already has zero armor do not trigger the passive ability again.
bool hadArmor = m_iArmor > 0; bool hadArmor = m_iArmor > 0;
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>(); auto characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->TrackArmorDelta(value - m_iArmor); characterComponent->TrackArmorDelta(value - m_iArmor);
} }
m_iArmor = value; m_iArmor = value;
auto* inventroyComponent = m_OwningEntity->GetComponent<InventoryComponent>(); auto inventroyComponent = m_OwningEntity->GetComponent<InventoryComponent>();
if (m_iArmor == 0 && inventroyComponent != nullptr && hadArmor) { if (m_iArmor == 0 && inventroyComponent != nullptr && hadArmor) {
inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::SentinelArmor); inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::SentinelArmor);
} }
@ -300,14 +300,14 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) {
void DestroyableComponent::SetImagination(int32_t value) { void DestroyableComponent::SetImagination(int32_t value) {
m_DirtyHealth = true; m_DirtyHealth = true;
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>(); auto characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->TrackImaginationDelta(value - m_iImagination); characterComponent->TrackImaginationDelta(value - m_iImagination);
} }
m_iImagination = value; m_iImagination = value;
auto* inventroyComponent = m_OwningEntity->GetComponent<InventoryComponent>(); auto inventroyComponent = m_OwningEntity->GetComponent<InventoryComponent>();
if (m_iImagination == 0 && inventroyComponent != nullptr) { if (m_iImagination == 0 && inventroyComponent != nullptr) {
inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::AssemblyImagination); inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::AssemblyImagination);
} }
@ -407,7 +407,7 @@ void DestroyableComponent::AddFaction(const int32_t factionID, const bool ignore
} }
bool DestroyableComponent::IsEnemy(const Entity* other) const { bool DestroyableComponent::IsEnemy(const Entity* other) const {
const auto* otherDestroyableComponent = other->GetComponent<DestroyableComponent>(); const auto otherDestroyableComponent = other->GetComponent<DestroyableComponent>();
if (otherDestroyableComponent != nullptr) { if (otherDestroyableComponent != nullptr) {
for (const auto enemyFaction : m_EnemyFactionIDs) { for (const auto enemyFaction : m_EnemyFactionIDs) {
for (const auto otherFaction : otherDestroyableComponent->GetFactionIDs()) { for (const auto otherFaction : otherDestroyableComponent->GetFactionIDs()) {
@ -421,7 +421,7 @@ bool DestroyableComponent::IsEnemy(const Entity* other) const {
} }
bool DestroyableComponent::IsFriend(const Entity* other) const { bool DestroyableComponent::IsFriend(const Entity* other) const {
const auto* otherDestroyableComponent = other->GetComponent<DestroyableComponent>(); const auto otherDestroyableComponent = other->GetComponent<DestroyableComponent>();
if (otherDestroyableComponent != nullptr) { if (otherDestroyableComponent != nullptr) {
for (const auto enemyFaction : m_EnemyFactionIDs) { for (const auto enemyFaction : m_EnemyFactionIDs) {
for (const auto otherFaction : otherDestroyableComponent->GetFactionIDs()) { for (const auto otherFaction : otherDestroyableComponent->GetFactionIDs()) {
@ -455,8 +455,8 @@ bool DestroyableComponent::IsImmune() const {
} }
bool DestroyableComponent::IsKnockbackImmune() const { bool DestroyableComponent::IsKnockbackImmune() const {
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>(); auto characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
auto* inventoryComponent = m_OwningEntity->GetComponent<InventoryComponent>(); auto inventoryComponent = m_OwningEntity->GetComponent<InventoryComponent>();
if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivity::QUICKBUILDING) { if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivity::QUICKBUILDING) {
const auto hasPassive = inventoryComponent->HasAnyPassive({ const auto hasPassive = inventoryComponent->HasAnyPassive({
@ -493,13 +493,13 @@ bool DestroyableComponent::CheckValidity(const LWOOBJID target, const bool ignor
return false; return false;
} }
auto* targetDestroyable = targetEntity->GetComponent<DestroyableComponent>(); auto targetDestroyable = targetEntity->GetComponent<DestroyableComponent>();
if (targetDestroyable == nullptr) { if (targetDestroyable == nullptr) {
return false; return false;
} }
auto* targetQuickbuild = targetEntity->GetComponent<RebuildComponent>(); auto targetQuickbuild = targetEntity->GetComponent<RebuildComponent>();
if (targetQuickbuild != nullptr) { if (targetQuickbuild != nullptr) {
const auto state = targetQuickbuild->GetState(); const auto state = targetQuickbuild->GetState();
@ -651,7 +651,7 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
} }
if (health != 0) { if (health != 0) {
auto* combatComponent = m_OwningEntity->GetComponent<BaseCombatAIComponent>(); auto combatComponent = m_OwningEntity->GetComponent<BaseCombatAIComponent>();
if (combatComponent != nullptr) { if (combatComponent != nullptr) {
combatComponent->Taunt(source, sourceDamage * 10); // * 10 is arbatrary combatComponent->Taunt(source, sourceDamage * 10); // * 10 is arbatrary
@ -710,13 +710,13 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
const auto isEnemy = m_OwningEntity->GetComponent<BaseCombatAIComponent>() != nullptr; const auto isEnemy = m_OwningEntity->GetComponent<BaseCombatAIComponent>() != nullptr;
auto* inventoryComponent = owner->GetComponent<InventoryComponent>(); auto inventoryComponent = owner->GetComponent<InventoryComponent>();
if (inventoryComponent != nullptr && isEnemy) { if (inventoryComponent != nullptr && isEnemy) {
inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_OwningEntity); inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_OwningEntity);
} }
auto* missions = owner->GetComponent<MissionComponent>(); auto missions = owner->GetComponent<MissionComponent>();
if (missions != nullptr) { if (missions != nullptr) {
if (team != nullptr) { if (team != nullptr) {
@ -725,7 +725,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
if (member == nullptr) continue; if (member == nullptr) continue;
auto* memberMissions = member->GetComponent<MissionComponent>(); auto memberMissions = member->GetComponent<MissionComponent>();
if (memberMissions == nullptr) continue; if (memberMissions == nullptr) continue;
@ -750,7 +750,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
if (team != nullptr && m_OwningEntity->GetComponent<BaseCombatAIComponent>() != nullptr) { if (team != nullptr && m_OwningEntity->GetComponent<BaseCombatAIComponent>() != nullptr) {
LWOOBJID specificOwner = LWOOBJID_EMPTY; LWOOBJID specificOwner = LWOOBJID_EMPTY;
auto* scriptedActivityComponent = m_OwningEntity->GetComponent<ScriptedActivityComponent>(); auto scriptedActivityComponent = m_OwningEntity->GetComponent<ScriptedActivityComponent>();
uint32_t teamSize = team->members.size(); uint32_t teamSize = team->members.size();
uint32_t lootMatrixId = GetLootMatrixID(); uint32_t lootMatrixId = GetLootMatrixID();
@ -877,11 +877,11 @@ void DestroyableComponent::FixStats() {
if (entity == nullptr) return; if (entity == nullptr) return;
// Reset skill component and buff component // Reset skill component and buff component
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto skillComponent = entity->GetComponent<SkillComponent>();
auto* buffComponent = entity->GetComponent<BuffComponent>(); auto buffComponent = entity->GetComponent<BuffComponent>();
auto* missionComponent = entity->GetComponent<MissionComponent>(); auto missionComponent = entity->GetComponent<MissionComponent>();
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>(); auto destroyableComponent = entity->GetComponent<DestroyableComponent>();
// If any of the components are nullptr, return // If any of the components are nullptr, return
if (skillComponent == nullptr || buffComponent == nullptr || missionComponent == nullptr || inventoryComponent == nullptr || destroyableComponent == nullptr) { if (skillComponent == nullptr || buffComponent == nullptr || missionComponent == nullptr || inventoryComponent == nullptr || destroyableComponent == nullptr) {
@ -976,7 +976,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
//check if this is a player: //check if this is a player:
if (m_OwningEntity->IsPlayer()) { if (m_OwningEntity->IsPlayer()) {
//remove hardcore_lose_uscore_on_death_percent from the player's uscore: //remove hardcore_lose_uscore_on_death_percent from the player's uscore:
auto* character = m_OwningEntity->GetComponent<CharacterComponent>(); auto character = m_OwningEntity->GetComponent<CharacterComponent>();
auto uscore = character->GetUScore(); auto uscore = character->GetUScore();
auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100); auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100);
@ -986,7 +986,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) { if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) {
//drop all items from inventory: //drop all items from inventory:
auto* inventory = m_OwningEntity->GetComponent<InventoryComponent>(); auto inventory = m_OwningEntity->GetComponent<InventoryComponent>();
if (inventory) { if (inventory) {
//get the items inventory: //get the items inventory:
auto items = inventory->GetInventory(eInventoryType::ITEMS); auto items = inventory->GetInventory(eInventoryType::ITEMS);
@ -1029,7 +1029,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
//award the player some u-score: //award the player some u-score:
auto* player = EntityManager::Instance()->GetEntity(source); auto* player = EntityManager::Instance()->GetEntity(source);
if (player && player->IsPlayer()) { if (player && player->IsPlayer()) {
auto* playerStats = player->GetComponent<CharacterComponent>(); auto playerStats = player->GetComponent<CharacterComponent>();
if (playerStats) { if (playerStats) {
//get the maximum health from this enemy: //get the maximum health from this enemy:
auto maxHealth = GetMaxHealth(); auto maxHealth = GetMaxHealth();

View File

@ -19,7 +19,7 @@ enum class eStateChangeType : uint32_t;
*/ */
class DestroyableComponent : public Component { class DestroyableComponent : public Component {
public: public:
static const eReplicaComponentType ComponentType = eReplicaComponentType::DESTROYABLE; inline static const eReplicaComponentType ComponentType = eReplicaComponentType::DESTROYABLE;
DestroyableComponent(Entity* parentEntity); DestroyableComponent(Entity* parentEntity);
~DestroyableComponent() override; ~DestroyableComponent() override;

View File

@ -189,7 +189,7 @@ void InventoryComponent::AddItem(
inventoryType = Inventory::FindInventoryTypeForLot(lot); inventoryType = Inventory::FindInventoryTypeForLot(lot);
} }
auto* missions = static_cast<MissionComponent*>(this->m_OwningEntity->GetComponent(eReplicaComponentType::MISSION)); auto missions = m_OwningEntity->GetComponent<MissionComponent>();
auto* inventory = GetInventory(inventoryType); auto* inventory = GetInventory(inventoryType);
@ -378,7 +378,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in
item->SetCount(item->GetCount() - delta, false, false); item->SetCount(item->GetCount() - delta, false, false);
} }
auto* missionComponent = m_OwningEntity->GetComponent<MissionComponent>(); auto missionComponent = m_OwningEntity->GetComponent<MissionComponent>();
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
if (IsTransferInventory(inventory)) { if (IsTransferInventory(inventory)) {
@ -833,7 +833,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
for (auto* lauchPad : rocketLauchPads) { for (auto* lauchPad : rocketLauchPads) {
if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue; if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>(); auto characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId()); if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId());
@ -950,10 +950,10 @@ void InventoryComponent::UnequipScripts(Item* unequippedItem) {
} }
void InventoryComponent::HandlePossession(Item* item) { void InventoryComponent::HandlePossession(Item* item) {
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>(); auto characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
if (!characterComponent) return; if (!characterComponent) return;
auto* possessorComponent = m_OwningEntity->GetComponent<PossessorComponent>(); auto possessorComponent = m_OwningEntity->GetComponent<PossessorComponent>();
if (!possessorComponent) return; if (!possessorComponent) return;
// Don't do anything if we are busy dismounting // Don't do anything if we are busy dismounting
@ -986,7 +986,7 @@ void InventoryComponent::HandlePossession(Item* item) {
auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity); auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity);
// Check to see if the mount is a vehicle, if so, flip it // Check to see if the mount is a vehicle, if so, flip it
auto* vehicleComponent = mount->GetComponent<VehiclePhysicsComponent>(); auto vehicleComponent = mount->GetComponent<VehiclePhysicsComponent>();
if (vehicleComponent) { if (vehicleComponent) {
auto angles = startRotation.GetEulerAngles(); auto angles = startRotation.GetEulerAngles();
// Make it right side up // Make it right side up
@ -1000,14 +1000,14 @@ void InventoryComponent::HandlePossession(Item* item) {
} }
// Setup the destroyable stats // Setup the destroyable stats
auto* destroyableComponent = mount->GetComponent<DestroyableComponent>(); auto destroyableComponent = mount->GetComponent<DestroyableComponent>();
if (destroyableComponent) { if (destroyableComponent) {
destroyableComponent->SetIsSmashable(false); destroyableComponent->SetIsSmashable(false);
destroyableComponent->SetIsImmune(true); destroyableComponent->SetIsImmune(true);
} }
// Mount it // Mount it
auto* possessableComponent = mount->GetComponent<PossessableComponent>(); auto possessableComponent = mount->GetComponent<PossessableComponent>();
if (possessableComponent) { if (possessableComponent) {
possessableComponent->SetIsItemSpawned(true); possessableComponent->SetIsItemSpawned(true);
possessableComponent->SetPossessor(m_OwningEntity->GetObjectID()); possessableComponent->SetPossessor(m_OwningEntity->GetObjectID());
@ -1227,7 +1227,7 @@ bool InventoryComponent::HasAnyPassive(const std::vector<eItemSetPassiveAbilityI
} }
void InventoryComponent::DespawnPet() { void InventoryComponent::DespawnPet() {
auto* current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID()); auto current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID());
if (current != nullptr) { if (current != nullptr) {
current->Deactivate(); current->Deactivate();
@ -1235,7 +1235,7 @@ void InventoryComponent::DespawnPet() {
} }
void InventoryComponent::SpawnPet(Item* item) { void InventoryComponent::SpawnPet(Item* item) {
auto* current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID()); auto current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID());
if (current != nullptr) { if (current != nullptr) {
current->Deactivate(); current->Deactivate();
@ -1261,7 +1261,7 @@ void InventoryComponent::SpawnPet(Item* item) {
auto* pet = EntityManager::Instance()->CreateEntity(info); auto* pet = EntityManager::Instance()->CreateEntity(info);
auto* petComponent = pet->GetComponent<PetComponent>(); auto petComponent = pet->GetComponent<PetComponent>();
if (petComponent != nullptr) { if (petComponent != nullptr) {
petComponent->Activate(item); petComponent->Activate(item);
@ -1339,7 +1339,7 @@ std::vector<uint32_t> InventoryComponent::FindBuffs(Item* item, bool castOnEquip
return entry.objectTemplate == static_cast<unsigned int>(item->GetLot()); return entry.objectTemplate == static_cast<unsigned int>(item->GetLot());
}); });
auto* missions = static_cast<MissionComponent*>(m_OwningEntity->GetComponent(eReplicaComponentType::MISSION)); auto missions = m_OwningEntity->GetComponent<MissionComponent>();
for (const auto& result : results) { for (const auto& result : results) {
if (result.castOnType == 1) { if (result.castOnType == 1) {

View File

@ -49,8 +49,8 @@ void LevelProgressionComponent::HandleLevelUp() {
const auto& rewards = rewardsTable->GetByLevelID(m_Level); const auto& rewards = rewardsTable->GetByLevelID(m_Level);
bool rewardingItem = rewards.size() > 0; bool rewardingItem = rewards.size() > 0;
auto* inventoryComponent = m_OwningEntity->GetComponent<InventoryComponent>(); auto inventoryComponent = m_OwningEntity->GetComponent<InventoryComponent>();
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
if (!inventoryComponent || !controllablePhysicsComponent) return; if (!inventoryComponent || !controllablePhysicsComponent) return;
// Tell the client we beginning to send level rewards. // Tell the client we beginning to send level rewards.
@ -84,6 +84,6 @@ void LevelProgressionComponent::HandleLevelUp() {
void LevelProgressionComponent::SetRetroactiveBaseSpeed(){ void LevelProgressionComponent::SetRetroactiveBaseSpeed(){
if (m_Level >= 20) m_SpeedBase = 525.0f; if (m_Level >= 20) m_SpeedBase = 525.0f;
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
if (controllablePhysicsComponent) controllablePhysicsComponent->SetSpeedMultiplier(m_SpeedBase / 500.0f); if (controllablePhysicsComponent) controllablePhysicsComponent->SetSpeedMultiplier(m_SpeedBase / 500.0f);
} }

View File

@ -79,7 +79,7 @@ void MissionOfferComponent::OnUse(Entity* originator) {
void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifiedMissionId) { void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifiedMissionId) {
// First, get the entity's MissionComponent. If there is not one, then we cannot offer missions to this entity. // First, get the entity's MissionComponent. If there is not one, then we cannot offer missions to this entity.
auto* missionComponent = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION)); auto missionComponent = entity->GetComponent<MissionComponent>();
if (!missionComponent) { if (!missionComponent) {
Game::logger->Log("MissionOfferComponent", "Unable to get mission component for Entity %llu", entity->GetObjectID()); Game::logger->Log("MissionOfferComponent", "Unable to get mission component for Entity %llu", entity->GetObjectID());

View File

@ -22,7 +22,7 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) :
m_BaseCombatAI = nullptr; m_BaseCombatAI = nullptr;
m_BaseCombatAI = reinterpret_cast<BaseCombatAIComponent*>(m_OwningEntity->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); m_BaseCombatAI = m_OwningEntity->GetComponent<BaseCombatAIComponent>();
//Try and fix the insane values: //Try and fix the insane values:
if (m_Info.wanderRadius > 5.0f) m_Info.wanderRadius = m_Info.wanderRadius * 0.5f; if (m_Info.wanderRadius > 5.0f) m_Info.wanderRadius = m_Info.wanderRadius * 0.5f;
@ -322,7 +322,7 @@ foundComponent:
} }
void MovementAIComponent::SetPosition(const NiPoint3& value) { void MovementAIComponent::SetPosition(const NiPoint3& value) {
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
if (controllablePhysicsComponent != nullptr) { if (controllablePhysicsComponent != nullptr) {
controllablePhysicsComponent->SetPosition(value); controllablePhysicsComponent->SetPosition(value);
@ -330,7 +330,7 @@ void MovementAIComponent::SetPosition(const NiPoint3& value) {
return; return;
} }
auto* simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>(); auto simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>();
if (simplePhysicsComponent != nullptr) { if (simplePhysicsComponent != nullptr) {
simplePhysicsComponent->SetPosition(value); simplePhysicsComponent->SetPosition(value);
@ -342,7 +342,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) {
return; return;
} }
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
if (controllablePhysicsComponent != nullptr) { if (controllablePhysicsComponent != nullptr) {
controllablePhysicsComponent->SetRotation(value); controllablePhysicsComponent->SetRotation(value);
@ -350,7 +350,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) {
return; return;
} }
auto* simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>(); auto simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>();
if (simplePhysicsComponent != nullptr) { if (simplePhysicsComponent != nullptr) {
simplePhysicsComponent->SetRotation(value); simplePhysicsComponent->SetRotation(value);
@ -358,7 +358,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) {
} }
void MovementAIComponent::SetVelocity(const NiPoint3& value) { void MovementAIComponent::SetVelocity(const NiPoint3& value) {
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
if (controllablePhysicsComponent != nullptr) { if (controllablePhysicsComponent != nullptr) {
controllablePhysicsComponent->SetVelocity(value); controllablePhysicsComponent->SetVelocity(value);
@ -366,7 +366,7 @@ void MovementAIComponent::SetVelocity(const NiPoint3& value) {
return; return;
} }
auto* simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>(); auto simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>();
if (simplePhysicsComponent != nullptr) { if (simplePhysicsComponent != nullptr) {
simplePhysicsComponent->SetVelocity(value); simplePhysicsComponent->SetVelocity(value);

View File

@ -57,7 +57,7 @@ struct MovementAIInfo {
*/ */
class MovementAIComponent : public Component { class MovementAIComponent : public Component {
public: public:
static const eReplicaComponentType ComponentType = eReplicaComponentType::MOVEMENT_AI; inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MOVEMENT_AI;
MovementAIComponent(Entity* parentEntity, MovementAIInfo info); MovementAIComponent(Entity* parentEntity, MovementAIInfo info);
~MovementAIComponent() override; ~MovementAIComponent() override;
@ -310,7 +310,7 @@ private:
/** /**
* Optional direct link to the combat AI component of the parent entity * Optional direct link to the combat AI component of the parent entity
*/ */
BaseCombatAIComponent* m_BaseCombatAI = nullptr; std::shared_ptr<BaseCombatAIComponent> m_BaseCombatAI = nullptr;
/** /**
* The path the entity is currently following * The path the entity is currently following

View File

@ -163,7 +163,7 @@ void PetComponent::OnUse(Entity* originator) {
m_Tamer = LWOOBJID_EMPTY; m_Tamer = LWOOBJID_EMPTY;
} }
auto* inventoryComponent = originator->GetComponent<InventoryComponent>(); auto inventoryComponent = originator->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) { if (inventoryComponent == nullptr) {
return; return;
@ -173,7 +173,7 @@ void PetComponent::OnUse(Entity* originator) {
return; return;
} }
auto* movementAIComponent = m_OwningEntity->GetComponent<MovementAIComponent>(); auto movementAIComponent = m_OwningEntity->GetComponent<MovementAIComponent>();
if (movementAIComponent != nullptr) { if (movementAIComponent != nullptr) {
movementAIComponent->Stop(); movementAIComponent->Stop();
@ -224,7 +224,7 @@ void PetComponent::OnUse(Entity* originator) {
imaginationCost = cached->second.imaginationCost; imaginationCost = cached->second.imaginationCost;
} }
auto* destroyableComponent = originator->GetComponent<DestroyableComponent>(); auto destroyableComponent = originator->GetComponent<DestroyableComponent>();
if (destroyableComponent == nullptr) { if (destroyableComponent == nullptr) {
return; return;
@ -362,10 +362,9 @@ void PetComponent::Update(float deltaTime) {
return; return;
} }
m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
if (m_MovementAI == nullptr) { if (m_MovementAI == nullptr) {
return; m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
if (!m_MovementAI) return;
} }
if (m_TresureTime > 0) { if (m_TresureTime > 0) {
@ -488,7 +487,7 @@ void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
if (cached == buildCache.end()) return; if (cached == buildCache.end()) return;
auto* destroyableComponent = tamer->GetComponent<DestroyableComponent>(); auto destroyableComponent = tamer->GetComponent<DestroyableComponent>();
if (destroyableComponent == nullptr) return; if (destroyableComponent == nullptr) return;
@ -549,7 +548,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
GameMessages::SendPetResponse(m_Tamer, m_OwningEntity->GetObjectID(), 0, 10, 0, tamer->GetSystemAddress()); GameMessages::SendPetResponse(m_Tamer, m_OwningEntity->GetObjectID(), 0, 10, 0, tamer->GetSystemAddress());
auto* inventoryComponent = tamer->GetComponent<InventoryComponent>(); auto inventoryComponent = tamer->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) { if (inventoryComponent == nullptr) {
return; return;
@ -607,7 +606,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
tamer->GetCharacter()->SetPlayerFlag(petFlags.at(m_OwningEntity->GetLOT()), true); tamer->GetCharacter()->SetPlayerFlag(petFlags.at(m_OwningEntity->GetLOT()), true);
} }
auto* missionComponent = tamer->GetComponent<MissionComponent>(); auto missionComponent = tamer->GetComponent<MissionComponent>();
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
missionComponent->Progress(eMissionTaskType::PET_TAMING, m_OwningEntity->GetLOT()); missionComponent->Progress(eMissionTaskType::PET_TAMING, m_OwningEntity->GetLOT());
@ -615,7 +614,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
SetStatus(1); SetStatus(1);
auto* characterComponent = tamer->GetComponent<CharacterComponent>(); auto characterComponent = tamer->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->UpdatePlayerStatistic(PetsTamed); characterComponent->UpdatePlayerStatistic(PetsTamed);
} }
@ -649,7 +648,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
Game::logger->Log("PetComponent", "Got set pet name (%s)", GeneralUtils::UTF16ToWTF8(name).c_str()); Game::logger->Log("PetComponent", "Got set pet name (%s)", GeneralUtils::UTF16ToWTF8(name).c_str());
auto* inventoryComponent = tamer->GetComponent<InventoryComponent>(); auto inventoryComponent = tamer->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) { if (inventoryComponent == nullptr) {
return; return;
@ -841,7 +840,7 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
m_ItemId = item->GetId(); m_ItemId = item->GetId();
m_DatabaseId = item->GetSubKey(); m_DatabaseId = item->GetSubKey();
auto* inventoryComponent = item->GetInventory()->GetComponent(); auto inventoryComponent = item->GetInventory()->GetComponent();
if (inventoryComponent == nullptr) return; if (inventoryComponent == nullptr) return;
@ -963,7 +962,7 @@ void PetComponent::Deactivate() {
} }
void PetComponent::Release() { void PetComponent::Release() {
auto* inventoryComponent = GetOwner()->GetComponent<InventoryComponent>(); auto inventoryComponent = GetOwner()->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) { if (inventoryComponent == nullptr) {
return; return;
@ -1039,7 +1038,7 @@ void PetComponent::SetAbility(PetAbilityType value) {
m_Ability = value; m_Ability = value;
} }
PetComponent* PetComponent::GetTamingPet(LWOOBJID tamer) { std::shared_ptr<PetComponent> PetComponent::GetTamingPet(LWOOBJID tamer) {
const auto& pair = currentActivities.find(tamer); const auto& pair = currentActivities.find(tamer);
if (pair == currentActivities.end()) { if (pair == currentActivities.end()) {
@ -1057,7 +1056,7 @@ PetComponent* PetComponent::GetTamingPet(LWOOBJID tamer) {
return entity->GetComponent<PetComponent>(); return entity->GetComponent<PetComponent>();
} }
PetComponent* PetComponent::GetActivePet(LWOOBJID owner) { std::shared_ptr<PetComponent> PetComponent::GetActivePet(LWOOBJID owner) {
const auto& pair = activePets.find(owner); const auto& pair = activePets.find(owner);
if (pair == activePets.end()) { if (pair == activePets.end()) {

View File

@ -195,14 +195,14 @@ public:
* @param tamer the entity that's currently taming * @param tamer the entity that's currently taming
* @return the pet component of the entity that's being tamed * @return the pet component of the entity that's being tamed
*/ */
static PetComponent* GetTamingPet(LWOOBJID tamer); static std::shared_ptr<PetComponent> GetTamingPet(LWOOBJID tamer);
/** /**
* Returns the pet that's currently spawned for some entity (if any) * Returns the pet that's currently spawned for some entity (if any)
* @param owner the owner of the pet that's spawned * @param owner the owner of the pet that's spawned
* @return the pet component of the entity that was spawned by the owner * @return the pet component of the entity that was spawned by the owner
*/ */
static PetComponent* GetActivePet(LWOOBJID owner); static std::shared_ptr<PetComponent> GetActivePet(LWOOBJID owner);
/** /**
* Adds the timer to the owner of this pet to drain imagination at the rate * Adds the timer to the owner of this pet to drain imagination at the rate
@ -349,7 +349,7 @@ private:
/** /**
* The movement AI component that is related to this pet, required to move it around * The movement AI component that is related to this pet, required to move it around
*/ */
MovementAIComponent* m_MovementAI; std::shared_ptr<MovementAIComponent> m_MovementAI;
/** /**
* Preconditions that need to be met before an entity can tame this pet * Preconditions that need to be met before an entity can tame this pet

View File

@ -48,7 +48,7 @@ void PossessableComponent::Dismount() {
} }
void PossessableComponent::OnUse(Entity* originator) { void PossessableComponent::OnUse(Entity* originator) {
auto* possessor = originator->GetComponent<PossessorComponent>(); auto possessor = originator->GetComponent<PossessorComponent>();
if (possessor) { if (possessor) {
possessor->Mount(m_OwningEntity); possessor->Mount(m_OwningEntity);
} }

View File

@ -15,7 +15,7 @@ PossessorComponent::~PossessorComponent() {
if (m_Possessable != LWOOBJID_EMPTY) { if (m_Possessable != LWOOBJID_EMPTY) {
auto* mount = EntityManager::Instance()->GetEntity(m_Possessable); auto* mount = EntityManager::Instance()->GetEntity(m_Possessable);
if (mount) { if (mount) {
auto* possessable = mount->GetComponent<PossessableComponent>(); auto possessable = mount->GetComponent<PossessableComponent>();
if (possessable) { if (possessable) {
if (possessable->GetIsItemSpawned()) { if (possessable->GetIsItemSpawned()) {
GameMessages::SendMarkInventoryItemAsActive(m_OwningEntity->GetObjectID(), false, eUnequippableActiveType::MOUNT, GetMountItemID(), m_OwningEntity->GetSystemAddress()); GameMessages::SendMarkInventoryItemAsActive(m_OwningEntity->GetObjectID(), false, eUnequippableActiveType::MOUNT, GetMountItemID(), m_OwningEntity->GetSystemAddress());
@ -43,7 +43,7 @@ void PossessorComponent::Mount(Entity* mount) {
if (GetIsDismounting() || !mount) return; if (GetIsDismounting() || !mount) return;
GameMessages::SendSetMountInventoryID(m_OwningEntity, mount->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendSetMountInventoryID(m_OwningEntity, mount->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
auto* possessableComponent = mount->GetComponent<PossessableComponent>(); auto possessableComponent = mount->GetComponent<PossessableComponent>();
if (possessableComponent) { if (possessableComponent) {
possessableComponent->SetPossessor(m_OwningEntity->GetObjectID()); possessableComponent->SetPossessor(m_OwningEntity->GetObjectID());
SetPossessable(mount->GetObjectID()); SetPossessable(mount->GetObjectID());
@ -68,7 +68,7 @@ void PossessorComponent::Dismount(Entity* mount, bool forceDismount) {
SetIsDismounting(true); SetIsDismounting(true);
if (mount) { if (mount) {
auto* possessableComponent = mount->GetComponent<PossessableComponent>(); auto possessableComponent = mount->GetComponent<PossessableComponent>();
if (possessableComponent) { if (possessableComponent) {
possessableComponent->SetPossessor(LWOOBJID_EMPTY); possessableComponent->SetPossessor(LWOOBJID_EMPTY);
if (forceDismount) possessableComponent->ForceDepossess(); if (forceDismount) possessableComponent->ForceDepossess();

View File

@ -26,10 +26,10 @@ PropertyEntranceComponent::PropertyEntranceComponent(uint32_t componentID, Entit
} }
void PropertyEntranceComponent::OnUse(Entity* entity) { void PropertyEntranceComponent::OnUse(Entity* entity) {
auto* characterComponent = entity->GetComponent<CharacterComponent>(); auto characterComponent = entity->GetComponent<CharacterComponent>();
if (!characterComponent) return; if (!characterComponent) return;
auto* rocket = entity->GetComponent<CharacterComponent>()->RocketEquip(entity); auto rocket = entity->GetComponent<CharacterComponent>()->RocketEquip(entity);
if (!rocket) return; if (!rocket) return;
GameMessages::SendPropertyEntranceBegin(m_OwningEntity->GetObjectID(), entity->GetSystemAddress()); GameMessages::SendPropertyEntranceBegin(m_OwningEntity->GetObjectID(), entity->GetSystemAddress());
@ -63,7 +63,7 @@ void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index,
cloneId = query[index].CloneId; cloneId = query[index].CloneId;
} }
auto* launcher = m_OwningEntity->GetComponent<RocketLaunchpadControlComponent>(); auto launcher = m_OwningEntity->GetComponent<RocketLaunchpadControlComponent>();
if (launcher == nullptr) { if (launcher == nullptr) {
return; return;

View File

@ -263,7 +263,7 @@ void PropertyManagementComponent::OnStartBuilding() {
SetPrivacyOption(PropertyPrivacyOption::Private); // Cant visit player which is building SetPrivacyOption(PropertyPrivacyOption::Private); // Cant visit player which is building
if (!entrance.empty()) { if (!entrance.empty()) {
auto* rocketPad = entrance[0]->GetComponent<RocketLaunchpadControlComponent>(); auto rocketPad = entrance[0]->GetComponent<RocketLaunchpadControlComponent>();
if (rocketPad != nullptr) { if (rocketPad != nullptr) {
zoneId = rocketPad->GetDefaultZone(); zoneId = rocketPad->GetDefaultZone();
@ -302,7 +302,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
return; return;
} }
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) { if (inventoryComponent == nullptr) {
return; return;
@ -417,7 +417,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
return; return;
} }
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) { if (inventoryComponent == nullptr) {
return; return;

View File

@ -87,7 +87,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
return; return;
} }
auto* inventoryComponent = player->GetComponent<InventoryComponent>(); auto inventoryComponent = player->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) { if (inventoryComponent == nullptr) {
return; return;
@ -141,8 +141,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
// Make the vehicle a child of the racing controller. // Make the vehicle a child of the racing controller.
m_OwningEntity->AddChild(carEntity); m_OwningEntity->AddChild(carEntity);
auto* destroyableComponent = auto destroyableComponent = carEntity->GetComponent<DestroyableComponent>();
carEntity->GetComponent<DestroyableComponent>();
// Setup the vehicle stats. // Setup the vehicle stats.
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
@ -151,16 +150,14 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
} }
// Setup the vehicle as being possessed by the player. // Setup the vehicle as being possessed by the player.
auto* possessableComponent = auto possessableComponent = carEntity->GetComponent<PossessableComponent>();
carEntity->GetComponent<PossessableComponent>();
if (possessableComponent != nullptr) { if (possessableComponent != nullptr) {
possessableComponent->SetPossessor(player->GetObjectID()); possessableComponent->SetPossessor(player->GetObjectID());
} }
// Load the vehicle's assemblyPartLOTs for display. // Load the vehicle's assemblyPartLOTs for display.
auto* moduleAssemblyComponent = auto moduleAssemblyComponent = carEntity->GetComponent<ModuleAssemblyComponent>();
carEntity->GetComponent<ModuleAssemblyComponent>();
if (moduleAssemblyComponent) { if (moduleAssemblyComponent) {
moduleAssemblyComponent->SetSubKey(item->GetSubKey()); moduleAssemblyComponent->SetSubKey(item->GetSubKey());
@ -175,7 +172,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
} }
// Setup the player as possessing the vehicle. // Setup the player as possessing the vehicle.
auto* possessorComponent = player->GetComponent<PossessorComponent>(); auto possessorComponent = player->GetComponent<PossessorComponent>();
if (possessorComponent != nullptr) { if (possessorComponent != nullptr) {
possessorComponent->SetPossessable(carEntity->GetObjectID()); possessorComponent->SetPossessable(carEntity->GetObjectID());
@ -183,7 +180,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
} }
// Set the player's current activity as racing. // Set the player's current activity as racing.
auto* characterComponent = player->GetComponent<CharacterComponent>(); auto characterComponent = player->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->SetIsRacing(true); characterComponent->SetIsRacing(true);
@ -293,7 +290,7 @@ void RacingControlComponent::OnRequestDie(Entity* player) {
GameMessages::SendDie(vehicle, vehicle->GetObjectID(), LWOOBJID_EMPTY, true, GameMessages::SendDie(vehicle, vehicle->GetObjectID(), LWOOBJID_EMPTY, true,
eKillType::VIOLENT, u"", 0, 0, 90.0f, false, true, 0); eKillType::VIOLENT, u"", 0, 0, 90.0f, false, true, 0);
auto* destroyableComponent = vehicle->GetComponent<DestroyableComponent>(); auto destroyableComponent = vehicle->GetComponent<DestroyableComponent>();
uint32_t respawnImagination = 0; uint32_t respawnImagination = 0;
// Reset imagination to half its current value, rounded up to the nearest value divisible by 10, as it was done in live. // Reset imagination to half its current value, rounded up to the nearest value divisible by 10, as it was done in live.
// Do not actually change the value yet. Do that on respawn. // Do not actually change the value yet. Do that on respawn.
@ -318,13 +315,13 @@ void RacingControlComponent::OnRequestDie(Entity* player) {
UNASSIGNED_SYSTEM_ADDRESS); UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::SendResurrect(vehicle); GameMessages::SendResurrect(vehicle);
auto* destroyableComponent = vehicle->GetComponent<DestroyableComponent>(); auto destroyableComponent = vehicle->GetComponent<DestroyableComponent>();
// Reset imagination to half its current value, rounded up to the nearest value divisible by 10, as it was done in live. // Reset imagination to half its current value, rounded up to the nearest value divisible by 10, as it was done in live.
if (destroyableComponent) destroyableComponent->SetImagination(respawnImagination); if (destroyableComponent) destroyableComponent->SetImagination(respawnImagination);
EntityManager::Instance()->SerializeEntity(vehicle); EntityManager::Instance()->SerializeEntity(vehicle);
}); });
auto* characterComponent = player->GetComponent<CharacterComponent>(); auto characterComponent = player->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->UpdatePlayerStatistic(RacingTimesWrecked); characterComponent->UpdatePlayerStatistic(RacingTimesWrecked);
} }
@ -386,7 +383,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu
m_OwningEntity->GetObjectID(), 2, 0, LWOOBJID_EMPTY, u"", m_OwningEntity->GetObjectID(), 2, 0, LWOOBJID_EMPTY, u"",
player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
auto* missionComponent = player->GetComponent<MissionComponent>(); auto missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent == nullptr) return; if (missionComponent == nullptr) return;
@ -639,8 +636,7 @@ void RacingControlComponent::Update(float deltaTime) {
vehicle->SetPosition(player.respawnPosition); vehicle->SetPosition(player.respawnPosition);
vehicle->SetRotation(player.respawnRotation); vehicle->SetRotation(player.respawnRotation);
auto* destroyableComponent = auto destroyableComponent = vehicle->GetComponent<DestroyableComponent>();
vehicle->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
destroyableComponent->SetImagination(0); destroyableComponent->SetImagination(0);
@ -817,8 +813,7 @@ void RacingControlComponent::Update(float deltaTime) {
"Best lap time (%llu)", lapTime); "Best lap time (%llu)", lapTime);
} }
auto* missionComponent = auto missionComponent = playerEntity->GetComponent<MissionComponent>();
playerEntity->GetComponent<MissionComponent>();
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
@ -841,7 +836,7 @@ void RacingControlComponent::Update(float deltaTime) {
// Entire race time // Entire race time
missionComponent->Progress(eMissionTaskType::RACING, (raceTime) * 1000, (LWOOBJID)eRacingTaskParam::TOTAL_TRACK_TIME); missionComponent->Progress(eMissionTaskType::RACING, (raceTime) * 1000, (LWOOBJID)eRacingTaskParam::TOTAL_TRACK_TIME);
auto* characterComponent = playerEntity->GetComponent<CharacterComponent>(); auto characterComponent = playerEntity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->TrackRaceCompleted(m_Finished == 1); characterComponent->TrackRaceCompleted(m_Finished == 1);
} }

View File

@ -43,7 +43,7 @@ RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t component
RailActivatorComponent::~RailActivatorComponent() = default; RailActivatorComponent::~RailActivatorComponent() = default;
void RailActivatorComponent::OnUse(Entity* originator) { void RailActivatorComponent::OnUse(Entity* originator) {
auto* rebuildComponent = m_OwningEntity->GetComponent<RebuildComponent>(); auto rebuildComponent = m_OwningEntity->GetComponent<RebuildComponent>();
if (rebuildComponent != nullptr && rebuildComponent->GetState() != eRebuildState::COMPLETED) if (rebuildComponent != nullptr && rebuildComponent->GetState() != eRebuildState::COMPLETED)
return; return;
@ -116,7 +116,7 @@ void RailActivatorComponent::OnCancelRailMovement(Entity* originator) {
true, true, true, true, true, true, true true, true, true, true, true, true, true
); );
auto* rebuildComponent = m_OwningEntity->GetComponent<RebuildComponent>(); auto rebuildComponent = m_OwningEntity->GetComponent<RebuildComponent>();
if (rebuildComponent != nullptr) { if (rebuildComponent != nullptr) {
// Set back reset time // Set back reset time

View File

@ -194,7 +194,7 @@ void RebuildComponent::Update(float deltaTime) {
if (m_TimeBeforeDrain <= 0.0f) { if (m_TimeBeforeDrain <= 0.0f) {
m_TimeBeforeDrain = m_CompleteTime / static_cast<float>(m_TakeImagination); m_TimeBeforeDrain = m_CompleteTime / static_cast<float>(m_TakeImagination);
DestroyableComponent* destComp = builder->GetComponent<DestroyableComponent>(); auto destComp = builder->GetComponent<DestroyableComponent>();
if (!destComp) break; if (!destComp) break;
int newImagination = destComp->GetImagination(); int newImagination = destComp->GetImagination();
@ -400,7 +400,7 @@ void RebuildComponent::StartRebuild(Entity* user) {
if (m_State == eRebuildState::OPEN || m_State == eRebuildState::COMPLETED || m_State == eRebuildState::INCOMPLETE) { if (m_State == eRebuildState::OPEN || m_State == eRebuildState::COMPLETED || m_State == eRebuildState::INCOMPLETE) {
m_Builder = user->GetObjectID(); m_Builder = user->GetObjectID();
auto* character = user->GetComponent<CharacterComponent>(); auto character = user->GetComponent<CharacterComponent>();
character->SetCurrentActivity(eGameActivity::QUICKBUILDING); character->SetCurrentActivity(eGameActivity::QUICKBUILDING);
EntityManager::Instance()->SerializeEntity(user); EntityManager::Instance()->SerializeEntity(user);
@ -412,7 +412,7 @@ void RebuildComponent::StartRebuild(Entity* user) {
m_StateDirty = true; m_StateDirty = true;
EntityManager::Instance()->SerializeEntity(m_OwningEntity); EntityManager::Instance()->SerializeEntity(m_OwningEntity);
auto* movingPlatform = m_OwningEntity->GetComponent<MovingPlatformComponent>(); auto movingPlatform = m_OwningEntity->GetComponent<MovingPlatformComponent>();
if (movingPlatform != nullptr) { if (movingPlatform != nullptr) {
movingPlatform->OnRebuildInitilized(); movingPlatform->OnRebuildInitilized();
} }
@ -434,7 +434,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
return; return;
} }
auto* characterComponent = user->GetComponent<CharacterComponent>(); auto characterComponent = user->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->SetCurrentActivity(eGameActivity::NONE); characterComponent->SetCurrentActivity(eGameActivity::NONE);
characterComponent->TrackRebuildComplete(); characterComponent->TrackRebuildComplete();
@ -478,12 +478,12 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
for (const auto memberId : team->members) { // progress missions for all team members for (const auto memberId : team->members) { // progress missions for all team members
auto* member = EntityManager::Instance()->GetEntity(memberId); auto* member = EntityManager::Instance()->GetEntity(memberId);
if (member) { if (member) {
auto* missionComponent = member->GetComponent<MissionComponent>(); auto missionComponent = member->GetComponent<MissionComponent>();
if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId); if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId);
} }
} }
} else{ } else{
auto* missionComponent = builder->GetComponent<MissionComponent>(); auto missionComponent = builder->GetComponent<MissionComponent>();
if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId); if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId);
} }
LootGenerator::Instance().DropActivityLoot(builder, m_OwningEntity, m_ActivityId, 1); LootGenerator::Instance().DropActivityLoot(builder, m_OwningEntity, m_ActivityId, 1);
@ -503,7 +503,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
m_OwningEntity->TriggerEvent(eTriggerEventType::REBUILD_COMPLETE, user); m_OwningEntity->TriggerEvent(eTriggerEventType::REBUILD_COMPLETE, user);
auto* movingPlatform = m_OwningEntity->GetComponent<MovingPlatformComponent>(); auto movingPlatform = m_OwningEntity->GetComponent<MovingPlatformComponent>();
if (movingPlatform != nullptr) { if (movingPlatform != nullptr) {
movingPlatform->OnCompleteRebuild(); movingPlatform->OnCompleteRebuild();
} }
@ -588,7 +588,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failR
return; return;
} }
CharacterComponent* characterComponent = entity->GetComponent<CharacterComponent>(); auto characterComponent = entity->GetComponent<CharacterComponent>();
if (characterComponent) { if (characterComponent) {
characterComponent->SetCurrentActivity(eGameActivity::NONE); characterComponent->SetCurrentActivity(eGameActivity::NONE);
EntityManager::Instance()->SerializeEntity(entity); EntityManager::Instance()->SerializeEntity(entity);

View File

@ -214,7 +214,7 @@ float RenderComponent::GetAnimationTime(Entity* self, const std::string& animati
float RenderComponent::DoAnimation(Entity* self, const std::string& animation, bool sendAnimation, float priority, float scale) { float RenderComponent::DoAnimation(Entity* self, const std::string& animation, bool sendAnimation, float priority, float scale) {
float returnlength = 0.0f; float returnlength = 0.0f;
if (!self) return returnlength; if (!self) return returnlength;
auto* renderComponent = self->GetComponent<RenderComponent>(); auto renderComponent = self->GetComponent<RenderComponent>();
if (!renderComponent) return returnlength; if (!renderComponent) return returnlength;
auto* animationsTable = CDClientManager::Instance().GetTable<CDAnimationsTable>(); auto* animationsTable = CDClientManager::Instance().GetTable<CDAnimationsTable>();

View File

@ -17,7 +17,7 @@ RocketLaunchLupComponent::RocketLaunchLupComponent(Entity* parent) : Component(p
RocketLaunchLupComponent::~RocketLaunchLupComponent() {} RocketLaunchLupComponent::~RocketLaunchLupComponent() {}
void RocketLaunchLupComponent::OnUse(Entity* originator) { void RocketLaunchLupComponent::OnUse(Entity* originator) {
auto* rocket = originator->GetComponent<CharacterComponent>()->RocketEquip(originator); auto rocket = originator->GetComponent<CharacterComponent>()->RocketEquip(originator);
if (!rocket) return; if (!rocket) return;
// the LUP world menu is just the property menu, the client knows how to handle it // the LUP world menu is just the property menu, the client knows how to handle it
@ -25,7 +25,7 @@ void RocketLaunchLupComponent::OnUse(Entity* originator) {
} }
void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index) { void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index) {
auto* rocketLaunchpadControlComponent = m_OwningEntity->GetComponent<RocketLaunchpadControlComponent>(); auto rocketLaunchpadControlComponent = m_OwningEntity->GetComponent<RocketLaunchpadControlComponent>();
if (!rocketLaunchpadControlComponent) return; if (!rocketLaunchpadControlComponent) return;
rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0); rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0);

View File

@ -50,7 +50,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId,
} }
// This also gets triggered by a proximity monitor + item equip, I will set that up when havok is ready // This also gets triggered by a proximity monitor + item equip, I will set that up when havok is ready
auto* characterComponent = originator->GetComponent<CharacterComponent>(); auto characterComponent = originator->GetComponent<CharacterComponent>();
auto* character = originator->GetCharacter(); auto* character = originator->GetCharacter();
if (!characterComponent || !character) return; if (!characterComponent || !character) return;
@ -89,18 +89,18 @@ void RocketLaunchpadControlComponent::OnUse(Entity* originator) {
// instead we let their OnUse handlers do their things // instead we let their OnUse handlers do their things
// which components of an Object have their OnUse called when using them // which components of an Object have their OnUse called when using them
// so we don't need to call it here // so we don't need to call it here
auto* propertyEntrance = m_OwningEntity->GetComponent<PropertyEntranceComponent>(); auto propertyEntrance = m_OwningEntity->GetComponent<PropertyEntranceComponent>();
if (propertyEntrance) { if (propertyEntrance) {
return; return;
} }
auto* rocketLaunchLUP = m_OwningEntity->GetComponent<RocketLaunchLupComponent>(); auto rocketLaunchLUP = m_OwningEntity->GetComponent<RocketLaunchLupComponent>();
if (rocketLaunchLUP) { if (rocketLaunchLUP) {
return; return;
} }
// No rocket no launch // No rocket no launch
auto* rocket = originator->GetComponent<CharacterComponent>()->RocketEquip(originator); auto rocket = originator->GetComponent<CharacterComponent>()->RocketEquip(originator);
if (!rocket) { if (!rocket) {
return; return;
} }

View File

@ -53,7 +53,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit
} }
} }
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>(); auto destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
if (destroyableComponent) { if (destroyableComponent) {
// check for LMIs and set the loot LMIs // check for LMIs and set the loot LMIs
@ -305,7 +305,7 @@ bool ScriptedActivityComponent::IsValidActivity(Entity* player) {
// Makes it so that scripted activities with an unimplemented map cannot be joined // Makes it so that scripted activities with an unimplemented map cannot be joined
/*if (player->GetGMLevel() < eGameMasterLevel::DEVELOPER && (m_ActivityInfo.instanceMapID == 1302 || m_ActivityInfo.instanceMapID == 1301)) { /*if (player->GetGMLevel() < eGameMasterLevel::DEVELOPER && (m_ActivityInfo.instanceMapID == 1302 || m_ActivityInfo.instanceMapID == 1301)) {
if (m_OwningEntity->GetLOT() == 4860) { if (m_OwningEntity->GetLOT() == 4860) {
auto* missionComponent = player->GetComponent<MissionComponent>(); auto missionComponent = player->GetComponent<MissionComponent>();
missionComponent->CompleteMission(229); missionComponent->CompleteMission(229);
} }
@ -354,7 +354,7 @@ bool ScriptedActivityComponent::TakeCost(Entity* player) const {
if (m_ActivityInfo.optionalCostLOT <= 0 || m_ActivityInfo.optionalCostCount <= 0) if (m_ActivityInfo.optionalCostLOT <= 0 || m_ActivityInfo.optionalCostCount <= 0)
return true; return true;
auto* inventoryComponent = player->GetComponent<InventoryComponent>(); auto inventoryComponent = player->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) if (inventoryComponent == nullptr)
return false; return false;
@ -555,7 +555,7 @@ void ActivityInstance::StartZone() {
} }
void ActivityInstance::RewardParticipant(Entity* participant) { void ActivityInstance::RewardParticipant(Entity* participant) {
auto* missionComponent = participant->GetComponent<MissionComponent>(); auto missionComponent = participant->GetComponent<MissionComponent>();
if (missionComponent) { if (missionComponent) {
missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityInfo.ActivityID); missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityInfo.ActivityID);
} }

View File

@ -193,7 +193,7 @@ void SkillComponent::Reset() {
void SkillComponent::Interrupt() { void SkillComponent::Interrupt() {
// TODO: need to check immunities on the destroyable component, but they aren't implemented // TODO: need to check immunities on the destroyable component, but they aren't implemented
auto* combat = m_OwningEntity->GetComponent<BaseCombatAIComponent>(); auto combat = m_OwningEntity->GetComponent<BaseCombatAIComponent>();
if (combat != nullptr && combat->GetStunImmune()) return; if (combat != nullptr && combat->GetStunImmune()) return;
for (const auto& behavior : this->m_managedBehaviors) { for (const auto& behavior : this->m_managedBehaviors) {

View File

@ -75,7 +75,7 @@ private:
/** /**
* Attached rebuild component. * Attached rebuild component.
*/ */
RebuildComponent* m_Rebuild; std::shared_ptr<RebuildComponent> m_Rebuild;
/** /**
* If the switch is on or off. * If the switch is on or off.

View File

@ -196,7 +196,7 @@ void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string arg
} }
void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){ void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){
auto* triggerComponent = targetEntity->GetComponent<TriggerComponent>(); auto triggerComponent = targetEntity->GetComponent<TriggerComponent>();
if (!triggerComponent) { if (!triggerComponent) {
Game::logger->LogDebug("TriggerComponent::HandleToggleTrigger", "Trigger component not found!"); Game::logger->LogDebug("TriggerComponent::HandleToggleTrigger", "Trigger component not found!");
return; return;
@ -205,7 +205,7 @@ void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string arg
} }
void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args){ void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args){
auto* rebuildComponent = targetEntity->GetComponent<RebuildComponent>(); auto rebuildComponent = targetEntity->GetComponent<RebuildComponent>();
if (!rebuildComponent) { if (!rebuildComponent) {
Game::logger->LogDebug("TriggerComponent::HandleResetRebuild", "Rebuild component not found!"); Game::logger->LogDebug("TriggerComponent::HandleResetRebuild", "Rebuild component not found!");
return; return;
@ -237,7 +237,7 @@ void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std:
void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::string> argArray){ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::string> argArray){
if (argArray.size() < 3) return; if (argArray.size() < 3) return;
auto* phantomPhysicsComponent = m_OwningEntity->GetComponent<PhantomPhysicsComponent>(); auto phantomPhysicsComponent = m_OwningEntity->GetComponent<PhantomPhysicsComponent>();
if (!phantomPhysicsComponent) { if (!phantomPhysicsComponent) {
Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!"); Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!");
return; return;
@ -254,7 +254,7 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::s
void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args){ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args){
auto* phantomPhysicsComponent = m_OwningEntity->GetComponent<PhantomPhysicsComponent>(); auto phantomPhysicsComponent = m_OwningEntity->GetComponent<PhantomPhysicsComponent>();
if (!phantomPhysicsComponent) { if (!phantomPhysicsComponent) {
Game::logger->LogDebug("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!"); Game::logger->LogDebug("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!");
return; return;
@ -334,7 +334,7 @@ void TriggerComponent::HandleUpdateMission(Entity* targetEntity, std::vector<std
// If others need to be implemented for modding // If others need to be implemented for modding
// then we need a good way to convert this from a string to that enum // then we need a good way to convert this from a string to that enum
if (argArray.at(0) != "exploretask") return; if (argArray.at(0) != "exploretask") return;
MissionComponent* missionComponent = targetEntity->GetComponent<MissionComponent>(); auto missionComponent = targetEntity->GetComponent<MissionComponent>();
if (!missionComponent){ if (!missionComponent){
Game::logger->LogDebug("TriggerComponent::HandleUpdateMission", "Mission component not found!"); Game::logger->LogDebug("TriggerComponent::HandleUpdateMission", "Mission component not found!");
return; return;
@ -353,7 +353,7 @@ void TriggerComponent::HandlePlayEffect(Entity* targetEntity, std::vector<std::s
} }
void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){ void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){
auto* skillComponent = targetEntity->GetComponent<SkillComponent>(); auto skillComponent = targetEntity->GetComponent<SkillComponent>();
if (!skillComponent) { if (!skillComponent) {
Game::logger->LogDebug("TriggerComponent::HandleCastSkill", "Skill component not found!"); Game::logger->LogDebug("TriggerComponent::HandleCastSkill", "Skill component not found!");
return; return;
@ -364,7 +364,7 @@ void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){
} }
void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::vector<std::string> argArray) { void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::vector<std::string> argArray) {
auto* phantomPhysicsComponent = targetEntity->GetComponent<PhantomPhysicsComponent>(); auto phantomPhysicsComponent = targetEntity->GetComponent<PhantomPhysicsComponent>();
if (!phantomPhysicsComponent) { if (!phantomPhysicsComponent) {
Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!"); Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!");
return; return;
@ -399,7 +399,7 @@ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::v
} }
void TriggerComponent::HandleSetPhysicsVolumeStatus(Entity* targetEntity, std::string args) { void TriggerComponent::HandleSetPhysicsVolumeStatus(Entity* targetEntity, std::string args) {
auto* phantomPhysicsComponent = targetEntity->GetComponent<PhantomPhysicsComponent>(); auto phantomPhysicsComponent = targetEntity->GetComponent<PhantomPhysicsComponent>();
if (!phantomPhysicsComponent) { if (!phantomPhysicsComponent) {
Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!"); Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!");
return; return;

View File

@ -110,7 +110,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
player->ConstructLimboEntities(); player->ConstructLimboEntities();
} }
InventoryComponent* inv = entity->GetComponent<InventoryComponent>(); auto inv = entity->GetComponent<InventoryComponent>();
if (inv) { if (inv) {
auto items = inv->GetEquippedItems(); auto items = inv->GetEquippedItems();
for (auto pair : items) { for (auto pair : items) {
@ -120,13 +120,13 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
} }
} }
auto* destroyable = entity->GetComponent<DestroyableComponent>(); auto destroyable = entity->GetComponent<DestroyableComponent>();
destroyable->SetImagination(destroyable->GetImagination()); destroyable->SetImagination(destroyable->GetImagination());
EntityManager::Instance()->SerializeEntity(entity); EntityManager::Instance()->SerializeEntity(entity);
std::vector<Entity*> racingControllers = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL); std::vector<Entity*> racingControllers = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
for (Entity* racingController : racingControllers) { for (Entity* racingController : racingControllers) {
auto* racingComponent = racingController->GetComponent<RacingControlComponent>(); auto racingComponent = racingController->GetComponent<RacingControlComponent>();
if (racingComponent != nullptr) { if (racingComponent != nullptr) {
racingComponent->OnPlayerLoaded(entity); racingComponent->OnPlayerLoaded(entity);
} }
@ -243,13 +243,6 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
case eGameMessageType::REQUEST_RESURRECT: { case eGameMessageType::REQUEST_RESURRECT: {
GameMessages::SendResurrect(entity); GameMessages::SendResurrect(entity);
/*auto* dest = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE));
if (dest) {
dest->SetHealth(4);
dest->SetArmor(0);
dest->SetImagination(6);
EntityManager::Instance()->SerializeEntity(entity);
}*/
break; break;
} }
case eGameMessageType::HANDLE_HOT_PROPERTY_DATA: { case eGameMessageType::HANDLE_HOT_PROPERTY_DATA: {
@ -263,7 +256,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
message.Deserialize(inStream); message.Deserialize(inStream);
auto* skill_component = entity->GetComponent<SkillComponent>(); auto skill_component = entity->GetComponent<SkillComponent>();
if (skill_component != nullptr) { if (skill_component != nullptr) {
auto* bs = new RakNet::BitStream((unsigned char*)message.sBitStream.c_str(), message.sBitStream.size(), false); auto* bs = new RakNet::BitStream((unsigned char*)message.sBitStream.c_str(), message.sBitStream.size(), false);
@ -282,7 +275,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
if (startSkill.skillID == 1561 || startSkill.skillID == 1562 || startSkill.skillID == 1541) return; if (startSkill.skillID == 1561 || startSkill.skillID == 1562 || startSkill.skillID == 1541) return;
MissionComponent* comp = entity->GetComponent<MissionComponent>(); auto comp = entity->GetComponent<MissionComponent>();
if (comp) { if (comp) {
comp->Progress(eMissionTaskType::USE_SKILL, startSkill.skillID); comp->Progress(eMissionTaskType::USE_SKILL, startSkill.skillID);
} }
@ -295,12 +288,12 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
if (behaviorId > 0) { if (behaviorId > 0) {
RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)startSkill.sBitStream.c_str(), startSkill.sBitStream.size(), false); RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)startSkill.sBitStream.c_str(), startSkill.sBitStream.size(), false);
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto skillComponent = entity->GetComponent<SkillComponent>();
success = skillComponent->CastPlayerSkill(behaviorId, startSkill.uiSkillHandle, bs, startSkill.optionalTargetID, startSkill.skillID); success = skillComponent->CastPlayerSkill(behaviorId, startSkill.uiSkillHandle, bs, startSkill.optionalTargetID, startSkill.skillID);
if (success && entity->GetCharacter()) { if (success && entity->GetCharacter()) {
DestroyableComponent* destComp = entity->GetComponent<DestroyableComponent>(); auto destComp = entity->GetComponent<DestroyableComponent>();
destComp->SetImagination(destComp->GetImagination() - skillTable->GetSkillByID(startSkill.skillID).imaginationcost); destComp->SetImagination(destComp->GetImagination() - skillTable->GetSkillByID(startSkill.skillID).imaginationcost);
} }
@ -357,7 +350,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
if (usr != nullptr) { if (usr != nullptr) {
RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)sync.sBitStream.c_str(), sync.sBitStream.size(), false); RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)sync.sBitStream.c_str(), sync.sBitStream.size(), false);
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto skillComponent = entity->GetComponent<SkillComponent>();
skillComponent->SyncPlayerSkill(sync.uiSkillHandle, sync.uiBehaviorHandle, bs); skillComponent->SyncPlayerSkill(sync.uiSkillHandle, sync.uiBehaviorHandle, bs);

View File

@ -935,10 +935,10 @@ void GameMessages::SendResurrect(Entity* entity) {
// and just make sure the client has time to be ready. // and just make sure the client has time to be ready.
constexpr float respawnTime = 3.66700005531311f + 0.5f; constexpr float respawnTime = 3.66700005531311f + 0.5f;
entity->AddCallbackTimer(respawnTime, [=]() { entity->AddCallbackTimer(respawnTime, [=]() {
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>(); auto destroyableComponent = entity->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr && entity->GetLOT() == 1) { if (destroyableComponent != nullptr && entity->GetLOT() == 1) {
auto* levelComponent = entity->GetComponent<LevelProgressionComponent>(); auto levelComponent = entity->GetComponent<LevelProgressionComponent>();
if (levelComponent) { if (levelComponent) {
int32_t healthToRestore = levelComponent->GetLevel() >= 45 ? 8 : 4; int32_t healthToRestore = levelComponent->GetLevel() >= 45 ? 8 : 4;
if (healthToRestore > destroyableComponent->GetMaxHealth()) healthToRestore = destroyableComponent->GetMaxHealth(); if (healthToRestore > destroyableComponent->GetMaxHealth()) healthToRestore = destroyableComponent->GetMaxHealth();
@ -952,7 +952,7 @@ void GameMessages::SendResurrect(Entity* entity) {
}); });
auto cont = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); auto cont = entity->GetComponent<ControllablePhysicsComponent>();
if (cont && entity->GetLOT() == 1) { if (cont && entity->GetLOT() == 1) {
cont->SetPosition(entity->GetRespawnPosition()); cont->SetPosition(entity->GetRespawnPosition());
cont->SetRotation(entity->GetRespawnRotation()); cont->SetRotation(entity->GetRespawnRotation());
@ -1149,7 +1149,7 @@ void GameMessages::SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPo
bitStream.Write(position.y); bitStream.Write(position.y);
bitStream.Write(position.z); bitStream.Write(position.z);
auto con = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); auto con = entity->GetComponent<ControllablePhysicsComponent>();
if (con) { if (con) {
auto rot = con->GetRotation(); auto rot = con->GetRotation();
bitStream.Write(rot.x); bitStream.Write(rot.x);
@ -1284,7 +1284,7 @@ void GameMessages::SendVendorStatusUpdate(Entity* entity, const SystemAddress& s
CBITSTREAM; CBITSTREAM;
CMSGHEADER; CMSGHEADER;
VendorComponent* vendor = static_cast<VendorComponent*>(entity->GetComponent(eReplicaComponentType::VENDOR)); auto vendor = entity->GetComponent<VendorComponent>();
if (!vendor) return; if (!vendor) return;
std::map<LOT, int> vendorItems = vendor->GetInventory(); std::map<LOT, int> vendorItems = vendor->GetInventory();
@ -1406,7 +1406,7 @@ void GameMessages::SendMoveInventoryBatch(Entity* entity, uint32_t stackCount, i
CBITSTREAM; CBITSTREAM;
CMSGHEADER; CMSGHEADER;
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = entity->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
Item* itemStack = inv->FindItemById(iObjID); Item* itemStack = inv->FindItemById(iObjID);
@ -2182,7 +2182,7 @@ void GameMessages::HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity,
LWOOBJID objIdToAddToInventory{}; LWOOBJID objIdToAddToInventory{};
inStream->Read(unknown); inStream->Read(unknown);
inStream->Read(objIdToAddToInventory); inStream->Read(objIdToAddToInventory);
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
if (inventoryComponent) { if (inventoryComponent) {
auto* inventory = inventoryComponent->GetInventory(eInventoryType::MODELS_IN_BBB); auto* inventory = inventoryComponent->GetInventory(eInventoryType::MODELS_IN_BBB);
auto* item = inventory->FindItemById(objIdToAddToInventory); auto* item = inventory->FindItemById(objIdToAddToInventory);
@ -2244,7 +2244,7 @@ void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity*
entity = entites[0]; entity = entites[0];
*/ */
auto* propertyVendorComponent = static_cast<PropertyVendorComponent*>(entity->GetComponent(eReplicaComponentType::PROPERTY_VENDOR)); auto propertyVendorComponent = entity->GetComponent<PropertyVendorComponent>();
if (propertyVendorComponent != nullptr) { if (propertyVendorComponent != nullptr) {
propertyVendorComponent->OnQueryPropertyData(entity, sysAddr); propertyVendorComponent->OnQueryPropertyData(entity, sysAddr);
@ -2256,7 +2256,7 @@ void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity*
entity = entites[0]; entity = entites[0];
*/ */
auto* propertyManagerComponent = static_cast<PropertyManagementComponent*>(entity->GetComponent(eReplicaComponentType::PROPERTY_MANAGEMENT)); auto propertyManagerComponent = entity->GetComponent<PropertyManagementComponent>();
if (propertyManagerComponent != nullptr) { if (propertyManagerComponent != nullptr) {
propertyManagerComponent->OnQueryPropertyData(entity, sysAddr); propertyManagerComponent->OnQueryPropertyData(entity, sysAddr);
@ -2422,7 +2422,7 @@ void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity*
Game::logger->Log("BBB", "Load item request for: %lld", previousItemID); Game::logger->Log("BBB", "Load item request for: %lld", previousItemID);
LWOOBJID newId = previousItemID; LWOOBJID newId = previousItemID;
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
if (inventoryComponent) { if (inventoryComponent) {
auto* inventory = inventoryComponent->GetInventory(eInventoryType::MODELS); auto* inventory = inventoryComponent->GetInventory(eInventoryType::MODELS);
auto* itemToMove = inventory->FindItemById(previousItemID); auto* itemToMove = inventory->FindItemById(previousItemID);
@ -2776,7 +2776,7 @@ void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entit
auto* player = Player::GetPlayer(sysAddr); auto* player = Player::GetPlayer(sysAddr);
auto* entranceComponent = entity->GetComponent<PropertyEntranceComponent>(); auto entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
if (entranceComponent == nullptr) return; if (entranceComponent == nullptr) return;
@ -2803,7 +2803,7 @@ void GameMessages::HandleEnterProperty(RakNet::BitStream* inStream, Entity* enti
auto* player = Player::GetPlayer(sysAddr); auto* player = Player::GetPlayer(sysAddr);
auto* entranceComponent = entity->GetComponent<PropertyEntranceComponent>(); auto entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
if (entranceComponent != nullptr) { if (entranceComponent != nullptr) {
entranceComponent->OnEnterProperty(player, index, returnToZone, sysAddr); entranceComponent->OnEnterProperty(player, index, returnToZone, sysAddr);
return; return;
@ -2820,7 +2820,7 @@ void GameMessages::HandleSetConsumableItem(RakNet::BitStream* inStream, Entity*
inStream->Read(lot); inStream->Read(lot);
auto* inventory = entity->GetComponent<InventoryComponent>(); auto inventory = entity->GetComponent<InventoryComponent>();
if (inventory == nullptr) return; if (inventory == nullptr) return;
@ -3719,7 +3719,7 @@ void GameMessages::SendPetNameChanged(LWOOBJID objectId, int32_t moderationStatu
void GameMessages::HandleClientExitTamingMinigame(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { void GameMessages::HandleClientExitTamingMinigame(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
bool bVoluntaryExit = inStream->ReadBit(); bool bVoluntaryExit = inStream->ReadBit();
auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
if (petComponent == nullptr) { if (petComponent == nullptr) {
return; return;
@ -3729,7 +3729,7 @@ void GameMessages::HandleClientExitTamingMinigame(RakNet::BitStream* inStream, E
} }
void GameMessages::HandleStartServerPetMinigameTimer(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { void GameMessages::HandleStartServerPetMinigameTimer(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
if (petComponent == nullptr) { if (petComponent == nullptr) {
return; return;
@ -3757,7 +3757,7 @@ void GameMessages::HandlePetTamingTryBuild(RakNet::BitStream* inStream, Entity*
clientFailed = inStream->ReadBit(); clientFailed = inStream->ReadBit();
auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
if (petComponent == nullptr) { if (petComponent == nullptr) {
return; return;
@ -3771,7 +3771,7 @@ void GameMessages::HandleNotifyTamingBuildSuccess(RakNet::BitStream* inStream, E
inStream->Read(position); inStream->Read(position);
auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
if (petComponent == nullptr) { if (petComponent == nullptr) {
return; return;
@ -3792,7 +3792,7 @@ void GameMessages::HandleRequestSetPetName(RakNet::BitStream* inStream, Entity*
name.push_back(character); name.push_back(character);
} }
auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
if (petComponent == nullptr) { if (petComponent == nullptr) {
petComponent = PetComponent::GetActivePet(entity->GetObjectID()); petComponent = PetComponent::GetActivePet(entity->GetObjectID());
@ -3818,7 +3818,7 @@ void GameMessages::HandleCommandPet(RakNet::BitStream* inStream, Entity* entity,
inStream->Read(iTypeID); inStream->Read(iTypeID);
overrideObey = inStream->ReadBit(); overrideObey = inStream->ReadBit();
auto* petComponent = entity->GetComponent<PetComponent>(); auto petComponent = entity->GetComponent<PetComponent>();
if (petComponent == nullptr) { if (petComponent == nullptr) {
return; return;
@ -3832,7 +3832,7 @@ void GameMessages::HandleDespawnPet(RakNet::BitStream* inStream, Entity* entity,
bDeletePet = inStream->ReadBit(); bDeletePet = inStream->ReadBit();
auto* petComponent = PetComponent::GetActivePet(entity->GetObjectID()); auto petComponent = PetComponent::GetActivePet(entity->GetObjectID());
if (petComponent == nullptr) { if (petComponent == nullptr) {
return; return;
@ -3884,13 +3884,13 @@ void GameMessages::HandleMessageBoxResponse(RakNet::BitStream* inStream, Entity*
entity->OnMessageBoxResponse(userEntity, iButton, identifier, userData); entity->OnMessageBoxResponse(userEntity, iButton, identifier, userData);
auto* scriptedActivityComponent = entity->GetComponent<ScriptedActivityComponent>(); auto scriptedActivityComponent = entity->GetComponent<ScriptedActivityComponent>();
if (scriptedActivityComponent != nullptr) { if (scriptedActivityComponent != nullptr) {
scriptedActivityComponent->HandleMessageBoxResponse(userEntity, GeneralUtils::UTF16ToWTF8(identifier)); scriptedActivityComponent->HandleMessageBoxResponse(userEntity, GeneralUtils::UTF16ToWTF8(identifier));
} }
auto* racingControlComponent = entity->GetComponent<RacingControlComponent>(); auto racingControlComponent = entity->GetComponent<RacingControlComponent>();
if (racingControlComponent != nullptr) { if (racingControlComponent != nullptr) {
racingControlComponent->HandleMessageBoxResponse(userEntity, iButton, GeneralUtils::UTF16ToWTF8(identifier)); racingControlComponent->HandleMessageBoxResponse(userEntity, iButton, GeneralUtils::UTF16ToWTF8(identifier));
@ -4056,7 +4056,7 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e
// If we aren't possessing somethings, the don't do anything // If we aren't possessing somethings, the don't do anything
if (objectId != LWOOBJID_EMPTY) { if (objectId != LWOOBJID_EMPTY) {
auto* possessorComponent = entity->GetComponent<PossessorComponent>(); auto possessorComponent = entity->GetComponent<PossessorComponent>();
auto* mount = EntityManager::Instance()->GetEntity(objectId); auto* mount = EntityManager::Instance()->GetEntity(objectId);
// make sure we have the things we need and they aren't null // make sure we have the things we need and they aren't null
if (possessorComponent && mount) { if (possessorComponent && mount) {
@ -4066,7 +4066,7 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e
possessorComponent->SetPossessableType(ePossessionType::NO_POSSESSION); possessorComponent->SetPossessableType(ePossessionType::NO_POSSESSION);
// character related things // character related things
auto* character = entity->GetComponent<CharacterComponent>(); auto character = entity->GetComponent<CharacterComponent>();
if (character) { if (character) {
// If we had an active item turn it off // If we had an active item turn it off
if (possessorComponent->GetMountItemID() != LWOOBJID_EMPTY) GameMessages::SendMarkInventoryItemAsActive(entity->GetObjectID(), false, eUnequippableActiveType::MOUNT, possessorComponent->GetMountItemID(), entity->GetSystemAddress()); if (possessorComponent->GetMountItemID() != LWOOBJID_EMPTY) GameMessages::SendMarkInventoryItemAsActive(entity->GetObjectID(), false, eUnequippableActiveType::MOUNT, possessorComponent->GetMountItemID(), entity->GetSystemAddress());
@ -4074,11 +4074,11 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e
} }
// Set that the controllabel phsyics comp is teleporting // Set that the controllabel phsyics comp is teleporting
auto* controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
if (controllablePhysicsComponent) controllablePhysicsComponent->SetIsTeleporting(true); if (controllablePhysicsComponent) controllablePhysicsComponent->SetIsTeleporting(true);
// Call dismoint on the possessable comp to let it handle killing the possessable // Call dismoint on the possessable comp to let it handle killing the possessable
auto* possessableComponent = mount->GetComponent<PossessableComponent>(); auto possessableComponent = mount->GetComponent<PossessableComponent>();
if (possessableComponent) possessableComponent->Dismount(); if (possessableComponent) possessableComponent->Dismount();
// Update the entity that was possessing // Update the entity that was possessing
@ -4102,7 +4102,7 @@ void GameMessages::HandleAcknowledgePossession(RakNet::BitStream* inStream, Enti
//Racing //Racing
void GameMessages::HandleModuleAssemblyQueryData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { void GameMessages::HandleModuleAssemblyQueryData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
auto* moduleAssemblyComponent = entity->GetComponent<ModuleAssemblyComponent>(); auto moduleAssemblyComponent = entity->GetComponent<ModuleAssemblyComponent>();
Game::logger->Log("HandleModuleAssemblyQueryData", "Got Query from %i", entity->GetLOT()); Game::logger->Log("HandleModuleAssemblyQueryData", "Got Query from %i", entity->GetLOT());
@ -4138,7 +4138,7 @@ void GameMessages::HandleRacingClientReady(RakNet::BitStream* inStream, Entity*
return; return;
} }
auto* racingControlComponent = dZoneManager::Instance()->GetZoneControlObject()->GetComponent<RacingControlComponent>(); auto racingControlComponent = dZoneManager::Instance()->GetZoneControlObject()->GetComponent<RacingControlComponent>();
if (racingControlComponent == nullptr) { if (racingControlComponent == nullptr) {
return; return;
@ -4188,12 +4188,12 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity,
auto* zoneController = dZoneManager::Instance()->GetZoneControlObject(); auto* zoneController = dZoneManager::Instance()->GetZoneControlObject();
auto* racingControlComponent = zoneController->GetComponent<RacingControlComponent>(); auto racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
Game::logger->Log("HandleRequestDie", "Got die request: %i", entity->GetLOT()); Game::logger->Log("HandleRequestDie", "Got die request: %i", entity->GetLOT());
if (racingControlComponent != nullptr) { if (racingControlComponent != nullptr) {
auto* possessableComponent = entity->GetComponent<PossessableComponent>(); auto possessableComponent = entity->GetComponent<PossessableComponent>();
if (possessableComponent != nullptr) { if (possessableComponent != nullptr) {
entity = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor()); entity = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
@ -4231,7 +4231,7 @@ void GameMessages::HandleRacingPlayerInfoResetFinished(RakNet::BitStream* inStre
auto* zoneController = dZoneManager::Instance()->GetZoneControlObject(); auto* zoneController = dZoneManager::Instance()->GetZoneControlObject();
auto* racingControlComponent = zoneController->GetComponent<RacingControlComponent>(); auto racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
Game::logger->Log("HandleRacingPlayerInfoResetFinished", "Got finished: %i", entity->GetLOT()); Game::logger->Log("HandleRacingPlayerInfoResetFinished", "Got finished: %i", entity->GetLOT());
@ -4293,7 +4293,7 @@ void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* in
return; return;
} }
auto* possessableComponent = entity->GetComponent<PossessableComponent>(); auto possessableComponent = entity->GetComponent<PossessableComponent>();
if (possessableComponent != nullptr) { if (possessableComponent != nullptr) {
entity = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor()); entity = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
@ -4303,7 +4303,7 @@ void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* in
} }
} }
auto* characterComponent = entity->GetComponent<CharacterComponent>(); auto characterComponent = entity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->UpdatePlayerStatistic(RacingImaginationPowerUpsCollected); characterComponent->UpdatePlayerStatistic(RacingImaginationPowerUpsCollected);
} }
@ -4630,7 +4630,7 @@ void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream*
return; return;
} }
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
if (inventoryComponent != nullptr) { if (inventoryComponent != nullptr) {
if (itemID != LWOOBJID_EMPTY) { if (itemID != LWOOBJID_EMPTY) {
@ -4639,7 +4639,7 @@ void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream*
if (!item) return; if (!item) return;
// Despawn the pet if we are moving that pet to the vault. // Despawn the pet if we are moving that pet to the vault.
auto* petComponent = PetComponent::GetActivePet(entity->GetObjectID()); auto petComponent = PetComponent::GetActivePet(entity->GetObjectID());
if (petComponent && petComponent->GetDatabaseId() == item->GetSubKey()) { if (petComponent && petComponent->GetDatabaseId() == item->GetSubKey()) {
inventoryComponent->DespawnPet(); inventoryComponent->DespawnPet();
} }
@ -4723,7 +4723,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
Entity* player = EntityManager::Instance()->GetEntity(user->GetLoggedInChar()); Entity* player = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
if (!player) return; if (!player) return;
auto* propertyVendorComponent = static_cast<PropertyVendorComponent*>(entity->GetComponent(eReplicaComponentType::PROPERTY_VENDOR)); auto propertyVendorComponent = entity->GetComponent<PropertyVendorComponent>();
if (propertyVendorComponent != nullptr) { if (propertyVendorComponent != nullptr) {
propertyVendorComponent->OnBuyFromVendor(player, bConfirmed, item, count); propertyVendorComponent->OnBuyFromVendor(player, bConfirmed, item, count);
@ -4733,10 +4733,10 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
const auto isCommendationVendor = entity->GetLOT() == 13806; const auto isCommendationVendor = entity->GetLOT() == 13806;
auto* vend = entity->GetComponent<VendorComponent>(); auto vend = entity->GetComponent<VendorComponent>();
if (!vend && !isCommendationVendor) return; if (!vend && !isCommendationVendor) return;
auto* inv = player->GetComponent<InventoryComponent>(); auto inv = player->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
if (!isCommendationVendor && !vend->SellsItem(item)) { if (!isCommendationVendor && !vend->SellsItem(item)) {
@ -4764,7 +4764,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
return; return;
} }
auto* missionComponent = player->GetComponent<MissionComponent>(); auto missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent == nullptr) { if (missionComponent == nullptr) {
return; return;
@ -4827,10 +4827,10 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit
if (!player) return; if (!player) return;
Character* character = player->GetCharacter(); Character* character = player->GetCharacter();
if (!character) return; if (!character) return;
InventoryComponent* inv = static_cast<InventoryComponent*>(player->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = player->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
VendorComponent* vend = static_cast<VendorComponent*>(entity->GetComponent(eReplicaComponentType::VENDOR)); auto vend = entity->GetComponent<VendorComponent>();
if (!vend) return; if (!vend) return;
Item* item = inv->FindItemById(iObjID); Item* item = inv->FindItemById(iObjID);
@ -4877,10 +4877,10 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity*
if (!player) return; if (!player) return;
Character* character = player->GetCharacter(); Character* character = player->GetCharacter();
if (!character) return; if (!character) return;
InventoryComponent* inv = static_cast<InventoryComponent*>(player->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = player->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
VendorComponent* vend = static_cast<VendorComponent*>(entity->GetComponent(eReplicaComponentType::VENDOR)); auto vend = entity->GetComponent<VendorComponent>();
if (!vend) return; if (!vend) return;
Item* item = inv->FindItemById(iObjID); Item* item = inv->FindItemById(iObjID);
@ -4974,7 +4974,7 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity
LWOCLONEID cloneId = 0; LWOCLONEID cloneId = 0;
LWOMAPID mapId = 0; LWOMAPID mapId = 0;
auto* rocketPad = entity->GetComponent<RocketLaunchpadControlComponent>(); auto rocketPad = entity->GetComponent<RocketLaunchpadControlComponent>();
if (rocketPad == nullptr) return; if (rocketPad == nullptr) return;
@ -5031,7 +5031,7 @@ void GameMessages::HandleRebuildCancel(RakNet::BitStream* inStream, Entity* enti
inStream->Read(bEarlyRelease); inStream->Read(bEarlyRelease);
inStream->Read(userID); inStream->Read(userID);
RebuildComponent* rebComp = static_cast<RebuildComponent*>(entity->GetComponent(eReplicaComponentType::QUICK_BUILD)); auto rebComp = entity->GetComponent<RebuildComponent>();
if (!rebComp) return; if (!rebComp) return;
rebComp->CancelRebuild(EntityManager::Instance()->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY); rebComp->CancelRebuild(EntityManager::Instance()->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY);
@ -5064,7 +5064,7 @@ void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity,
if (bIsMultiInteractUse) { if (bIsMultiInteractUse) {
if (multiInteractType == 0) { if (multiInteractType == 0) {
auto* missionOfferComponent = static_cast<MissionOfferComponent*>(interactedObject->GetComponent(eReplicaComponentType::MISSION_OFFER)); auto missionOfferComponent = interactedObject->GetComponent<MissionOfferComponent>();
if (missionOfferComponent != nullptr) { if (missionOfferComponent != nullptr) {
missionOfferComponent->OfferMissions(entity, multiInteractID); missionOfferComponent->OfferMissions(entity, multiInteractID);
@ -5077,7 +5077,7 @@ void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity,
} }
//Perform use task if possible: //Perform use task if possible:
auto missionComponent = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION)); auto missionComponent = entity->GetComponent<MissionComponent>();
if (missionComponent == nullptr) return; if (missionComponent == nullptr) return;
@ -5099,7 +5099,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity)
if (emoteID == 0) return; if (emoteID == 0) return;
std::string sAnimationName = "deaded"; //Default name in case we fail to get the emote std::string sAnimationName = "deaded"; //Default name in case we fail to get the emote
MissionComponent* missionComponent = entity->GetComponent<MissionComponent>(); auto missionComponent = entity->GetComponent<MissionComponent>();
if (!missionComponent) return; if (!missionComponent) return;
if (targetID != LWOOBJID_EMPTY) { if (targetID != LWOOBJID_EMPTY) {
@ -5143,7 +5143,7 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E
if (!user) return; if (!user) return;
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar()); Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
if (!character) return; if (!character) return;
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = character->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
auto* item = inv->FindItemById(modelID); auto* item = inv->FindItemById(modelID);
@ -5186,7 +5186,7 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* e
inStream->Read(isDefaultReward); inStream->Read(isDefaultReward);
if (isDefaultReward) inStream->Read(reward); if (isDefaultReward) inStream->Read(reward);
MissionComponent* missionComponent = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION)); auto missionComponent = entity->GetComponent<MissionComponent>();
if (!missionComponent) { if (!missionComponent) {
Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle RespondToMission", playerID); Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle RespondToMission", playerID);
return; return;
@ -5229,7 +5229,7 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* en
} }
// Get the player's mission component // Get the player's mission component
MissionComponent* missionComponent = static_cast<MissionComponent*>(player->GetComponent(eReplicaComponentType::MISSION)); auto missionComponent = player->GetComponent<MissionComponent>();
if (!missionComponent) { if (!missionComponent) {
Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle MissionDialogueOK", player->GetObjectID()); Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle MissionDialogueOK", player->GetObjectID());
return; return;
@ -5253,7 +5253,7 @@ void GameMessages::HandleRequestLinkedMission(RakNet::BitStream* inStream, Entit
auto* player = EntityManager::Instance()->GetEntity(playerId); auto* player = EntityManager::Instance()->GetEntity(playerId);
auto* missionOfferComponent = static_cast<MissionOfferComponent*>(entity->GetComponent(eReplicaComponentType::MISSION_OFFER)); auto missionOfferComponent = entity->GetComponent<MissionOfferComponent>();
if (missionOfferComponent != nullptr) { if (missionOfferComponent != nullptr) {
missionOfferComponent->OfferMissions(player, 0); missionOfferComponent->OfferMissions(player, 0);
@ -5267,16 +5267,16 @@ void GameMessages::HandleHasBeenCollected(RakNet::BitStream* inStream, Entity* e
Entity* player = EntityManager::Instance()->GetEntity(playerID); Entity* player = EntityManager::Instance()->GetEntity(playerID);
if (!player || !entity || entity->GetCollectibleID() == 0) return; if (!player || !entity || entity->GetCollectibleID() == 0) return;
MissionComponent* missionComponent = static_cast<MissionComponent*>(player->GetComponent(eReplicaComponentType::MISSION)); auto missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent) { if (missionComponent) {
missionComponent->Progress(eMissionTaskType::COLLECTION, entity->GetLOT(), entity->GetObjectID()); missionComponent->Progress(eMissionTaskType::COLLECTION, entity->GetLOT(), entity->GetObjectID());
} }
} }
void GameMessages::HandleNotifyServerLevelProcessingComplete(RakNet::BitStream* inStream, Entity* entity) { void GameMessages::HandleNotifyServerLevelProcessingComplete(RakNet::BitStream* inStream, Entity* entity) {
auto* levelComp = entity->GetComponent<LevelProgressionComponent>(); auto levelComp = entity->GetComponent<LevelProgressionComponent>();
if (!levelComp) return; if (!levelComp) return;
auto* character = entity->GetComponent<CharacterComponent>(); auto character = entity->GetComponent<CharacterComponent>();
if (!character) return; if (!character) return;
//Update our character's level in memory: //Update our character's level in memory:
@ -5284,7 +5284,7 @@ void GameMessages::HandleNotifyServerLevelProcessingComplete(RakNet::BitStream*
levelComp->HandleLevelUp(); levelComp->HandleLevelUp();
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
if (inventoryComponent != nullptr) { if (inventoryComponent != nullptr) {
auto* inventory = inventoryComponent->GetInventory(ITEMS); auto* inventory = inventoryComponent->GetInventory(ITEMS);
@ -5370,7 +5370,7 @@ void GameMessages::HandleEquipItem(RakNet::BitStream* inStream, Entity* entity)
inStream->Read(immediate); //twice? inStream->Read(immediate); //twice?
inStream->Read(objectID); inStream->Read(objectID);
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = entity->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
Item* item = inv->FindItemById(objectID); Item* item = inv->FindItemById(objectID);
@ -5389,7 +5389,7 @@ void GameMessages::HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity
inStream->Read(immediate); inStream->Read(immediate);
inStream->Read(objectID); inStream->Read(objectID);
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = entity->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
auto* item = inv->FindItemById(objectID); auto* item = inv->FindItemById(objectID);
@ -5464,7 +5464,7 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En
inStream->Read(iTradeIDIsDefault); inStream->Read(iTradeIDIsDefault);
if (iTradeIDIsDefault) inStream->Read(iTradeID); if (iTradeIDIsDefault) inStream->Read(iTradeID);
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = entity->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
auto* item = inv->FindItemById(iObjID); auto* item = inv->FindItemById(iObjID);
@ -5485,7 +5485,7 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En
item->SetCount(item->GetCount() - iStackCount, true); item->SetCount(item->GetCount() - iStackCount, true);
EntityManager::Instance()->SerializeEntity(entity); EntityManager::Instance()->SerializeEntity(entity);
auto* missionComponent = entity->GetComponent<MissionComponent>(); auto missionComponent = entity->GetComponent<MissionComponent>();
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
missionComponent->Progress(eMissionTaskType::GATHER, item->GetLot(), LWOOBJID_EMPTY, "", -iStackCount); missionComponent->Progress(eMissionTaskType::GATHER, item->GetLot(), LWOOBJID_EMPTY, "", -iStackCount);
@ -5507,7 +5507,7 @@ void GameMessages::HandleMoveItemInInventory(RakNet::BitStream* inStream, Entity
inStream->Read(responseCode); inStream->Read(responseCode);
inStream->Read(slot); inStream->Read(slot);
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = entity->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
auto* item = inv->FindItemById(iObjID); auto* item = inv->FindItemById(iObjID);
@ -5584,7 +5584,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
if (!user) return; if (!user) return;
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar()); Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
if (!character) return; if (!character) return;
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = character->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
Game::logger->Log("GameMessages", "Build finished"); Game::logger->Log("GameMessages", "Build finished");
@ -5639,7 +5639,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config); inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config);
} }
auto* missionComponent = character->GetComponent<MissionComponent>(); auto missionComponent = character->GetComponent<MissionComponent>();
if (entity->GetLOT() != 9980 || Game::server->GetZoneID() != 1200) { if (entity->GetLOT() != 9980 || Game::server->GetZoneID() != 1200) {
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
@ -5649,7 +5649,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
} }
} }
ScriptComponent* script = static_cast<ScriptComponent*>(entity->GetComponent(eReplicaComponentType::SCRIPT)); auto script = entity->GetComponent<ScriptComponent>();
for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) { for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) {
script->OnModularBuildExit(entity, character, count >= 3, modList); script->OnModularBuildExit(entity, character, count >= 3, modList);
@ -5672,7 +5672,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti
if (!user) return; if (!user) return;
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar()); Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
if (!character) return; if (!character) return;
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = character->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
/** /**
@ -5790,7 +5790,7 @@ void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, E
inStream->Read(templateID); inStream->Read(templateID);
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = character->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
auto* item = inv->FindItemByLot(templateID, TEMP_MODELS); auto* item = inv->FindItemByLot(templateID, TEMP_MODELS);
@ -5842,13 +5842,13 @@ void GameMessages::HandleResurrect(RakNet::BitStream* inStream, Entity* entity)
} }
void GameMessages::HandlePushEquippedItemsState(RakNet::BitStream* inStream, Entity* entity) { void GameMessages::HandlePushEquippedItemsState(RakNet::BitStream* inStream, Entity* entity) {
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = entity->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
inv->PushEquippedItems(); inv->PushEquippedItems();
} }
void GameMessages::HandlePopEquippedItemsState(RakNet::BitStream* inStream, Entity* entity) { void GameMessages::HandlePopEquippedItemsState(RakNet::BitStream* inStream, Entity* entity) {
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = entity->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
inv->PopEquippedItems(); inv->PopEquippedItems();
EntityManager::Instance()->SerializeEntity(entity); // so it updates on client side EntityManager::Instance()->SerializeEntity(entity); // so it updates on client side
@ -5860,7 +5860,7 @@ void GameMessages::HandleClientItemConsumed(RakNet::BitStream* inStream, Entity*
inStream->Read(itemConsumed); inStream->Read(itemConsumed);
auto* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inventory = entity->GetComponent<InventoryComponent>();
if (inventory == nullptr) { if (inventory == nullptr) {
return; return;
@ -5874,7 +5874,7 @@ void GameMessages::HandleClientItemConsumed(RakNet::BitStream* inStream, Entity*
item->Consume(); item->Consume();
auto* missions = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION)); auto missions = entity->GetComponent<MissionComponent>();
if (missions != nullptr) { if (missions != nullptr) {
missions->Progress(eMissionTaskType::USE_ITEM, itemLot); missions->Progress(eMissionTaskType::USE_ITEM, itemLot);
} }
@ -5886,7 +5886,7 @@ void GameMessages::HandleUseNonEquipmentItem(RakNet::BitStream* inStream, Entity
inStream->Read(itemConsumed); inStream->Read(itemConsumed);
auto* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = entity->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
@ -5921,7 +5921,7 @@ void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entit
if (type == 0) { // join if (type == 0) { // join
if (value != 0) { if (value != 0) {
for (Entity* scriptedAct : scriptedActs) { for (Entity* scriptedAct : scriptedActs) {
ScriptedActivityComponent* comp = static_cast<ScriptedActivityComponent*>(scriptedAct->GetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY)); auto comp = scriptedAct->GetComponent<ScriptedActivityComponent>();
if (!comp) continue; if (!comp) continue;
if (comp->GetActivityID() == value) { if (comp->GetActivityID() == value) {
comp->PlayerJoin(entity); comp->PlayerJoin(entity);
@ -5932,7 +5932,7 @@ void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entit
} }
} else if (type == 1) { // ready/unready } else if (type == 1) { // ready/unready
for (Entity* scriptedAct : scriptedActs) { for (Entity* scriptedAct : scriptedActs) {
ScriptedActivityComponent* comp = static_cast<ScriptedActivityComponent*>(scriptedAct->GetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY)); auto comp = scriptedAct->GetComponent<ScriptedActivityComponent>();
if (!comp) continue; if (!comp) continue;
if (comp->PlayerIsInQueue(entity)) { if (comp->PlayerIsInQueue(entity)) {
comp->PlayerReady(entity, value); comp->PlayerReady(entity, value);
@ -6052,7 +6052,7 @@ void
GameMessages::HandleClientRailMovementReady(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { GameMessages::HandleClientRailMovementReady(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR); const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
for (const auto* possibleRail : possibleRails) { for (const auto* possibleRail : possibleRails) {
const auto* rail = possibleRail->GetComponent<RailActivatorComponent>(); const auto rail = possibleRail->GetComponent<RailActivatorComponent>();
if (rail != nullptr) { if (rail != nullptr) {
rail->OnRailMovementReady(entity); rail->OnRailMovementReady(entity);
} }
@ -6064,7 +6064,7 @@ void GameMessages::HandleCancelRailMovement(RakNet::BitStream* inStream, Entity*
const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR); const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
for (const auto* possibleRail : possibleRails) { for (const auto* possibleRail : possibleRails) {
auto* rail = possibleRail->GetComponent<RailActivatorComponent>(); auto rail = possibleRail->GetComponent<RailActivatorComponent>();
if (rail != nullptr) { if (rail != nullptr) {
rail->OnCancelRailMovement(entity); rail->OnCancelRailMovement(entity);
} }
@ -6113,7 +6113,7 @@ void GameMessages::HandleModifyPlayerZoneStatistic(RakNet::BitStream* inStream,
} }
// Notify the character component that something's changed // Notify the character component that something's changed
auto* characterComponent = entity->GetComponent<CharacterComponent>(); auto characterComponent = entity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->HandleZoneStatisticsUpdate(zone, statisticsName, value); characterComponent->HandleZoneStatisticsUpdate(zone, statisticsName, value);
} }
@ -6130,7 +6130,7 @@ void GameMessages::HandleUpdatePlayerStatistic(RakNet::BitStream* inStream, Enti
updateValue = 1; updateValue = 1;
} }
auto* characterComponent = entity->GetComponent<CharacterComponent>(); auto characterComponent = entity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->UpdatePlayerStatistic((StatisticID)updateID, (uint64_t)std::max(updateValue, int64_t(0))); characterComponent->UpdatePlayerStatistic((StatisticID)updateID, (uint64_t)std::max(updateValue, int64_t(0)));
} }

View File

@ -92,7 +92,7 @@ Item::Item(
inventory->AddManagedItem(this); inventory->AddManagedItem(this);
auto* entity = inventory->GetComponent()->GetOwningEntity(); auto entity = inventory->GetComponent()->GetOwningEntity();
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast<int>(this->count), subKey, lootSourceType); GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast<int>(this->count), subKey, lootSourceType);
if (isModMoveAndEquip) { if (isModMoveAndEquip) {
@ -166,7 +166,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem
} }
if (!silent) { if (!silent) {
auto* entity = inventory->GetComponent()->GetOwningEntity(); auto entity = inventory->GetComponent()->GetOwningEntity();
if (value > count) { if (value > count) {
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, LWOOBJID_EMPTY, lootSourceType); GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, LWOOBJID_EMPTY, lootSourceType);
@ -231,7 +231,7 @@ void Item::UnEquip() {
} }
bool Item::IsEquipped() const { bool Item::IsEquipped() const {
auto* component = inventory->GetComponent(); auto component = inventory->GetComponent();
for (const auto& pair : component->GetEquippedItems()) { for (const auto& pair : component->GetEquippedItems()) {
const auto item = pair.second; const auto item = pair.second;
@ -278,7 +278,7 @@ void Item::UseNonEquip(Item* item) {
return; return;
} }
auto* playerInventoryComponent = GetInventory()->GetComponent(); auto playerInventoryComponent = GetInventory()->GetComponent();
if (!playerInventoryComponent) { if (!playerInventoryComponent) {
Game::logger->LogDebug("Item", "no inventory component attached to item id %llu lot %i", this->GetId(), this->GetLot()); Game::logger->LogDebug("Item", "no inventory component attached to item id %llu lot %i", this->GetId(), this->GetLot());
return; return;

View File

@ -125,8 +125,8 @@ void ItemSet::OnEquip(const LOT lot) {
return; return;
} }
auto* skillComponent = m_InventoryComponent->GetOwningEntity()->GetComponent<SkillComponent>(); auto skillComponent = m_InventoryComponent->GetOwningEntity()->GetComponent<SkillComponent>();
auto* missionComponent = m_InventoryComponent->GetOwningEntity()->GetComponent<MissionComponent>(); auto missionComponent = m_InventoryComponent->GetOwningEntity()->GetComponent<MissionComponent>();
for (const auto skill : skillSet) { for (const auto skill : skillSet) {
auto* skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>(); auto* skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();

View File

@ -37,8 +37,8 @@ void ItemSetPassiveAbility::Activate(Entity* target) {
return; return;
} }
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>(); auto destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
auto* skillComponent = m_Parent->GetComponent<SkillComponent>(); auto skillComponent = m_Parent->GetComponent<SkillComponent>();
if (destroyableComponent == nullptr || skillComponent == nullptr) { if (destroyableComponent == nullptr || skillComponent == nullptr) {
return; return;
@ -196,8 +196,8 @@ std::vector<ItemSetPassiveAbility> ItemSetPassiveAbility::FindAbilities(uint32_t
} }
void ItemSetPassiveAbility::OnEnemySmshed(Entity* target) { void ItemSetPassiveAbility::OnEnemySmshed(Entity* target) {
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>(); auto destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
auto* skillComponent = m_Parent->GetComponent<SkillComponent>(); auto skillComponent = m_Parent->GetComponent<SkillComponent>();
if (destroyableComponent == nullptr || skillComponent == nullptr) { if (destroyableComponent == nullptr || skillComponent == nullptr) {
return; return;

View File

@ -319,12 +319,12 @@ void Mission::Complete(const bool yieldRewards) {
return; return;
} }
auto* characterComponent = entity->GetComponent<CharacterComponent>(); auto characterComponent = entity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->TrackMissionCompletion(!info->isMission); characterComponent->TrackMissionCompletion(!info->isMission);
} }
auto* missionComponent = entity->GetComponent<MissionComponent>(); auto missionComponent = entity->GetComponent<MissionComponent>();
missionComponent->Progress(eMissionTaskType::META, info->id); missionComponent->Progress(eMissionTaskType::META, info->id);
@ -372,7 +372,7 @@ void Mission::CheckCompletion() {
void Mission::Catchup() { void Mission::Catchup() {
auto* entity = GetAssociate(); auto* entity = GetAssociate();
auto* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inventory = entity->GetComponent<InventoryComponent>();
for (auto* task : m_Tasks) { for (auto* task : m_Tasks) {
const auto type = task->GetType(); const auto type = task->GetType();
@ -414,11 +414,11 @@ void Mission::YieldRewards() {
auto* character = GetUser()->GetLastUsedChar(); auto* character = GetUser()->GetLastUsedChar();
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
auto* levelComponent = entity->GetComponent<LevelProgressionComponent>(); auto levelComponent = entity->GetComponent<LevelProgressionComponent>();
auto* characterComponent = entity->GetComponent<CharacterComponent>(); auto characterComponent = entity->GetComponent<CharacterComponent>();
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>(); auto destroyableComponent = entity->GetComponent<DestroyableComponent>();
auto* missionComponent = entity->GetComponent<MissionComponent>(); auto missionComponent = entity->GetComponent<MissionComponent>();
// Remove mission items // Remove mission items
for (auto* task : m_Tasks) { for (auto* task : m_Tasks) {

View File

@ -194,7 +194,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
return; return;
} }
auto* inventoryComponent = mission->GetAssociate()->GetComponent<InventoryComponent>(); auto inventoryComponent = mission->GetAssociate()->GetComponent<InventoryComponent>();
if (inventoryComponent != nullptr) { if (inventoryComponent != nullptr) {
int32_t itemCount = inventoryComponent->GetLotCountNonTransfer(value); int32_t itemCount = inventoryComponent->GetLotCountNonTransfer(value);
@ -213,7 +213,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
} }
Entity* entity; Entity* entity;
ScriptedActivityComponent* activity; std::shared_ptr<ScriptedActivityComponent> activity;
uint32_t activityId; uint32_t activityId;
uint32_t lot; uint32_t lot;
uint32_t collectionId; uint32_t collectionId;
@ -238,7 +238,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
break; break;
} }
activity = static_cast<ScriptedActivityComponent*>(entity->GetComponent(eReplicaComponentType::QUICK_BUILD)); activity = entity->GetComponent<ScriptedActivityComponent>();
if (activity == nullptr) { if (activity == nullptr) {
break; break;
} }
@ -308,7 +308,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
int32_t gameID = minigameManager->GetLOT(); int32_t gameID = minigameManager->GetLOT();
auto* sac = minigameManager->GetComponent<ScriptedActivityComponent>(); auto sac = minigameManager->GetComponent<ScriptedActivityComponent>();
if (sac != nullptr) { if (sac != nullptr) {
gameID = sac->GetActivityID(); gameID = sac->GetActivityID();
} }
@ -368,7 +368,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
if (entity == nullptr) break; if (entity == nullptr) break;
auto* missionComponent = entity->GetComponent<MissionComponent>(); auto missionComponent = entity->GetComponent<MissionComponent>();
if (missionComponent == nullptr) break; if (missionComponent == nullptr) break;

View File

@ -30,7 +30,7 @@
#include "UpdateActionMessage.h" #include "UpdateActionMessage.h"
#include "UpdateStripUiMessage.h" #include "UpdateStripUiMessage.h"
void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, ModelComponent* modelComponent, Entity* modelOwner, const SystemAddress& sysAddr) { void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, std::shared_ptr<ModelComponent> modelComponent, Entity* modelOwner, const SystemAddress& sysAddr) {
// auto behavior = modelComponent->FindBehavior(behaviorID); // auto behavior = modelComponent->FindBehavior(behaviorID);
// if (behavior->GetBehaviorID() == -1 || behavior->GetShouldSetNewID()) { // if (behavior->GetBehaviorID() == -1 || behavior->GetShouldSetNewID()) {
// ObjectIDManager::Instance()->RequestPersistentID( // ObjectIDManager::Instance()->RequestPersistentID(
@ -57,7 +57,7 @@ void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, ModelComponent* mode
} }
void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner) { void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner) {
auto* modelComponent = modelEntity->GetComponent<ModelComponent>(); auto modelComponent = modelEntity->GetComponent<ModelComponent>();
if (!modelComponent) return; if (!modelComponent) return;
@ -79,7 +79,7 @@ void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const Syste
GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", behaviorsToSerialize); GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", behaviorsToSerialize);
} }
void ControlBehaviors::ModelTypeChanged(AMFArrayValue* arguments, ModelComponent* ModelComponent) { void ControlBehaviors::ModelTypeChanged(AMFArrayValue* arguments, std::shared_ptr<ModelComponent> ModelComponent) {
auto* modelTypeAmf = arguments->Get<double>("ModelType"); auto* modelTypeAmf = arguments->Get<double>("ModelType");
if (!modelTypeAmf) return; if (!modelTypeAmf) return;
@ -137,7 +137,7 @@ void ControlBehaviors::Rename(Entity* modelEntity, const SystemAddress& sysAddr,
} }
// TODO This is also supposed to serialize the state of the behaviors in progress but those aren't implemented yet // TODO This is also supposed to serialize the state of the behaviors in progress but those aren't implemented yet
void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) { void ControlBehaviors::SendBehaviorBlocksToClient(std::shared_ptr<ModelComponent> modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) {
// uint32_t behaviorID = ControlBehaviors::GetBehaviorIDFromArgument(arguments); // uint32_t behaviorID = ControlBehaviors::GetBehaviorIDFromArgument(arguments);
// auto modelBehavior = modelComponent->FindBehavior(behaviorID); // auto modelBehavior = modelComponent->FindBehavior(behaviorID);
@ -266,7 +266,7 @@ void ControlBehaviors::UpdateAction(AMFArrayValue* arguments) {
} }
} }
void ControlBehaviors::MoveToInventory(ModelComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) { void ControlBehaviors::MoveToInventory(std::shared_ptr<ModelComponent> modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) {
// This closes the UI menu should it be open while the player is removing behaviors // This closes the UI menu should it be open while the player is removing behaviors
AMFArrayValue args; AMFArrayValue args;
@ -281,7 +281,7 @@ void ControlBehaviors::MoveToInventory(ModelComponent* modelComponent, const Sys
void ControlBehaviors::ProcessCommand(Entity* modelEntity, const SystemAddress& sysAddr, AMFArrayValue* arguments, std::string command, Entity* modelOwner) { void ControlBehaviors::ProcessCommand(Entity* modelEntity, const SystemAddress& sysAddr, AMFArrayValue* arguments, std::string command, Entity* modelOwner) {
if (!isInitialized || !modelEntity || !modelOwner || !arguments) return; if (!isInitialized || !modelEntity || !modelOwner || !arguments) return;
auto* modelComponent = modelEntity->GetComponent<ModelComponent>(); auto modelComponent = modelEntity->GetComponent<ModelComponent>();
if (!modelComponent) return; if (!modelComponent) return;

View File

@ -41,9 +41,9 @@ public:
*/ */
BlockDefinition* GetBlockInfo(const BlockName& blockName); BlockDefinition* GetBlockInfo(const BlockName& blockName);
private: private:
void RequestUpdatedID(int32_t behaviorID, ModelComponent* modelComponent, Entity* modelOwner, const SystemAddress& sysAddr); void RequestUpdatedID(int32_t behaviorID, std::shared_ptr<ModelComponent> modelComponent, Entity* modelOwner, const SystemAddress& sysAddr);
void SendBehaviorListToClient(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner); void SendBehaviorListToClient(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner);
void ModelTypeChanged(AMFArrayValue* arguments, ModelComponent* ModelComponent); void ModelTypeChanged(AMFArrayValue* arguments, std::shared_ptr<ModelComponent> ModelComponent);
void ToggleExecutionUpdates(); void ToggleExecutionUpdates();
void AddStrip(AMFArrayValue* arguments); void AddStrip(AMFArrayValue* arguments);
void RemoveStrip(AMFArrayValue* arguments); void RemoveStrip(AMFArrayValue* arguments);
@ -56,9 +56,9 @@ private:
void Add(AMFArrayValue* arguments); void Add(AMFArrayValue* arguments);
void RemoveActions(AMFArrayValue* arguments); void RemoveActions(AMFArrayValue* arguments);
void Rename(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments); void Rename(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments);
void SendBehaviorBlocksToClient(ModelComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments); void SendBehaviorBlocksToClient(std::shared_ptr<ModelComponent> modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments);
void UpdateAction(AMFArrayValue* arguments); void UpdateAction(AMFArrayValue* arguments);
void MoveToInventory(ModelComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments); void MoveToInventory(std::shared_ptr<ModelComponent> modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments);
std::map<BlockName, BlockDefinition*> blockTypes{}; std::map<BlockName, BlockDefinition*> blockTypes{};
// If false, property behaviors will not be able to be edited. // If false, property behaviors will not be able to be edited.

View File

@ -137,7 +137,7 @@ LootGenerator::LootGenerator() {
} }
std::unordered_map<LOT, int32_t> LootGenerator::RollLootMatrix(Entity* player, uint32_t matrixIndex) { std::unordered_map<LOT, int32_t> LootGenerator::RollLootMatrix(Entity* player, uint32_t matrixIndex) {
auto* missionComponent = player->GetComponent<MissionComponent>(); auto missionComponent = player->GetComponent<MissionComponent>();
std::unordered_map<LOT, int32_t> drops; std::unordered_map<LOT, int32_t> drops;
@ -283,7 +283,7 @@ void LootGenerator::GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceTy
void LootGenerator::GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& result, eLootSourceType lootSourceType) { void LootGenerator::GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& result, eLootSourceType lootSourceType) {
player = player->GetOwner(); // if the owner is overwritten, we collect that here player = player->GetOwner(); // if the owner is overwritten, we collect that here
auto* inventoryComponent = player->GetComponent<InventoryComponent>(); auto inventoryComponent = player->GetComponent<InventoryComponent>();
if (!inventoryComponent) if (!inventoryComponent)
return; return;
@ -330,7 +330,7 @@ void LootGenerator::GiveActivityLoot(Entity* player, Entity* source, uint32_t ac
void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) { void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) {
player = player->GetOwner(); // if the owner is overwritten, we collect that here player = player->GetOwner(); // if the owner is overwritten, we collect that here
auto* inventoryComponent = player->GetComponent<InventoryComponent>(); auto inventoryComponent = player->GetComponent<InventoryComponent>();
if (!inventoryComponent) if (!inventoryComponent)
return; return;
@ -343,7 +343,7 @@ void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matr
void LootGenerator::DropLoot(Entity* player, Entity* killedObject, std::unordered_map<LOT, int32_t>& result, uint32_t minCoins, uint32_t maxCoins) { void LootGenerator::DropLoot(Entity* player, Entity* killedObject, std::unordered_map<LOT, int32_t>& result, uint32_t minCoins, uint32_t maxCoins) {
player = player->GetOwner(); // if the owner is overwritten, we collect that here player = player->GetOwner(); // if the owner is overwritten, we collect that here
auto* inventoryComponent = player->GetComponent<InventoryComponent>(); auto inventoryComponent = player->GetComponent<InventoryComponent>();
if (!inventoryComponent) if (!inventoryComponent)
return; return;

View File

@ -197,7 +197,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd
//Inventory::InventoryType itemType; //Inventory::InventoryType itemType;
int mailCost = dZoneManager::Instance()->GetWorldConfig()->mailBaseFee; int mailCost = dZoneManager::Instance()->GetWorldConfig()->mailBaseFee;
int stackSize = 0; int stackSize = 0;
auto inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = entity->GetComponent<InventoryComponent>();
Item* item = nullptr; Item* item = nullptr;
if (itemID > 0 && attachmentCount > 0 && inv) { if (itemID > 0 && attachmentCount > 0 && inv) {
@ -267,7 +267,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd
Game::logger->Log("Mail", "Trying to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT); Game::logger->Log("Mail", "Trying to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT);
inv->RemoveItem(itemLOT, attachmentCount, INVALID, true); inv->RemoveItem(itemLOT, attachmentCount, INVALID, true);
auto* missionCompoent = entity->GetComponent<MissionComponent>(); auto missionCompoent = entity->GetComponent<MissionComponent>();
if (missionCompoent != nullptr) { if (missionCompoent != nullptr) {
missionCompoent->Progress(eMissionTaskType::GATHER, itemLOT, LWOOBJID_EMPTY, "", -attachmentCount); missionCompoent->Progress(eMissionTaskType::GATHER, itemLOT, LWOOBJID_EMPTY, "", -attachmentCount);
@ -356,7 +356,7 @@ void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddres
attachmentCount = res->getInt(2); attachmentCount = res->getInt(2);
} }
auto inv = static_cast<InventoryComponent*>(player->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = player->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
inv->AddItem(attachmentLOT, attachmentCount, eLootSourceType::MAIL); inv->AddItem(attachmentLOT, attachmentCount, eLootSourceType::MAIL);

View File

@ -115,10 +115,10 @@ bool Precondition::Check(Entity* player, bool evaluateCosts) const {
bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluateCosts) const { bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluateCosts) const {
auto* missionComponent = player->GetComponent<MissionComponent>(); auto missionComponent = player->GetComponent<MissionComponent>();
auto* inventoryComponent = player->GetComponent<InventoryComponent>(); auto inventoryComponent = player->GetComponent<InventoryComponent>();
auto* destroyableComponent = player->GetComponent<DestroyableComponent>(); auto destroyableComponent = player->GetComponent<DestroyableComponent>();
auto* levelComponent = player->GetComponent<LevelProgressionComponent>(); auto levelComponent = player->GetComponent<LevelProgressionComponent>();
auto* character = player->GetCharacter(); auto* character = player->GetCharacter();
Mission* mission; Mission* mission;

View File

@ -176,7 +176,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (chatCommand == "pvp") { if (chatCommand == "pvp") {
auto* character = entity->GetComponent<CharacterComponent>(); auto character = entity->GetComponent<CharacterComponent>();
if (character == nullptr) { if (character == nullptr) {
Game::logger->Log("SlashCommandHandler", "Failed to find character component!"); Game::logger->Log("SlashCommandHandler", "Failed to find character component!");
@ -227,9 +227,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
if (chatCommand == "fix-stats") { if (chatCommand == "fix-stats") {
// Reset skill component and buff component // Reset skill component and buff component
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto skillComponent = entity->GetComponent<SkillComponent>();
auto* buffComponent = entity->GetComponent<BuffComponent>(); auto buffComponent = entity->GetComponent<BuffComponent>();
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>(); auto destroyableComponent = entity->GetComponent<DestroyableComponent>();
// If any of the components are nullptr, return // If any of the components are nullptr, return
if (skillComponent == nullptr || buffComponent == nullptr || destroyableComponent == nullptr) { if (skillComponent == nullptr || buffComponent == nullptr || destroyableComponent == nullptr) {
@ -336,7 +336,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
if (chatCommand == "resurrect") { if (chatCommand == "resurrect") {
ScriptedActivityComponent* scriptedActivityComponent = dZoneManager::Instance()->GetZoneControlObject()->GetComponent<ScriptedActivityComponent>(); auto scriptedActivityComponent = dZoneManager::Instance()->GetZoneControlObject()->GetComponent<ScriptedActivityComponent>();
if (scriptedActivityComponent) { // check if user is in activity world and if so, they can't resurrect if (scriptedActivityComponent) { // check if user is in activity world and if so, they can't resurrect
ChatPackets::SendSystemMessage(sysAddr, u"You cannot resurrect in an activity world."); ChatPackets::SendSystemMessage(sysAddr, u"You cannot resurrect in an activity world.");
@ -373,7 +373,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
EntityManager::Instance()->DestructEntity(entity, sysAddr); EntityManager::Instance()->DestructEntity(entity, sysAddr);
auto* charComp = entity->GetComponent<CharacterComponent>(); auto charComp = entity->GetComponent<CharacterComponent>();
std::string lowerName = args[0]; std::string lowerName = args[0];
if (lowerName.empty()) return; if (lowerName.empty()) return;
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower); std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower);
@ -413,7 +413,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
if ((chatCommand == "playanimation" || chatCommand == "playanim") && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { if ((chatCommand == "playanimation" || chatCommand == "playanim") && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
std::u16string anim = GeneralUtils::ASCIIToUTF16(args[0], args[0].size()); std::u16string anim = GeneralUtils::ASCIIToUTF16(args[0], args[0].size());
RenderComponent::PlayAnimation(entity, anim); RenderComponent::PlayAnimation(entity, anim);
auto* possessorComponent = entity->GetComponent<PossessorComponent>(); auto possessorComponent = entity->GetComponent<PossessorComponent>();
if (possessorComponent) { if (possessorComponent) {
auto* possessedComponent = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable()); auto* possessedComponent = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
if (possessedComponent) RenderComponent::PlayAnimation(possessedComponent, anim); if (possessedComponent) RenderComponent::PlayAnimation(possessedComponent, anim);
@ -468,7 +468,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
auto* controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>(); auto controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
if (!controllablePhysicsComponent) return; if (!controllablePhysicsComponent) return;
controllablePhysicsComponent->SetSpeedMultiplier(boost); controllablePhysicsComponent->SetSpeedMultiplier(boost);
@ -480,7 +480,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
if (possessedID != LWOOBJID_EMPTY) { if (possessedID != LWOOBJID_EMPTY) {
auto possessable = EntityManager::Instance()->GetEntity(possessedID); auto possessable = EntityManager::Instance()->GetEntity(possessedID);
if (possessable) { if (possessable) {
auto* possessControllablePhysicsComponent = possessable->GetComponent<ControllablePhysicsComponent>(); auto possessControllablePhysicsComponent = possessable->GetComponent<ControllablePhysicsComponent>();
if (possessControllablePhysicsComponent) { if (possessControllablePhysicsComponent) {
possessControllablePhysicsComponent->SetSpeedMultiplier(boost); possessControllablePhysicsComponent->SetSpeedMultiplier(boost);
} }
@ -579,7 +579,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
GeneralUtils::to_u16string(size)); GeneralUtils::to_u16string(size));
} else ChatPackets::SendSystemMessage(sysAddr, u"Setting inventory ITEMS to size " + GeneralUtils::to_u16string(size)); } else ChatPackets::SendSystemMessage(sysAddr, u"Setting inventory ITEMS to size " + GeneralUtils::to_u16string(size));
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
if (inventoryComponent) { if (inventoryComponent) {
auto* inventory = inventoryComponent->GetInventory(selectedInventory); auto* inventory = inventoryComponent->GetInventory(selectedInventory);
@ -629,7 +629,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
auto comp = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION)); auto comp = entity->GetComponent<MissionComponent>();
if (comp) comp->AcceptMission(missionID, true); if (comp) comp->AcceptMission(missionID, true);
return; return;
} }
@ -644,7 +644,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
auto comp = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION)); auto comp = entity->GetComponent<MissionComponent>();
if (comp) comp->CompleteMission(missionID, true); if (comp) comp->CompleteMission(missionID, true);
return; return;
} }
@ -694,7 +694,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
auto* comp = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION)); auto comp = entity->GetComponent<MissionComponent>();
if (comp == nullptr) { if (comp == nullptr) {
return; return;
@ -771,7 +771,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
if (chatCommand == "getnavmeshheight" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { if (chatCommand == "getnavmeshheight" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
auto control = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); auto control = entity->GetComponent<ControllablePhysicsComponent>();
if (!control) return; if (!control) return;
float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(control->GetPosition()); float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(control->GetPosition());
@ -788,7 +788,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
InventoryComponent* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inventory = entity->GetComponent<InventoryComponent>();
inventory->AddItem(itemLOT, 1, eLootSourceType::MODERATION); inventory->AddItem(itemLOT, 1, eLootSourceType::MODERATION);
} else if (args.size() == 2) { } else if (args.size() == 2) {
@ -806,7 +806,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
InventoryComponent* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY)); auto inventory = entity->GetComponent<InventoryComponent>();
inventory->AddItem(itemLOT, count, eLootSourceType::MODERATION); inventory->AddItem(itemLOT, count, eLootSourceType::MODERATION);
} else { } else {
@ -935,12 +935,12 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
auto* possessorComponent = entity->GetComponent<PossessorComponent>(); auto possessorComponent = entity->GetComponent<PossessorComponent>();
if (possessorComponent) { if (possessorComponent) {
auto* possassableEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable()); auto* possassableEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
if (possassableEntity != nullptr) { if (possassableEntity != nullptr) {
auto* vehiclePhysicsComponent = possassableEntity->GetComponent<VehiclePhysicsComponent>(); auto vehiclePhysicsComponent = possassableEntity->GetComponent<VehiclePhysicsComponent>();
if (vehiclePhysicsComponent) { if (vehiclePhysicsComponent) {
vehiclePhysicsComponent->SetPosition(pos); vehiclePhysicsComponent->SetPosition(pos);
EntityManager::Instance()->SerializeEntity(possassableEntity); EntityManager::Instance()->SerializeEntity(possassableEntity);
@ -962,7 +962,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
if (chatCommand == "dismount" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { if (chatCommand == "dismount" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
auto* possessorComponent = entity->GetComponent<PossessorComponent>(); auto possessorComponent = entity->GetComponent<PossessorComponent>();
if (possessorComponent) { if (possessorComponent) {
auto possessableId = possessorComponent->GetPossessable(); auto possessableId = possessorComponent->GetPossessable();
if (possessableId != LWOOBJID_EMPTY) { if (possessableId != LWOOBJID_EMPTY) {
@ -1171,7 +1171,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
//------------------------------------------------- //-------------------------------------------------
if (chatCommand == "buffme" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { if (chatCommand == "buffme" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
auto dest = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); auto dest = entity->GetComponent<DestroyableComponent>();
if (dest) { if (dest) {
dest->SetHealth(999); dest->SetHealth(999);
dest->SetMaxHealth(999.0f); dest->SetMaxHealth(999.0f);
@ -1195,7 +1195,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
if (chatCommand == "buffmed" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { if (chatCommand == "buffmed" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
auto dest = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); auto dest = entity->GetComponent<DestroyableComponent>();
if (dest) { if (dest) {
dest->SetHealth(9); dest->SetHealth(9);
dest->SetMaxHealth(9.0f); dest->SetMaxHealth(9.0f);
@ -1209,7 +1209,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
if (chatCommand == "refillstats" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { if (chatCommand == "refillstats" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
auto dest = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); auto dest = entity->GetComponent<DestroyableComponent>();
if (dest) { if (dest) {
dest->SetHealth((int)dest->GetMaxHealth()); dest->SetHealth((int)dest->GetMaxHealth());
dest->SetArmor((int)dest->GetMaxArmor()); dest->SetArmor((int)dest->GetMaxArmor());
@ -1242,7 +1242,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
if (chatCommand == "spawn" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) { if (chatCommand == "spawn" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
ControllablePhysicsComponent* comp = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); auto comp = entity->GetComponent<ControllablePhysicsComponent>();
if (!comp) return; if (!comp) return;
uint32_t lot; uint32_t lot;
@ -1341,7 +1341,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
CharacterComponent* character = entity->GetComponent<CharacterComponent>(); auto character = entity->GetComponent<CharacterComponent>();
if (character) character->SetUScore(character->GetUScore() + uscore); if (character) character->SetUScore(character->GetUScore() + uscore);
// MODERATION should work but it doesn't. Relog to see uscore changes // MODERATION should work but it doesn't. Relog to see uscore changes
@ -1486,7 +1486,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
if (chatCommand == "gmimmune" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { if (chatCommand == "gmimmune" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>(); auto destroyableComponent = entity->GetComponent<DestroyableComponent>();
int32_t state = false; int32_t state = false;
@ -1503,7 +1503,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
if (chatCommand == "buff" && args.size() >= 2 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { if (chatCommand == "buff" && args.size() >= 2 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
auto* buffComponent = entity->GetComponent<BuffComponent>(); auto buffComponent = entity->GetComponent<BuffComponent>();
int32_t id = 0; int32_t id = 0;
int32_t duration = 0; int32_t duration = 0;
@ -1615,7 +1615,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
if ((chatCommand == "boost") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { if ((chatCommand == "boost") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
auto* possessorComponent = entity->GetComponent<PossessorComponent>(); auto possessorComponent = entity->GetComponent<PossessorComponent>();
if (possessorComponent == nullptr) { if (possessorComponent == nullptr) {
return; return;
@ -1647,7 +1647,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
if ((chatCommand == "unboost") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { if ((chatCommand == "unboost") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
auto* possessorComponent = entity->GetComponent<PossessorComponent>(); auto possessorComponent = entity->GetComponent<PossessorComponent>();
if (possessorComponent == nullptr) return; if (possessorComponent == nullptr) return;
auto* vehicle = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable()); auto* vehicle = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
@ -1674,7 +1674,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
//Go tell physics to spawn all the vertices: //Go tell physics to spawn all the vertices:
auto entities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::PHANTOM_PHYSICS); auto entities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::PHANTOM_PHYSICS);
for (auto en : entities) { for (auto en : entities) {
auto phys = static_cast<PhantomPhysicsComponent*>(en->GetComponent(eReplicaComponentType::PHANTOM_PHYSICS)); auto phys = en->GetComponent<PhantomPhysicsComponent>();
if (phys) if (phys)
phys->SpawnVertices(); phys->SpawnVertices();
} }
@ -1683,7 +1683,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
if (chatCommand == "reportproxphys" && entity->GetGMLevel() >= eGameMasterLevel::JUNIOR_DEVELOPER) { if (chatCommand == "reportproxphys" && entity->GetGMLevel() >= eGameMasterLevel::JUNIOR_DEVELOPER) {
auto entities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::PROXIMITY_MONITOR); auto entities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::PROXIMITY_MONITOR);
for (auto en : entities) { for (auto en : entities) {
auto phys = static_cast<ProximityMonitorComponent*>(en->GetComponent(eReplicaComponentType::PROXIMITY_MONITOR)); auto phys = en->GetComponent<ProximityMonitorComponent>();
if (phys) { if (phys) {
for (auto prox : phys->GetProximitiesData()) { for (auto prox : phys->GetProximitiesData()) {
if (!prox.second) continue; if (!prox.second) continue;
@ -1717,7 +1717,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
if (!GeneralUtils::TryParse(args[0], baseItem)) return; if (!GeneralUtils::TryParse(args[0], baseItem)) return;
if (!GeneralUtils::TryParse(args[1], reforgedItem)) return; if (!GeneralUtils::TryParse(args[1], reforgedItem)) return;
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) return; if (inventoryComponent == nullptr) return;
@ -1779,7 +1779,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
dpWorld::Instance().Reload(); dpWorld::Instance().Reload();
auto entities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY); auto entities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
for (auto entity : entities) { for (auto entity : entities) {
auto* scriptedActivityComponent = entity->GetComponent<ScriptedActivityComponent>(); auto scriptedActivityComponent = entity->GetComponent<ScriptedActivityComponent>();
if (!scriptedActivityComponent) continue; if (!scriptedActivityComponent) continue;
scriptedActivityComponent->ReloadConfig(); scriptedActivityComponent->ReloadConfig();
@ -1842,7 +1842,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
if (!inventoryComponent) return; if (!inventoryComponent) return;
auto* inventoryToDelete = inventoryComponent->GetInventory(inventoryType); auto* inventoryToDelete = inventoryComponent->GetInventory(inventoryType);
@ -1930,7 +1930,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
if (args.size() >= 2) { if (args.size() >= 2) {
if (args[1] == "-m" && args.size() >= 3) { if (args[1] == "-m" && args.size() >= 3) {
auto* movingPlatformComponent = closest->GetComponent<MovingPlatformComponent>(); auto movingPlatformComponent = closest->GetComponent<MovingPlatformComponent>();
int32_t value = 0; int32_t value = 0;
@ -1964,7 +1964,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
GeneralUtils::ASCIIToUTF16("< " + std::to_string(postion.x) + ", " + std::to_string(postion.y) + ", " + std::to_string(postion.z) + " >") GeneralUtils::ASCIIToUTF16("< " + std::to_string(postion.x) + ", " + std::to_string(postion.y) + ", " + std::to_string(postion.z) + " >")
); );
} else if (args[1] == "-f") { } else if (args[1] == "-f") {
auto* destuctable = closest->GetComponent<DestroyableComponent>(); auto destuctable = closest->GetComponent<DestroyableComponent>();
if (destuctable == nullptr) { if (destuctable == nullptr) {
ChatPackets::SendSystemMessage(sysAddr, u"No destroyable component on this entity!"); ChatPackets::SendSystemMessage(sysAddr, u"No destroyable component on this entity!");
@ -1993,7 +1993,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
destuctable->AddFaction(faction, true); destuctable->AddFaction(faction, true);
} }
} else if (args[1] == "-t") { } else if (args[1] == "-t") {
auto* phantomPhysicsComponent = closest->GetComponent<PhantomPhysicsComponent>(); auto phantomPhysicsComponent = closest->GetComponent<PhantomPhysicsComponent>();
if (phantomPhysicsComponent != nullptr) { if (phantomPhysicsComponent != nullptr) {
ChatPackets::SendSystemMessage(sysAddr, u"Type: " + (GeneralUtils::to_u16string(static_cast<uint32_t>(phantomPhysicsComponent->GetEffectType())))); ChatPackets::SendSystemMessage(sysAddr, u"Type: " + (GeneralUtils::to_u16string(static_cast<uint32_t>(phantomPhysicsComponent->GetEffectType()))));
@ -2003,7 +2003,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
ChatPackets::SendSystemMessage(sysAddr, u"Active: " + (GeneralUtils::to_u16string(phantomPhysicsComponent->GetPhysicsEffectActive()))); ChatPackets::SendSystemMessage(sysAddr, u"Active: " + (GeneralUtils::to_u16string(phantomPhysicsComponent->GetPhysicsEffectActive())));
} }
auto* triggerComponent = closest->GetComponent<TriggerComponent>(); auto triggerComponent = closest->GetComponent<TriggerComponent>();
if (triggerComponent) { if (triggerComponent) {
auto trigger = triggerComponent->GetTrigger(); auto trigger = triggerComponent->GetTrigger();
if (trigger) { if (trigger) {

View File

@ -117,7 +117,7 @@ void VanityUtilities::SpawnVanity() {
npcEntity->SetVar<std::vector<std::string>>(u"chats", npc.m_Phrases); npcEntity->SetVar<std::vector<std::string>>(u"chats", npc.m_Phrases);
auto* scriptComponent = npcEntity->GetComponent<ScriptComponent>(); auto scriptComponent = npcEntity->GetComponent<ScriptComponent>();
if (scriptComponent != nullptr) { if (scriptComponent != nullptr) {
scriptComponent->SetScript(npc.m_Script); scriptComponent->SetScript(npc.m_Script);
@ -161,13 +161,13 @@ Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoin
auto* entity = EntityManager::Instance()->CreateEntity(info); auto* entity = EntityManager::Instance()->CreateEntity(info);
entity->SetVar(u"npcName", name); entity->SetVar(u"npcName", name);
auto* inventoryComponent = entity->GetComponent<InventoryComponent>(); auto inventoryComponent = entity->GetComponent<InventoryComponent>();
if (inventoryComponent != nullptr) { if (inventoryComponent != nullptr) {
inventoryComponent->SetNPCItems(inventory); inventoryComponent->SetNPCItems(inventory);
} }
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>(); auto destroyableComponent = entity->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
destroyableComponent->SetIsGMImmune(true); destroyableComponent->SetIsGMImmune(true);
@ -519,7 +519,7 @@ void VanityUtilities::SetupNPCTalk(Entity* npc) {
} }
void VanityUtilities::NPCTalk(Entity* npc) { void VanityUtilities::NPCTalk(Entity* npc) {
auto* proximityMonitorComponent = npc->GetComponent<ProximityMonitorComponent>(); auto proximityMonitorComponent = npc->GetComponent<ProximityMonitorComponent>();
if (!proximityMonitorComponent->GetProximityObjects("talk").empty()) { if (!proximityMonitorComponent->GetProximityObjects("talk").empty()) {
const auto& chats = npc->GetVar<std::vector<std::string>>(u"chats"); const auto& chats = npc->GetVar<std::vector<std::string>>(u"chats");

View File

@ -29,9 +29,9 @@ void BossSpiderQueenEnemyServer::OnStartup(Entity* self) {
//self:SetStatusImmunity{ StateChangeType = "PUSH", bImmuneToPullToPoint = true, bImmuneToKnockback = true, bImmuneToInterrupt = true } //self:SetStatusImmunity{ StateChangeType = "PUSH", bImmuneToPullToPoint = true, bImmuneToKnockback = true, bImmuneToInterrupt = true }
//Get our components: //Get our components:
destroyable = static_cast<DestroyableComponent*>(self->GetComponent(eReplicaComponentType::DESTROYABLE)); auto destroyable = self->GetComponent<DestroyableComponent>();
controllable = static_cast<ControllablePhysicsComponent*>(self->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); auto controllable = self->GetComponent<ControllablePhysicsComponent>();
combat = static_cast<BaseCombatAIComponent*>(self->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); auto combat = self->GetComponent<BaseCombatAIComponent>();
if (!destroyable || !controllable) return; if (!destroyable || !controllable) return;
@ -53,7 +53,7 @@ void BossSpiderQueenEnemyServer::OnStartup(Entity* self) {
void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) { void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) {
if (dZoneManager::Instance()->GetZoneID().GetMapID() == instanceZoneID) { if (dZoneManager::Instance()->GetZoneID().GetMapID() == instanceZoneID) {
auto* missionComponent = killer->GetComponent<MissionComponent>(); auto missionComponent = killer->GetComponent<MissionComponent>();
if (missionComponent == nullptr) if (missionComponent == nullptr)
return; return;
@ -99,7 +99,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
EntityManager::Instance()->SerializeEntity(self); EntityManager::Instance()->SerializeEntity(self);
auto* baseCombatAi = self->GetComponent<BaseCombatAIComponent>(); auto baseCombatAi = self->GetComponent<BaseCombatAIComponent>();
baseCombatAi->SetDisabled(true); baseCombatAi->SetDisabled(true);
@ -123,7 +123,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
//Cancel all remaining timers for say idle anims: //Cancel all remaining timers for say idle anims:
self->CancelAllTimers(); self->CancelAllTimers();
auto* baseCombatAi = self->GetComponent<BaseCombatAIComponent>(); auto baseCombatAi = self->GetComponent<BaseCombatAIComponent>();
baseCombatAi->SetDisabled(false); baseCombatAi->SetDisabled(false);
@ -314,7 +314,7 @@ void BossSpiderQueenEnemyServer::RainOfFireManager(Entity* self) {
return; return;
} }
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto skillComponent = entity->GetComponent<SkillComponent>();
if (skillComponent == nullptr) { if (skillComponent == nullptr) {
Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find impact skill component!"); Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find impact skill component!");
@ -347,7 +347,7 @@ void BossSpiderQueenEnemyServer::RapidFireShooterManager(Entity* self) {
const auto target = attackTargetTable[0]; const auto target = attackTargetTable[0];
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
skillComponent->CalculateBehavior(1394, 32612, target, true); skillComponent->CalculateBehavior(1394, 32612, target, true);
@ -381,7 +381,7 @@ void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self) {
attackTargetTable.push_back(attackFocus); attackTargetTable.push_back(attackFocus);
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
skillComponent->CalculateBehavior(1480, 36652, attackFocus, true); skillComponent->CalculateBehavior(1480, 36652, attackFocus, true);
@ -493,14 +493,14 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
auto landingTarget = self->GetI64(u"LandingTarget"); auto landingTarget = self->GetI64(u"LandingTarget");
auto landingEntity = EntityManager::Instance()->GetEntity(landingTarget); auto landingEntity = EntityManager::Instance()->GetEntity(landingTarget);
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent != nullptr) { if (skillComponent != nullptr) {
skillComponent->CalculateBehavior(bossLandingSkill, 37739, LWOOBJID_EMPTY); skillComponent->CalculateBehavior(bossLandingSkill, 37739, LWOOBJID_EMPTY);
} }
if (landingEntity) { if (landingEntity) {
auto* landingSkill = landingEntity->GetComponent<SkillComponent>(); auto landingSkill = landingEntity->GetComponent<SkillComponent>();
if (landingSkill != nullptr) { if (landingSkill != nullptr) {
landingSkill->CalculateBehavior(bossLandingSkill, 37739, LWOOBJID_EMPTY, true); landingSkill->CalculateBehavior(bossLandingSkill, 37739, LWOOBJID_EMPTY, true);

View File

@ -12,7 +12,7 @@
void AmDarklingDragon::OnStartup(Entity* self) { void AmDarklingDragon::OnStartup(Entity* self) {
self->SetVar<int32_t>(u"weakspot", 0); self->SetVar<int32_t>(u"weakspot", 0);
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (baseCombatAIComponent != nullptr) { if (baseCombatAIComponent != nullptr) {
baseCombatAIComponent->SetStunImmune(true); baseCombatAIComponent->SetStunImmune(true);
@ -46,7 +46,7 @@ void AmDarklingDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t
} }
} }
auto* destroyableComponent = self->GetComponent<DestroyableComponent>(); auto destroyableComponent = self->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
if (destroyableComponent->GetArmor() > 0) return; if (destroyableComponent->GetArmor() > 0) return;
@ -56,8 +56,8 @@ void AmDarklingDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t
if (weakpoint == 0) { if (weakpoint == 0) {
self->AddTimer("ReviveTimer", 12); self->AddTimer("ReviveTimer", 12);
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (baseCombatAIComponent != nullptr) { if (baseCombatAIComponent != nullptr) {
baseCombatAIComponent->SetDisabled(true); baseCombatAIComponent->SetDisabled(true);
@ -127,8 +127,8 @@ void AmDarklingDragon::OnTimerDone(Entity* self, std::string timerName) {
RenderComponent::PlayAnimation(self, u"stunend", 2.0f); RenderComponent::PlayAnimation(self, u"stunend", 2.0f);
self->AddTimer("backToAttack", 1); self->AddTimer("backToAttack", 1);
} else if (timerName == "backToAttack") { } else if (timerName == "backToAttack") {
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (baseCombatAIComponent != nullptr) { if (baseCombatAIComponent != nullptr) {
baseCombatAIComponent->SetDisabled(false); baseCombatAIComponent->SetDisabled(false);
baseCombatAIComponent->SetStunned(false); baseCombatAIComponent->SetStunned(false);

View File

@ -3,8 +3,8 @@
#include "SkillComponent.h" #include "SkillComponent.h"
void AmSkeletonEngineer::OnHit(Entity* self, Entity* attacker) { void AmSkeletonEngineer::OnHit(Entity* self, Entity* attacker) {
auto* destroyableComponent = self->GetComponent<DestroyableComponent>(); auto destroyableComponent = self->GetComponent<DestroyableComponent>();
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (destroyableComponent == nullptr || skillComponent == nullptr) { if (destroyableComponent == nullptr || skillComponent == nullptr) {
return; return;

View File

@ -10,7 +10,7 @@
void FvMaelstromDragon::OnStartup(Entity* self) { void FvMaelstromDragon::OnStartup(Entity* self) {
self->SetVar<int32_t>(u"weakspot", 0); self->SetVar<int32_t>(u"weakspot", 0);
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (baseCombatAIComponent != nullptr) { if (baseCombatAIComponent != nullptr) {
baseCombatAIComponent->SetStunImmune(true); baseCombatAIComponent->SetStunImmune(true);
@ -59,7 +59,7 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_
} }
} }
auto* destroyableComponent = self->GetComponent<DestroyableComponent>(); auto destroyableComponent = self->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
if (destroyableComponent->GetArmor() > 0) return; if (destroyableComponent->GetArmor() > 0) return;
@ -71,8 +71,8 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_
self->AddTimer("ReviveTimer", 12); self->AddTimer("ReviveTimer", 12);
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (baseCombatAIComponent != nullptr) { if (baseCombatAIComponent != nullptr) {
baseCombatAIComponent->SetDisabled(true); baseCombatAIComponent->SetDisabled(true);
@ -143,8 +143,8 @@ void FvMaelstromDragon::OnTimerDone(Entity* self, std::string timerName) {
RenderComponent::PlayAnimation(self, u"stunend", 2.0f); RenderComponent::PlayAnimation(self, u"stunend", 2.0f);
self->AddTimer("backToAttack", 1.0f); self->AddTimer("backToAttack", 1.0f);
} else if (timerName == "backToAttack") { } else if (timerName == "backToAttack") {
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (baseCombatAIComponent != nullptr) { if (baseCombatAIComponent != nullptr) {
baseCombatAIComponent->SetDisabled(false); baseCombatAIComponent->SetDisabled(false);

View File

@ -31,11 +31,11 @@ void BaseEnemyApe::OnSkillCast(Entity* self, uint32_t skillID) {
} }
void BaseEnemyApe::OnHit(Entity* self, Entity* attacker) { void BaseEnemyApe::OnHit(Entity* self, Entity* attacker) {
auto* destroyableComponent = self->GetComponent<DestroyableComponent>(); auto destroyableComponent = self->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr && destroyableComponent->GetArmor() < 1 && !self->GetBoolean(u"knockedOut")) { if (destroyableComponent != nullptr && destroyableComponent->GetArmor() < 1 && !self->GetBoolean(u"knockedOut")) {
StunApe(self, true); StunApe(self, true);
self->CancelTimer("spawnQBTime"); self->CancelTimer("spawnQBTime");
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent) { if (skillComponent) {
skillComponent->Reset(); skillComponent->Reset();
} }
@ -52,7 +52,7 @@ void BaseEnemyApe::OnTimerDone(Entity* self, std::string timerName) {
// Revives the ape, giving it back some armor // Revives the ape, giving it back some armor
const auto timesStunned = self->GetVar<uint32_t>(u"timesStunned"); const auto timesStunned = self->GetVar<uint32_t>(u"timesStunned");
auto* destroyableComponent = self->GetComponent<DestroyableComponent>(); auto destroyableComponent = self->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
destroyableComponent->SetArmor(destroyableComponent->GetMaxArmor() / timesStunned); destroyableComponent->SetArmor(destroyableComponent->GetMaxArmor() / timesStunned);
} }
@ -104,7 +104,7 @@ void BaseEnemyApe::OnTimerDone(Entity* self, std::string timerName) {
return; return;
} }
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent != nullptr) { if (skillComponent != nullptr) {
skillComponent->CalculateBehavior(1273, 29446, self->GetObjectID(), true, false, player->GetObjectID()); skillComponent->CalculateBehavior(1273, 29446, self->GetObjectID(), true, false, player->GetObjectID());
} }
@ -123,12 +123,12 @@ void BaseEnemyApe::OnFireEventServerSide(Entity* self, Entity* sender, std::stri
} }
void BaseEnemyApe::StunApe(Entity* self, bool stunState) { void BaseEnemyApe::StunApe(Entity* self, bool stunState) {
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) { if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(stunState); combatAIComponent->SetDisabled(stunState);
combatAIComponent->SetStunned(stunState); combatAIComponent->SetStunned(stunState);
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent != nullptr) { if (skillComponent != nullptr) {
skillComponent->Interrupt(); skillComponent->Interrupt();
} }

View File

@ -9,14 +9,14 @@
#include "eReplicaComponentType.h" #include "eReplicaComponentType.h"
void BaseEnemyMech::OnStartup(Entity* self) { void BaseEnemyMech::OnStartup(Entity* self) {
auto* destroyableComponent = self->GetComponent<DestroyableComponent>(); auto destroyableComponent = self->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
destroyableComponent->SetFaction(4); destroyableComponent->SetFaction(4);
} }
} }
void BaseEnemyMech::OnDie(Entity* self, Entity* killer) { void BaseEnemyMech::OnDie(Entity* self, Entity* killer) {
ControllablePhysicsComponent* controlPhys = static_cast<ControllablePhysicsComponent*>(self->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); auto controlPhys = self->GetComponent<ControllablePhysicsComponent>();
if (!controlPhys) return; if (!controlPhys) return;
NiPoint3 newLoc = { controlPhys->GetPosition().x, dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(controlPhys->GetPosition()), controlPhys->GetPosition().z }; NiPoint3 newLoc = { controlPhys->GetPosition().x, dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(controlPhys->GetPosition()), controlPhys->GetPosition().z };

View File

@ -2,7 +2,7 @@
#include "SkillComponent.h" #include "SkillComponent.h"
void EnemyNjBuff::OnStartup(Entity* self) { void EnemyNjBuff::OnStartup(Entity* self) {
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent == nullptr) { if (skillComponent == nullptr) {
return; return;

View File

@ -15,7 +15,7 @@ void TreasureChestDragonServer::OnUse(Entity* self, Entity* user) {
self->SetVar<bool>(u"bUsed", true); self->SetVar<bool>(u"bUsed", true);
auto* scriptedActivityComponent = self->GetComponent<ScriptedActivityComponent>(); auto scriptedActivityComponent = self->GetComponent<ScriptedActivityComponent>();
if (scriptedActivityComponent == nullptr) { if (scriptedActivityComponent == nullptr) {
return; return;

View File

@ -4,7 +4,7 @@
void AgSurvivalMech::OnStartup(Entity* self) { void AgSurvivalMech::OnStartup(Entity* self) {
BaseWavesGenericEnemy::OnStartup(self); BaseWavesGenericEnemy::OnStartup(self);
auto* destroyable = self->GetComponent<DestroyableComponent>(); auto destroyable = self->GetComponent<DestroyableComponent>();
if (destroyable != nullptr) { if (destroyable != nullptr) {
destroyable->SetFaction(4); destroyable->SetFaction(4);
} }

View File

@ -4,7 +4,7 @@
void AgSurvivalSpiderling::OnStartup(Entity* self) { void AgSurvivalSpiderling::OnStartup(Entity* self) {
BaseWavesGenericEnemy::OnStartup(self); BaseWavesGenericEnemy::OnStartup(self);
auto* combatAI = self->GetComponent<BaseCombatAIComponent>(); auto combatAI = self->GetComponent<BaseCombatAIComponent>();
if (combatAI != nullptr) { if (combatAI != nullptr) {
combatAI->SetStunImmune(true); combatAI->SetStunImmune(true);
} }

View File

@ -11,7 +11,7 @@ void WaveBossApe::OnStartup(Entity* self) {
self->SetVar<float_t>(u"AnchorDamageDelayTime", 0.5f); self->SetVar<float_t>(u"AnchorDamageDelayTime", 0.5f);
self->SetVar<float_t>(u"spawnQBTime", 5.0f); self->SetVar<float_t>(u"spawnQBTime", 5.0f);
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) { if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(true); combatAIComponent->SetDisabled(true);
combatAIComponent->SetStunImmune(true); combatAIComponent->SetStunImmune(true);
@ -30,7 +30,7 @@ void WaveBossApe::OnDie(Entity* self, Entity* killer) {
void WaveBossApe::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, void WaveBossApe::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) { int32_t param3) {
if (args == "startAI") { if (args == "startAI") {
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) { if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(false); combatAIComponent->SetDisabled(false);
combatAIComponent->SetStunImmune(false); combatAIComponent->SetStunImmune(false);

View File

@ -5,7 +5,7 @@
void WaveBossHammerling::OnStartup(Entity* self) { void WaveBossHammerling::OnStartup(Entity* self) {
BaseWavesGenericEnemy::OnStartup(self); BaseWavesGenericEnemy::OnStartup(self);
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) { if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(true); combatAIComponent->SetDisabled(true);
combatAIComponent->SetStunImmune(true); combatAIComponent->SetStunImmune(true);
@ -17,7 +17,7 @@ void WaveBossHammerling::OnStartup(Entity* self) {
void WaveBossHammerling::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, void WaveBossHammerling::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1,
int32_t param2, int32_t param3) { int32_t param2, int32_t param3) {
if (args == "startAI") { if (args == "startAI") {
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) { if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(false); combatAIComponent->SetDisabled(false);
} }

View File

@ -5,7 +5,7 @@
void WaveBossHorsemen::OnStartup(Entity* self) { void WaveBossHorsemen::OnStartup(Entity* self) {
BaseWavesGenericEnemy::OnStartup(self); BaseWavesGenericEnemy::OnStartup(self);
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) { if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(true); combatAIComponent->SetDisabled(true);
combatAIComponent->SetStunImmune(true); combatAIComponent->SetStunImmune(true);
@ -18,7 +18,7 @@ void
WaveBossHorsemen::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, WaveBossHorsemen::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) { int32_t param3) {
if (args == "startAI") { if (args == "startAI") {
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) { if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(false); combatAIComponent->SetDisabled(false);
} }

View File

@ -5,7 +5,7 @@
void WaveBossSpiderling::OnStartup(Entity* self) { void WaveBossSpiderling::OnStartup(Entity* self) {
BaseWavesGenericEnemy::OnStartup(self); BaseWavesGenericEnemy::OnStartup(self);
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) { if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(true); combatAIComponent->SetDisabled(true);
combatAIComponent->SetStunImmune(true); combatAIComponent->SetStunImmune(true);
@ -17,7 +17,7 @@ void WaveBossSpiderling::OnStartup(Entity* self) {
void WaveBossSpiderling::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, void WaveBossSpiderling::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1,
int32_t param2, int32_t param3) { int32_t param2, int32_t param3) {
if (args == "startAI") { if (args == "startAI") {
auto* combatAIComponent = self->GetComponent<BaseCombatAIComponent>(); auto combatAIComponent = self->GetComponent<BaseCombatAIComponent>();
if (combatAIComponent != nullptr) { if (combatAIComponent != nullptr) {
combatAIComponent->SetDisabled(false); combatAIComponent->SetDisabled(false);
combatAIComponent->SetStunImmune(false); combatAIComponent->SetStunImmune(false);

View File

@ -35,13 +35,13 @@ BootyDigServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string
// Make sure players only dig up one booty per instance // Make sure players only dig up one booty per instance
player->SetVar<bool>(u"bootyDug", true); player->SetVar<bool>(u"bootyDug", true);
auto* missionComponent = player->GetComponent<MissionComponent>(); auto missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
auto* mission = missionComponent->GetMission(1881); auto* mission = missionComponent->GetMission(1881);
if (mission != nullptr && (mission->GetMissionState() == eMissionState::ACTIVE || mission->GetMissionState() == eMissionState::COMPLETE_ACTIVE)) { if (mission != nullptr && (mission->GetMissionState() == eMissionState::ACTIVE || mission->GetMissionState() == eMissionState::COMPLETE_ACTIVE)) {
mission->Progress(eMissionTaskType::SCRIPT, self->GetLOT()); mission->Progress(eMissionTaskType::SCRIPT, self->GetLOT());
auto* renderComponent = self->GetComponent<RenderComponent>(); auto renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent != nullptr) if (renderComponent != nullptr)
renderComponent->PlayEffect(7730, u"cast", "bootyshine"); renderComponent->PlayEffect(7730, u"cast", "bootyshine");

View File

@ -8,7 +8,7 @@ void AgBugsprayer::OnRebuildComplete(Entity* self, Entity* target) {
void AgBugsprayer::OnTimerDone(Entity* self, std::string timerName) { void AgBugsprayer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "castSkill") { if (timerName == "castSkill") {
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent == nullptr) return; if (skillComponent == nullptr) return;

View File

@ -21,7 +21,7 @@ void AgCagedBricksServer::OnUse(Entity* self, Entity* user) {
character->SetPlayerFlag(ePlayerFlag::CAGED_SPIDER, true); character->SetPlayerFlag(ePlayerFlag::CAGED_SPIDER, true);
//Remove the maelstrom cube: //Remove the maelstrom cube:
auto inv = static_cast<InventoryComponent*>(user->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = user->GetComponent<InventoryComponent>();
if (inv) { if (inv) {
inv->RemoveItem(14553, 1); inv->RemoveItem(14553, 1);

View File

@ -8,7 +8,7 @@ void AgLaserSensorServer::OnStartup(Entity* self) {
self->SetBoolean(u"active", true); self->SetBoolean(u"active", true);
auto repelForce = self->GetVarAs<float>(u"repelForce"); auto repelForce = self->GetVarAs<float>(u"repelForce");
if (!repelForce) repelForce = m_RepelForce; if (!repelForce) repelForce = m_RepelForce;
auto* phantomPhysicsComponent = self->GetComponent<PhantomPhysicsComponent>(); auto phantomPhysicsComponent = self->GetComponent<PhantomPhysicsComponent>();
if (!phantomPhysicsComponent) return; if (!phantomPhysicsComponent) return;
phantomPhysicsComponent->SetPhysicsEffectActive(true); phantomPhysicsComponent->SetPhysicsEffectActive(true);
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE); phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
@ -22,7 +22,7 @@ void AgLaserSensorServer::OnCollisionPhantom(Entity* self, Entity* target) {
if (!active) return; if (!active) return;
auto skillCastID = self->GetVarAs<float>(u"skillCastID"); auto skillCastID = self->GetVarAs<float>(u"skillCastID");
if (skillCastID == 0) skillCastID = m_SkillCastID; if (skillCastID == 0) skillCastID = m_SkillCastID;
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (!skillComponent) return; if (!skillComponent) return;
skillComponent->CastSkill(m_SkillCastID, target->GetObjectID()); skillComponent->CastSkill(m_SkillCastID, target->GetObjectID());
} }

View File

@ -13,7 +13,7 @@ void NpcAgCourseStarter::OnStartup(Entity* self) {
} }
void NpcAgCourseStarter::OnUse(Entity* self, Entity* user) { void NpcAgCourseStarter::OnUse(Entity* self, Entity* user) {
auto* scriptedActivityComponent = self->GetComponent<ScriptedActivityComponent>(); auto scriptedActivityComponent = self->GetComponent<ScriptedActivityComponent>();
if (scriptedActivityComponent == nullptr) { if (scriptedActivityComponent == nullptr) {
return; return;
@ -27,7 +27,7 @@ void NpcAgCourseStarter::OnUse(Entity* self, Entity* user) {
} }
void NpcAgCourseStarter::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) { void NpcAgCourseStarter::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
auto* scriptedActivityComponent = self->GetComponent<ScriptedActivityComponent>(); auto scriptedActivityComponent = self->GetComponent<ScriptedActivityComponent>();
if (scriptedActivityComponent == nullptr) { if (scriptedActivityComponent == nullptr) {
return; return;
@ -70,7 +70,7 @@ void NpcAgCourseStarter::OnMessageBoxResponse(Entity* self, Entity* sender, int3
void NpcAgCourseStarter::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, void NpcAgCourseStarter::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) { int32_t param3) {
auto* scriptedActivityComponent = self->GetComponent<ScriptedActivityComponent>(); auto scriptedActivityComponent = self->GetComponent<ScriptedActivityComponent>();
if (scriptedActivityComponent == nullptr) if (scriptedActivityComponent == nullptr)
return; return;
@ -88,7 +88,7 @@ void NpcAgCourseStarter::OnFireEventServerSide(Entity* self, Entity* sender, std
data->values[2] = *(float*)&finish; data->values[2] = *(float*)&finish;
auto* missionComponent = sender->GetComponent<MissionComponent>(); auto missionComponent = sender->GetComponent<MissionComponent>();
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
missionComponent->ForceProgressTaskType(1884, 1, 1, false); missionComponent->ForceProgressTaskType(1884, 1, 1, false);
missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, -finish, self->GetObjectID(), missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, -finish, self->GetObjectID(),

View File

@ -7,7 +7,7 @@ void NpcCowboyServer::OnMissionDialogueOK(Entity* self, Entity* target, int miss
return; return;
} }
auto* inventoryComponent = target->GetComponent<InventoryComponent>(); auto inventoryComponent = target->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) { if (inventoryComponent == nullptr) {
return; return;

View File

@ -12,7 +12,7 @@ void NpcNjAssistantServer::OnMissionDialogueOK(Entity* self, Entity* target, int
if (missionState == eMissionState::COMPLETE || missionState == eMissionState::READY_TO_COMPLETE) { if (missionState == eMissionState::COMPLETE || missionState == eMissionState::READY_TO_COMPLETE) {
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"switch", 0, 0, LWOOBJID_EMPTY, "", target->GetSystemAddress()); GameMessages::SendNotifyClientObject(self->GetObjectID(), u"switch", 0, 0, LWOOBJID_EMPTY, "", target->GetSystemAddress());
auto* inv = static_cast<InventoryComponent*>(target->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = target->GetComponent<InventoryComponent>();
// If we are ready to complete our missions, we take the kit from you: // If we are ready to complete our missions, we take the kit from you:
if (inv && missionState == eMissionState::READY_TO_COMPLETE) { if (inv && missionState == eMissionState::READY_TO_COMPLETE) {
@ -23,7 +23,7 @@ void NpcNjAssistantServer::OnMissionDialogueOK(Entity* self, Entity* target, int
} }
} }
} else if (missionState == eMissionState::AVAILABLE) { } else if (missionState == eMissionState::AVAILABLE) {
auto* missionComponent = static_cast<MissionComponent*>(target->GetComponent(eReplicaComponentType::MISSION)); auto missionComponent = target->GetComponent<MissionComponent>();
missionComponent->CompleteMission(mailAchievement, true); missionComponent->CompleteMission(mailAchievement, true);
} }
} }

View File

@ -3,7 +3,7 @@
#include "InventoryComponent.h" #include "InventoryComponent.h"
void NpcPirateServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { void NpcPirateServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
auto* inventory = target->GetComponent<InventoryComponent>(); auto inventory = target->GetComponent<InventoryComponent>();
if (inventory != nullptr && missionID == 1881) { if (inventory != nullptr && missionID == 1881) {
auto* luckyShovel = inventory->FindItemByLot(14591); auto* luckyShovel = inventory->FindItemByLot(14591);

View File

@ -9,7 +9,7 @@ void NpcWispServer::OnMissionDialogueOK(Entity* self, Entity* target, int missio
if (missionID != 1849 && missionID != 1883) if (missionID != 1849 && missionID != 1883)
return; return;
auto* inventory = target->GetComponent<InventoryComponent>(); auto inventory = target->GetComponent<InventoryComponent>();
if (inventory == nullptr) if (inventory == nullptr)
return; return;

View File

@ -23,7 +23,7 @@ void RemoveRentalGear::OnMissionDialogueOK(Entity* self, Entity* target, int mis
if (missionID != defaultMission && missionID != 313) return; if (missionID != defaultMission && missionID != 313) return;
if (missionState == eMissionState::COMPLETE || missionState == eMissionState::READY_TO_COMPLETE) { if (missionState == eMissionState::COMPLETE || missionState == eMissionState::READY_TO_COMPLETE) {
auto inv = static_cast<InventoryComponent*>(target->GetComponent(eReplicaComponentType::INVENTORY)); auto inv = target->GetComponent<InventoryComponent>();
if (!inv) return; if (!inv) return;
//remove the inventory items //remove the inventory items

View File

@ -28,7 +28,7 @@ void ZoneAgSpiderQueen::BasePlayerLoaded(Entity* self, Entity* player) {
ActivityManager::TakeActivityCost(self, player->GetObjectID()); ActivityManager::TakeActivityCost(self, player->GetObjectID());
// Make sure the player has full stats when they join // Make sure the player has full stats when they join
auto* playerDestroyableComponent = player->GetComponent<DestroyableComponent>(); auto playerDestroyableComponent = player->GetComponent<DestroyableComponent>();
if (playerDestroyableComponent != nullptr) { if (playerDestroyableComponent != nullptr) {
playerDestroyableComponent->SetImagination(playerDestroyableComponent->GetMaxImagination()); playerDestroyableComponent->SetImagination(playerDestroyableComponent->GetMaxImagination());
playerDestroyableComponent->SetArmor(playerDestroyableComponent->GetMaxArmor()); playerDestroyableComponent->SetArmor(playerDestroyableComponent->GetMaxArmor());

View File

@ -5,7 +5,7 @@
#include "Character.h" #include "Character.h"
void AmBlueX::OnUse(Entity* self, Entity* user) { void AmBlueX::OnUse(Entity* self, Entity* user) {
auto* skillComponent = user->GetComponent<SkillComponent>(); auto skillComponent = user->GetComponent<SkillComponent>();
if (skillComponent != nullptr) { if (skillComponent != nullptr) {
skillComponent->CalculateBehavior(m_SwordSkill, m_SwordBehavior, self->GetObjectID()); skillComponent->CalculateBehavior(m_SwordSkill, m_SwordBehavior, self->GetObjectID());
} }
@ -37,7 +37,7 @@ void AmBlueX::OnSkillEventFired(Entity* self, Entity* caster, const std::string&
self->AddCallbackTimer(m_BombTime, [this, self, fxObjectID, playerID]() { self->AddCallbackTimer(m_BombTime, [this, self, fxObjectID, playerID]() {
auto* fxObject = EntityManager::Instance()->GetEntity(fxObjectID); auto* fxObject = EntityManager::Instance()->GetEntity(fxObjectID);
auto* player = EntityManager::Instance()->GetEntity(playerID); auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent == nullptr) if (skillComponent == nullptr)
return; return;

View File

@ -60,7 +60,7 @@ void AmDrawBridge::OnTimerDone(Entity* self, std::string timerName) {
self->SetNetworkVar(u"BridgeLeaving", false); self->SetNetworkVar(u"BridgeLeaving", false);
auto* simplePhysicsComponent = bridge->GetComponent<SimplePhysicsComponent>(); auto simplePhysicsComponent = bridge->GetComponent<SimplePhysicsComponent>();
if (simplePhysicsComponent == nullptr) { if (simplePhysicsComponent == nullptr) {
return; return;
@ -87,7 +87,7 @@ void AmDrawBridge::OnNotifyObject(Entity* self, Entity* sender, const std::strin
} }
void AmDrawBridge::MoveBridgeDown(Entity* self, Entity* bridge, bool down) { void AmDrawBridge::MoveBridgeDown(Entity* self, Entity* bridge, bool down) {
auto* simplePhysicsComponent = bridge->GetComponent<SimplePhysicsComponent>(); auto simplePhysicsComponent = bridge->GetComponent<SimplePhysicsComponent>();
if (simplePhysicsComponent == nullptr) { if (simplePhysicsComponent == nullptr) {
return; return;

View File

@ -10,14 +10,14 @@ void AmDropshipComputer::OnStartup(Entity* self) {
} }
void AmDropshipComputer::OnUse(Entity* self, Entity* user) { void AmDropshipComputer::OnUse(Entity* self, Entity* user) {
auto* rebuildComponent = self->GetComponent<RebuildComponent>(); auto rebuildComponent = self->GetComponent<RebuildComponent>();
if (rebuildComponent == nullptr || rebuildComponent->GetState() != eRebuildState::COMPLETED) { if (rebuildComponent == nullptr || rebuildComponent->GetState() != eRebuildState::COMPLETED) {
return; return;
} }
auto* missionComponent = user->GetComponent<MissionComponent>(); auto missionComponent = user->GetComponent<MissionComponent>();
auto* inventoryComponent = user->GetComponent<InventoryComponent>(); auto inventoryComponent = user->GetComponent<InventoryComponent>();
if (missionComponent == nullptr || inventoryComponent == nullptr) { if (missionComponent == nullptr || inventoryComponent == nullptr) {
return; return;
@ -70,7 +70,7 @@ void AmDropshipComputer::OnDie(Entity* self, Entity* killer) {
} }
void AmDropshipComputer::OnTimerDone(Entity* self, std::string timerName) { void AmDropshipComputer::OnTimerDone(Entity* self, std::string timerName) {
auto* rebuildComponent = self->GetComponent<RebuildComponent>(); auto rebuildComponent = self->GetComponent<RebuildComponent>();
if (rebuildComponent == nullptr) { if (rebuildComponent == nullptr) {
return; return;

View File

@ -3,7 +3,7 @@
void AmScrollReaderServer::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) { void AmScrollReaderServer::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
if (identifier == u"story_end") { if (identifier == u"story_end") {
auto* missionComponent = sender->GetComponent<MissionComponent>(); auto missionComponent = sender->GetComponent<MissionComponent>();
if (missionComponent == nullptr) { if (missionComponent == nullptr) {
return; return;

View File

@ -15,7 +15,7 @@ void AmShieldGenerator::OnStartup(Entity* self) {
} }
void AmShieldGenerator::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { void AmShieldGenerator::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
auto* destroyableComponent = entering->GetComponent<DestroyableComponent>(); auto destroyableComponent = entering->GetComponent<DestroyableComponent>();
if (status == "ENTER" && name == "shield") { if (status == "ENTER" && name == "shield") {
if (destroyableComponent->HasFaction(4)) { if (destroyableComponent->HasFaction(4)) {
@ -102,7 +102,7 @@ void AmShieldGenerator::StartShield(Entity* self) {
} }
void AmShieldGenerator::BuffPlayers(Entity* self) { void AmShieldGenerator::BuffPlayers(Entity* self) {
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent == nullptr) { if (skillComponent == nullptr) {
return; return;
@ -122,8 +122,8 @@ void AmShieldGenerator::BuffPlayers(Entity* self) {
} }
void AmShieldGenerator::EnemyEnteredShield(Entity* self, Entity* intruder) { void AmShieldGenerator::EnemyEnteredShield(Entity* self, Entity* intruder) {
auto* baseCombatAIComponent = intruder->GetComponent<BaseCombatAIComponent>(); auto baseCombatAIComponent = intruder->GetComponent<BaseCombatAIComponent>();
auto* movementAIComponent = intruder->GetComponent<MovementAIComponent>(); auto movementAIComponent = intruder->GetComponent<MovementAIComponent>();
if (baseCombatAIComponent == nullptr || movementAIComponent == nullptr) { if (baseCombatAIComponent == nullptr || movementAIComponent == nullptr) {
return; return;

View File

@ -15,7 +15,7 @@ void AmShieldGeneratorQuickbuild::OnStartup(Entity* self) {
} }
void AmShieldGeneratorQuickbuild::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { void AmShieldGeneratorQuickbuild::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
auto* destroyableComponent = entering->GetComponent<DestroyableComponent>(); auto destroyableComponent = entering->GetComponent<DestroyableComponent>();
if (name == "shield") { if (name == "shield") {
if (!destroyableComponent->HasFaction(4) || entering->IsPlayer()) { if (!destroyableComponent->HasFaction(4) || entering->IsPlayer()) {
@ -122,7 +122,7 @@ void AmShieldGeneratorQuickbuild::OnRebuildComplete(Entity* self, Entity* target
continue; continue;
} }
auto* missionComponent = player->GetComponent<MissionComponent>(); auto missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent == nullptr) { if (missionComponent == nullptr) {
return; return;
@ -154,7 +154,7 @@ void AmShieldGeneratorQuickbuild::StartShield(Entity* self) {
} }
void AmShieldGeneratorQuickbuild::BuffPlayers(Entity* self) { void AmShieldGeneratorQuickbuild::BuffPlayers(Entity* self) {
auto* skillComponent = self->GetComponent<SkillComponent>(); auto skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent == nullptr) { if (skillComponent == nullptr) {
return; return;
@ -174,14 +174,14 @@ void AmShieldGeneratorQuickbuild::BuffPlayers(Entity* self) {
} }
void AmShieldGeneratorQuickbuild::EnemyEnteredShield(Entity* self, Entity* intruder) { void AmShieldGeneratorQuickbuild::EnemyEnteredShield(Entity* self, Entity* intruder) {
auto* rebuildComponent = self->GetComponent<RebuildComponent>(); auto rebuildComponent = self->GetComponent<RebuildComponent>();
if (rebuildComponent == nullptr || rebuildComponent->GetState() != eRebuildState::COMPLETED) { if (rebuildComponent == nullptr || rebuildComponent->GetState() != eRebuildState::COMPLETED) {
return; return;
} }
auto* baseCombatAIComponent = intruder->GetComponent<BaseCombatAIComponent>(); auto baseCombatAIComponent = intruder->GetComponent<BaseCombatAIComponent>();
auto* movementAIComponent = intruder->GetComponent<MovementAIComponent>(); auto movementAIComponent = intruder->GetComponent<MovementAIComponent>();
if (baseCombatAIComponent == nullptr || movementAIComponent == nullptr) { if (baseCombatAIComponent == nullptr || movementAIComponent == nullptr) {
return; return;

Some files were not shown because too many files have changed in this diff Show More