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

Remove entity myTimer and related Lua functions. Fix warnings for now unsigned Entity::layer

- entity_resetTimer()
- entity_stopTimer()
This commit is contained in:
fgenesis 2017-01-20 20:54:17 +01:00
parent f3f93ef89e
commit 8411838636
6 changed files with 8 additions and 63 deletions

View file

@ -82,16 +82,15 @@ Ingredient *Game::getNearestIngredient(const Vector &pos, float radius)
return returnIngredient;
}
Entity *Game::getNearestEntity(const Vector &pos, int radius, Entity *ignore, EntityType et, DamageType dt, int lrStart, int lrEnd)
Entity *Game::getNearestEntity(const Vector &pos, float radius, Entity *ignore, EntityType et, DamageType dt, unsigned lrStart, unsigned lrEnd)
{
int sqrRadius = radius*radius;
Entity *closest = 0;
int sml=-1;
int dist = 0;
float sml=-1;
FOR_ENTITIES(i)
{
Entity *e = *i;
dist = (e->position - pos).getSquaredLength2D();
const float dist = (e->position - pos).getSquaredLength2D();
if (dist <= sqrRadius)
{
if (e != ignore && e->isPresent())

View file

@ -461,7 +461,7 @@ public:
void spawnIngredientFromEntity(Entity *ent, IngredientData *data);
Ingredient *getNearestIngredient(const Vector &pos, float radius);
Entity *getNearestEntity(const Vector &pos, int radius, Entity *ignore = 0, EntityType et=ET_NOTYPE, DamageType dt=DT_NONE, int lrStart=-1, int lrEnd=-1);
Entity *getNearestEntity(const Vector &pos, float radius, Entity *ignore = 0, EntityType et=ET_NOTYPE, DamageType dt=DT_NONE, unsigned lrStart=-1, unsigned lrEnd=-1);
Script *cookingScript;

View file

@ -3970,14 +3970,6 @@ luaFunc(bone_lookAtPosition)
luaReturnNil();
}
luaFunc(entity_resetTimer)
{
ScriptedEntity *se = scriptedEntity(L);
if (se)
se->resetTimer(lua_tonumber(L, 2));
luaReturnNil();
}
luaFunc(entity_stopFollowingPath)
{
Entity *e = entity(L);
@ -4009,14 +4001,6 @@ luaFunc(entity_slowToStopPath)
luaReturnNil();
}
luaFunc(entity_stopTimer)
{
ScriptedEntity *se = scriptedEntity(L);
if (se)
se->stopTimer();
luaReturnNil();
}
luaFunc(entity_createEntity)
{
Entity *e = entity(L);
@ -7726,7 +7710,7 @@ luaFunc(entity_getNearestEntity)
luaFunc(getNearestEntity)
{
Vector p(lua_tonumber(L, 1), lua_tonumber(L, 2));
int radius = lua_tointeger(L, 3);
float radius = lua_tonumber(L, 3);
Entity *ignore = lua_isuserdata(L, 4) ? entity(L, 4) : NULL;
//EntityType et = lua_isnumber(L, 5) ? (EntityType)lua_tointeger(L, 5) : ET_NOTYPE;
DamageType dt = lua_isnumber(L, 6) ? (DamageType)lua_tointeger(L, 6) : DT_NONE;
@ -7824,8 +7808,8 @@ static size_t _entityFilter(lua_State *L)
const Entity *ignore = lua_isuserdata(L, 4) ? entity(L, 4) : NULL;
const EntityType et = lua_isnumber(L, 5) ? (EntityType)lua_tointeger(L, 5) : ET_NOTYPE;
const DamageType dt = lua_isnumber(L, 6) ? (DamageType)lua_tointeger(L, 6) : DT_NONE;
const int lrStart = lua_isnumber(L, 7) ? lua_tointeger(L, 7) : -1;
const int lrEnd = lua_isnumber(L, 8) ? lua_tointeger(L, 8) : -1;
const unsigned lrStart = lua_isnumber(L, 7) ? lua_tointeger(L, 7) : -1;
const unsigned lrEnd = lua_isnumber(L, 8) ? lua_tointeger(L, 8) : -1;
const float sqrRadius = radius * radius;
float distsq;
@ -9899,8 +9883,6 @@ static const struct {
luaRegister(entity_offsetUpdate),
luaRegister(entity_createEntity),
luaRegister(entity_resetTimer),
luaRegister(entity_stopTimer),
luaRegister(entity_stopPull),
luaRegister(entity_setTargetPriority),
luaRegister(entity_getTargetPriority),

View file

@ -43,7 +43,6 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E
setEntityType(et);
myTimer = 0;
layer = LR_ENTITIES;
surfaceMoveDir = 1;
this->position = position;
@ -505,17 +504,6 @@ void ScriptedEntity::onUpdate(float dt)
if (life != 1 || isEntityDead()) return;
if (myTimer > 0)
{
myTimer -= dt;
if (myTimer <= 0)
{
myTimer = 0;
onExitTimer();
}
}
if (this->isEntityDead() || this->getState() == STATE_DEATHSCENE || this->getState() == STATE_DEAD)
{
return;
@ -533,25 +521,6 @@ void ScriptedEntity::onUpdate(float dt)
}
}
void ScriptedEntity::resetTimer(float t)
{
myTimer = t;
}
void ScriptedEntity::stopTimer()
{
myTimer = 0;
}
void ScriptedEntity::onExitTimer()
{
if (script)
{
if (!script->call("exitTimer", this))
debugLog(this->name + " : " + script->getLastError() + " exitTimer");
}
}
void ScriptedEntity::onAnimationKeyPassed(int key)
{
if (script && animKeyFunc)

View file

@ -36,8 +36,6 @@ public:
void init();
void postInit();
void destroy();
void stopTimer();
void resetTimer(float t);
void setEntityLayer(int layer);
void setupEntity(const std::string &tex, int layer=0);
void setupBasicEntity(const std::string& texture, int health, int manaBall, int exp, int money, float collideRadius, int state, int w, int h, int expType, bool hitEntity, int updateCull, int layer);
@ -104,9 +102,6 @@ protected:
void updateStrands(float dt);
bool animKeyFunc;
void onExitTimer();
float myTimer;
void onHitWall();
bool reverseSegments;
Script *script;

View file

@ -260,7 +260,7 @@ public:
bool cull;
float updateCull;
size_t layer;
unsigned layer;
InterpolatedVector *positionSnapTo;