diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 27ad9cf..0f5725a 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -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()) diff --git a/Aquaria/Game.h b/Aquaria/Game.h index a8e9d08..85273d1 100644 --- a/Aquaria/Game.h +++ b/Aquaria/Game.h @@ -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; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 4152384..bc9f620 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -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), diff --git a/Aquaria/ScriptedEntity.cpp b/Aquaria/ScriptedEntity.cpp index 1cdad28..67d3e13 100644 --- a/Aquaria/ScriptedEntity.cpp +++ b/Aquaria/ScriptedEntity.cpp @@ -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) diff --git a/Aquaria/ScriptedEntity.h b/Aquaria/ScriptedEntity.h index ff3dfde..763b870 100644 --- a/Aquaria/ScriptedEntity.h +++ b/Aquaria/ScriptedEntity.h @@ -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; diff --git a/BBGE/RenderObject.h b/BBGE/RenderObject.h index 38a78da..f99eae3 100644 --- a/BBGE/RenderObject.h +++ b/BBGE/RenderObject.h @@ -260,7 +260,7 @@ public: bool cull; float updateCull; - size_t layer; + unsigned layer; InterpolatedVector *positionSnapTo;