mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-14 12:16:41 +00:00
Allow entities and nodes to update while the game is paused.
Added Lua functions: - node_setPauseFreeze() - entity_setPauseFreeze() - getFPS() Also fixed possible crash in entity_setStateTime().
This commit is contained in:
parent
41929955d3
commit
fefb30a7b3
5 changed files with 39 additions and 3 deletions
|
@ -209,6 +209,7 @@ Entity::Entity()
|
|||
eatType = EAT_DEFAULT;
|
||||
stickToNaijasHead = false;
|
||||
spiritFreeze = true;
|
||||
pauseFreeze = true;
|
||||
canLeaveWater = false;
|
||||
targetPriority = 0;
|
||||
//renderPass = RENDER_ALL;
|
||||
|
@ -350,6 +351,11 @@ void Entity::setSpiritFreeze(bool v)
|
|||
spiritFreeze = v;
|
||||
}
|
||||
|
||||
void Entity::setPauseFreeze(bool v)
|
||||
{
|
||||
pauseFreeze = v;
|
||||
}
|
||||
|
||||
void Entity::setEntityProperty(EntityProperty ep, bool value)
|
||||
{
|
||||
entityProperties[int(ep)] = value;
|
||||
|
@ -1145,7 +1151,7 @@ void Entity::update(float dt)
|
|||
Vector backupVel = vel;
|
||||
|
||||
bool doUpdate = (updateCull == -1 || (position - core->screenCenter).isLength2DIn(updateCull));
|
||||
if (doUpdate && !dsq->game->isPaused())
|
||||
if (doUpdate && !(pauseFreeze && dsq->game->isPaused()))
|
||||
{
|
||||
|
||||
if (!(getEntityType() == ET_AVATAR || getEntityType() == ET_INGREDIENT))
|
||||
|
|
|
@ -428,6 +428,7 @@ public:
|
|||
virtual void shiftWorlds(WorldType lastWorld, WorldType worldType){}
|
||||
void setCanLeaveWater(bool v);
|
||||
void setSpiritFreeze(bool v);
|
||||
void setPauseFreeze(bool v);
|
||||
void setEatType(EatType et, const std::string &file="");
|
||||
EatType getEatType() { return eatType; }
|
||||
void setRiding(Entity *e);
|
||||
|
@ -535,6 +536,7 @@ protected:
|
|||
bool stickToNaijasHead;
|
||||
|
||||
bool spiritFreeze;
|
||||
bool pauseFreeze;
|
||||
bool canLeaveWater;
|
||||
bool wasUnderWater;
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ Path::Path()
|
|||
spawnEnemyDistance = 0;
|
||||
warpType = 0;
|
||||
spiritFreeze = true;
|
||||
pauseFreeze = true;
|
||||
}
|
||||
|
||||
void Path::clampPosition(Vector *pos, float radius)
|
||||
|
@ -479,7 +480,7 @@ void Path::init()
|
|||
|
||||
void Path::update(float dt)
|
||||
{
|
||||
if (!dsq->game->isPaused() && !(spiritFreeze && dsq->game->isWorldPaused()))
|
||||
if (!(pauseFreeze && dsq->game->isPaused()) && !(spiritFreeze && dsq->game->isWorldPaused()))
|
||||
{
|
||||
if (addEmitter && emitter)
|
||||
{
|
||||
|
|
|
@ -144,6 +144,7 @@ public:
|
|||
|
||||
bool effectOn;
|
||||
bool spiritFreeze;
|
||||
bool pauseFreeze;
|
||||
|
||||
PathShape pathShape;
|
||||
|
||||
|
|
|
@ -2806,6 +2806,16 @@ luaFunc(entity_setSpiritFreeze)
|
|||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(entity_setPauseFreeze)
|
||||
{
|
||||
Entity *e = entity(L);
|
||||
if (e)
|
||||
{
|
||||
e->setPauseFreeze(getBool(L,2));
|
||||
}
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(node_setSpiritFreeze)
|
||||
{
|
||||
Path *e = path(L);
|
||||
|
@ -2814,6 +2824,14 @@ luaFunc(node_setSpiritFreeze)
|
|||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(node_setPauseFreeze)
|
||||
{
|
||||
Path *e = path(L);
|
||||
if (e)
|
||||
e->pauseFreeze = getBool(L,2);
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(entity_setFillGrid)
|
||||
{
|
||||
Entity *e = entity(L);
|
||||
|
@ -6486,6 +6504,11 @@ luaFunc(getDT)
|
|||
luaReturnNum(core->get_current_dt());
|
||||
}
|
||||
|
||||
luaFunc(getFPS)
|
||||
{
|
||||
luaReturnInt(core->fps);
|
||||
}
|
||||
|
||||
luaFunc(isNested)
|
||||
{
|
||||
luaReturnBool(core->isNested());
|
||||
|
@ -7234,7 +7257,7 @@ luaFunc(entity_setStateTime)
|
|||
float t = lua_tonumber(L, 2);
|
||||
if (e)
|
||||
e->setStateTime(t);
|
||||
luaReturnNum(e->getStateTime());
|
||||
luaReturnNum(t);
|
||||
}
|
||||
|
||||
luaFunc(entity_offsetUpdate)
|
||||
|
@ -8317,6 +8340,7 @@ static const struct {
|
|||
luaRegister(getHalfTimer),
|
||||
luaRegister(getOldDT),
|
||||
luaRegister(getDT),
|
||||
luaRegister(getFPS),
|
||||
luaRegister(setCostume),
|
||||
luaRegister(getCostume),
|
||||
luaRegister(getNoteName),
|
||||
|
@ -8381,7 +8405,9 @@ static const struct {
|
|||
luaRegister(entity_setEatType),
|
||||
|
||||
luaRegister(entity_setSpiritFreeze),
|
||||
luaRegister(entity_setPauseFreeze),
|
||||
luaRegister(node_setSpiritFreeze),
|
||||
luaRegister(node_setPauseFreeze),
|
||||
|
||||
luaRegister(entity_setCanLeaveWater),
|
||||
|
||||
|
|
Loading…
Reference in a new issue