2021-12-05 17:54:36 +00:00
|
|
|
/*
|
|
|
|
* Darkflame Universe
|
|
|
|
* Copyright 2018
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SCRIPTCOMPONENT_H
|
|
|
|
#define SCRIPTCOMPONENT_H
|
|
|
|
|
|
|
|
#include "CppScripts.h"
|
|
|
|
#include "Component.h"
|
|
|
|
#include <string>
|
2023-03-04 07:16:37 +00:00
|
|
|
#include "eReplicaComponentType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
class Entity;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the loading and execution of server side scripts on entities, scripts were originally written in Lua,
|
|
|
|
* here they're written in C++
|
|
|
|
*/
|
|
|
|
class ScriptComponent : public Component {
|
|
|
|
public:
|
2023-06-09 08:22:45 +00:00
|
|
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-11 10:06:18 +00:00
|
|
|
ScriptComponent(Entity* parent, std::string scriptName);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* Returns the script that's attached to this entity
|
|
|
|
* @return the script that's attached to this entity
|
|
|
|
*/
|
|
|
|
CppScripts::Script* GetScript();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the script using a path by looking through dScripts for a script that matches
|
|
|
|
* @param scriptName the name of the script to find
|
|
|
|
*/
|
|
|
|
void SetScript(const std::string& scriptName);
|
|
|
|
|
2023-06-11 10:06:18 +00:00
|
|
|
// Get the script attached to the provided component id.
|
|
|
|
// LDF key custom_script_server overrides component id script.
|
|
|
|
static const std::string GetScriptName(Entity* parentEntity, const uint32_t componentId = 0);
|
|
|
|
|
|
|
|
static const std::string GetZoneScriptName(const uint32_t componentId);
|
2021-12-05 17:54:36 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The script attached to this entity
|
|
|
|
*/
|
|
|
|
CppScripts::Script* m_Script;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SCRIPTCOMPONENT_H
|