Merge branch 'master' of github.com:teamfisk/TacticalZ

This commit is contained in:
Tleety
2016-03-13 23:30:26 +01:00
7 changed files with 2676 additions and 359 deletions
+11 -2
View File
@@ -83,15 +83,24 @@ void PlayerSpawnSystem::Update(double dt)
if (it->Team == cSpawnerTeam["Team"].Enum("Spectator")) {
++playersSpectating;
break;
} else {
continue;
}
continue;
}
}
// TODO: Choose a different spawner depending on class picked?
std::string playerEntityFile;
if (it->Class == PlayerClass::Assault) {
playerEntityFile = (const std::string&)cPlayerSpawn["AssaultFile"];
} else if (it->Class == PlayerClass::Defender) {
playerEntityFile = (const std::string&)cPlayerSpawn["DefenderFile"];
} else if (it->Class == PlayerClass::Sniper) {
playerEntityFile = (const std::string&)cPlayerSpawn["SniperFile"];
}
// Spawn the player!
EntityWrapper player = SpawnerSystem::Spawn(spawner, EntityWrapper::Invalid, "Player");
EntityWrapper player = SpawnerSystem::SpawnEntityFile(playerEntityFile, spawner, EntityWrapper::Invalid, "Player");
// Set the player team affiliation
player["Team"]["Team"] = it->Team;
+12 -3
View File
@@ -8,6 +8,17 @@ SpawnerSystem::SpawnerSystem(SystemParams params)
}
EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /*= EntityWrapper::Invalid*/, const std::string& dontCollideComponent)
{
// Load the entity file and parse it
const std::string& entityFilePath = spawner["Spawner"]["EntityFile"];
if (!entityFilePath.empty()) {
return SpawnEntityFile(entityFilePath, spawner, parent, dontCollideComponent);
} else {
return EntityWrapper::Invalid;
}
}
EntityWrapper SpawnerSystem::SpawnEntityFile(const std::string& entityFilePath, EntityWrapper spawner, EntityWrapper parent /*= EntityWrapper::Invalid*/, const std::string& dontCollideComponent /*= ""*/)
{
// Spawn the entity in the parent's world if it exists, otherwise in the spawner's world
World* world = parent.World;
@@ -15,8 +26,6 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /
world = spawner.World;
}
// Load the entity file and parse it
const std::string& entityFilePath = spawner["Spawner"]["EntityFile"];
EntityWrapper spawnedEntity;
try {
auto entityFile = ResourceManager::Load<EntityFile>(entityFilePath);
@@ -39,7 +48,7 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /
// Find any SpawnPoints existing as children of spawner
auto children = spawner.World->GetDirectChildren(spawner.ID);
std::vector<EntityWrapper> spawnPoints;
std::list<EntityWrapper> spawnPoints;
for (auto kv = children.first; kv != children.second; ++kv) {
const EntityID& child = kv->second;
if (spawner.World->HasComponent(child, "SpawnPoint")) {