refactor(component): the script component picks its own script

The ScriptComponent row (server and client script) loads in
LoadDataFromTemplate and custom_script_server / custom_script_client in
LoadConfigData, out of Entity::Initialize, which only decides whether there
is one (a registry entry, a character or a custom script), as the client's
allocator does. Same scripts and bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-01 16:03:00 -05:00
parent bff3fe6363
commit 4ea1762e0a
3 changed files with 51 additions and 48 deletions

View File

@@ -26,6 +26,13 @@ public:
ScriptComponent(Entity* parent, const int32_t componentID, const std::string& scriptName, bool serialized, bool client = false);
// One the object's registry or level config gives (LWOScriptComponent's allocator): its script comes from the
// ScriptComponent row and custom_script_server / custom_script_client
ScriptComponent(Entity* parent, const int32_t componentID);
void LoadDataFromTemplate() override;
void LoadConfigData() override;
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
/**
@@ -79,6 +86,11 @@ private:
bool m_Client;
std::string m_ScriptName;
// Made from the registry / level config: LoadDataFromTemplate and LoadConfigData pick the script
bool m_FromObject = false;
// The row's client script name (the client runs one when there is no server script)
std::string m_ClientScriptName;
};
#endif // SCRIPTCOMPONENT_H