Merge branch 'master' of github.com:teamfisk/TacticalZ
This commit is contained in:
@@ -19,9 +19,9 @@ private:
|
||||
enum class PlayerClass
|
||||
{
|
||||
None = 0,
|
||||
Assault,
|
||||
Defender,
|
||||
Sniper
|
||||
Assault = 1,
|
||||
Defender = 2,
|
||||
Sniper = 2
|
||||
};
|
||||
struct SpawnRequest
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
// will try to pick a spawn location so that the spawned entity doesn't
|
||||
// collide with anything that has that component and is collidable.
|
||||
static EntityWrapper Spawn(EntityWrapper spawner, EntityWrapper parent = EntityWrapper::Invalid, const std::string& dontCollideComponent = "");
|
||||
static EntityWrapper SpawnEntityFile(const std::string& entityFilePath, EntityWrapper spawner, EntityWrapper parent = EntityWrapper::Invalid, const std::string& dontCollideComponent = "");
|
||||
|
||||
private:
|
||||
EventRelay<SpawnerSystem, Events::SpawnerSpawn> m_OnSpawnerSpawn;
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<PlayerSpawn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PlayerSpawn.xsd"/>
|
||||
<PlayerSpawn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PlayerSpawn.xsd">
|
||||
<AssaultFile>Schema/Entities/PlayerAssaultBlue.xml</AssaultFile>
|
||||
<DefenderFile>Schema/Entities/PlayerDefenderBlue.xml</DefenderFile>
|
||||
<SniperFile></SniperFile>
|
||||
</PlayerSpawn>
|
||||
@@ -7,5 +7,12 @@
|
||||
<xs:annotation>
|
||||
<xs:documentation>Combined with a Spawner and a Team component, defines a spawn point for a player team.</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="AssaultFile" type="t:string" minOccurs="0"/>
|
||||
<xs:element name="DefenderFile" type="t:string" minOccurs="0"/>
|
||||
<xs:element name="SniperFile" type="t:string" minOccurs="0"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
Reference in New Issue
Block a user