mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-20 10:45:27 +00:00
refactor(component): the rail activator loads its row and level config in the client's phases
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
RailActivatorComponent::RailActivatorComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
|
RailActivatorComponent::RailActivatorComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
|
||||||
RegisterMsg(&RailActivatorComponent::OnRequestUse);
|
RegisterMsg(&RailActivatorComponent::OnRequestUse);
|
||||||
const auto tableData = CDClientManager::GetTable<CDRailActivatorComponentTable>()->GetEntryByID(componentID);
|
}
|
||||||
|
|
||||||
m_Path = parent->GetVar<std::u16string>(u"rail_path");
|
// The RailActivatorComponent row
|
||||||
m_PathDirection = parent->GetVar<bool>(u"rail_path_direction");
|
void RailActivatorComponent::LoadDataFromTemplate() {
|
||||||
m_PathStart = parent->GetVar<uint32_t>(u"rail_path_start");
|
const auto tableData = CDClientManager::GetTable<CDRailActivatorComponentTable>()->GetEntryByID(m_ComponentID);
|
||||||
|
|
||||||
m_StartSound = tableData.startSound;
|
m_StartSound = tableData.startSound;
|
||||||
m_loopSound = tableData.loopSound;
|
m_loopSound = tableData.loopSound;
|
||||||
@@ -35,22 +35,33 @@ RailActivatorComponent::RailActivatorComponent(Entity* parent, const int32_t com
|
|||||||
m_LoopEffect = tableData.loopEffectID;
|
m_LoopEffect = tableData.loopEffectID;
|
||||||
m_StopEffect = tableData.stopEffectID;
|
m_StopEffect = tableData.stopEffectID;
|
||||||
|
|
||||||
// The RailActivatorComponent row gives these (the client reads DamageImmune, NoAggro and ShowNameBillboard in
|
// The client reads DamageImmune, NoAggro and ShowNameBillboard from the row in
|
||||||
// LWOPlayerForcedMovementComponent::LoadRailData 0x00c85dc0); a level key, when there, replaces the row's value
|
// LWOPlayerForcedMovementComponent::LoadRailData (0x00c85dc0)
|
||||||
// as StartRailMovement's flags replace the row's in msgStartRailMovement (0x00ccd9c0) unless bUseDB is set.
|
m_DamageImmune = tableData.damageImmune;
|
||||||
const auto levelOr = [parent](const std::u16string& key, const bool tableValue) {
|
m_NoAggro = tableData.noAggro;
|
||||||
return parent->HasVar(key) ? parent->GetVar<bool>(key) : tableValue;
|
m_ShowNameBillboard = tableData.showNameBillboard;
|
||||||
};
|
|
||||||
m_DamageImmune = levelOr(u"rail_activator_damage_immune", tableData.damageImmune);
|
|
||||||
m_NoAggro = levelOr(u"rail_no_aggro", tableData.noAggro);
|
|
||||||
m_NotifyArrived = parent->GetVar<bool>(u"rail_notify_activator_arrived");
|
|
||||||
m_ShowNameBillboard = levelOr(u"rail_show_name_billboard", tableData.showNameBillboard);
|
|
||||||
m_UseDB = parent->GetVar<bool>(u"rail_use_db");
|
|
||||||
m_Active = levelOr(u"rail_activator_active", true);
|
|
||||||
m_CameraLocked = tableData.cameraLocked;
|
m_CameraLocked = tableData.cameraLocked;
|
||||||
m_CollisionEnabled = tableData.playerCollision;
|
m_CollisionEnabled = tableData.playerCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The level config: a key, when there, replaces the row's value, as StartRailMovement's flags replace the row's in
|
||||||
|
// msgStartRailMovement (0x00ccd9c0) unless bUseDB is set
|
||||||
|
void RailActivatorComponent::LoadConfigData() {
|
||||||
|
m_Path = m_Parent->GetVar<std::u16string>(u"rail_path");
|
||||||
|
m_PathDirection = m_Parent->GetVar<bool>(u"rail_path_direction");
|
||||||
|
m_PathStart = m_Parent->GetVar<uint32_t>(u"rail_path_start");
|
||||||
|
|
||||||
|
const auto levelOr = [this](const std::u16string& key, const bool tableValue) {
|
||||||
|
return m_Parent->HasVar(key) ? m_Parent->GetVar<bool>(key) : tableValue;
|
||||||
|
};
|
||||||
|
m_DamageImmune = levelOr(u"rail_activator_damage_immune", m_DamageImmune);
|
||||||
|
m_NoAggro = levelOr(u"rail_no_aggro", m_NoAggro);
|
||||||
|
m_NotifyArrived = m_Parent->GetVar<bool>(u"rail_notify_activator_arrived");
|
||||||
|
m_ShowNameBillboard = levelOr(u"rail_show_name_billboard", m_ShowNameBillboard);
|
||||||
|
m_UseDB = m_Parent->GetVar<bool>(u"rail_use_db");
|
||||||
|
m_Active = levelOr(u"rail_activator_active", true);
|
||||||
|
}
|
||||||
|
|
||||||
RailActivatorComponent::~RailActivatorComponent() = default;
|
RailActivatorComponent::~RailActivatorComponent() = default;
|
||||||
|
|
||||||
bool RailActivatorComponent::OnRequestUse(GameMessages::RequestUseEvent& event) {
|
bool RailActivatorComponent::OnRequestUse(GameMessages::RequestUseEvent& event) {
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ public:
|
|||||||
explicit RailActivatorComponent(Entity* parent, const int32_t componentID);
|
explicit RailActivatorComponent(Entity* parent, const int32_t componentID);
|
||||||
~RailActivatorComponent() override;
|
~RailActivatorComponent() override;
|
||||||
|
|
||||||
|
void LoadDataFromTemplate() override;
|
||||||
|
void LoadConfigData() override;
|
||||||
|
|
||||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RAIL_ACTIVATOR;
|
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RAIL_ACTIVATOR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user