Utils for Locations:
bool LocationHasCritters (Location& loc, uint findType)
uint LocationGetCritters (Location& loc, uint findType, array<Critter@>@ critters)
bool LocationHasItems (Location& loc, uint16 protoId)
uint LocationGetItems (Location& loc, uint16 protoId, array<Item@>@ items)
void LocationDeleteItems (Location& loc, uint16 protoId)
// Returns true if there is at least one Critter of given type inside Location.
//
bool LocationHasCritters (Location& loc, uint findType)
{
array<Map@> maps;
uint num = loc.GetMaps(maps);
array<Critter@> critters;
for (uint i = 0; i < num; i++)
{
if (maps[i].GetCritters(0, findType, critters) > 0)
{
return true;
}
}
return false;
}
// Gets all Critters of given type inside Location.
//
uint LocationGetCritters (Location& loc, uint findType, array<Critter@>@ critters)
{
array<Map@> maps;
uint num = loc.GetMaps(maps);
for (uint i = 0; i < num; i++)
{
maps[i].GetCritters(0, findType, critters);
}
return critters.length();
}
// Returns true if there is at least one Item with given protoId inside Location.
//
bool LocationHasItems (Location& loc, uint16 protoId)
{
array<Map@> maps;
uint num = loc.GetMaps(maps);
array<Item@> items;
for (uint i = 0; i < num; i++)
{
if (maps[i].GetItems(protoId, items) > 0)
{
return true;
}
}
return false;
}
// Gets all items with given protoId inside Location.
//
uint LocationGetItems (Location& loc, uint16 protoId, array<Item@>@ items)
{
array<Map@> maps;
uint num = loc.GetMaps(maps);
for (uint i = 0; i < num; i++)
{
maps[i].GetItems(protoId, items);
}
return items.length();
}
// Deletes all items with given protoId inside Location.
//
void LocationDeleteItems (Location& loc, uint16 protoId)
{
array<Item@> items;
LocationGetItems(loc, protoId, items);
DeleteItems(items);
}