mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-15 14:09:06 +00:00
Some fixes (...)
- Get colliding hair segment - drop AnimatedSprite & Interpolator classes - repair entity_setAutoSkeletalUpdate() - remove some old code
This commit is contained in:
parent
5d74665323
commit
b242d80c75
10 changed files with 38 additions and 129 deletions
|
@ -4584,7 +4584,6 @@ Avatar::Avatar() : Entity(), ActionMapper()
|
|||
this->pushingOffWallEffect = 0;
|
||||
lockToWallFallTimer = 0;
|
||||
swimming = false;
|
||||
dodgeDelay = 0;
|
||||
charging = false;
|
||||
bursting = false;
|
||||
animatedBurst = false;
|
||||
|
@ -4595,8 +4594,6 @@ Avatar::Avatar() : Entity(), ActionMapper()
|
|||
splashDelay = 0;
|
||||
avatar = this;
|
||||
|
||||
frame = 0;
|
||||
|
||||
particleDelay = 0;
|
||||
|
||||
swimming = false;
|
||||
|
@ -5006,44 +5003,6 @@ void Avatar::setActiveSpell(Spells spell)
|
|||
}
|
||||
*/
|
||||
|
||||
void Avatar::dodge(std::string dir)
|
||||
{
|
||||
if (bursting) return;
|
||||
if (!canMove) return;
|
||||
if (dodgeDelay == 0)
|
||||
{
|
||||
Vector mov;
|
||||
|
||||
if (dir == "right")
|
||||
mov = Vector(1,0);
|
||||
else if (dir == "left")
|
||||
mov = Vector(-1, 0);
|
||||
else if (dir == "down")
|
||||
mov = Vector(0, 1);
|
||||
else if (dir == "up")
|
||||
mov = Vector(0, -1);
|
||||
|
||||
Vector lastPosition = position;
|
||||
//position += mov * 80;
|
||||
|
||||
dodgeVec = mov * 8000;
|
||||
vel += mov * vars->maxDodgeSpeed;
|
||||
//dodgeEffectTimer = 0.125;
|
||||
state.dodgeEffectTimer.start(/*0.125*/vars->dodgeTime);
|
||||
/*
|
||||
float vlen = vel.getLength2D();
|
||||
mov |= 500;
|
||||
vel += mov;
|
||||
*/
|
||||
/*
|
||||
if (dsq->game->collideCircleWithGrid(position, 24))
|
||||
{
|
||||
position = lastPosition;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void Avatar::startBackFlip()
|
||||
{
|
||||
if (boneLock.on) return;
|
||||
|
@ -5284,29 +5243,6 @@ void Avatar::startWallBurst(bool useCursor)
|
|||
}
|
||||
}
|
||||
|
||||
void Avatar::doDodgeInput(const std::string &action, int s)
|
||||
{
|
||||
if (s)
|
||||
{
|
||||
if (tapped.empty())
|
||||
{
|
||||
tapped = action;
|
||||
state.tapTimer.start(0.25);
|
||||
}
|
||||
else if (tapped == action)
|
||||
{
|
||||
if (state.tapTimer.isActive())
|
||||
dodge(action);
|
||||
tapped = "";
|
||||
dodgeDelay = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tapped = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector Avatar::getKeyDir()
|
||||
{
|
||||
Vector dir;
|
||||
|
@ -5983,13 +5919,7 @@ int Avatar::getBeamWidth()
|
|||
void Avatar::onEnterState(int action)
|
||||
{
|
||||
Entity::onEnterState(action);
|
||||
if (action == STATE_TRANSFORM)
|
||||
{
|
||||
animator.stop();
|
||||
frame = 0;
|
||||
animate(anim_fish);
|
||||
}
|
||||
else if (action == STATE_PUSH)
|
||||
if (action == STATE_PUSH)
|
||||
{
|
||||
state.lockedToWall = false;
|
||||
state.crawlingOnWall = false;
|
||||
|
@ -7983,10 +7913,6 @@ void Avatar::onUpdate(float dt)
|
|||
{
|
||||
}
|
||||
|
||||
if (state.tapTimer.updateCheck(dt))
|
||||
{
|
||||
tapped = "";
|
||||
}
|
||||
if (pushingOffWallEffect > 0)
|
||||
{
|
||||
pushingOffWallEffect -= dt;
|
||||
|
@ -8035,14 +7961,6 @@ void Avatar::onUpdate(float dt)
|
|||
}
|
||||
}
|
||||
*/
|
||||
if (dodgeDelay > 0)
|
||||
{
|
||||
dodgeDelay -= dt;
|
||||
if (dodgeDelay <= 0)
|
||||
{
|
||||
dodgeDelay = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (text)
|
||||
{
|
||||
|
|
|
@ -127,7 +127,6 @@ public:
|
|||
float shotDelay;
|
||||
//Timer shockTimer;
|
||||
Timer useItemDelay;
|
||||
Timer tapTimer;
|
||||
Timer lockToWallDelay;
|
||||
float spellCharge;
|
||||
bool lockedToWall;
|
||||
|
@ -151,8 +150,6 @@ public:
|
|||
virtual ~Avatar();
|
||||
void destroy();
|
||||
void action(int actionID, int state);
|
||||
// anim data
|
||||
AnimData anim_swim, anim_stopTransition, anim_idle, anim_idle2, anim_burst, anim_fish;
|
||||
AvatarState state;
|
||||
void setIgnoreInputDelay(float delay)
|
||||
{
|
||||
|
@ -518,19 +515,10 @@ protected:
|
|||
|
||||
bool charging;
|
||||
|
||||
AnimData tongueAnim;
|
||||
|
||||
//Quad *chargeGraphic;
|
||||
|
||||
|
||||
Vector lastPush;
|
||||
|
||||
std::string tapped;
|
||||
float dodgeDelay;
|
||||
float pushingOffWallEffect;
|
||||
float lockToWallFallTimer;
|
||||
void dodge(std::string dir);
|
||||
void doDodgeInput(const std::string &action, int state);
|
||||
|
||||
Vector dodgeVec;
|
||||
Vector wallPushVec, wallTurnVec;
|
||||
|
|
|
@ -501,9 +501,9 @@ void Entity::followPath(Path *p, int speedType, int dir, bool deleteOnEnd)
|
|||
position.data->path.addPathNode(pn.position, float(i/float(p->nodes.size())));
|
||||
}
|
||||
}
|
||||
debugLog("Calculating Time");
|
||||
//debugLog("Calculating Time");
|
||||
float time = position.data->path.getLength()/(float)dsq->continuity.getSpeedType(speedType);
|
||||
debugLog("Starting");
|
||||
//debugLog("Starting");
|
||||
position.data->path.getPathNode(0)->value = position;
|
||||
position.startPath(time);//, 1.0f/2.0f);
|
||||
}
|
||||
|
@ -1266,7 +1266,7 @@ void Entity::update(float dt)
|
|||
//skeletalSprite.setFreeze(true);
|
||||
|
||||
if (frozenTimer == 0 || getState() == STATE_PUSH)
|
||||
AnimatedSprite::update(dt);
|
||||
Quad::update(dt);
|
||||
onAlwaysUpdate(dt);
|
||||
|
||||
// always, always update:
|
||||
|
@ -1873,7 +1873,7 @@ void Entity::onUpdate(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
AnimatedSprite::onUpdate(dt);
|
||||
Quad::onUpdate(dt);
|
||||
|
||||
Vector v = position - lastPos;
|
||||
lastMove = v;
|
||||
|
@ -2971,7 +2971,7 @@ void Entity::render()
|
|||
blurShader.bind();
|
||||
set = true;
|
||||
}
|
||||
AnimatedSprite::render();
|
||||
Quad::render();
|
||||
//if (beautyFlip && blurShader.isLoaded() && flipScale.isInterpolating())
|
||||
if (set)
|
||||
blurShader.unbind();
|
||||
|
|
|
@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#ifndef ENTITY_H
|
||||
#define ENTITY_H
|
||||
|
||||
#include "../BBGE/AnimatedSprite.h"
|
||||
#include "../BBGE/StateMachine.h"
|
||||
#include "../ExternalLibs/tinyxml.h"
|
||||
#include "../BBGE/SkeletalSprite.h"
|
||||
|
@ -195,7 +194,7 @@ enum BounceType
|
|||
BOUNCE_REAL = 1
|
||||
};
|
||||
|
||||
class Entity : public AnimatedSprite, public StateMachine
|
||||
class Entity : public Quad, public StateMachine
|
||||
{
|
||||
public:
|
||||
Entity();
|
||||
|
@ -592,7 +591,7 @@ protected:
|
|||
void updateBoneLock();
|
||||
|
||||
int pushMaxSpeed;
|
||||
|
||||
std::string currentAnim;
|
||||
|
||||
|
||||
protected:
|
||||
|
|
|
@ -8346,26 +8346,25 @@ bool Game::collideCircleVsCircle(Entity *a, Entity *b)
|
|||
return (a->position - b->position).isLength2DIn(a->collideRadius + b->collideRadius);
|
||||
}
|
||||
|
||||
bool Game::collideHairVsCircle(Entity *a, int num, const Vector &pos2, int radius, float perc)
|
||||
bool Game::collideHairVsCircle(Entity *a, int num, const Vector &pos2, int radius, float perc, int *colSegment)
|
||||
{
|
||||
if (perc == 0)
|
||||
perc = 1;
|
||||
bool c = false;
|
||||
if (a->hair)
|
||||
if (a && a->hair)
|
||||
{
|
||||
if (a)
|
||||
if (num == 0)
|
||||
num = a->hair->hairNodes.size();
|
||||
// HACK: minus 2
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
if (num == 0)
|
||||
num = a->hair->hairNodes.size();
|
||||
// HACK: minus 2
|
||||
for (int i = 0; i < num; i++)
|
||||
// + a->hair->position
|
||||
c = ((a->hair->hairNodes[i].position) - pos2).isLength2DIn(a->hair->hairWidth*perc + radius);
|
||||
if (c)
|
||||
{
|
||||
// + a->hair->position
|
||||
c = ((a->hair->hairNodes[i].position) - pos2).isLength2DIn(a->hair->hairWidth*perc + radius);
|
||||
if (c)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (colSegment)
|
||||
*colSegment = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -677,7 +677,7 @@ public:
|
|||
bool collideBoxWithGrid(const Vector& position, int w, int h);
|
||||
bool collideCircleWithGrid(const Vector& position, int r);
|
||||
|
||||
bool collideHairVsCircle(Entity *a, int num, const Vector &pos2, int radius, float perc=0);
|
||||
bool collideHairVsCircle(Entity *a, int num, const Vector &pos2, int radius, float perc=0, int *colSegment=0);
|
||||
|
||||
bool collideCircleVsCircle(Entity *a, Entity *b);
|
||||
Bone *collideSkeletalVsCircle(Entity *skeletal, Entity *circle);
|
||||
|
|
|
@ -4140,9 +4140,16 @@ luaFunc(entity_collideHairVsCircle)
|
|||
int num = lua_tonumber(L, 3);
|
||||
// perc: percent of hairWidth to use as collide radius
|
||||
float perc = lua_tonumber(L, 4);
|
||||
col = dsq->game->collideHairVsCircle(e, num, e2->position, e2->collideRadius, perc);
|
||||
int colSegment;
|
||||
col = dsq->game->collideHairVsCircle(e, num, e2->position, e2->collideRadius, perc, &colSegment);
|
||||
if(col)
|
||||
{
|
||||
lua_pushboolean(L, true);
|
||||
lua_pushinteger(L, colSegment);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
luaReturnBool(col);
|
||||
luaReturnBool(false);
|
||||
}
|
||||
|
||||
luaFunc(entity_collideSkeletalVsCircleForListByName)
|
||||
|
@ -4276,7 +4283,12 @@ luaFunc(entity_updateSkeletal)
|
|||
{
|
||||
Entity *e = entity(L);
|
||||
if (e)
|
||||
{
|
||||
bool oldIgnore = e->skeletalSprite.ignoreUpdate;
|
||||
e->skeletalSprite.ignoreUpdate = false;
|
||||
e->skeletalSprite.update(lua_tonumber(L, 2));
|
||||
e->skeletalSprite.ignoreUpdate = oldIgnore;
|
||||
}
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E
|
|||
{
|
||||
addType(SCO_SCRIPTED_ENTITY);
|
||||
crushDelay = 0;
|
||||
autoSkeletalSpriteUpdate = true;
|
||||
script = 0;
|
||||
songNoteFunction = songNoteDoneFunction = true;
|
||||
addChild(&pullEmitter, PM_STATIC);
|
||||
|
@ -83,7 +82,7 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E
|
|||
|
||||
void ScriptedEntity::setAutoSkeletalUpdate(bool v)
|
||||
{
|
||||
autoSkeletalSpriteUpdate = v;
|
||||
skeletalSprite.ignoreUpdate = !v;
|
||||
}
|
||||
|
||||
void ScriptedEntity::message(const std::string &msg, int v)
|
||||
|
@ -640,13 +639,8 @@ void ScriptedEntity::onUpdate(float dt)
|
|||
}
|
||||
*/
|
||||
|
||||
if (!autoSkeletalSpriteUpdate)
|
||||
skeletalSprite.ignoreUpdate = true;
|
||||
|
||||
CollideEntity::onUpdate(dt);
|
||||
|
||||
if (!autoSkeletalSpriteUpdate)
|
||||
skeletalSprite.ignoreUpdate = false;
|
||||
//updateStrands(dt);
|
||||
|
||||
if (becomeSolidDelay)
|
||||
|
|
|
@ -93,7 +93,6 @@ protected:
|
|||
void onDieEaten();
|
||||
void luaDebugMsg(const std::string &func, const std::string &msg);
|
||||
float crushDelay;
|
||||
bool autoSkeletalSpriteUpdate;
|
||||
int beforePullMaxSpeed;
|
||||
bool songNoteFunction, preUpdateFunc;
|
||||
bool songNoteDoneFunction;
|
||||
|
|
|
@ -373,7 +373,6 @@ SET(BBGE_SRCS
|
|||
${BBGEDIR}/ActionMapper.cpp
|
||||
${BBGEDIR}/ActionSet.cpp
|
||||
${BBGEDIR}/AfterEffect.cpp
|
||||
${BBGEDIR}/AnimatedSprite.cpp
|
||||
${BBGEDIR}/Base.cpp
|
||||
${BBGEDIR}/BitmapFont.cpp
|
||||
${BBGEDIR}/Collision.cpp
|
||||
|
@ -387,7 +386,6 @@ SET(BBGE_SRCS
|
|||
${BBGEDIR}/Flags.cpp
|
||||
${BBGEDIR}/FrameBuffer.cpp
|
||||
${BBGEDIR}/Gradient.cpp
|
||||
${BBGEDIR}/Interpolator.cpp
|
||||
${BBGEDIR}/Joystick.cpp
|
||||
${BBGEDIR}/LensFlare.cpp
|
||||
${BBGEDIR}/Localization.cpp
|
||||
|
@ -460,12 +458,14 @@ SET(PNG_SRCS
|
|||
|
||||
# Apparently not used at the moment. Listed here just for completeness.
|
||||
SET(BBGE_SRCS_UNUSED
|
||||
${BBGEDIR}/AnimatedSprite.cpp
|
||||
${BBGEDIR}/BloomEffect.cpp
|
||||
${BBGEDIR}/CShim.cpp
|
||||
${BBGEDIR}/Cutscene.cpp
|
||||
${BBGEDIR}/Datafile.cpp
|
||||
${BBGEDIR}/DFSprite.cpp
|
||||
${BBGEDIR}/FileVars.cpp
|
||||
${BBGEDIR}/Interpolator.cpp
|
||||
${BBGEDIR}/Light.cpp
|
||||
${BBGEDIR}/LightCone.cpp
|
||||
${BBGEDIR}/Model.cpp
|
||||
|
|
Loading…
Reference in a new issue