Cleaning out some dead code.

This adds a small compile error, to be fixed in next commit.
This commit is contained in:
fgenesis 2013-09-04 16:07:46 +02:00
parent 31ab72334b
commit a91a22f463
7 changed files with 30 additions and 365 deletions

View File

@ -93,7 +93,6 @@ const float QUICK_SONG_CAST_DELAY = 0.4;
const float BURST_RECOVER_RATE = 1.2; // 3.0 // 0.75
const float BURST_USE_RATE = 1.5; //0.9 //1.5;
const float BURST_DELAY = 0.1;
const float BURST_ACCEL = 4000; //2000 // 1000
// Minimum time between two splash effects (seconds).
@ -265,13 +264,6 @@ void Avatar::postInit()
void Avatar::onAnimationKeyPassed(int key)
{
if (swimming && !isRolling() && !bursting && _isUnderWater)
{
if (key == 0 || key == 2)
{
//core->sound->playSfx("SwimKick", 255, 0, 1000+getMaxSpeed()/10.0f);
}
}
Entity::onAnimationKeyPassed(key);
}
@ -3496,31 +3488,15 @@ void Avatar::lockToWall()
if (dsq->game->isPaused()) return;
TileVector t(position);
TileVector myTile = t;
// 3 + 4
// 4 + 5
Vector m = vel;
m.setLength2D(3);
t.x += int(m.x);
t.y += int(m.y);
m.setLength2D(2);
TileVector tback = myTile;
tback.x += int(m.x);
tback.y += int(m.y);
Vector add = m;
add.setLength2D(1);
TileVector tnext = myTile;
tnext.x += int(add.x);
tnext.y += int(add.y);
bool good = true;
if (!dsq->game->isObstructed(t))
{
int tried = 0;
//tryAgain:
while(1)
do
{
TileVector test;
@ -3572,46 +3548,23 @@ void Avatar::lockToWall()
t = test;
break;
}
tried++;
//if (tried >= 2)
if (true)
{
good = false;
break;
}
else
{
//debugLog("trying other");
//t = myTile;
//goto tryAgain;
}
good = false;
}
while(0);
}
if (dsq->game->getGrid(t)==OT_HURT && isDamageTarget(DT_WALLHURT))
{
good = false;
}
if (good /*&& dsq->game->)isObstructed(t2, OT_BLACK)*/ /*&& diff.getSquaredLength2D() > sqr(40)*/)
if (good)
{
wallNormal = dsq->game->getWallNormal(position);
bool outOfWaterHit = (!_isUnderWater && !(wallNormal.y < -0.1f));
if (wallNormal.isZero() ) //|| outOfWaterHit
if (wallNormal.isZero() )
{
debugLog("COULD NOT FIND NORMAL, GOING TO BOUNCE");
if (outOfWaterHit)
{
/*
Animation *anim = skeletalSprite.getCurrentAnimation();
if (anim && anim->name == "hitGround")
{
}
else
{
skeletalSprite.animate("hitGround");
}
*/
}
return;
}
else
@ -3648,16 +3601,6 @@ void Avatar::lockToWall()
offset.stop();
Vector goIn;
TileVector uset;
if (!dsq->game->isObstructed(tnext))
{
uset = tnext;
}
else
uset = tback;
int tileType = dsq->game->getGrid(t);
Vector offdiff = t.worldVector() - position;
if (!offdiff.isZero())
@ -3948,12 +3891,9 @@ Avatar::Avatar() : Entity(), ActionMapper()
bursting = false;
burst = 1;
burstDelay = 0;
ignoreInputDelay = 0;
splashDelay = 0;
avatar = this;
particleDelay = 0;
swimming = false;
debugLog("Avatar 3");
@ -6558,32 +6498,15 @@ void Avatar::onUpdate(float dt)
if (!rolling && !state.backFlip && !flourish)
{
bool swimOnBack = false;
if (swimOnBack)
if (addVec.x > 0)
{
if (addVec.x > 0)
{
if (isfh())
flipHorizontal();
}
if (addVec.x < 0)
{
if (!isfh())
flipHorizontal();
}
if (!isfh())
flipHorizontal();
}
else
if (addVec.x < 0)
{
if (addVec.x > 0)
{
if (!isfh())
flipHorizontal();
}
if (addVec.x < 0)
{
if (isfh())
flipHorizontal();
}
if (isfh())
flipHorizontal();
}
}

View File

@ -445,7 +445,6 @@ protected:
bool checkWarpAreas();
void toggleZoom();
float ignoreInputDelay;
float splashDelay;
//Hair *hair;
@ -453,8 +452,6 @@ protected:
void onUpdate(float dt);
void onRender();
float particleDelay;
//float rippleDelay;
Quad *glow;
bool swimming;
@ -469,8 +466,7 @@ protected:
float pushingOffWallEffect;
float lockToWallFallTimer;
Vector dodgeVec;
Vector wallPushVec, wallTurnVec;
Vector wallPushVec;

View File

@ -29,9 +29,6 @@ CollideEntity::CollideEntity() : Entity()
this->canBeTargetedByAvatar = true;
weight = 0;
bounceAmount = 0.5f;
bounceEntityAmount = 0.5f;
doCusion = false;
friction = 0;
this->updateCull = 4000;
}
@ -115,56 +112,6 @@ void CollideEntity::updateMovement(float dt)
updateVel2(dt);
if (doCusion)
{
Vector push;
TileVector t(position+vel*dt);
if (dsq->game->isObstructed(TileVector(t.x-1, t.y)))
{
push += Vector(1.25,0);
}
if (dsq->game->isObstructed(TileVector(t.x+1, t.y)))
{
push += Vector(-1.25,0);
}
if (dsq->game->isObstructed(TileVector(t.x, t.y-1)))
{
push += Vector(0,1.25);
}
if (dsq->game->isObstructed(TileVector(t.x, t.y+1)))
{
push += Vector(0,-1.25);
}
if (dsq->game->isObstructed(TileVector(t.x-1, t.y-1)))
{
push += Vector(0.5,0.5);
}
if (dsq->game->isObstructed(TileVector(t.x-1, t.y+1)))
{
push += Vector(0.5,-0.5);
}
if (dsq->game->isObstructed(TileVector(t.x+1, t.y-1)))
{
push += Vector(-0.5,0.5);
}
if (dsq->game->isObstructed(TileVector(t.x+1, t.y+1)))
{
push += Vector(-0.5,-0.5);
}
// cushion
if (push.x != 0 || push.y != 0)
{
if (vel.getSquaredLength2D() > sqr(10))
{
push.setLength2D(100 * dt * 60);
push.z = 0;
}
vel += push;
}
}
Vector lastPosition = position;
bool underWater = isUnderWater();
@ -252,16 +199,6 @@ void CollideEntity::updateMovement(float dt)
}
}
if (collided && friction != 0 && (vel.x != 0 || vel.y != 0))
{
Vector fric = vel;
fric.setLength2D(-friction);
vel.z = 0;
vel += fric*dt;
}
//doFriction(dt);
if (!collided && weight != 0)
{
vel += Vector(0, weight*dt);

View File

@ -27,9 +27,8 @@ class CollideEntity : public Entity
{
public:
CollideEntity();
float bounceAmount, bounceEntityAmount;
float bounceAmount;
float weight;
Vector collideOffset;
void updateMovement(float dt);
void entityDied(Entity *e);
protected:
@ -37,8 +36,6 @@ protected:
void onUpdateFrozen(float dt);
virtual void onBounce() {}
float friction;
bool doCusion;
void bounce(float ba);
};

View File

@ -35,13 +35,12 @@ class Path;
struct BoneLock
{
BoneLock() : entity(0), bone(0), on(false), origRot(0), offRot(0) {}
BoneLock() : entity(0), bone(0), on(false), origRot(0) {}
Entity *entity;
Bone *bone;
Vector localOffset;
bool on;
float origRot;
float offRot;
Vector wallNormal, circleOffset;
int collisionMaskIndex;
};

View File

@ -38,7 +38,6 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E
becomeSolidDelay = false;
strandSpacing = 10;
animKeyFunc = true;
preUpdateFunc = true;
//runningActivation = false;
setEntityType(et);
@ -120,16 +119,8 @@ void ScriptedEntity::init()
if (!script->call("init", this))
luaDebugMsg("init", script->getLastError());
}
//update(0);
Entity::init();
/*
if (script)
{
bool fail=false;
//update(0);
}
*/
}
void ScriptedEntity::postInit()
@ -257,11 +248,6 @@ void ScriptedEntity::initStrands(int num, int segs, int dist, int strandSpacing,
strands.resize(num);
for (int i = 0; i < strands.size(); i++)
{
/*
int sz = 5;
if (i == 0 || i == strands.size()-1)
sz = 4;
*/
strands[i] = new Strand(position, segs, dist);
strands[i]->color = color;
dsq->game->addRenderObject(strands[i], this->layer);
@ -269,113 +255,32 @@ void ScriptedEntity::initStrands(int num, int segs, int dist, int strandSpacing,
updateStrands(0);
}
/*
// write this if/when needed, set all strands to color (with lerp)
void ScriptedEntity::setStrandsColor(const Vector &color, float time)
{
}
*/
void ScriptedEntity::onAlwaysUpdate(float dt)
{
Entity::onAlwaysUpdate(dt);
// debugLog("calling updateStrands");
updateStrands(dt);
//HACK: this would be better in base Entity
/*
if (frozenTimer)
{
}
*/
if (!isEntityDead() && getState() != STATE_DEAD && getState() != STATE_DEATHSCENE && isPresent())
{
const bool useEV=false;
if (useEV)
{
int mov = getv(EV_MOVEMENT);
if (mov && frozenTimer)
{
doFriction(dt, 50);
}
else
{
// don't update friction if we're in a bubble.
int fric = getv(EV_FRICTION);
if (fric)
{
doFriction(dt, fric);
}
}
switch (mov)
{
case 1:
updateMovement(dt);
break;
case 2:
updateCurrents(dt);
updateMovement(dt);
break;
}
if (mov)
{
if (hair)
{
setHairHeadPosition(position);
updateHair(dt);
}
}
switch (getv(EV_COLLIDE))
{
case 1:
if (skeletalSprite.isLoaded())
dsq->game->handleShotCollisionsSkeletal(this);
else
dsq->game->handleShotCollisions(this);
break;
case 2:
if (skeletalSprite.isLoaded())
dsq->game->handleShotCollisionsSkeletal(this);
else
dsq->game->handleShotCollisions(this);
int dmg = getv(EV_TOUCHDMG);
if (frozenTimer > 0)
dmg = 0;
touchAvatarDamage(collideRadius, dmg);
break;
}
}
if (frozenTimer > 0)
{
pullEmitter.update(dt);
if (!useEV)
doFriction(dt, 50);
updateCurrents(dt);
updateMovement(dt);
if (hair)
{
doFriction(dt, 50);
updateCurrents(dt);
updateMovement(dt);
if (hair)
{
setHairHeadPosition(position);
updateHair(dt);
}
if (skeletalSprite.isLoaded())
dsq->game->handleShotCollisionsSkeletal(this);
else
dsq->game->handleShotCollisions(this);
setHairHeadPosition(position);
updateHair(dt);
}
if (skeletalSprite.isLoaded())
dsq->game->handleShotCollisionsSkeletal(this);
else
dsq->game->handleShotCollisions(this);
}
if (isPullable() && !fillGridFromQuad)
@ -387,7 +292,6 @@ void ScriptedEntity::onAlwaysUpdate(float dt)
crushDelay = 0.2;
doCrush = true;
}
//if ((dsq->game->avatar->position - this->position).getSquaredLength2D() < sqr(collideRadius + dsq->game->avatar->collideRadius))
FOR_ENTITIES(i)
{
Entity *e = *i;
@ -397,9 +301,6 @@ void ScriptedEntity::onAlwaysUpdate(float dt)
{
if (this->isEntityProperty(EP_BLOCKER) && doCrush)
{
//bool doit = !vel.isLength2DIn(200) || (e->position.y > position.y && vel.y > 0);
/*dsq->game->avatar->pullTarget != this ||*/
/*&& */
bool doit = !vel.isLength2DIn(64) || (e->position.y > position.y && vel.y > 0);
if (doit)
{
@ -432,11 +333,9 @@ void ScriptedEntity::onAlwaysUpdate(float dt)
if (isPullable())
{
//debugLog("movable!");
Entity *followEntity = dsq->game->avatar;
if (followEntity && dsq->game->avatar->pullTarget == this)
{
//debugLog("followentity!");
Vector dist = followEntity->position - this->position;
if (dist.isLength2DIn(followEntity->collideRadius + collideRadius + 16))
{
@ -468,7 +367,6 @@ void ScriptedEntity::onAlwaysUpdate(float dt)
if (vel.isLength2DIn(100))
vel = 0;
}
//vel = 0;
}
doCollisionAvoidance(dt, 2, 0.5);
}
@ -497,28 +395,8 @@ void ScriptedEntity::updateStrands(float dt)
void ScriptedEntity::destroy()
{
//debugLog("calling target died");
CollideEntity::destroy();
/*
// spring plant might already be destroyed at this point (end of state)
// could add as child?
if (springPlant)
{
//springPlant->life = 0.1;
springPlant->alpha = 0;
}
*/
/*
if (hair)
{
//dsq->removeRenderObject(hair, DESTROY_RENDER_OBJECT);
dsq->game->removeRenderObject(hair);
hair->destroy();
delete hair;
hair = 0;
}
*/
if (script)
{
dsq->scriptInterface.closeScript(script);
@ -552,14 +430,9 @@ void ScriptedEntity::startPull()
debugLog("HERE!");
if (isEntityProperty(EP_BLOCKER))
{
//debugLog("property set!");
fillGridFromQuad = false;
dsq->game->reconstructEntityGrid();
}
else
{
//debugLog("property not set!");
}
pullEmitter.load("Pulled");
pullEmitter.start();
@ -603,21 +476,8 @@ void ScriptedEntity::onUpdate(float dt)
{
BBGE_PROF(ScriptedEntity_onUpdate);
/*
if (script && preUpdateFunc)
{
if (!script->call("preUpdate", this, dt))
{
debugLog(name + " : preUpdate : " + script->getLastError());
preUpdateFunc = false;
}
}
*/
CollideEntity::onUpdate(dt);
//updateStrands(dt);
if (becomeSolidDelay)
{
if (vel.isLength2DIn(5))
@ -659,15 +519,6 @@ void ScriptedEntity::onUpdate(float dt)
updateSegments(position, reverseSegments);
updateAlpha(alpha.x);
}
/*
//HACK: if this is wanted (to support moving placed entities), then
// springPlant has to notify ScriptedEntity when it is deleted / pulled out
if (springPlant)
{
springPlant->position = this->position;
}
*/
}
void ScriptedEntity::resetTimer(float t)
@ -720,25 +571,14 @@ bool ScriptedEntity::damage(const DamageData &d)
if (!script->call("damage", this, d.attacker, d.bone, int(d.damageType), d.damage, d.hitPos.x, d.hitPos.y, d.shot, &doDefault))
{
debugLog(name + ": damage function failed");
//debugLog(this->name + " : " + script->getLastError() + " hit");
}
else
{
/*
std::ostringstream os;
os << "doDefault: " << doDefault;
debugLog(os.str());
*/
}
}
if (doDefault)
{
//debugLog("doing default damage");
return Entity::damage(d);
}
//debugLog("not doing default damage");
return false;
}
@ -835,24 +675,6 @@ void ScriptedEntity::activate()
{
if (runningActivation) return;
Entity::activate();
/*
if (dsq->game->avatar)
{
Avatar *a = dsq->game->avatar;
if (a->position.x < this->position.x)
{
if (!a->isFlippedHorizontal())
a->flipHorizontal();
}
else
{
if (a->isFlippedHorizontal())
a->flipHorizontal();
}
if (getEntityType() == ET_NEUTRAL)
flipToTarget(dsq->game->avatar->position);
}
*/
runningActivation = true;
if (script)
@ -940,15 +762,6 @@ void ScriptedEntity::onEnterState(int action)
strands.clear();
// BASE ENTITY CLASS WILL HANDLE CLEANING UP HAIR
/*
if (hair)
{
hair->setLife(1.0);
hair->setDecayRate(10);
hair->fadeAlphaWithLife = true;
hair = 0;
}
*/
break;
}
}

View File

@ -91,7 +91,7 @@ protected:
void luaDebugMsg(const std::string &func, const std::string &msg);
float crushDelay;
int beforePullMaxSpeed;
bool songNoteFunction, preUpdateFunc;
bool songNoteFunction;
bool songNoteDoneFunction;
std::vector<ParticleEffect*> emitters;
bool becomeSolidDelay;