mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-06-08 01:22:02 +00:00
Remove spirit form dependency on WorldType, and add related Lua interfaces.
This commit introduces a second pause mode: Full game pause (as in menu), and world pause (as in spirit form). All related checks are no longer done against WT_* constants, but against the new world pause which is functionally equivalent, but more flexible. Continuity::worldType is now only used to toggle world pause correctly, and to apply some related graphical effects. The world pause can also be controlled via script without actually switching forms. Added Lua functions: + node_setSpiritFreeze() + quad_setPauseLevel() + isWorldPaused() + setWorldPaused()
This commit is contained in:
parent
3ed40e73d3
commit
55ead19076
16 changed files with 65 additions and 27 deletions
|
@ -752,11 +752,6 @@ bool Avatar::isSinging()
|
|||
return singing;
|
||||
}
|
||||
|
||||
void Avatar::shift()
|
||||
{
|
||||
dsq->continuity.shiftWorlds();
|
||||
}
|
||||
|
||||
void Avatar::applyWorldEffects(WorldType type)
|
||||
{
|
||||
static bool oldfh=false;
|
||||
|
@ -5275,7 +5270,7 @@ void Avatar::updateWallJump(float dt)
|
|||
|
||||
void Avatar::updateRoll(float dt)
|
||||
{
|
||||
if (!inputEnabled || dsq->continuity.getWorldType() == WT_SPIRIT)
|
||||
if (!inputEnabled || dsq->game->isWorldPaused())
|
||||
{
|
||||
if (rolling)
|
||||
stopRoll();
|
||||
|
@ -6205,7 +6200,7 @@ void Avatar::onUpdate(float dt)
|
|||
|
||||
//if (core->getNestedMains() == 1)
|
||||
{
|
||||
if (getState() != STATE_TRANSFORM && dsq->continuity.getWorldType() == WT_NORMAL)
|
||||
if (getState() != STATE_TRANSFORM && !dsq->game->isWorldPaused())
|
||||
{
|
||||
formAbilityUpdate(dt);
|
||||
}
|
||||
|
@ -6439,7 +6434,7 @@ void Avatar::onUpdate(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
if (!state.lockedToWall && _isUnderWater && dsq->continuity.getWorldType() == WT_NORMAL && canMove)
|
||||
if (!state.lockedToWall && _isUnderWater && !dsq->game->isWorldPaused() && canMove)
|
||||
{
|
||||
if (bursting)
|
||||
{
|
||||
|
@ -7156,7 +7151,7 @@ void Avatar::onUpdate(float dt)
|
|||
if (dsq->game->collideCircleWithGrid(position, collideRadius))
|
||||
{
|
||||
if (dsq->game->lastCollideTileType == OT_HURT
|
||||
&& dsq->continuity.getWorldType() != WT_SPIRIT
|
||||
&& !dsq->game->isWorldPaused()
|
||||
&& dsq->continuity.form != FORM_NATURE)
|
||||
{
|
||||
DamageData d;
|
||||
|
|
|
@ -160,7 +160,6 @@ public:
|
|||
Entity *entityToActivate;
|
||||
Path *pathToActivate;
|
||||
|
||||
void shift();
|
||||
void applyWorldEffects(WorldType type);
|
||||
|
||||
void toggleMovement(bool on);
|
||||
|
|
|
@ -1916,9 +1916,15 @@ void Continuity::shiftWorlds()
|
|||
{
|
||||
WorldType lastWorld = worldType;
|
||||
if (worldType == WT_NORMAL)
|
||||
{
|
||||
worldType = WT_SPIRIT;
|
||||
dsq->game->setWorldPaused(true);
|
||||
}
|
||||
else if (worldType == WT_SPIRIT)
|
||||
{
|
||||
worldType = WT_NORMAL;
|
||||
dsq->game->setWorldPaused(false);
|
||||
}
|
||||
FOR_ENTITIES(i)
|
||||
{
|
||||
Entity *e = *i;
|
||||
|
@ -2018,7 +2024,7 @@ void Continuity::applyWorldEffects(WorldType type, bool transition, bool affectM
|
|||
dsq->game->avatar->enableInput();
|
||||
*/
|
||||
}
|
||||
worldType = type;
|
||||
//worldType = type;
|
||||
}
|
||||
|
||||
void Continuity::eatBeast(const EatData &eatData)
|
||||
|
|
|
@ -4576,6 +4576,7 @@ void DSQ::onUpdate(float dt)
|
|||
os << "altState: " << core->getKeyState(KEY_LALT) << " | " << core->getKeyState(KEY_RALT) << std::endl;
|
||||
os << "PMFree: " << particleManager->getFree() << " Active: " << particleManager->getNumActive() << std::endl;
|
||||
os << "cameraPos: (" << dsq->cameraPos.x << ", " << dsq->cameraPos.y << ")" << std::endl;
|
||||
os << "worldType: " << continuity.getWorldType() << " worldPaused: " << game->isWorldPaused() << std::endl;
|
||||
os << "voiceTime: " << dsq->sound->getVoiceTime() << " bNat: " << dsq->game->bNatural;
|
||||
int ca, ma;
|
||||
dsq->sound->getStats(&ca, &ma);
|
||||
|
|
|
@ -1142,9 +1142,9 @@ void Entity::update(float dt)
|
|||
if (doUpdate && !dsq->game->isPaused())
|
||||
{
|
||||
|
||||
if (getEntityType() == ET_ENEMY || getEntityType() == ET_NEUTRAL || getEntityType() == ET_PET)
|
||||
if (!(getEntityType() == ET_AVATAR || getEntityType() == ET_INGREDIENT))
|
||||
{
|
||||
if (spiritFreeze && dsq->continuity.getWorldType() == WT_SPIRIT)
|
||||
if (spiritFreeze && dsq->game->isWorldPaused())
|
||||
{
|
||||
// possible bug here because of return
|
||||
return;
|
||||
|
@ -1382,7 +1382,7 @@ bool Entity::updateCurrents(float dt)
|
|||
// why?
|
||||
{
|
||||
//Path *p = dsq->game->getNearestPath(position, PATH_CURRENT);
|
||||
if (dsq->continuity.getWorldType() != WT_SPIRIT)
|
||||
if (!dsq->game->isWorldPaused())
|
||||
{
|
||||
for (Path *p = dsq->game->getFirstPathOfType(PATH_CURRENT); p; p = p->nextOfType)
|
||||
{
|
||||
|
|
|
@ -1234,7 +1234,7 @@ Game::Game() : StateObject()
|
|||
loadEntityTypeList();
|
||||
|
||||
lastCollideMaskIndex = -1;
|
||||
|
||||
worldPaused = false;
|
||||
|
||||
}
|
||||
|
||||
|
@ -5719,7 +5719,7 @@ void Game::updateParticlePause()
|
|||
{
|
||||
core->particlesPaused = 2;
|
||||
}
|
||||
else if (dsq->continuity.getWorldType() == WT_SPIRIT)
|
||||
else if (this->isWorldPaused())
|
||||
{
|
||||
core->particlesPaused = 1;
|
||||
}
|
||||
|
|
|
@ -1001,6 +1001,9 @@ public:
|
|||
void toggleHelpScreen(bool on, const std::string &label="");
|
||||
void onToggleHelpScreen();
|
||||
|
||||
void setWorldPaused(bool b) { worldPaused = b; }
|
||||
bool isWorldPaused() const { return worldPaused; }
|
||||
|
||||
protected:
|
||||
|
||||
void onHelpUp();
|
||||
|
@ -1158,6 +1161,7 @@ protected:
|
|||
std::vector<AquariaMenuItem*> menu;
|
||||
Quad *menuBg, *menuBg2;
|
||||
bool paused;
|
||||
bool worldPaused;
|
||||
|
||||
Vector getClosestPointOnTriangle(Vector a, Vector b, Vector c, Vector p);
|
||||
Vector getClosestPointOnLine(Vector a, Vector b, Vector p);
|
||||
|
|
|
@ -109,7 +109,7 @@ void Ingredient::eat(Entity *e)
|
|||
void Ingredient::onUpdate(float dt)
|
||||
{
|
||||
if (dsq->game->isPaused()) return;
|
||||
if (dsq->continuity.getWorldType() == WT_SPIRIT) return;
|
||||
if (dsq->game->isWorldPaused()) return;
|
||||
|
||||
Vector lastPosition = position;
|
||||
Entity::onUpdate(dt);
|
||||
|
|
|
@ -284,6 +284,7 @@ void Mod::stop()
|
|||
debugMenu = false;
|
||||
shuttingDown = false;
|
||||
dsq->scriptInterface.reset();
|
||||
dsq->game->setWorldPaused(false);
|
||||
}
|
||||
|
||||
void Mod::update(float dt)
|
||||
|
|
|
@ -53,12 +53,7 @@ Path::Path()
|
|||
spawnEnemyNumber = 0;
|
||||
spawnEnemyDistance = 0;
|
||||
warpType = 0;
|
||||
/*
|
||||
rect.x1 = -10;
|
||||
rect.x2 = 20;
|
||||
rect.y1 = -256;
|
||||
rect.y2 = 256;
|
||||
*/
|
||||
spiritFreeze = true;
|
||||
}
|
||||
|
||||
void Path::clampPosition(Vector *pos, int radius)
|
||||
|
@ -484,7 +479,7 @@ void Path::init()
|
|||
|
||||
void Path::update(float dt)
|
||||
{
|
||||
if (!dsq->game->isPaused() && dsq->continuity.getWorldType() == WT_NORMAL)
|
||||
if (!dsq->game->isPaused() && !(spiritFreeze && dsq->game->isWorldPaused()))
|
||||
{
|
||||
if (addEmitter && emitter)
|
||||
{
|
||||
|
@ -523,7 +518,7 @@ void Path::update(float dt)
|
|||
{
|
||||
spawnedEntity = 0;
|
||||
}
|
||||
if (pathType == PATH_CURRENT && dsq->continuity.getWorldType() == WT_NORMAL)
|
||||
if (pathType == PATH_CURRENT && !dsq->game->isWorldPaused())
|
||||
{
|
||||
animOffset -= currentMod*(dt/830);
|
||||
/*
|
||||
|
@ -559,7 +554,7 @@ void Path::update(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
if (pathType == PATH_STEAM && dsq->continuity.getWorldType() == WT_NORMAL && effectOn)
|
||||
if (pathType == PATH_STEAM && !dsq->game->isWorldPaused() && effectOn)
|
||||
{
|
||||
animOffset -= 1000*0.00002f;
|
||||
|
||||
|
|
|
@ -143,6 +143,7 @@ public:
|
|||
std::string gem;
|
||||
|
||||
bool effectOn;
|
||||
bool spiritFreeze;
|
||||
|
||||
PathShape pathShape;
|
||||
|
||||
|
|
|
@ -377,6 +377,7 @@ void compile_time_assertions()
|
|||
compile_assert(oo(Path) == oo(Quad));
|
||||
compile_assert(oo(Path) == oo(Avatar));
|
||||
compile_assert(oo(Path) == oo(BaseText));
|
||||
compile_assert(oo(Path) == oo(PauseQuad));
|
||||
#undef oo
|
||||
}
|
||||
#endif
|
||||
|
@ -2351,6 +2352,17 @@ luaFunc(getWorldType)
|
|||
luaReturnNum((int)dsq->continuity.getWorldType());
|
||||
}
|
||||
|
||||
luaFunc(isWorldPaused)
|
||||
{
|
||||
luaReturnBool(dsq->game->isWorldPaused());
|
||||
}
|
||||
|
||||
luaFunc(setWorldPaused)
|
||||
{
|
||||
dsq->game->setWorldPaused(getBool(L, 1));
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(getNearestNodeByType)
|
||||
{
|
||||
int x = lua_tonumber(L, 1);
|
||||
|
@ -2546,6 +2558,14 @@ luaFunc(entity_setSpiritFreeze)
|
|||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(node_setSpiritFreeze)
|
||||
{
|
||||
Path *e = path(L);
|
||||
if (e)
|
||||
e->spiritFreeze = getBool(L,2);
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(entity_setFillGrid)
|
||||
{
|
||||
Entity *e = entity(L);
|
||||
|
@ -4755,6 +4775,15 @@ luaFunc(createQuad)
|
|||
luaReturnPtr(q);
|
||||
}
|
||||
|
||||
luaFunc(quad_setPauseLevel)
|
||||
{
|
||||
Quad *q = getQuad(L);
|
||||
ENSURE_TYPE(q, SCO_PAUSEQUAD);
|
||||
if (q)
|
||||
((PauseQuad*)q)->pauseLevel = lua_tointeger(L, 2);
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(setupEntity)
|
||||
{
|
||||
ScriptedEntity *se = scriptedEntity(L);
|
||||
|
@ -7597,11 +7626,14 @@ static const struct {
|
|||
luaRegister(getNoteName),
|
||||
|
||||
luaRegister(getWorldType),
|
||||
luaRegister(setWorldPaused),
|
||||
luaRegister(isWorldPaused),
|
||||
|
||||
luaRegister(getWaterLevel),
|
||||
luaRegister(setWaterLevel),
|
||||
|
||||
luaRegister(createQuad),
|
||||
luaRegister(quad_setPauseLevel),
|
||||
|
||||
luaRegister(setupEntity),
|
||||
luaRegister(setActivePet),
|
||||
|
@ -7651,6 +7683,7 @@ static const struct {
|
|||
luaRegister(entity_setEatType),
|
||||
|
||||
luaRegister(entity_setSpiritFreeze),
|
||||
luaRegister(node_setSpiritFreeze),
|
||||
|
||||
luaRegister(entity_setCanLeaveWater),
|
||||
|
||||
|
|
|
@ -778,7 +778,7 @@ bool Shot::isObstructed(float dt) const
|
|||
void Shot::onUpdate(float dt)
|
||||
{
|
||||
if (dsq->game->isPaused()) return;
|
||||
if (dsq->continuity.getWorldType() != WT_NORMAL) return;
|
||||
if (dsq->game->isWorldPaused()) return;
|
||||
if (!shotData) return;
|
||||
|
||||
|
||||
|
|
|
@ -802,6 +802,7 @@ void Quad::onSetTexture()
|
|||
|
||||
PauseQuad::PauseQuad() : Quad(), pauseLevel(0)
|
||||
{
|
||||
addType(SCO_PAUSEQUAD);
|
||||
}
|
||||
|
||||
void PauseQuad::onUpdate(float dt)
|
||||
|
|
|
@ -37,6 +37,7 @@ static const char *scriptObjTypeNames[] =
|
|||
/* (1 << 9) */ "Path/Node",
|
||||
/* (1 <<10) */ "Quad",
|
||||
/* (1 <<11) */ "Text",
|
||||
/* (1 <<12) */ "PauseQuad",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ enum ScriptObjectType
|
|||
SCO_PATH = 0x0200,
|
||||
SCO_QUAD = 0x0400,
|
||||
SCO_TEXT = 0x0800,
|
||||
SCO_PAUSEQUAD = 0x1000,
|
||||
|
||||
SCO_FORCE_32BIT = 0xFFFFFFFF
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue