mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 17:26:41 +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;
|
hair = 0;
|
||||||
maxSpeedLerp = 1;
|
maxSpeedLerp = 1;
|
||||||
fillGridFromQuad = false;
|
fillGridFromQuad = false;
|
||||||
|
fillGridFromSkel = false;
|
||||||
dropChance = 0;
|
dropChance = 0;
|
||||||
inCurrent = false;
|
inCurrent = false;
|
||||||
for (size_t i = 0; i < EP_MAX; i++)
|
for (size_t i = 0; i < EP_MAX; i++)
|
||||||
|
@ -2422,7 +2423,17 @@ void Entity::fillGrid()
|
||||||
{
|
{
|
||||||
if (fillGridFromQuad)
|
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 canBeTargetedByAvatar;
|
||||||
bool stopSoundsOnDeath;
|
bool stopSoundsOnDeath;
|
||||||
public:
|
public:
|
||||||
bool fillGridFromQuad;
|
unsigned char fillGridFromQuad;
|
||||||
|
unsigned char fillGridFromSkel;
|
||||||
bool beautyFlip;
|
bool beautyFlip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -342,10 +342,12 @@ void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim)
|
||||||
GridFiller f;
|
GridFiller f;
|
||||||
f.obs = obsType;
|
f.obs = obsType;
|
||||||
f.trim = trim;
|
f.trim = trim;
|
||||||
f.fh = q->isfh();
|
f.fh = q->isfhr();
|
||||||
f.position = q->position;
|
Vector posrot = q->getWorldPositionAndRotation();
|
||||||
f.rotation = q->rotation.z;
|
f.position.x = posrot.x;
|
||||||
f.scale = q->scale;
|
f.position.y = posrot.y;
|
||||||
|
f.rotation = posrot.z;
|
||||||
|
f.scale = q->getRealScale();
|
||||||
f.texture = q->texture.content();
|
f.texture = q->texture.content();
|
||||||
f.width = q->width;
|
f.width = q->width;
|
||||||
f.height = q->height;
|
f.height = q->height;
|
||||||
|
|
|
@ -567,6 +567,24 @@ bool getBool(lua_State *L, int slot = 1)
|
||||||
return false;
|
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
|
static inline
|
||||||
Entity *entity(lua_State *L, int slot = 1)
|
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 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 luaReturnInt(num) do {lua_pushinteger(L, (num)); return 1;} while(0)
|
||||||
#define luaReturnNum(num) do {lua_pushnumber(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)
|
#define luaReturnPtr(ptr) do {luaPushPointer(L, (ptr)); return 1;} while(0)
|
||||||
|
@ -3561,10 +3579,10 @@ luaFunc(node_setPauseFreeze)
|
||||||
luaFunc(entity_setFillGrid)
|
luaFunc(entity_setFillGrid)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
bool b = getBool(L,2);
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
e->fillGridFromQuad = b;
|
e->fillGridFromQuad = getBoolOrInt(L, 2);
|
||||||
|
e->fillGridFromSkel = getBoolOrInt(L, 3);
|
||||||
}
|
}
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
@ -3572,7 +3590,12 @@ luaFunc(entity_setFillGrid)
|
||||||
luaFunc(entity_isFillGrid)
|
luaFunc(entity_isFillGrid)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
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)
|
luaFunc(entity_getAimVector)
|
||||||
|
|
Loading…
Reference in a new issue