Made SpawnerSystem utilize the new EntityFile for spawning instead
This commit is contained in:
@@ -7,8 +7,7 @@
|
||||
#include "Core/System.h"
|
||||
#include "Events/ESpawnerSpawn.h"
|
||||
#include "Core/Transform.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/EntityXMLFileParser.h"
|
||||
#include "Core/EntityFile.h"
|
||||
|
||||
class SpawnerSystem : public System
|
||||
{
|
||||
|
||||
@@ -17,14 +17,16 @@ 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<EntityXMLFile>(entityFilePath);
|
||||
if (entityFile == nullptr) {
|
||||
EntityWrapper spawnedEntity;
|
||||
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;
|
||||
}
|
||||
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.
|
||||
bool spawnOnCollidable = dontCollideComponent.empty() || !spawnedEntity.HasComponent("Collidable");
|
||||
if (!spawnOnCollidable) {
|
||||
|
||||
Reference in New Issue
Block a user