Renamed EntityFile to EntityXMLFile to be able to separate file parsing from entity creation
This commit is contained in:
@@ -134,13 +134,13 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
class EntityFile : public Resource
|
||||
class EntityXMLFile : public Resource
|
||||
{
|
||||
friend class ResourceManager;
|
||||
friend class EntityFileSAXHandler;
|
||||
private:
|
||||
EntityFile(boost::filesystem::path path);
|
||||
~EntityFile();
|
||||
EntityXMLFile(boost::filesystem::path path);
|
||||
~EntityXMLFile();
|
||||
|
||||
public:
|
||||
static unsigned int GetTypeStride(std::string typeName);
|
||||
@@ -1,18 +1,18 @@
|
||||
#ifndef EntityFileParser_h__
|
||||
#define EntityFileParser_h__
|
||||
|
||||
#include "EntityFile.h"
|
||||
#include "EntityXMLFile.h"
|
||||
#include "World.h"
|
||||
|
||||
class EntityFileParser
|
||||
class EntityXMLFileParser
|
||||
{
|
||||
public:
|
||||
EntityFileParser(const EntityFile* entityFile);
|
||||
EntityXMLFileParser(const EntityXMLFile* entityFile);
|
||||
|
||||
EntityID MergeEntities(World* world, EntityID baseParent = EntityID_Invalid);
|
||||
|
||||
private:
|
||||
const EntityFile* m_EntityFile;
|
||||
const EntityXMLFile* m_EntityFile;
|
||||
EntityFileHandler m_Handler;
|
||||
World* m_World = nullptr;
|
||||
EntityID m_FirstEntity = EntityID_Invalid;
|
||||
+4
-4
@@ -17,17 +17,17 @@
|
||||
#include "Util/XercesString.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "World.h"
|
||||
#include "EntityFile.h"
|
||||
#include "EntityXMLFile.h"
|
||||
|
||||
class EntityFilePreprocessor
|
||||
class EntityXMLFilePreprocessor
|
||||
{
|
||||
public:
|
||||
EntityFilePreprocessor(const EntityFile* entityFile);
|
||||
EntityXMLFilePreprocessor(const EntityXMLFile* entityFile);
|
||||
|
||||
void RegisterComponents(World* world);
|
||||
|
||||
private:
|
||||
const EntityFile* m_EntityFile;
|
||||
const EntityXMLFile* m_EntityFile;
|
||||
std::map<std::string, unsigned int> m_ComponentCounts;
|
||||
std::map<std::string, ComponentInfo> m_ComponentInfo;
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
#include <xercesc/framework/LocalFileFormatTarget.hpp>
|
||||
|
||||
#include "Util/XercesString.h"
|
||||
#include "EntityFile.h"
|
||||
#include "EntityXMLFile.h"
|
||||
#include "World.h"
|
||||
|
||||
class EntityFileWriter
|
||||
class EntityXMLFileWriter
|
||||
{
|
||||
public:
|
||||
EntityFileWriter(boost::filesystem::path file)
|
||||
EntityXMLFileWriter(boost::filesystem::path file)
|
||||
: m_FilePath(file)
|
||||
{
|
||||
using namespace xercesc;
|
||||
@@ -5,9 +5,9 @@
|
||||
#include "../Core/World.h"
|
||||
#include "../Core/SystemPipeline.h"
|
||||
#include "../Core/ResourceManager.h"
|
||||
#include "../Core/EntityFilePreprocessor.h"
|
||||
#include "../Core/EntityFileParser.h"
|
||||
#include "../Core/EntityFileWriter.h"
|
||||
#include "../Core/EntityXMLFilePreprocessor.h"
|
||||
#include "../Core/EntityXMLFileParser.h"
|
||||
#include "../Core/EntityXMLFileWriter.h"
|
||||
#include "../Core/EMousePress.h"
|
||||
#include "../Input/EInputCommand.h"
|
||||
#include "EditorGUI.h"
|
||||
|
||||
+3
-3
@@ -13,13 +13,13 @@
|
||||
#include "Input/KeyboardInputHandler.h"
|
||||
#include "Input/MouseInputHandler.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EntityFilePreprocessor.h"
|
||||
#include "Core/EntityXMLFilePreprocessor.h"
|
||||
#include "Core/SystemPipeline.h"
|
||||
#include "Systems/ExplosionEffectSystem.h"
|
||||
#include "Editor/EditorSystem.h"
|
||||
#include "Core/EntityFile.h"
|
||||
#include "Core/EntityXMLFile.h"
|
||||
#include "Rendering/RenderSystem.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
#include "Core/Octree.h"
|
||||
#include "Rendering/Font.h"
|
||||
#include "Systems/InterpolationSystem.h"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "Core/System.h"
|
||||
#include "Core/Transform.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
#include "Core/EPickupSpawned.h"
|
||||
#include "Core/EAmmoPickup.h"
|
||||
#include "Engine/Collision/ETrigger.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
#include "Core/EPlayerDamage.h"
|
||||
#include "Common.h"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "Core/System.h"
|
||||
#include "Core/Transform.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
#include "Core/EPlayerDamage.h"
|
||||
#include "Common.h"
|
||||
#include <tuple>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "Core/System.h"
|
||||
#include "Core/Transform.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
#include "Core/EPickupSpawned.h"
|
||||
#include "Core/EPlayerHealthPickup.h"
|
||||
#include "Engine/Collision/ETrigger.h"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "Rendering/ESetCamera.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
|
||||
#include "Core/EntityFile.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityXMLFile.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
|
||||
#include "Core/EPlayerDeath.h"
|
||||
#include "Core/EEntityDeleted.h"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "Events/EDoubleJump.h"
|
||||
#include "../Engine/Sound/EPlaySoundOnEntity.h"
|
||||
|
||||
#include "Core/EntityFile.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityXMLFile.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
|
||||
class PlayerMovementSystem : public ImpureSystem
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "Events/ESpawnerSpawn.h"
|
||||
#include "Core/Transform.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
|
||||
class SpawnerSystem : public System
|
||||
{
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "Core/EShoot.h"
|
||||
#include "Core/EPlayerSpawned.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
#include "Core/EntityFile.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityXMLFile.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
#include "Core/Octree.h"
|
||||
#include "Collision/EntityAABB.h"
|
||||
#include "Systems/SpawnerSystem.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "Core/EntityFile.h"
|
||||
#include "Core/EntityXMLFile.h"
|
||||
|
||||
EntityFile::EntityFile(boost::filesystem::path path)
|
||||
EntityXMLFile::EntityXMLFile(boost::filesystem::path path)
|
||||
: m_FilePath(path)
|
||||
{
|
||||
using namespace xercesc;
|
||||
@@ -9,14 +9,14 @@ EntityFile::EntityFile(boost::filesystem::path path)
|
||||
m_SAX2XMLReader = XMLReaderFactory::createXMLReader(XMLPlatformUtils::fgMemoryManager, m_GrammarPool);
|
||||
}
|
||||
|
||||
EntityFile::~EntityFile()
|
||||
EntityXMLFile::~EntityXMLFile()
|
||||
{
|
||||
delete m_SAX2XMLReader;
|
||||
delete m_GrammarPool;
|
||||
xercesc::XMLPlatformUtils::Terminate();
|
||||
}
|
||||
|
||||
void EntityFile::Parse(const EntityFileHandler* handler) const
|
||||
void EntityXMLFile::Parse(const EntityFileHandler* handler) const
|
||||
{
|
||||
using namespace xercesc;
|
||||
|
||||
@@ -28,7 +28,7 @@ void EntityFile::Parse(const EntityFileHandler* handler) const
|
||||
m_SAX2XMLReader->parse(m_FilePath.string().c_str());
|
||||
}
|
||||
|
||||
void EntityFile::setReaderFeatures(xercesc::SAX2XMLReader* reader)
|
||||
void EntityXMLFile::setReaderFeatures(xercesc::SAX2XMLReader* reader)
|
||||
{
|
||||
using namespace xercesc;
|
||||
reader->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true);
|
||||
@@ -41,7 +41,7 @@ void EntityFile::setReaderFeatures(xercesc::SAX2XMLReader* reader)
|
||||
reader->setFeature(XMLUni::fgXercesIdentityConstraintChecking, true);
|
||||
}
|
||||
|
||||
unsigned int EntityFile::GetTypeStride(std::string typeName)
|
||||
unsigned int EntityXMLFile::GetTypeStride(std::string typeName)
|
||||
{
|
||||
std::map<std::string, unsigned int> typeStrides{
|
||||
{ "bool", sizeof(bool) },
|
||||
@@ -59,7 +59,7 @@ unsigned int EntityFile::GetTypeStride(std::string typeName)
|
||||
return (it != typeStrides.end()) ? it->second : 0;
|
||||
}
|
||||
|
||||
void EntityFile::WriteAttributeData(char* outData, const ComponentInfo::Field_t& field, const std::map<std::string, std::string>& attributes)
|
||||
void EntityXMLFile::WriteAttributeData(char* outData, const ComponentInfo::Field_t& field, const std::map<std::string, std::string>& attributes)
|
||||
{
|
||||
if (field.Type == "Vector") {
|
||||
glm::vec3 vec;
|
||||
@@ -86,7 +86,7 @@ void EntityFile::WriteAttributeData(char* outData, const ComponentInfo::Field_t&
|
||||
}
|
||||
}
|
||||
|
||||
void EntityFile::WriteValueData(char* outData, const ComponentInfo::Field_t& field, const char* valueData)
|
||||
void EntityXMLFile::WriteValueData(char* outData, const ComponentInfo::Field_t& field, const char* valueData)
|
||||
{
|
||||
// Catch and ignore casting errors so whitespace around string enums won't mess anything up
|
||||
try {
|
||||
@@ -243,7 +243,7 @@ void EntityFileSAXHandler::onStartEntityRef(const xercesc::Attributes& attrs)
|
||||
std::string path = XS::ToString(attrs.getValue(XS::ToXMLCh("file")));
|
||||
|
||||
xercesc::SAX2XMLReader* reader = xercesc::XMLReaderFactory::createXMLReader();
|
||||
EntityFile::setReaderFeatures(reader);
|
||||
EntityXMLFile::setReaderFeatures(reader);
|
||||
reader->setContentHandler(this);
|
||||
reader->setErrorHandler(this);
|
||||
reader->parse(path.c_str());
|
||||
@@ -1,15 +1,15 @@
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
|
||||
EntityFileParser::EntityFileParser(const EntityFile* entityFile)
|
||||
EntityXMLFileParser::EntityXMLFileParser(const EntityXMLFile* entityFile)
|
||||
: m_EntityFile(entityFile)
|
||||
{
|
||||
m_Handler.SetStartEntityCallback(std::bind(&EntityFileParser::onStartEntity, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_Handler.SetStartComponentCallback(std::bind(&EntityFileParser::onStartComponent, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_Handler.SetStartFieldCallback(std::bind(&EntityFileParser::onStartComponentField, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||
m_Handler.SetStartFieldDataCallback(std::bind(&EntityFileParser::onFieldData, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||
m_Handler.SetStartEntityCallback(std::bind(&EntityXMLFileParser::onStartEntity, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_Handler.SetStartComponentCallback(std::bind(&EntityXMLFileParser::onStartComponent, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_Handler.SetStartFieldCallback(std::bind(&EntityXMLFileParser::onStartComponentField, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||
m_Handler.SetStartFieldDataCallback(std::bind(&EntityXMLFileParser::onFieldData, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||
}
|
||||
|
||||
EntityID EntityFileParser::MergeEntities(World* world, EntityID baseParent /*= EntityID_Invalid */)
|
||||
EntityID EntityXMLFileParser::MergeEntities(World* world, EntityID baseParent /*= EntityID_Invalid */)
|
||||
{
|
||||
m_World = world;
|
||||
m_EntityIDMapper[0] = baseParent;
|
||||
@@ -17,7 +17,7 @@ EntityID EntityFileParser::MergeEntities(World* world, EntityID baseParent /*= E
|
||||
return m_FirstEntity;
|
||||
}
|
||||
|
||||
void EntityFileParser::onStartEntity(EntityID entity, EntityID parent, const std::string& name)
|
||||
void EntityXMLFileParser::onStartEntity(EntityID entity, EntityID parent, const std::string& name)
|
||||
{
|
||||
EntityID realParent = m_EntityIDMapper.at(parent);
|
||||
EntityID realEntity = m_World->CreateEntity(realParent);
|
||||
@@ -31,7 +31,7 @@ void EntityFileParser::onStartEntity(EntityID entity, EntityID parent, const std
|
||||
//LOG_DEBUG("Created entity #%i (%i) with parent %i (%i)", entity, realEntity, parent, realParent);
|
||||
}
|
||||
|
||||
void EntityFileParser::onStartComponent(EntityID entity, const std::string& component)
|
||||
void EntityXMLFileParser::onStartComponent(EntityID entity, const std::string& component)
|
||||
{
|
||||
if (m_World->GetComponentPools().count(component) != 0) {
|
||||
EntityID realEntity = m_EntityIDMapper.at(entity);
|
||||
@@ -42,7 +42,7 @@ void EntityFileParser::onStartComponent(EntityID entity, const std::string& comp
|
||||
//LOG_DEBUG("Attached component of type \"%s\" to entity #%i (%i)", component.c_str(), entity, realEntity);
|
||||
}
|
||||
|
||||
void EntityFileParser::onStartComponentField(EntityID entity, const std::string& componentType, const std::string& fieldName, const std::map<std::string, std::string>& attributes)
|
||||
void EntityXMLFileParser::onStartComponentField(EntityID entity, const std::string& componentType, const std::string& fieldName, const std::map<std::string, std::string>& attributes)
|
||||
{
|
||||
if (m_World->GetComponentPools().count(componentType) == 0) {
|
||||
return;
|
||||
@@ -63,10 +63,10 @@ void EntityFileParser::onStartComponentField(EntityID entity, const std::string&
|
||||
//}
|
||||
|
||||
char* data = component.Data + field.Offset;
|
||||
EntityFile::WriteAttributeData(data, field, attributes);
|
||||
EntityXMLFile::WriteAttributeData(data, field, attributes);
|
||||
}
|
||||
|
||||
void EntityFileParser::onFieldData(EntityID entity, const std::string& componentType, const std::string& fieldName, const char* fieldData)
|
||||
void EntityXMLFileParser::onFieldData(EntityID entity, const std::string& componentType, const std::string& fieldName, const char* fieldData)
|
||||
{
|
||||
if (m_World->GetComponentPools().count(componentType) == 0) {
|
||||
return;
|
||||
@@ -80,5 +80,5 @@ void EntityFileParser::onFieldData(EntityID entity, const std::string& component
|
||||
auto& field = fieldIt->second;
|
||||
|
||||
char* data = component.Data + field.Offset;
|
||||
EntityFile::WriteValueData(data, field, fieldData);
|
||||
EntityXMLFile::WriteValueData(data, field, fieldData);
|
||||
}
|
||||
+12
-12
@@ -1,10 +1,10 @@
|
||||
#include "Core/EntityFilePreprocessor.h"
|
||||
#include "Core/EntityXMLFilePreprocessor.h"
|
||||
|
||||
EntityFilePreprocessor::EntityFilePreprocessor(const EntityFile* entityFile)
|
||||
EntityXMLFilePreprocessor::EntityXMLFilePreprocessor(const EntityXMLFile* entityFile)
|
||||
: m_EntityFile(entityFile)
|
||||
{
|
||||
EntityFileHandler handler;
|
||||
handler.SetStartComponentCallback(std::bind(&EntityFilePreprocessor::onStartComponent, this, std::placeholders::_1, std::placeholders::_2));
|
||||
handler.SetStartComponentCallback(std::bind(&EntityXMLFilePreprocessor::onStartComponent, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_EntityFile->Parse(&handler);
|
||||
|
||||
//LOG_DEBUG("___ COMPONENT DEFINITIONS ___");
|
||||
@@ -28,20 +28,20 @@ EntityFilePreprocessor::EntityFilePreprocessor(const EntityFile* entityFile)
|
||||
parseDefaults();
|
||||
}
|
||||
|
||||
void EntityFilePreprocessor::RegisterComponents(World* world)
|
||||
void EntityXMLFilePreprocessor::RegisterComponents(World* world)
|
||||
{
|
||||
for (auto& kv : m_ComponentInfo) {
|
||||
world->RegisterComponent(kv.second);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityFilePreprocessor::onStartComponent(EntityID entity, std::string type)
|
||||
void EntityXMLFilePreprocessor::onStartComponent(EntityID entity, std::string type)
|
||||
{
|
||||
//LOG_DEBUG("Component: %s", type.c_str());
|
||||
m_ComponentCounts[type]++;
|
||||
}
|
||||
|
||||
void EntityFilePreprocessor::parseComponentInfo()
|
||||
void EntityXMLFilePreprocessor::parseComponentInfo()
|
||||
{
|
||||
using namespace xercesc;
|
||||
EntityFileXMLErrorHandler errorHandler;
|
||||
@@ -141,9 +141,9 @@ void EntityFilePreprocessor::parseComponentInfo()
|
||||
std::string baseType = XS::ToString(elementDeclaration->getTypeDefinition()->getBaseType()->getName());
|
||||
|
||||
std::string effectiveType = type;
|
||||
unsigned int stride = EntityFile::GetTypeStride(type);
|
||||
unsigned int stride = EntityXMLFile::GetTypeStride(type);
|
||||
if (stride == 0) {
|
||||
stride = EntityFile::GetTypeStride(baseType);
|
||||
stride = EntityXMLFile::GetTypeStride(baseType);
|
||||
if (stride == 0) {
|
||||
LOG_WARNING("Field \"%s\" in component \"%s\" uses unexpected field type \"%s\" with base type \"%s\". Skipping.", name.c_str(), compInfo.Name.c_str(), type.c_str(), baseType.c_str());
|
||||
continue;
|
||||
@@ -196,7 +196,7 @@ void EntityFilePreprocessor::parseComponentInfo()
|
||||
}
|
||||
}
|
||||
|
||||
void EntityFilePreprocessor::parseDefaults()
|
||||
void EntityXMLFilePreprocessor::parseDefaults()
|
||||
{
|
||||
using namespace xercesc;
|
||||
|
||||
@@ -261,7 +261,7 @@ void EntityFilePreprocessor::parseDefaults()
|
||||
auto attribItem = attributeMap->item(i);
|
||||
attributes[XS::ToString(attribItem->getNodeName())] = XS::ToString(attribItem->getNodeValue());
|
||||
}
|
||||
EntityFile::WriteAttributeData(data, field, attributes);
|
||||
EntityXMLFile::WriteAttributeData(data, field, attributes);
|
||||
}
|
||||
|
||||
auto childNode = fieldElement->getFirstChild();
|
||||
@@ -278,14 +278,14 @@ void EntityFilePreprocessor::parseDefaults()
|
||||
// Handle potential field values
|
||||
if (childNode->getNodeType() == DOMNode::TEXT_NODE) {
|
||||
char* cstrValue = XMLString::transcode(childNode->getNodeValue());
|
||||
EntityFile::WriteValueData(data, field, cstrValue);
|
||||
EntityXMLFile::WriteValueData(data, field, cstrValue);
|
||||
XMLString::release(&cstrValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string EntityFilePreprocessor::parseAnnotationXML(const XMLCh* xml)
|
||||
std::string EntityXMLFilePreprocessor::parseAnnotationXML(const XMLCh* xml)
|
||||
{
|
||||
using namespace xercesc;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "Core/EntityFileWriter.h"
|
||||
#include "Core/EntityXMLFileWriter.h"
|
||||
|
||||
#define X(str) XS::ToXMLCh(str)
|
||||
|
||||
void EntityFileWriter::WriteWorld(World* world)
|
||||
void EntityXMLFileWriter::WriteWorld(World* world)
|
||||
{
|
||||
WriteEntity(world, 0);
|
||||
}
|
||||
|
||||
void EntityFileWriter::WriteEntity(World* world, EntityID entity)
|
||||
void EntityXMLFileWriter::WriteEntity(World* world, EntityID entity)
|
||||
{
|
||||
using namespace xercesc;
|
||||
DOMDocument* doc = m_DOMImplementation->createDocument(nullptr, X("Entity"), nullptr);
|
||||
@@ -41,7 +41,7 @@ void EntityFileWriter::WriteEntity(World* world, EntityID entity)
|
||||
doc->release();
|
||||
}
|
||||
|
||||
void EntityFileWriter::appendEntityChildren(xercesc::DOMElement* parentElement, const World* world, EntityID entity)
|
||||
void EntityXMLFileWriter::appendEntityChildren(xercesc::DOMElement* parentElement, const World* world, EntityID entity)
|
||||
{
|
||||
using namespace xercesc;
|
||||
DOMDocument* doc = parentElement->getOwnerDocument();
|
||||
@@ -67,7 +67,7 @@ void EntityFileWriter::appendEntityChildren(xercesc::DOMElement* parentElement,
|
||||
}
|
||||
}
|
||||
|
||||
void EntityFileWriter::appentEntityComponents(xercesc::DOMElement* parentElement, const World* world, EntityID entity)
|
||||
void EntityXMLFileWriter::appentEntityComponents(xercesc::DOMElement* parentElement, const World* world, EntityID entity)
|
||||
{
|
||||
using namespace xercesc;
|
||||
DOMDocument* doc = parentElement->getOwnerDocument();
|
||||
@@ -129,7 +129,7 @@ void EditorSystem::OnEntitySelected(EntityWrapper entity)
|
||||
|
||||
void EditorSystem::OnEntitySave(EntityWrapper entity, boost::filesystem::path filePath)
|
||||
{
|
||||
EntityFileWriter writer(filePath);
|
||||
EntityXMLFileWriter writer(filePath);
|
||||
writer.WriteEntity(entity.World, entity.ID);
|
||||
}
|
||||
|
||||
@@ -259,10 +259,10 @@ EntityWrapper EditorSystem::importEntity(EntityWrapper parent, boost::filesystem
|
||||
}
|
||||
|
||||
try {
|
||||
auto entityFile = ResourceManager::Load<EntityFile>(filePath.string());
|
||||
EntityFilePreprocessor fpp(entityFile);
|
||||
auto entityFile = ResourceManager::Load<EntityXMLFile>(filePath.string());
|
||||
EntityXMLFilePreprocessor fpp(entityFile);
|
||||
fpp.RegisterComponents(parent.World);
|
||||
EntityFileParser fp(entityFile);
|
||||
EntityXMLFileParser fp(entityFile);
|
||||
EntityID newEntity = fp.MergeEntities(parent.World, parent.ID);
|
||||
return EntityWrapper(parent.World, newEntity);
|
||||
} catch (const std::exception& e) {
|
||||
|
||||
+5
-5
@@ -11,7 +11,7 @@
|
||||
#include "Systems/PlayerSpawnSystem.h"
|
||||
#include "Systems/PlayerDeathSystem.h"
|
||||
#include "Systems/FloatingEffectSystem.h"
|
||||
#include "Core/EntityFileWriter.h"
|
||||
#include "Core/EntityXMLFileWriter.h"
|
||||
#include "Game/Systems/CapturePointSystem.h"
|
||||
#include "Game/Systems/CapturePointHUDSystem.h"
|
||||
#include "Game/Systems/PickupSpawnSystem.h"
|
||||
@@ -44,7 +44,7 @@ Game::Game(int argc, char* argv[])
|
||||
ResourceManager::RegisterType<Texture>("Texture");
|
||||
ResourceManager::RegisterType<PNG>("Png");
|
||||
ResourceManager::RegisterType<ShaderProgram>("ShaderProgram");
|
||||
ResourceManager::RegisterType<EntityFile>("EntityFile");
|
||||
ResourceManager::RegisterType<EntityXMLFile>("EntityFile");
|
||||
ResourceManager::RegisterType<Font>("FontFile");
|
||||
|
||||
m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
@@ -80,10 +80,10 @@ Game::Game(int argc, char* argv[])
|
||||
m_World = new World(m_EventBroker);
|
||||
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
|
||||
if (!mapToLoad.empty()) {
|
||||
auto file = ResourceManager::Load<EntityFile>(mapToLoad);
|
||||
EntityFilePreprocessor fpp(file);
|
||||
auto file = ResourceManager::Load<EntityXMLFile>(mapToLoad);
|
||||
EntityXMLFilePreprocessor fpp(file);
|
||||
fpp.RegisterComponents(m_World);
|
||||
EntityFileParser fp(file);
|
||||
EntityXMLFileParser fp(file);
|
||||
fp.MergeEntities(m_World);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ void AmmoPickupSystem::Update(double dt)
|
||||
auto& somePickup = *it;
|
||||
somePickup.DecreaseThisRespawnTimer -= dt;
|
||||
if (somePickup.DecreaseThisRespawnTimer < 0.0) {
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/AmmoPickup.xml");
|
||||
EntityFileParser parser(entityFile);
|
||||
auto entityFile = ResourceManager::Load<EntityXMLFile>("Schema/Entities/AmmoPickup.xml");
|
||||
EntityXMLFileParser parser(entityFile);
|
||||
EntityID ammoPickupID = parser.MergeEntities(m_World);
|
||||
|
||||
//let the world know a pickup has spawned
|
||||
|
||||
@@ -38,8 +38,8 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
||||
m_World->DeleteEntity(playerBoostAssaultEntity.ID);
|
||||
}
|
||||
//load boost XML file, set it entity parented with the victim player
|
||||
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
|
||||
EntityFileParser parser(entityFile);
|
||||
auto entityFile = ResourceManager::Load<EntityXMLFile>(classXML);
|
||||
EntityXMLFileParser parser(entityFile);
|
||||
EntityID boostAssaultEntity = parser.MergeEntities(m_World);
|
||||
m_World->SetName(boostAssaultEntity, className);
|
||||
m_World->SetParent(boostAssaultEntity, e.Victim.ID);
|
||||
|
||||
@@ -9,7 +9,7 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params)
|
||||
|
||||
//load texture to cache
|
||||
auto texture = CommonFunctions::LoadTexture("Textures/DamageIndicator.png", false);
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DamageIndicator.xml");
|
||||
auto entityFile = ResourceManager::Load<EntityXMLFile>("Schema/Entities/DamageIndicator.xml");
|
||||
}
|
||||
|
||||
void DamageIndicatorSystem::Update(double dt) {
|
||||
@@ -49,8 +49,8 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
||||
float angleBetweenVectors = CalculateAngle(e.Victim, inflictorPos);
|
||||
|
||||
//load & set the "2d" sprite
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DamageIndicator.xml");
|
||||
EntityFileParser parser(entityFile);
|
||||
auto entityFile = ResourceManager::Load<EntityXMLFile>("Schema/Entities/DamageIndicator.xml");
|
||||
EntityXMLFileParser parser(entityFile);
|
||||
EntityID spriteID = parser.MergeEntities(m_World);
|
||||
m_World->SetParent(spriteID, m_CurrentCamera);
|
||||
auto spriteWrapper = EntityWrapper(m_World, spriteID);
|
||||
@@ -127,8 +127,8 @@ glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) {
|
||||
auto inflictorPos = glm::vec3(currentPos.x + testVar*6.0f, currentPos.y, currentPos.z + testVar2*6.0f);
|
||||
|
||||
//load the explosioneffect XML
|
||||
auto deathEffect = ResourceManager::Load<EntityFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
||||
EntityFileParser parser(deathEffect);
|
||||
auto deathEffect = ResourceManager::Load<EntityXMLFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
||||
EntityXMLFileParser parser(deathEffect);
|
||||
EntityID deathEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ void PickupSpawnSystem::Update(double dt)
|
||||
somePickup.DecreaseThisRespawnTimer -= dt;
|
||||
if (somePickup.DecreaseThisRespawnTimer < 0.0) {
|
||||
//spawn the new healthPickup
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/HealthPickup.xml");
|
||||
EntityFileParser parser(entityFile);
|
||||
auto entityFile = ResourceManager::Load<EntityXMLFile>("Schema/Entities/HealthPickup.xml");
|
||||
EntityXMLFileParser parser(entityFile);
|
||||
EntityID healthPickupID = parser.MergeEntities(m_World);
|
||||
|
||||
//let the world know a pickup has spawned (graphics effects, etc)
|
||||
|
||||
@@ -28,8 +28,8 @@ bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
||||
void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
||||
{
|
||||
//load the explosioneffect XML
|
||||
auto deathEffect = ResourceManager::Load<EntityFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
||||
EntityFileParser parser(deathEffect);
|
||||
auto deathEffect = ResourceManager::Load<EntityXMLFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
||||
EntityXMLFileParser parser(deathEffect);
|
||||
EntityID deathEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
||||
|
||||
|
||||
@@ -328,8 +328,8 @@ bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e)
|
||||
void PlayerMovementSystem::spawnHexagon(EntityWrapper target)
|
||||
{
|
||||
//put a hexagon at the entitys... feet?
|
||||
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
|
||||
EntityFileParser parser(hexagonEffect);
|
||||
auto hexagonEffect = ResourceManager::Load<EntityXMLFile>("Schema/Entities/DoubleJumpHexagon.xml");
|
||||
EntityXMLFileParser parser(hexagonEffect);
|
||||
EntityID hexagonEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
|
||||
hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"];
|
||||
@@ -342,8 +342,8 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto dashEffectResource = ResourceManager::Load<EntityFile>("Schema/Entities/DashEffect.xml");
|
||||
EntityFileParser parser(dashEffectResource);
|
||||
auto dashEffectResource = ResourceManager::Load<EntityXMLFile>("Schema/Entities/DashEffect.xml");
|
||||
EntityXMLFileParser parser(dashEffectResource);
|
||||
EntityID dashEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper dashEffect(m_World, dashEffectID);
|
||||
auto playerModel = player.FirstChildByName("PlayerModel");
|
||||
|
||||
@@ -17,11 +17,11 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /
|
||||
|
||||
// Load the entity file and parse it
|
||||
const std::string& entityFilePath = spawner["Spawner"]["EntityFile"];
|
||||
auto entityFile = ResourceManager::Load<EntityFile>(entityFilePath);
|
||||
auto entityFile = ResourceManager::Load<EntityXMLFile>(entityFilePath);
|
||||
if (entityFile == nullptr) {
|
||||
return EntityWrapper::Invalid;
|
||||
}
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityXMLFileParser parser(entityFile);
|
||||
EntityWrapper spawnedEntity(world, parser.MergeEntities(world, parent.ID));
|
||||
|
||||
//If the spawned entity is collideable, then we must not spawn it where it collides with something that
|
||||
|
||||
@@ -7,7 +7,7 @@ using boost::unit_test_framework::test_case;
|
||||
|
||||
#include "Collision/TriggerSystem.h"
|
||||
#include "Collision/CollisionSystem.h"
|
||||
#include "Core/EntityFileWriter.h"
|
||||
#include "Core/EntityXMLFileWriter.h"
|
||||
#include "Game/Systems/CapturePointSystem.h"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(CapturePointTestSuite)
|
||||
@@ -82,7 +82,7 @@ bool CapturePointTest::CapturePoint_Game_Loop_OneHundredTimes() {
|
||||
CapturePointTest::CapturePointTest(int runTestNumber)
|
||||
{
|
||||
ResourceManager::RegisterType<ConfigFile>("ConfigFile");
|
||||
ResourceManager::RegisterType<EntityFile>("EntityFile");
|
||||
ResourceManager::RegisterType<EntityXMLFile>("EntityFile");
|
||||
|
||||
m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("Debug.LogLevel", 1));
|
||||
@@ -99,10 +99,10 @@ CapturePointTest::CapturePointTest(int runTestNumber)
|
||||
m_SystemPipeline->AddSystem<CapturePointSystem>(1);
|
||||
|
||||
//must register components (Components.xsd), else you cant create entities. Easiest done by loading a test xsd file
|
||||
auto file = ResourceManager::Load<EntityFile>("Schema/Entities/TeamTest.xml");
|
||||
EntityFilePreprocessor fpp(file);
|
||||
auto file = ResourceManager::Load<EntityXMLFile>("Schema/Entities/TeamTest.xml");
|
||||
EntityXMLFilePreprocessor fpp(file);
|
||||
fpp.RegisterComponents(m_World);
|
||||
EntityFileParser fp(file);
|
||||
EntityXMLFileParser fp(file);
|
||||
fp.MergeEntities(m_World);
|
||||
|
||||
EntityID playerID = m_World->CreateEntity();
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#include "Input/KeyboardInputHandler.h"
|
||||
#include "Input/MouseInputHandler.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EntityFile.h"
|
||||
#include "Core/EntityXMLFile.h"
|
||||
#include "Core/SystemPipeline.h"
|
||||
|
||||
#include "Core/EntityFilePreprocessor.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityFileWriter.h"
|
||||
#include "Core/EntityXMLFilePreprocessor.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
#include "Core/EntityXMLFileWriter.h"
|
||||
|
||||
#include "Engine/Collision/ETrigger.h"
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ BOOST_AUTO_TEST_SUITE_END()
|
||||
GameHealthSystemTest::GameHealthSystemTest()
|
||||
{
|
||||
ResourceManager::RegisterType<ConfigFile>("ConfigFile");
|
||||
ResourceManager::RegisterType<EntityFile>("EntityFile");
|
||||
ResourceManager::RegisterType<EntityXMLFile>("EntityFile");
|
||||
|
||||
m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("Debug.LogLevel", 1));
|
||||
@@ -41,10 +41,10 @@ GameHealthSystemTest::GameHealthSystemTest()
|
||||
// Create a world
|
||||
m_World = new World();
|
||||
|
||||
auto file = ResourceManager::Load<EntityFile>("Schema/Entities/TeamTest.xml");
|
||||
EntityFilePreprocessor fpp(file);
|
||||
auto file = ResourceManager::Load<EntityXMLFile>("Schema/Entities/TeamTest.xml");
|
||||
EntityXMLFilePreprocessor fpp(file);
|
||||
fpp.RegisterComponents(m_World);
|
||||
EntityFileParser fp(file);
|
||||
EntityXMLFileParser fp(file);
|
||||
fp.MergeEntities(m_World);
|
||||
|
||||
// Create system pipeline
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "Input/KeyboardInputHandler.h"
|
||||
#include "Input/MouseInputHandler.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EntityFile.h"
|
||||
#include "Core/EntityXMLFile.h"
|
||||
#include "Core/SystemPipeline.h"
|
||||
#include "Editor/EditorSystem.h"
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ BOOST_AUTO_TEST_SUITE_END()
|
||||
PickupSpawnTest::PickupSpawnTest(int runTestNumber)
|
||||
{
|
||||
ResourceManager::RegisterType<ConfigFile>("ConfigFile");
|
||||
ResourceManager::RegisterType<EntityFile>("EntityFile");
|
||||
ResourceManager::RegisterType<EntityXMLFile>("EntityFile");
|
||||
|
||||
m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("Debug.LogLevel", 1));
|
||||
@@ -44,10 +44,10 @@ PickupSpawnTest::PickupSpawnTest(int runTestNumber)
|
||||
m_SystemPipeline->AddSystem<PickupSpawnSystem>(1);
|
||||
|
||||
//must register components (Components.xsd), else you cant create entities. Easiest done by loading a test xsd file
|
||||
auto file = ResourceManager::Load<EntityFile>("Schema/Entities/HealthPickup.xml");
|
||||
EntityFilePreprocessor fpp(file);
|
||||
auto file = ResourceManager::Load<EntityXMLFile>("Schema/Entities/HealthPickup.xml");
|
||||
EntityXMLFilePreprocessor fpp(file);
|
||||
fpp.RegisterComponents(m_World);
|
||||
EntityFileParser fp(file);
|
||||
EntityXMLFileParser fp(file);
|
||||
//connect the healthpickup to the world
|
||||
m_HealthPickupID = fp.MergeEntities(m_World);
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#include "Input/KeyboardInputHandler.h"
|
||||
#include "Input/MouseInputHandler.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EntityFile.h"
|
||||
#include "Core/EntityXMLFile.h"
|
||||
#include "Core/SystemPipeline.h"
|
||||
|
||||
#include "Core/EntityFilePreprocessor.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EntityFileWriter.h"
|
||||
#include "Core/EntityXMLFilePreprocessor.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
#include "Core/EntityXMLFileWriter.h"
|
||||
|
||||
#include "Engine/Collision/ETrigger.h"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
//#include <tuple>
|
||||
#include "Collision/TriggerSystem.h"
|
||||
#include "Collision/CollisionSystem.h"
|
||||
#include "Core/EntityFileWriter.h"
|
||||
#include "Core/EntityXMLFileWriter.h"
|
||||
#include "Game/Systems/HealthSystem.h"
|
||||
#include "Game/Systems/PickupSpawnSystem.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user