1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-02-04 02:24:00 +00:00

Merge branch 'experimental' of file:///Users/User/code/coding/Aquaria_fg_clean into experimental

This commit is contained in:
fgenesis 2013-10-21 02:27:29 +01:00
commit 77b56cf19b
5 changed files with 68 additions and 25 deletions

View file

@ -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)
{

View file

@ -486,7 +486,7 @@ public:
virtual bool canSetBoneLock();
void initHair(int numSegments, int segmentLength, int width, const std::string &tex);
void initHair(int numSegments, float segmentLength, float width, const std::string &tex);
void updateHair(float dt);
void setHairHeadPosition(const Vector &pos);
void exertHairForce(const Vector &force, float dt);

View file

@ -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);

View file

@ -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();

View file

@ -1535,6 +1535,21 @@ luaFunc(obj_fadeAlphaWithLife)
luaReturnNil();
}
luaFunc(obj_getWorldScale)
{
RenderObject *r = robj(L);
Vector s;
if (r)
s = r->getRealScale();
luaReturnVec2(s.x, s.y);
}
luaFunc(obj_getParent)
{
RenderObject *r = robj(L);
luaReturnPtr(r ? r->getParent() : NULL);
}
// ----- end RenderObject common functions -----
@ -1746,6 +1761,8 @@ luaFunc(quad_getBorderAlpha)
RO_FUNC(getter, prefix, collideCircleVsLineAngle) \
RO_FUNC(getter, prefix, getVectorToObj ) \
RO_FUNC(getter, prefix, fadeAlphaWithLife ) \
RO_FUNC(getter, prefix, getWorldScale ) \
RO_FUNC(getter, prefix, getParent ) \
MK_ALIAS(prefix, fh, flipHorizontal ) \
MK_ALIAS(prefix, fv, flipVertical )
@ -3815,17 +3832,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 +4262,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 +4449,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 +4488,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 +8772,7 @@ static const struct {
luaRegister(beam_setBeamWidth),
luaRegister(beam_setFirer),
luaRegister(beam_setDamageType),
luaRegister(beam_getEndPos),
luaRegister(getStringBank),
@ -9297,6 +9354,8 @@ static const struct {
luaRegister(entity_setHealth),
luaRegister(entity_setCurrentHealth),
luaRegister(entity_setMaxHealth),
luaRegister(entity_changeHealth),
luaRegister(node_setActive),
@ -9325,6 +9384,7 @@ static const struct {
luaRegister(entity_isAnimating),
luaRegister(entity_getAnimationName),
luaRegister(entity_getAnimationLength),
luaRegister(entity_hasAnimation),
luaRegister(entity_setCull),