DarkflameServer/dScripts/ScriptComponent.h
David Markowitz 8cdb388915
Optimize scripts for faster compilation (#597)
* Implement Precompiled Headers

* First volume of optimizations

* Scripts A-B

Gonna be doing this in alphabetical order now.

* C Scripts and remove unneeded includes from base cppscripts header

Remove the MissionComponent and Loot includes from all base scripts and place their needed includes in the respective scripts.

* D scripts

* F scripts

* F scripts 2

Finish up removing extraneous includes from scripts that start with the letter F

* G scripts

Removing extraneous includes from scripts that start with the letter G

* I scripts

Removing extraneous includes from scripts that start with the letter I

* M-Z scripts

Removing extraneous includes from scripts that start with the letter M-Z

* Revert "Implement Precompiled Headers"

This reverts commit d79d8d4991.

* Revert "Revert "Implement Precompiled Headers""

This reverts commit 0597faf308.

* Add back in PCH

Add back in PCH

* Fix CMake

Whitespace

Remove duplicate file glob

Remove newline
2022-07-04 23:00:10 -07:00

65 lines
1.5 KiB
C++

/*
* Darkflame Universe
* Copyright 2018
*/
#ifndef SCRIPTCOMPONENT_H
#define SCRIPTCOMPONENT_H
#include "CppScripts.h"
#include "Component.h"
#include <string>
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:
static const uint32_t ComponentType = COMPONENT_TYPE_SCRIPT;
ScriptComponent(Entity* parent, std::string scriptName, bool serialized, bool client = false);
~ScriptComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
/**
* Returns the script that's attached to this entity
* @return the script that's attached to this entity
*/
CppScripts::Script* GetScript();
/**
* Sets whether the entity should be serialized, unused
* @param var whether the entity should be serialized
*/
void SetSerialized(const bool var) { m_Serialized = var; }
/**
* 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);
private:
/**
* The script attached to this entity
*/
CppScripts::Script* m_Script;
/**
* Whether or not the comp should be serialized, unused
*/
bool m_Serialized;
/**
* Whether or not this script is a client script
*/
bool m_Client;
};
#endif // SCRIPTCOMPONENT_H