void L1_IsPointInSector() { lua_Object xObj = lua_getparam(1); lua_Object yObj = lua_getparam(2); lua_Object zObj = lua_getparam(3); lua_Object nameObj = lua_getparam(4); if (!lua_isstring(nameObj)) { lua_pushnil(); return; } const char *name = lua_getstring(nameObj); float x = lua_getnumber(xObj); float y = lua_getnumber(yObj); float z = lua_getnumber(zObj); Graphics::Vector3d pos(x, y, z); int numSectors = g_grim->getCurrScene()->getSectorCount(); for (int i = 0; i < numSectors; i++) { Sector *sector = g_grim->getCurrScene()->getSectorBase(i); if (strstr(sector->getName(), name)) { if (sector->isPointInSector(pos)) { lua_pushnumber(sector->getSectorId()); lua_pushstring(sector->getName()); lua_pushnumber(sector->getType()); return; } } } lua_pushnil(); }
void L1_IsActorInSector() { lua_Object actorObj = lua_getparam(1); lua_Object nameObj = lua_getparam(2); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; if (!lua_isstring(nameObj)) { lua_pushnil(); return; } Actor *actor = getactor(actorObj); const char *name = lua_getstring(nameObj); int numSectors = g_grim->getCurrScene()->getSectorCount(); for (int i = 0; i < numSectors; i++) { Sector *sector = g_grim->getCurrScene()->getSectorBase(i); if (strstr(sector->getName(), name)) { if (sector->isPointInSector(actor->getPos())) { lua_pushnumber(sector->getSectorId()); lua_pushstring(sector->getName()); lua_pushnumber(sector->getType()); return; } } } lua_pushnil(); }
Sector *Set::findPointSector(const Math::Vector3d &p, Sector::SectorType type) { for (int i = 0; i < _numSectors; i++) { Sector *sector = _sectors[i]; if (sector && (sector->getType() & type) && sector->isVisible() && sector->isPointInSector(p)) return sector; } return NULL; }
Sector *Set::getSector(const Common::String &name, const Math::Vector3d &pos) { for (int i = 0; i < _numSectors; i++) { Sector *sector = _sectors[i]; if (strstr(sector->getName(), name.c_str()) && sector->isPointInSector(pos)) { return sector; } } return NULL; }