mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-27 18:51:57 +00:00
Use only 1 script component per Entity
Serialization won't make sense if we allow two of the same component like that
This commit is contained in:
@@ -269,11 +269,13 @@ void Entity::Initialize() {
|
|||||||
AddComponent<PlayerForcedMovementComponent>();
|
AddComponent<PlayerForcedMovementComponent>();
|
||||||
break;
|
break;
|
||||||
case eReplicaComponentType::SCRIPT: {
|
case eReplicaComponentType::SCRIPT: {
|
||||||
AddComponent<ScriptComponent>(ScriptComponent::GetScriptName(this, componentId));
|
std::string script;
|
||||||
if (m_TemplateID == LOT_ZONE_CONTROL) {
|
if (m_TemplateID == LOT_ZONE_CONTROL) {
|
||||||
const auto zoneScript = ScriptComponent::GetZoneScriptName(componentId);
|
script = ScriptComponent::GetZoneScriptName(componentId);
|
||||||
if (!zoneScript.empty()) AddComponent<ScriptComponent>(zoneScript);
|
} else {
|
||||||
|
script = ScriptComponent::GetScriptName(this, componentId);
|
||||||
}
|
}
|
||||||
|
AddComponent<ScriptComponent>(script); // Technically this should check for if the script name is empty and not create a component if it is.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eReplicaComponentType::BOUNCER:
|
case eReplicaComponentType::BOUNCER:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "CDZoneTableTable.h"
|
#include "CDZoneTableTable.h"
|
||||||
#include "dZoneManager.h"
|
#include "dZoneManager.h"
|
||||||
|
|
||||||
ScriptComponent::ScriptComponent(Entity* parent, std::string scriptName) : Component(parent) {
|
ScriptComponent::ScriptComponent(Entity* parent, const std::string& scriptName) : Component(parent) {
|
||||||
SetScript(scriptName);
|
SetScript(scriptName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class ScriptComponent : public Component {
|
|||||||
public:
|
public:
|
||||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
|
||||||
|
|
||||||
ScriptComponent(Entity* parent, std::string scriptName);
|
ScriptComponent(Entity* parent, const std::string& scriptName);
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user