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:
parent
f3f93ef89e
commit
8411838636
6 changed files with 8 additions and 63 deletions
|
@ -82,16 +82,15 @@ Ingredient *Game::getNearestIngredient(const Vector &pos, float radius)
|
||||||
return returnIngredient;
|
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;
|
int sqrRadius = radius*radius;
|
||||||
Entity *closest = 0;
|
Entity *closest = 0;
|
||||||
int sml=-1;
|
float sml=-1;
|
||||||
int dist = 0;
|
|
||||||
FOR_ENTITIES(i)
|
FOR_ENTITIES(i)
|
||||||
{
|
{
|
||||||
Entity *e = *i;
|
Entity *e = *i;
|
||||||
dist = (e->position - pos).getSquaredLength2D();
|
const float dist = (e->position - pos).getSquaredLength2D();
|
||||||
if (dist <= sqrRadius)
|
if (dist <= sqrRadius)
|
||||||
{
|
{
|
||||||
if (e != ignore && e->isPresent())
|
if (e != ignore && e->isPresent())
|
||||||
|
|
|
@ -461,7 +461,7 @@ public:
|
||||||
void spawnIngredientFromEntity(Entity *ent, IngredientData *data);
|
void spawnIngredientFromEntity(Entity *ent, IngredientData *data);
|
||||||
|
|
||||||
Ingredient *getNearestIngredient(const Vector &pos, float radius);
|
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;
|
Script *cookingScript;
|
||||||
|
|
||||||
|
|
|
@ -3970,14 +3970,6 @@ luaFunc(bone_lookAtPosition)
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(entity_resetTimer)
|
|
||||||
{
|
|
||||||
ScriptedEntity *se = scriptedEntity(L);
|
|
||||||
if (se)
|
|
||||||
se->resetTimer(lua_tonumber(L, 2));
|
|
||||||
luaReturnNil();
|
|
||||||
}
|
|
||||||
|
|
||||||
luaFunc(entity_stopFollowingPath)
|
luaFunc(entity_stopFollowingPath)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
|
@ -4009,14 +4001,6 @@ luaFunc(entity_slowToStopPath)
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
luaFunc(entity_stopTimer)
|
|
||||||
{
|
|
||||||
ScriptedEntity *se = scriptedEntity(L);
|
|
||||||
if (se)
|
|
||||||
se->stopTimer();
|
|
||||||
luaReturnNil();
|
|
||||||
}
|
|
||||||
|
|
||||||
luaFunc(entity_createEntity)
|
luaFunc(entity_createEntity)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
|
@ -7726,7 +7710,7 @@ luaFunc(entity_getNearestEntity)
|
||||||
luaFunc(getNearestEntity)
|
luaFunc(getNearestEntity)
|
||||||
{
|
{
|
||||||
Vector p(lua_tonumber(L, 1), lua_tonumber(L, 2));
|
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;
|
Entity *ignore = lua_isuserdata(L, 4) ? entity(L, 4) : NULL;
|
||||||
//EntityType et = lua_isnumber(L, 5) ? (EntityType)lua_tointeger(L, 5) : ET_NOTYPE;
|
//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;
|
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 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 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 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 unsigned lrStart = lua_isnumber(L, 7) ? lua_tointeger(L, 7) : -1;
|
||||||
const int lrEnd = lua_isnumber(L, 8) ? lua_tointeger(L, 8) : -1;
|
const unsigned lrEnd = lua_isnumber(L, 8) ? lua_tointeger(L, 8) : -1;
|
||||||
|
|
||||||
const float sqrRadius = radius * radius;
|
const float sqrRadius = radius * radius;
|
||||||
float distsq;
|
float distsq;
|
||||||
|
@ -9899,8 +9883,6 @@ static const struct {
|
||||||
luaRegister(entity_offsetUpdate),
|
luaRegister(entity_offsetUpdate),
|
||||||
|
|
||||||
luaRegister(entity_createEntity),
|
luaRegister(entity_createEntity),
|
||||||
luaRegister(entity_resetTimer),
|
|
||||||
luaRegister(entity_stopTimer),
|
|
||||||
luaRegister(entity_stopPull),
|
luaRegister(entity_stopPull),
|
||||||
luaRegister(entity_setTargetPriority),
|
luaRegister(entity_setTargetPriority),
|
||||||
luaRegister(entity_getTargetPriority),
|
luaRegister(entity_getTargetPriority),
|
||||||
|
|
|
@ -43,7 +43,6 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E
|
||||||
|
|
||||||
|
|
||||||
setEntityType(et);
|
setEntityType(et);
|
||||||
myTimer = 0;
|
|
||||||
layer = LR_ENTITIES;
|
layer = LR_ENTITIES;
|
||||||
surfaceMoveDir = 1;
|
surfaceMoveDir = 1;
|
||||||
this->position = position;
|
this->position = position;
|
||||||
|
@ -505,17 +504,6 @@ void ScriptedEntity::onUpdate(float dt)
|
||||||
|
|
||||||
if (life != 1 || isEntityDead()) return;
|
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)
|
if (this->isEntityDead() || this->getState() == STATE_DEATHSCENE || this->getState() == STATE_DEAD)
|
||||||
{
|
{
|
||||||
return;
|
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)
|
void ScriptedEntity::onAnimationKeyPassed(int key)
|
||||||
{
|
{
|
||||||
if (script && animKeyFunc)
|
if (script && animKeyFunc)
|
||||||
|
|
|
@ -36,8 +36,6 @@ public:
|
||||||
void init();
|
void init();
|
||||||
void postInit();
|
void postInit();
|
||||||
void destroy();
|
void destroy();
|
||||||
void stopTimer();
|
|
||||||
void resetTimer(float t);
|
|
||||||
void setEntityLayer(int layer);
|
void setEntityLayer(int layer);
|
||||||
void setupEntity(const std::string &tex, int layer=0);
|
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);
|
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);
|
void updateStrands(float dt);
|
||||||
bool animKeyFunc;
|
bool animKeyFunc;
|
||||||
|
|
||||||
|
|
||||||
void onExitTimer();
|
|
||||||
float myTimer;
|
|
||||||
void onHitWall();
|
void onHitWall();
|
||||||
bool reverseSegments;
|
bool reverseSegments;
|
||||||
Script *script;
|
Script *script;
|
||||||
|
|
|
@ -260,7 +260,7 @@ public:
|
||||||
|
|
||||||
bool cull;
|
bool cull;
|
||||||
float updateCull;
|
float updateCull;
|
||||||
size_t layer;
|
unsigned layer;
|
||||||
|
|
||||||
InterpolatedVector *positionSnapTo;
|
InterpolatedVector *positionSnapTo;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue