mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 09:16:48 +00:00
Change entity_setFillGrid() to allow skeleton grid filling, and whether to trim
entity_isFillGrid() returns two bools now
This commit is contained in:
parent
2149fcd01e
commit
c598fde5e8
4 changed files with 47 additions and 10 deletions
|
@ -191,6 +191,7 @@ Entity::Entity()
|
|||
hair = 0;
|
||||
maxSpeedLerp = 1;
|
||||
fillGridFromQuad = false;
|
||||
fillGridFromSkel = false;
|
||||
dropChance = 0;
|
||||
inCurrent = false;
|
||||
for (size_t i = 0; i < EP_MAX; i++)
|
||||
|
@ -2422,7 +2423,17 @@ void Entity::fillGrid()
|
|||
{
|
||||
if (fillGridFromQuad)
|
||||
{
|
||||
game->fillGridFromQuad(this, OT_INVISIBLEENT);
|
||||
game->fillGridFromQuad(this, OT_INVISIBLEENT, fillGridFromQuad == 1);
|
||||
}
|
||||
if (fillGridFromSkel)
|
||||
{
|
||||
bool trim = fillGridFromSkel == 1;
|
||||
for(size_t i = 0; i < skeletalSprite.bones.size(); ++i)
|
||||
{
|
||||
Bone *b = skeletalSprite.bones[i];
|
||||
if(b->generateCollisionMask && b->renderQuad)
|
||||
game->fillGridFromQuad(b, OT_INVISIBLEENT, trim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -439,7 +439,8 @@ protected:
|
|||
bool canBeTargetedByAvatar;
|
||||
bool stopSoundsOnDeath;
|
||||
public:
|
||||
bool fillGridFromQuad;
|
||||
unsigned char fillGridFromQuad;
|
||||
unsigned char fillGridFromSkel;
|
||||
bool beautyFlip;
|
||||
};
|
||||
|
||||
|
|
|
@ -342,10 +342,12 @@ void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim)
|
|||
GridFiller f;
|
||||
f.obs = obsType;
|
||||
f.trim = trim;
|
||||
f.fh = q->isfh();
|
||||
f.position = q->position;
|
||||
f.rotation = q->rotation.z;
|
||||
f.scale = q->scale;
|
||||
f.fh = q->isfhr();
|
||||
Vector posrot = q->getWorldPositionAndRotation();
|
||||
f.position.x = posrot.x;
|
||||
f.position.y = posrot.y;
|
||||
f.rotation = posrot.z;
|
||||
f.scale = q->getRealScale();
|
||||
f.texture = q->texture.content();
|
||||
f.width = q->width;
|
||||
f.height = q->height;
|
||||
|
|
|
@ -567,6 +567,24 @@ bool getBool(lua_State *L, int slot = 1)
|
|||
return false;
|
||||
}
|
||||
|
||||
static inline
|
||||
int getBoolOrInt(lua_State *L, int slot = 1)
|
||||
{
|
||||
if (lua_isnumber(L, slot))
|
||||
{
|
||||
return lua_tointeger(L, slot);
|
||||
}
|
||||
else if (lua_islightuserdata(L, slot))
|
||||
{
|
||||
return (lua_touserdata(L, slot) != NULL);
|
||||
}
|
||||
else if (lua_isboolean(L, slot))
|
||||
{
|
||||
return !!lua_toboolean(L, slot);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline
|
||||
Entity *entity(lua_State *L, int slot = 1)
|
||||
{
|
||||
|
@ -777,7 +795,7 @@ static void safePath(lua_State *L, const std::string& path)
|
|||
//----------------------------------//
|
||||
|
||||
#define luaFunc(func) static int l_##func(lua_State *L)
|
||||
#define luaReturnBool(bool) do {lua_pushboolean(L, (bool)); return 1;} while(0)
|
||||
#define luaReturnBool(b) do {lua_pushboolean(L, (b)); return 1;} while(0)
|
||||
#define luaReturnInt(num) do {lua_pushinteger(L, (num)); return 1;} while(0)
|
||||
#define luaReturnNum(num) do {lua_pushnumber(L, (num)); return 1;} while(0)
|
||||
#define luaReturnPtr(ptr) do {luaPushPointer(L, (ptr)); return 1;} while(0)
|
||||
|
@ -3561,10 +3579,10 @@ luaFunc(node_setPauseFreeze)
|
|||
luaFunc(entity_setFillGrid)
|
||||
{
|
||||
Entity *e = entity(L);
|
||||
bool b = getBool(L,2);
|
||||
if (e)
|
||||
{
|
||||
e->fillGridFromQuad = b;
|
||||
e->fillGridFromQuad = getBoolOrInt(L, 2);
|
||||
e->fillGridFromSkel = getBoolOrInt(L, 3);
|
||||
}
|
||||
luaReturnNil();
|
||||
}
|
||||
|
@ -3572,7 +3590,12 @@ luaFunc(entity_setFillGrid)
|
|||
luaFunc(entity_isFillGrid)
|
||||
{
|
||||
Entity *e = entity(L);
|
||||
luaReturnBool(e ? e->fillGridFromQuad : false);
|
||||
if(!e)
|
||||
return 0;
|
||||
|
||||
lua_pushboolean(L, e->fillGridFromQuad);
|
||||
lua_pushboolean(L, e->fillGridFromSkel);
|
||||
return 2;
|
||||
}
|
||||
|
||||
luaFunc(entity_getAimVector)
|
||||
|
|
Loading…
Reference in a new issue