diff --git a/SCsub b/SCsub index ae92896..af521d0 100644 --- a/SCsub +++ b/SCsub @@ -4,6 +4,10 @@ Import('env') module_env = env.Clone() +if "ess_entity_base_class" in module_env: + module_env.Append(CPPDEFINES=[('ESS_ENTITY_BASE_CLASS', module_env["ess_entity_base_class"])]) + module_env.Append(CPPDEFINES=[('ESS_ENTITY_BASE_CLASS_INCLUDE', module_env["ess_entity_base_class_include"])]) + if os.path.isdir('../mesh_data_resource'): module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) diff --git a/config.py b/config.py index 7d83031..297241e 100644 --- a/config.py +++ b/config.py @@ -5,7 +5,14 @@ def can_build(env, platform): def configure(env): - pass + from SCons.Script import Variables, Help + + envvars = Variables() + envvars.Add("ess_entity_base_class", "What class Entity should inherit from. Default is Node.") + envvars.Add("ess_entity_base_class_include", "What The include for that class. Default is scene/main/node.h") + + envvars.Update(env) + Help(envvars.GenerateHelpText(env)) def get_doc_classes(): diff --git a/entities/entity.h b/entities/entity.h index f996ace..d584cf0 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -37,8 +37,6 @@ SOFTWARE. #include "core/io/networked_multiplayer_peer.h" -#include "scene/main/node.h" - #include "../data/items/craft_recipe.h" #include "../data/items/item_instance.h" #include "../data/spells/spell.h" @@ -69,6 +67,22 @@ SOFTWARE. #include spatial_h_path +#ifndef ESS_ENTITY_BASE_CLASS +// By default Entity inherits from Node +#define ENTITY_BASE_CLASS Node +#include "scene/main/node.h" +#else +// We turn the ESS_ENTITY_BASE_CLASS define into a text replace macro +#define ENTITY_BASE_CLASS ESS_ENTITY_BASE_CLASS + +// Abuse pre-processor macros to quote what's inside the ESS_ENTITY_BASE_CLASS_INCLUDE define +#define _ENTITY_BASE_CLASS_QUOTE(x) #x +#define _ENTITY_BASE_CLASS_QUOTE_H(x) _ENTITY_BASE_CLASS_QUOTE(x) + +#include _ENTITY_BASE_CLASS_QUOTE_H(ESS_ENTITY_BASE_CLASS_INCLUDE) +#endif + + class EntityData; class AuraData; class Spell; @@ -236,8 +250,8 @@ struct EntityStat { } \ variable = value; -class Entity : public Node { - GDCLASS(Entity, Node); +class Entity : public ENTITY_BASE_CLASS { + GDCLASS(Entity, ENTITY_BASE_CLASS); public: //// Base ////