getCreatures / getSpawns
This commit is contained in:
parent
cbfeef39bc
commit
93be0f975f
|
@ -144,6 +144,14 @@ void Spawn::removeCreature(const Position& pos)
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<CreatureTypePtr> Spawn::getCreatures()
|
||||
{
|
||||
std::vector<CreatureTypePtr> creatures;
|
||||
for (auto p : m_creatures)
|
||||
creatures.push_back(p.second);
|
||||
return creatures;
|
||||
}
|
||||
|
||||
CreaturePtr CreatureType::cast()
|
||||
{
|
||||
CreaturePtr ret(new Creature);
|
||||
|
@ -399,5 +407,12 @@ SpawnPtr CreatureManager::addSpawn(const Position& centerPos, int radius)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et: */
|
||||
std::vector<SpawnPtr> CreatureManager::getSpawns()
|
||||
{
|
||||
std::vector<SpawnPtr> spawns;
|
||||
for (auto p : m_spawns)
|
||||
spawns.push_back(p.second);
|
||||
return spawns;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et: */
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
void setCenterPos(const Position& pos) { m_attribs.set(SpawnAttrCenter, pos); }
|
||||
Position getCenterPos() { return m_attribs.get<Position>(SpawnAttrCenter); }
|
||||
|
||||
std::vector<CreatureTypePtr> getCreatures();
|
||||
void addCreature(const Position& placePos, const CreatureTypePtr& cType);
|
||||
void removeCreature(const Position& pos);
|
||||
void clear() { m_creatures.clear(); }
|
||||
|
@ -120,6 +121,7 @@ public:
|
|||
const CreatureTypePtr& getCreatureByName(std::string name);
|
||||
const CreatureTypePtr& getCreatureByLook(int look);
|
||||
|
||||
std::vector<SpawnPtr> getSpawns();
|
||||
SpawnPtr getSpawn(const Position& centerPos);
|
||||
SpawnPtr getSpawnForPlacePos(const Position& pos);
|
||||
SpawnPtr addSpawn(const Position& centerPos, int radius);
|
||||
|
|
|
@ -82,6 +82,8 @@ typedef std::list<TownPtr> TownList;
|
|||
typedef std::list<ItemPtr> ItemList;
|
||||
typedef std::vector<ItemPtr> ItemVector;
|
||||
typedef std::unordered_map<Position, TilePtr, PositionHasher> TileMap;
|
||||
typedef std::unordered_map<Position, CreatureTypePtr, PositionHasher> CreatureMap;
|
||||
typedef std::unordered_map<Position, SpawnPtr, PositionHasher> SpawnMap;
|
||||
|
||||
// net
|
||||
class ProtocolLogin;
|
||||
|
|
|
@ -172,6 +172,7 @@ void Client::registerLuaFunctions()
|
|||
g_lua.bindSingletonFunction("g_creatures", "isSpawnLoaded", &CreatureManager::isSpawnLoaded, &g_creatures);
|
||||
g_lua.bindSingletonFunction("g_creatures", "clear", &CreatureManager::clear, &g_creatures);
|
||||
g_lua.bindSingletonFunction("g_creatures", "clearSpawns", &CreatureManager::clearSpawns, &g_creatures);
|
||||
g_lua.bindSingletonFunction("g_creatures", "getSpawns", &CreatureManager::getSpawns, &g_creatures);
|
||||
|
||||
g_lua.registerSingletonClass("g_game");
|
||||
g_lua.bindSingletonFunction("g_game", "loginWorld", &Game::loginWorld, &g_game);
|
||||
|
@ -398,6 +399,7 @@ void Client::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<Spawn>("getCenterPos", &Spawn::getCenterPos);
|
||||
g_lua.bindClassMemberFunction<Spawn>("addCreature", &Spawn::addCreature);
|
||||
g_lua.bindClassMemberFunction<Spawn>("removeCreature", &Spawn::removeCreature);
|
||||
g_lua.bindClassMemberFunction<Spawn>("getCreatures", &Spawn::getCreatures);
|
||||
|
||||
g_lua.registerClass<Town>();
|
||||
g_lua.bindClassStaticFunction<Town>("create", []{ return TownPtr(new Town); });
|
||||
|
|
Loading…
Reference in New Issue