5#define SCRIPT_CONSTR(scr) \
7 std::string __nwname = #scr; \
8 std::string GetName() { return __nwname; }; \
9 static Scriptable* GetScript(GameObject* goc); \
10 scr(GameObject* goc) { \
46 virtual void Gui() {};
72 static std::string
GetType() {
return "Script";};
88 void Start()
override;
102 script =
new T(this->attachedObj);
111 int Serialize(std::fstream* data,
int offset)
override;
119 int Deserialize(std::fstream* data,
int offset)
override;
Defines the GameObject class and its related components.
Base class for game components.
Definition GameObject.h:29
Class representing a game object.
Definition GameObject.h:68
The base class for script components.
Definition Script.h:66
Scriptable * script
Definition Script.h:83
static std::string GetType()
Gets the type of the script component.
Definition Script.h:72
int Serialize(std::fstream *data, int offset) override
Serializes the script data.
Definition Script.cpp:37
int Deserialize(std::fstream *data, int offset) override
Deserializes the script data.
Definition Script.cpp:55
static std::map< GameObject *, Script > componentList
Definition Script.h:121
void Update() override
Called every frame to update the script.
Definition Script.cpp:21
void SetScript()
Sets the script to the specified type.
Definition Script.h:100
GameObject * attachedObj
Definition Script.h:82
void Start() override
Called when the script is started.
Definition Script.cpp:16
The base class for scriptable components.
Definition Script.h:17
virtual std::string GetName()
Gets the name of the script.
Definition Script.h:58
std::string __nwname
Definition Script.h:20
GameObject * goc
Definition Script.h:19
virtual void Update()
Called every frame to update the script.
Definition Script.h:41
virtual void Start()
Called when the script is started.
Definition Script.h:36
virtual void ShaderCode(void *sprite)
Called to generate shader code for the script.
Definition Script.cpp:75
Scriptable(GameObject *goc=nullptr, void *nws=nullptr)
Constructs a Scriptable object.
Definition Script.h:27
virtual void Gui()
Called to draw the script's GUI.
Definition Script.h:46
void * nws
Definition Script.h:60