88 template<
typename... Args>
93 lua_unit(std::size_t u): uid(u), ptr(), side(0), c_ptr() {}
95 lua_unit(
int s, std::size_t u): uid(u), ptr(), side(s), c_ptr() {}
99 bool on_map()
const {
return !ptr && side == 0; }
114 template<
typename... Args>
unit & luaW_checkunit(lua_State *L, int index, bool only_on_map=false)
Converts a Lua value to a unit pointer.
static void setmetatable(lua_State *L)
This class represents a single unit of a specific type.
friend lua_unit * luaW_pushlocalunit(lua_State *L, unit &u)
Pushes a private unit on the stack.
friend lua_unit * luaW_pushunit(lua_State *L, Args... args)
std::shared_ptr< unit > unit_ptr
lua_unit & operator=(const lua_unit &)=delete
lua_unit * luaW_checkunit_ref(lua_State *L, int index)
Similar to luaW_checkunit but returns a lua_unit; use this if you need to handle map and recall units...
std::string register_metatables(lua_State *L)
int on_recall_list() const
unit * luaW_tounit(lua_State *L, int index, bool only_on_map=false)
Converts a Lua value to a unit pointer.
Encapsulates the map of the game.
lua_unit * luaW_pushlocalunit(lua_State *L, unit &u)
Pushes a private unit on the stack.
Storage for a unit, either owned by the Lua code (ptr != 0), a local variable unit (c_ptr != 0)...
unit_ptr luaW_tounit_ptr(lua_State *L, int index, bool only_on_map)
Similar to luaW_tounit but returns a unit_ptr; use this instead of luaW_tounit when using an api that...
lua_unit * luaW_tounit_ref(lua_State *L, int index)
Similar to luaW_tounit but returns a lua_unit; use this if you need to handle map and recall units di...
static map_location::DIRECTION s
unit * operator->() const
unit_ptr get_shared() const
lua_unit(const lua_unit &)=delete
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
lua_unit(int s, std::size_t u)
bool put_map(const map_location &loc)
bool luaW_isunit(lua_State *, int index)
Test if a Lua value is a unit.
unit_ptr luaW_checkunit_ptr(lua_State *L, int index, bool only_on_map)
Similar to luaW_checkunit but returns a unit_ptr; use this instead of luaW_checkunit when using an ap...