Skip to content

Commit

Permalink
#5231: Rename EntityCreator to EntityModule
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed May 17, 2020
1 parent 638e918 commit 842bede
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 52 deletions.
16 changes: 8 additions & 8 deletions include/ientity.h
Expand Up @@ -317,17 +317,17 @@ class ITargetManager
};
typedef std::shared_ptr<ITargetManager> ITargetManagerPtr;

const char* const MODULE_ENTITYCREATOR("Doom3EntityCreator");
const char* const MODULE_ENTITY("EntityModule");

/**
* \brief
* Interface for the entity creator module.
* Interface for the entity module.
*/
class EntityCreator :
class IEntityModule :
public RegisterableModule
{
public:
virtual ~EntityCreator() {}
virtual ~IEntityModule() {}

/// Create an entity node with the given entity class.
virtual IEntityNodePtr createEntity(const IEntityClassPtr& eclass) = 0;
Expand All @@ -336,12 +336,12 @@ class EntityCreator :
virtual ITargetManagerPtr createTargetManager() = 0;
};

inline EntityCreator& GlobalEntityCreator()
inline IEntityModule& GlobalEntityModule()
{
// Cache the reference locally
static EntityCreator& _entityCreator(
*std::static_pointer_cast<EntityCreator>(
module::GlobalModuleRegistry().getModule(MODULE_ENTITYCREATOR)
static IEntityModule& _entityCreator(
*std::static_pointer_cast<IEntityModule>(
module::GlobalModuleRegistry().getModule(MODULE_ENTITY)
)
);
return _entityCreator;
Expand Down
2 changes: 1 addition & 1 deletion libs/entitylib.h
Expand Up @@ -436,7 +436,7 @@ inline scene::INodePtr changeEntityClassname(const scene::INodePtr& node,
assert(eclass);

// Create a new entity with the given class
IEntityNodePtr newNode(GlobalEntityCreator().createEntity(eclass));
IEntityNodePtr newNode(GlobalEntityModule().createEntity(eclass));

Entity* oldEntity = Node_getEntity(oldNode);

Expand Down
2 changes: 1 addition & 1 deletion libs/scene/BasicRootNode.h
Expand Up @@ -34,7 +34,7 @@ class BasicRootNode :
BasicRootNode()
{
_namespace = GlobalNamespaceFactory().createNamespace();
_targetManager = GlobalEntityCreator().createTargetManager();
_targetManager = GlobalEntityModule().createTargetManager();
_selectionGroupManager = GlobalSelectionGroupModule().createSelectionGroupManager();
_selectionSetManager = GlobalSelectionSetModule().createSelectionSetManager();
_layerManager = GlobalLayerModule().createLayerManager();
Expand Down
4 changes: 2 additions & 2 deletions libs/wxutil/preview/ModelPreview.cpp
Expand Up @@ -90,7 +90,7 @@ void ModelPreview::setupSceneGraph()
{
_rootNode = std::make_shared<scene::BasicRootNode>();

_entity = GlobalEntityCreator().createEntity(
_entity = GlobalEntityModule().createEntity(
GlobalEntityClassManager().findClass(FUNC_STATIC_CLASS));

_rootNode->addChildNode(_entity);
Expand All @@ -101,7 +101,7 @@ void ModelPreview::setupSceneGraph()
getScene()->setRoot(_rootNode);

// Set up the light
_light = GlobalEntityCreator().createEntity(
_light = GlobalEntityModule().createEntity(
GlobalEntityClassManager().findClass("light"));

Node_getEntity(_light)->setKeyValue("light_radius", "600 600 600");
Expand Down
2 changes: 1 addition & 1 deletion libs/wxutil/preview/ParticlePreview.cpp
Expand Up @@ -167,7 +167,7 @@ void ParticlePreview::setupSceneGraph()
{
_rootNode = std::make_shared<scene::BasicRootNode>();

_entity = GlobalEntityCreator().createEntity(
_entity = GlobalEntityModule().createEntity(
GlobalEntityClassManager().findClass(FUNC_EMITTER_CLASS));

_rootNode->addChildNode(_entity);
Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.conversation/ConversationDialog.cpp
Expand Up @@ -277,7 +277,7 @@ void ConversationDialog::onAddEntity(wxCommandEvent& ev)
if (eclass)
{
// Construct a Node of this entity type
IEntityNodePtr node(GlobalEntityCreator().createEntity(eclass));
IEntityNodePtr node(GlobalEntityModule().createEntity(eclass));

// Create a random offset
node->getEntity().setKeyValue(
Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.difficulty/DifficultySettingsManager.cpp
Expand Up @@ -212,7 +212,7 @@ void DifficultySettingsManager::saveSettings()
}

// Create and insert a new entity node into the scenegraph root
IEntityNodePtr entNode = GlobalEntityCreator().createEntity(diffEclass);
IEntityNodePtr entNode = GlobalEntityModule().createEntity(diffEclass);
GlobalSceneGraph().root()->addChildNode(entNode);

// Add the entity to the list
Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.objectives/ObjectivesEditor.cpp
Expand Up @@ -447,7 +447,7 @@ void ObjectivesEditor::_onAddEntity(wxCommandEvent& ev)
if (eclass)
{
// Construct a Node of this entity type
IEntityNodePtr node(GlobalEntityCreator().createEntity(eclass));
IEntityNodePtr node(GlobalEntityModule().createEntity(eclass));

// Create a random offset
node->getEntity().setKeyValue("origin", RandomOrigin::generate(128));
Expand Down
4 changes: 2 additions & 2 deletions plugins/script/interfaces/EntityInterface.cpp
Expand Up @@ -91,7 +91,7 @@ ScriptEntityNode ScriptEntityNode::getEntity(const ScriptSceneNode& node) {
// Creates a new entity for the given entityclass
ScriptSceneNode EntityInterface::createEntity(const ScriptEntityClass& eclass)
{
scene::INodePtr node = GlobalEntityCreator().createEntity(eclass);
scene::INodePtr node = GlobalEntityModule().createEntity(eclass);

// Add the node to the buffer otherwise it will be deleted immediately,
// as ScriptSceneNodes are using weak_ptrs.
Expand All @@ -110,7 +110,7 @@ ScriptSceneNode EntityInterface::createEntity(const std::string& eclassName) {
return ScriptSceneNode(scene::INodePtr());
}

scene::INodePtr node = GlobalEntityCreator().createEntity(eclass);
scene::INodePtr node = GlobalEntityModule().createEntity(eclass);

// Add the node to the buffer otherwise it will be deleted immediately,
// as ScriptSceneNodes are using weak_ptrs.
Expand Down
2 changes: 1 addition & 1 deletion radiant/Makefile.am
Expand Up @@ -93,7 +93,7 @@ darkradiant_SOURCES = main.cpp \
entity/curve/CurveEditInstance.cpp \
entity/curve/CurveNURBS.cpp \
entity/AngleKey.cpp \
entity/EntityCreator.cpp \
entity/EntityModule.cpp \
eventmanager/Accelerator.cpp \
eventmanager/EventManager.cpp \
eventmanager/GlobalKeyEventFilter.cpp \
Expand Down
@@ -1,4 +1,4 @@
#include "EntityCreator.h"
#include "EntityModule.h"
#include "EntitySettings.h"

#include "itextstream.h"
Expand Down Expand Up @@ -70,7 +70,7 @@ IEntityNodePtr createNodeForEntity(const IEntityClassPtr& eclass)
return node;
}

IEntityNodePtr Doom3EntityCreator::createEntity(const IEntityClassPtr& eclass)
IEntityNodePtr Doom3EntityModule::createEntity(const IEntityClassPtr& eclass)
{
IEntityNodePtr node = createNodeForEntity(eclass);

Expand Down Expand Up @@ -102,19 +102,19 @@ IEntityNodePtr Doom3EntityCreator::createEntity(const IEntityClassPtr& eclass)
return node;
}

ITargetManagerPtr Doom3EntityCreator::createTargetManager()
ITargetManagerPtr Doom3EntityModule::createTargetManager()
{
return std::make_shared<TargetManager>();
}

// RegisterableModule implementation
const std::string& Doom3EntityCreator::getName() const
const std::string& Doom3EntityModule::getName() const
{
static std::string _name(MODULE_ENTITYCREATOR);
static std::string _name(MODULE_ENTITY);
return _name;
}

const StringSet& Doom3EntityCreator::getDependencies() const
const StringSet& Doom3EntityModule::getDependencies() const
{
static StringSet _dependencies;

Expand All @@ -128,9 +128,9 @@ const StringSet& Doom3EntityCreator::getDependencies() const
return _dependencies;
}

void Doom3EntityCreator::initialiseModule(const ApplicationContext& ctx)
void Doom3EntityModule::initialiseModule(const ApplicationContext& ctx)
{
rMessage() << "Doom3EntityCreator::initialiseModule called." << std::endl;
rMessage() << getName() << "::initialiseModule called." << std::endl;

LightShader::m_defaultShader = game::current::getValue<std::string>("/defaults/lightShader");

Expand All @@ -139,15 +139,15 @@ void Doom3EntityCreator::initialiseModule(const ApplicationContext& ctx)
GlobalEventManager().addRegistryToggle("ToggleDragResizeEntitiesSymmetrically", RKEY_DRAG_RESIZE_SYMMETRICALLY);
}

void Doom3EntityCreator::shutdownModule()
void Doom3EntityModule::shutdownModule()
{
rMessage() << "Doom3EntityCreator::shutdownModule called." << std::endl;
rMessage() << getName() << "::shutdownModule called." << std::endl;

// Destroy the settings instance
EntitySettings::destroy();
}

// Static module instance
module::StaticModule<Doom3EntityCreator> entityCreatorModule;
module::StaticModule<Doom3EntityModule> entityModule;

} // namespace entity
Expand Up @@ -6,12 +6,11 @@
namespace entity
{

/// Implementation of the EntityCreator interface for Doom 3
class Doom3EntityCreator :
public EntityCreator
/// Implementation of the IEntityModule interface for Doom 3
class Doom3EntityModule :
public IEntityModule
{
public:

// EntityCreator implementation
IEntityNodePtr createEntity(const IEntityClassPtr& eclass) override;
ITargetManagerPtr createTargetManager() override;
Expand All @@ -22,6 +21,5 @@ class Doom3EntityCreator :
virtual void initialiseModule(const ApplicationContext& ctx) override;
virtual void shutdownModule() override;
};
typedef std::shared_ptr<Doom3EntityCreator> Doom3EntityCreatorPtr;

} // namespace entity
2 changes: 1 addition & 1 deletion radiant/map/Map.cpp
Expand Up @@ -255,7 +255,7 @@ scene::INodePtr Map::findWorldspawn()

scene::INodePtr Map::createWorldspawn()
{
scene::INodePtr worldspawn(GlobalEntityCreator().createEntity(
scene::INodePtr worldspawn(GlobalEntityModule().createEntity(
GlobalEntityClassManager().findOrInsert("worldspawn", true)));

// We want the world spawn entity to go for the pole position
Expand Down
2 changes: 1 addition & 1 deletion radiant/map/RegionManager.cpp
Expand Up @@ -152,7 +152,7 @@ void RegionManager::addRegionBrushes()
IEntityClassPtr playerStart = GlobalEntityClassManager().findOrInsert(eClassPlayerStart, false);

// Create the info_player_start entity
_playerStart = GlobalEntityCreator().createEntity(playerStart);
_playerStart = GlobalEntityModule().createEntity(playerStart);

ui::CamWndPtr camWnd = GlobalCamera().getActiveCamWnd();

Expand Down
2 changes: 1 addition & 1 deletion radiant/map/RootNode.cpp
Expand Up @@ -17,7 +17,7 @@ RootNode::RootNode(const std::string& name) :
_namespace = GlobalNamespaceFactory().createNamespace();
assert(_namespace);

_targetManager = GlobalEntityCreator().createTargetManager();
_targetManager = GlobalEntityModule().createTargetManager();
assert(_targetManager);

_selectionGroupManager = GlobalSelectionGroupModule().createSelectionGroupManager();
Expand Down
2 changes: 1 addition & 1 deletion radiant/map/format/Doom3MapReader.cpp
Expand Up @@ -179,7 +179,7 @@ scene::INodePtr Doom3MapReader::createEntity(const EntityKeyValues& keyValues)
}

// Create the actual entity node
IEntityNodePtr node(GlobalEntityCreator().createEntity(classPtr));
IEntityNodePtr node(GlobalEntityModule().createEntity(classPtr));

for (EntityKeyValues::const_iterator i = keyValues.begin();
i != keyValues.end();
Expand Down
2 changes: 1 addition & 1 deletion radiant/map/format/Quake3MapReader.cpp
Expand Up @@ -137,7 +137,7 @@ scene::INodePtr Quake3MapReader::createEntity(const EntityKeyValues& keyValues)
}

// Create the actual entity node
IEntityNodePtr node(GlobalEntityCreator().createEntity(classPtr));
IEntityNodePtr node(GlobalEntityModule().createEntity(classPtr));

for (EntityKeyValues::const_iterator i = keyValues.begin();
i != keyValues.end();
Expand Down
2 changes: 1 addition & 1 deletion radiant/map/format/portable/PortableMapReader.cpp
Expand Up @@ -375,7 +375,7 @@ void PortableMapReader::readEntity(const xml::Node& entityTag)
}

// Create the actual entity node
auto entityNode = GlobalEntityCreator().createEntity(eclass);
auto entityNode = GlobalEntityModule().createEntity(eclass);

for (const auto& pair : entityKeyValues)
{
Expand Down
2 changes: 1 addition & 1 deletion radiant/selection/algorithm/Curves.cpp
Expand Up @@ -54,7 +54,7 @@ void createCurve(const std::string& key)
);

// Create a new entity node deriving from this entityclass
IEntityNodePtr curve(GlobalEntityCreator().createEntity(entityClass));
IEntityNodePtr curve(GlobalEntityModule().createEntity(entityClass));

// Insert this new node into the scenegraph root
GlobalSceneGraph().root()->addChildNode(curve);
Expand Down
2 changes: 1 addition & 1 deletion radiant/selection/algorithm/Entity.cpp
Expand Up @@ -275,7 +275,7 @@ scene::INodePtr createEntityFromSelection(const std::string& name, const Vector3
AABB workzone = GlobalSelectionSystem().getWorkZone().bounds;

// Create the new node for the entity
IEntityNodePtr node(GlobalEntityCreator().createEntity(entityClass));
IEntityNodePtr node(GlobalEntityModule().createEntity(entityClass));

GlobalSceneGraph().root()->addChildNode(node);

Expand Down
2 changes: 1 addition & 1 deletion radiant/uimanager/animationpreview/AnimationPreview.cpp
Expand Up @@ -152,7 +152,7 @@ void AnimationPreview::setupSceneGraph()

_root = std::make_shared<scene::BasicRootNode>();

_entity = GlobalEntityCreator().createEntity(
_entity = GlobalEntityModule().createEntity(
GlobalEntityClassManager().findClass(FUNC_STATIC_CLASS)
);

Expand Down
4 changes: 2 additions & 2 deletions tools/msvc/DarkRadiant.vcxproj
Expand Up @@ -205,7 +205,7 @@
<ClCompile Include="..\..\radiant\entity\doom3group\Doom3Group.cpp" />
<ClCompile Include="..\..\radiant\entity\doom3group\Doom3GroupNode.cpp" />
<ClCompile Include="..\..\radiant\entity\eclassmodel\EclassModelNode.cpp" />
<ClCompile Include="..\..\radiant\entity\EntityCreator.cpp" />
<ClCompile Include="..\..\radiant\entity\EntityModule.cpp" />
<ClCompile Include="..\..\radiant\entity\EntityNode.cpp" />
<ClCompile Include="..\..\radiant\entity\EntitySettings.cpp" />
<ClCompile Include="..\..\radiant\entity\generic\GenericEntity.cpp" />
Expand Down Expand Up @@ -976,7 +976,7 @@
<ClInclude Include="..\..\radiant\entity\doom3group\Doom3Group.h" />
<ClInclude Include="..\..\radiant\entity\doom3group\Doom3GroupNode.h" />
<ClInclude Include="..\..\radiant\entity\eclassmodel\EclassModelNode.h" />
<ClInclude Include="..\..\radiant\entity\EntityCreator.h" />
<ClInclude Include="..\..\radiant\entity\EntityModule.h" />
<ClInclude Include="..\..\radiant\entity\EntityNode.h" />
<ClInclude Include="..\..\radiant\entity\EntitySettings.h" />
<ClInclude Include="..\..\radiant\entity\generic\GenericEntity.h" />
Expand Down
12 changes: 6 additions & 6 deletions tools/msvc/DarkRadiant.vcxproj.filters
Expand Up @@ -967,9 +967,6 @@
<ClCompile Include="..\..\radiant\entity\Doom3Entity.cpp">
<Filter>src\entity</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\entity\EntityCreator.cpp">
<Filter>src\entity</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\entity\EntityNode.cpp">
<Filter>src\entity</Filter>
</ClCompile>
Expand Down Expand Up @@ -1363,6 +1360,9 @@
<ClCompile Include="..\..\radiant\render\View.cpp">
<Filter>src\render</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\entity\EntityModule.cpp">
<Filter>src\entity</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\radiant\RadiantModule.h">
Expand Down Expand Up @@ -2262,9 +2262,6 @@
<ClInclude Include="..\..\radiant\entity\Doom3Entity.h">
<Filter>src\entity</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\entity\EntityCreator.h">
<Filter>src\entity</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\entity\EntityNode.h">
<Filter>src\entity</Filter>
</ClInclude>
Expand Down Expand Up @@ -2697,6 +2694,9 @@
<ClInclude Include="..\..\radiant\render\RenderStatistics.h">
<Filter>src\render</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\entity\EntityModule.h">
<Filter>src\entity</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\radiant\darkradiant.rc" />
Expand Down

0 comments on commit 842bede

Please sign in to comment.