mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-25 17:53:47 +00:00
Add getInterfaceFunctionNames(), isObstructedRaw(), OT_OUTOFBOUNDS
This commit is contained in:
parent
36f33da9a8
commit
9e0d59460a
2 changed files with 31 additions and 1 deletions
|
@ -572,6 +572,7 @@ typedef std::vector<QuadList> QuadArray;
|
|||
typedef std::vector<Element*> ElementUpdateList;
|
||||
|
||||
// Note: although this is a bitmask, only one of these values may be set at a time!
|
||||
// This is because GridRender and most Lua scripts check via ==, not for bits set (Lua 5.1 doesn't have bit ops)
|
||||
enum ObsType
|
||||
{
|
||||
OT_EMPTY = 0x00,
|
||||
|
@ -596,6 +597,8 @@ enum ObsType
|
|||
OT_USER1 = 0x40,
|
||||
OT_USER2 = 0x80,
|
||||
OT_USER_MASK = OT_USER1 | OT_USER2,
|
||||
|
||||
OT_OUTOFBOUNDS = 0xff
|
||||
};
|
||||
|
||||
struct EntitySaveData
|
||||
|
@ -635,6 +638,7 @@ public:
|
|||
void setGrid(const TileVector &tile, ObsType v);
|
||||
void addGrid(const TileVector &tile, ObsType v);
|
||||
bool isObstructed(const TileVector &tile, int t = OT_BLOCKING) const;
|
||||
bool isObstructedRaw(const TileVector &tile, int t) const;
|
||||
void trimGrid();
|
||||
void dilateGrid(unsigned int radius, ObsType test, ObsType set, ObsType allowOverwrite);
|
||||
|
||||
|
@ -1213,7 +1217,7 @@ ObsType Game::getGridRaw(const TileVector &tile) const
|
|||
{
|
||||
return (unsigned(tile.x) < unsigned(MAX_GRID) && unsigned(tile.y) < unsigned(MAX_GRID))
|
||||
? ObsType(grid[tile.x][tile.y])
|
||||
: OT_INVISIBLE;
|
||||
: OT_OUTOFBOUNDS;
|
||||
}
|
||||
|
||||
inline
|
||||
|
@ -1255,4 +1259,10 @@ bool Game::isObstructed(const TileVector &tile, int t /* = OT_BLOCKING */) const
|
|||
return (getGrid(tile) & t);
|
||||
}
|
||||
|
||||
inline
|
||||
bool Game::isObstructedRaw(const TileVector &tile, int t) const
|
||||
{
|
||||
return (getGridRaw(tile) & t);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -898,6 +898,17 @@ luaFunc(getModPath)
|
|||
luaReturnStr(path.c_str());
|
||||
}
|
||||
|
||||
luaFunc(getInterfaceFunctionNames)
|
||||
{
|
||||
lua_newtable(L);
|
||||
for(unsigned i = 0; interfaceFunctions[i]; ++i)
|
||||
{
|
||||
lua_pushstring(L, interfaceFunctions[i]);
|
||||
lua_rawseti(L, -2, i+1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----- RenderObject common functions -----
|
||||
|
@ -8681,6 +8692,12 @@ luaFunc(isObstructed)
|
|||
luaReturnBool(dsq->game->isObstructed(TileVector(Vector(lua_tonumber(L, 1), lua_tonumber(L, 2))), obs ? obs : -1));
|
||||
}
|
||||
|
||||
luaFunc(isObstructedRaw)
|
||||
{
|
||||
int obs = lua_tointeger(L, 3);
|
||||
luaReturnBool(dsq->game->isObstructedRaw(TileVector(Vector(lua_tonumber(L, 1), lua_tonumber(L, 2))), obs));
|
||||
}
|
||||
|
||||
luaFunc(getObstruction)
|
||||
{
|
||||
luaReturnInt(dsq->game->getGrid(TileVector(Vector(lua_tonumber(L, 1), lua_tonumber(L, 2)))));
|
||||
|
@ -9402,6 +9419,7 @@ static const struct {
|
|||
luaRegister(fileExists),
|
||||
luaRegister(getModName),
|
||||
luaRegister(getModPath),
|
||||
luaRegister(getInterfaceFunctionNames),
|
||||
|
||||
luaRegister(debugBreak),
|
||||
luaRegister(setIgnoreAction),
|
||||
|
@ -9952,6 +9970,7 @@ static const struct {
|
|||
|
||||
luaRegister(singSong),
|
||||
luaRegister(isObstructed),
|
||||
luaRegister(isObstructedRaw),
|
||||
luaRegister(isObstructedBlock),
|
||||
luaRegister(getObstruction),
|
||||
luaRegister(getGridRaw),
|
||||
|
@ -11124,6 +11143,7 @@ static const struct {
|
|||
luaConstant(OT_MASK_BLACK),
|
||||
luaConstant(OT_BLOCKING),
|
||||
luaConstant(OT_USER_MASK),
|
||||
luaConstant(OT_OUTOFBOUNDS),
|
||||
|
||||
luaConstant(SEE_MAP_NEVER),
|
||||
luaConstant(SEE_MAP_DEFAULT),
|
||||
|
|
Loading…
Reference in a new issue