mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-08 00:58:26 +00:00
Rename some variables in Component
And add more virtuals
This commit is contained in:
@@ -8,9 +8,9 @@ std::vector<SwitchComponent*> SwitchComponent::petSwitches;
|
||||
SwitchComponent::SwitchComponent(Entity* parent) : Component(parent) {
|
||||
m_Active = false;
|
||||
|
||||
m_ResetTime = m_Parent->GetVarAs<int32_t>(u"switch_reset_time");
|
||||
m_ResetTime = m_OwningEntity->GetVarAs<int32_t>(u"switch_reset_time");
|
||||
|
||||
m_Rebuild = m_Parent->GetComponent<RebuildComponent>();
|
||||
m_Rebuild = m_OwningEntity->GetComponent<RebuildComponent>();
|
||||
}
|
||||
|
||||
SwitchComponent::~SwitchComponent() {
|
||||
@@ -43,10 +43,10 @@ void SwitchComponent::EntityEnter(Entity* entity) {
|
||||
if (m_Rebuild->GetState() != eRebuildState::COMPLETED) return;
|
||||
}
|
||||
m_Active = true;
|
||||
if (!m_Parent) return;
|
||||
m_Parent->TriggerEvent(eTriggerEventType::ACTIVATED, entity);
|
||||
if (!m_OwningEntity) return;
|
||||
m_OwningEntity->TriggerEvent(eTriggerEventType::ACTIVATED, entity);
|
||||
|
||||
const auto grpName = m_Parent->GetVarAsString(u"grp_name");
|
||||
const auto grpName = m_OwningEntity->GetVarAsString(u"grp_name");
|
||||
|
||||
if (!grpName.empty()) {
|
||||
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
|
||||
@@ -59,11 +59,11 @@ void SwitchComponent::EntityEnter(Entity* entity) {
|
||||
m_Timer = m_ResetTime;
|
||||
|
||||
if (m_PetBouncer != nullptr) {
|
||||
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true);
|
||||
RenderComponent::PlayAnimation(m_Parent, u"engaged");
|
||||
GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true);
|
||||
RenderComponent::PlayAnimation(m_OwningEntity, u"engaged");
|
||||
m_PetBouncer->SetPetBouncerEnabled(true);
|
||||
} else {
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -79,10 +79,10 @@ void SwitchComponent::Update(float deltaTime) {
|
||||
|
||||
if (m_Timer <= 0.0f) {
|
||||
m_Active = false;
|
||||
if (!m_Parent) return;
|
||||
m_Parent->TriggerEvent(eTriggerEventType::DEACTIVATED, m_Parent);
|
||||
if (!m_OwningEntity) return;
|
||||
m_OwningEntity->TriggerEvent(eTriggerEventType::DEACTIVATED, m_OwningEntity);
|
||||
|
||||
const auto grpName = m_Parent->GetVarAsString(u"grp_name");
|
||||
const auto grpName = m_OwningEntity->GetVarAsString(u"grp_name");
|
||||
|
||||
if (!grpName.empty()) {
|
||||
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
|
||||
@@ -95,14 +95,14 @@ void SwitchComponent::Update(float deltaTime) {
|
||||
if (m_PetBouncer != nullptr) {
|
||||
m_PetBouncer->SetPetBouncerEnabled(false);
|
||||
} else {
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Entity* SwitchComponent::GetParentEntity() const {
|
||||
return m_Parent;
|
||||
return m_OwningEntity;
|
||||
}
|
||||
|
||||
SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) {
|
||||
@@ -110,7 +110,7 @@ SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) {
|
||||
SwitchComponent* closest = nullptr;
|
||||
|
||||
for (SwitchComponent* petSwitch : petSwitches) {
|
||||
float distance = Vector3::DistanceSquared(petSwitch->m_Parent->GetPosition(), position);
|
||||
float distance = Vector3::DistanceSquared(petSwitch->m_OwningEntity->GetPosition(), position);
|
||||
|
||||
if (closest == nullptr || distance < closestDistance) {
|
||||
closestDistance = distance;
|
||||
|
||||
Reference in New Issue
Block a user