mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-26 23:47:21 +00:00
Use more clear control paths
This commit is contained in:
parent
d224a86e93
commit
326c495776
@ -510,28 +510,41 @@ void Entity::Initialize() {
|
||||
});
|
||||
});
|
||||
|
||||
// Load data specific to this LOT first
|
||||
std::for_each(m_Components.begin(), m_Components.end(), [this](auto& component) {
|
||||
component.second->LoadTemplateData();
|
||||
});
|
||||
|
||||
// Then load data specific to this Entity. This will vary on an Entity to Entity basis.
|
||||
// If there is data you want to override the LOT default value, generally you would attach it via LDF
|
||||
// and it would get loaded and overridden here.
|
||||
std::for_each(m_Components.begin(), m_Components.end(), [this](auto& component) {
|
||||
component.second->LoadConfigData();
|
||||
});
|
||||
|
||||
/**
|
||||
* @brief Startup all the components. Some components need or want data from other components so
|
||||
* we want to ensure that
|
||||
* A) Most if not all components are newed and ready to be accessed.
|
||||
* B) All components have their personal data loaded and ready to be used.
|
||||
*/
|
||||
std::for_each(m_Components.begin(), m_Components.end(), [this](auto& component) {
|
||||
component.second->Startup();
|
||||
});
|
||||
// No save data to load for non players
|
||||
|
||||
/**
|
||||
* @brief Load the player save data from XML. Ideally we do this after all initialization so the player
|
||||
* save data overrides any defaults that may be applied.
|
||||
*/
|
||||
if (!IsPlayer()) std::for_each(m_Components.begin(), m_Components.end(), [this](auto& component) {
|
||||
component.second->LoadFromXml(m_Character->GetXMLDoc());
|
||||
});
|
||||
|
||||
TriggerEvent(eTriggerEventType::CREATE, this);
|
||||
IsGhosted();
|
||||
if (!m_Character && EntityManager::Instance()->GetGhostingEnabled()) IsGhosted();
|
||||
}
|
||||
|
||||
void Entity::IsGhosted() {
|
||||
if (!m_Character && EntityManager::Instance()->GetGhostingEnabled()) {
|
||||
// Don't ghost what is likely large scene elements
|
||||
if (HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER) && (m_Components.size() == 2 || (HasComponent(eReplicaComponentType::TRIGGER) && m_Components.size() == 3))) {
|
||||
return;
|
||||
@ -560,7 +573,6 @@ void Entity::IsGhosted() {
|
||||
m_IsGhostingCandidate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Entity::operator==(const Entity& other) const {
|
||||
return other.m_ObjectID == m_ObjectID;
|
||||
|
@ -82,7 +82,7 @@ void DestroyableComponent::LoadConfigData() {
|
||||
SetIsSmashable(m_ParentEntity->GetVarAs<int32_t>(u"is_smashable") != 0);
|
||||
}
|
||||
void DestroyableComponent::LoadTemplateData() {
|
||||
[[unlikely]] if (m_ParentEntity->IsPlayer()) return;
|
||||
if (m_ParentEntity->IsPlayer()) return;
|
||||
auto* destroyableComponentTable = CDClientManager::Instance().GetTable<CDDestructibleComponentTable>();
|
||||
auto destroyableDataLookup = destroyableComponentTable->Query([this](CDDestructibleComponent entry) { return (entry.id == this->m_ComponentId); });
|
||||
if (m_ComponentId == -1 || destroyableDataLookup.empty()) {
|
||||
|
@ -47,10 +47,10 @@ void ScriptComponent::SetScript(const std::string& scriptName) {
|
||||
}
|
||||
|
||||
const std::string ScriptComponent::GetScriptName(Entity* parentEntity, const uint32_t componentId) {
|
||||
if (!parentEntity) return "";
|
||||
if (!parentEntity || componentId == 0) return "";
|
||||
// LDF key script overrides script component Id
|
||||
const auto customScriptServer = parentEntity->GetVarAsString(u"custom_script_server");
|
||||
if (!customScriptServer.empty() || componentId == 0) return customScriptServer;
|
||||
if (!customScriptServer.empty()) return customScriptServer;
|
||||
|
||||
auto* scriptCompTable = CDClientManager::Instance().GetTable<CDScriptComponentTable>();
|
||||
CDScriptComponent scriptCompData = scriptCompTable->GetByID(componentId);
|
||||
|
Loading…
Reference in New Issue
Block a user