mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-15 05:59:16 +00:00
Add some Lua functions, changes to hair.
+ beam_getEndPos() + entity_setCurrentHealth() + entity_setMaxHealth() + beam_getEndPos() + entity_hasAnimation() - Add 3 new parameters to entity_damage: shot, hitX, hitY - entity_getAnimationLength() supports string as 2nd parameter now. This will lookup an animation's length via name. Passing an ANIMLAYER_* constant works as it used to.
This commit is contained in:
parent
84f1b12c67
commit
d97bb25b9e
4 changed files with 50 additions and 24 deletions
|
@ -3107,7 +3107,7 @@ bool Entity::doCollisionAvoidance(float dt, int search, float mod, Vector *vp, i
|
|||
return false;
|
||||
}
|
||||
|
||||
void Entity::initHair(int numSegments, int segmentLength, int width, const std::string &tex)
|
||||
void Entity::initHair(int numSegments, float segmentLength, float width, const std::string &tex)
|
||||
{
|
||||
if (hair)
|
||||
{
|
||||
|
|
|
@ -25,13 +25,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
// nodes = 40
|
||||
// segmentLength = 3
|
||||
Hair::Hair(int nodes, int segmentLength, int hairWidth) : RenderObject()
|
||||
Hair::Hair(int nodes, float segmentLength, float hairWidth) : RenderObject()
|
||||
{
|
||||
this->segmentLength = segmentLength;
|
||||
this->hairWidth = hairWidth;
|
||||
waveTimer = 0;
|
||||
waveAmount = 5;
|
||||
//hairWidth = 10;
|
||||
|
||||
cull = false;
|
||||
|
||||
|
@ -46,7 +43,6 @@ Hair::Hair(int nodes, int segmentLength, int hairWidth) : RenderObject()
|
|||
hairNodes[i].percent = 1.0f-perc;
|
||||
hairNodes[i].position = hairNodes[i].originalPosition = hairNodes[i].defaultPosition = Vector(0, i*segmentLength, 0);
|
||||
}
|
||||
hairTimer = 0;
|
||||
}
|
||||
|
||||
void Hair::exertWave(float dt)
|
||||
|
@ -196,15 +192,6 @@ void Hair::onRender()
|
|||
#endif
|
||||
}
|
||||
|
||||
void Hair::updateWaveTimer(float dt)
|
||||
{
|
||||
waveTimer += dt;
|
||||
for (int i = 1; i < hairNodes.size(); i++)
|
||||
{
|
||||
hairNodes[i].defaultPosition = hairNodes[i].originalPosition + Vector(cosf(waveTimer+i)*waveAmount*hairNodes[i].percent, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Hair::onUpdate(float dt)
|
||||
{
|
||||
RenderObject::onUpdate(dt);
|
||||
|
|
|
@ -38,13 +38,13 @@ struct HairNode
|
|||
class Hair : public RenderObject
|
||||
{
|
||||
public:
|
||||
Hair(int nodes=40, int segmentLength=3, int width=18);
|
||||
Hair(int nodes=40, float segmentLength=3, float width=18);
|
||||
|
||||
void exertForce(const Vector &force, float dt, int usePerc=0);
|
||||
void updatePositions();
|
||||
void returnToDefaultPositions(float dt);
|
||||
|
||||
int hairWidth;
|
||||
float hairWidth;
|
||||
|
||||
std::vector<HairNode> hairNodes;
|
||||
|
||||
|
@ -54,10 +54,6 @@ public:
|
|||
void exertGravityWave(float dt);
|
||||
HairNode *getHairNode(int idx);
|
||||
protected:
|
||||
float hairTimer;
|
||||
void updateWaveTimer(float dt);
|
||||
int waveAmount;
|
||||
float waveTimer;
|
||||
float segmentLength;
|
||||
void onUpdate(float dt);
|
||||
void onRender();
|
||||
|
|
|
@ -3815,17 +3815,29 @@ luaFunc(entity_getAnimationLength)
|
|||
{
|
||||
Entity *e = entity(L);
|
||||
float ret=0;
|
||||
int layer = lua_tonumber(L, 2);
|
||||
if (e)
|
||||
{
|
||||
if (Animation *anim = e->skeletalSprite.getCurrentAnimation(layer))
|
||||
Animation *anim = 0;
|
||||
if (lua_isstring(L, 2))
|
||||
anim = e->skeletalSprite.getAnimation(lua_tostring(L, 2));
|
||||
else
|
||||
{
|
||||
ret = anim->getAnimationLength();
|
||||
int layer = lua_tointeger(L, 2);
|
||||
anim = e->skeletalSprite.getCurrentAnimation(layer);
|
||||
}
|
||||
if (anim)
|
||||
ret = anim->getAnimationLength();
|
||||
}
|
||||
luaReturnNum(ret);
|
||||
}
|
||||
|
||||
luaFunc(entity_hasAnimation)
|
||||
{
|
||||
Entity *e = entity(L);
|
||||
Animation *anim = e->skeletalSprite.getAnimation(getString(L, 2));
|
||||
luaReturnBool(anim != NULL);
|
||||
}
|
||||
|
||||
luaFunc(entity_isFollowingPath)
|
||||
{
|
||||
Entity *e = entity(L);
|
||||
|
@ -4233,6 +4245,15 @@ luaFunc(beam_setPosition_override)
|
|||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(beam_getEndPos)
|
||||
{
|
||||
Beam *b = beam(L);
|
||||
Vector v;
|
||||
if (b)
|
||||
v = b->endPos;
|
||||
luaReturnVec2(v.x, v.y);
|
||||
}
|
||||
|
||||
luaFunc(getStringBank)
|
||||
{
|
||||
luaReturnStr(dsq->continuity.stringBank.get(lua_tointeger(L, 1)).c_str());
|
||||
|
@ -4411,6 +4432,8 @@ luaFunc(entity_damage)
|
|||
d.damageType = (DamageType)lua_tointeger(L, 4);
|
||||
d.effectTime = lua_tonumber(L, 5);
|
||||
d.useTimer = !getBool(L, 6);
|
||||
d.shot = lua_isuserdata(L, 7) ? getShot(L, 7) : NULL;
|
||||
d.hitPos = Vector(lua_tonumber(L, 8), lua_tonumber(L, 9));
|
||||
didDamage = e->damage(d);
|
||||
}
|
||||
luaReturnBool(didDamage);
|
||||
|
@ -4448,6 +4471,22 @@ luaFunc(entity_setHealth)
|
|||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(entity_setCurrentHealth)
|
||||
{
|
||||
Entity *e = entity(L, 1);
|
||||
if (e)
|
||||
e->health = lua_tonumber(L, 2);
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(entity_setMaxHealth)
|
||||
{
|
||||
Entity *e = entity(L, 1);
|
||||
if (e)
|
||||
e->maxHealth = lua_tonumber(L, 2);
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(entity_changeHealth)
|
||||
{
|
||||
Entity *e = entity(L, 1);
|
||||
|
@ -8716,6 +8755,7 @@ static const struct {
|
|||
luaRegister(beam_setBeamWidth),
|
||||
luaRegister(beam_setFirer),
|
||||
luaRegister(beam_setDamageType),
|
||||
luaRegister(beam_getEndPos),
|
||||
|
||||
luaRegister(getStringBank),
|
||||
|
||||
|
@ -9297,6 +9337,8 @@ static const struct {
|
|||
|
||||
|
||||
luaRegister(entity_setHealth),
|
||||
luaRegister(entity_setCurrentHealth),
|
||||
luaRegister(entity_setMaxHealth),
|
||||
luaRegister(entity_changeHealth),
|
||||
|
||||
luaRegister(node_setActive),
|
||||
|
@ -9325,6 +9367,7 @@ static const struct {
|
|||
luaRegister(entity_isAnimating),
|
||||
luaRegister(entity_getAnimationName),
|
||||
luaRegister(entity_getAnimationLength),
|
||||
luaRegister(entity_hasAnimation),
|
||||
|
||||
luaRegister(entity_setCull),
|
||||
|
||||
|
|
Loading…
Reference in a new issue