Made SpawnerSystem utilize the new EntityFile for spawning instead
This commit is contained in:
@@ -7,8 +7,7 @@
|
|||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Events/ESpawnerSpawn.h"
|
#include "Events/ESpawnerSpawn.h"
|
||||||
#include "Core/Transform.h"
|
#include "Core/Transform.h"
|
||||||
#include "Core/ResourceManager.h"
|
#include "Core/EntityFile.h"
|
||||||
#include "Core/EntityXMLFileParser.h"
|
|
||||||
|
|
||||||
class SpawnerSystem : public System
|
class SpawnerSystem : public System
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,15 +17,17 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /
|
|||||||
|
|
||||||
// Load the entity file and parse it
|
// Load the entity file and parse it
|
||||||
const std::string& entityFilePath = spawner["Spawner"]["EntityFile"];
|
const std::string& entityFilePath = spawner["Spawner"]["EntityFile"];
|
||||||
auto entityFile = ResourceManager::Load<EntityXMLFile>(entityFilePath);
|
EntityWrapper spawnedEntity;
|
||||||
if (entityFile == nullptr) {
|
try {
|
||||||
|
auto entityFile = ResourceManager::Load<EntityFile>(entityFilePath);
|
||||||
|
spawnedEntity = entityFile->MergeInto(world);
|
||||||
|
world->SetParent(spawnedEntity.ID, parent.ID);
|
||||||
|
} catch (const Resource::FailedLoadingException& e) {
|
||||||
return EntityWrapper::Invalid;
|
return EntityWrapper::Invalid;
|
||||||
}
|
}
|
||||||
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
|
// If the spawned entity is collidable, then we must not spawn it where it collides with something that
|
||||||
//has a dontCollideComponent attached.
|
// has a dontCollideComponent attached.
|
||||||
bool spawnOnCollidable = dontCollideComponent.empty() || !spawnedEntity.HasComponent("Collidable");
|
bool spawnOnCollidable = dontCollideComponent.empty() || !spawnedEntity.HasComponent("Collidable");
|
||||||
if (!spawnOnCollidable) {
|
if (!spawnOnCollidable) {
|
||||||
boost::optional<EntityAABB> optBox = Collision::EntityAbsoluteAABB(spawnedEntity);
|
boost::optional<EntityAABB> optBox = Collision::EntityAbsoluteAABB(spawnedEntity);
|
||||||
|
|||||||
Reference in New Issue
Block a user