mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-15 15:02:34 +02:00
Fade fix part2
This commit is contained in:
parent
070f58809e
commit
e98cb05c47
@ -210,9 +210,9 @@ void PlayerController::restartLogic() {
|
||||
switch (restartState) {
|
||||
case Alive: {
|
||||
if (isWasted() || isBusted() || isMissionRestartRequired()) {
|
||||
state->fade(2000 / 1000.f, false);
|
||||
state->fade(2.f, false);
|
||||
|
||||
restartState = FadingIn;
|
||||
restartState = FadingOut;
|
||||
}
|
||||
|
||||
if (isWasted()) {
|
||||
@ -241,7 +241,7 @@ void PlayerController::restartLogic() {
|
||||
|
||||
break;
|
||||
}
|
||||
case FadingIn: {
|
||||
case FadingOut: {
|
||||
if (!state->isFading()) {
|
||||
restartState = Restarting;
|
||||
}
|
||||
@ -249,7 +249,7 @@ void PlayerController::restartLogic() {
|
||||
break;
|
||||
}
|
||||
case Restarting: {
|
||||
state->fade(4000 / 1000.f, true);
|
||||
state->fade(4.f, true);
|
||||
|
||||
if (isWasted()) {
|
||||
state->setFadeColour(glm::i32vec3(0xc8, 0xc8, 0xc8));
|
||||
@ -261,11 +261,11 @@ void PlayerController::restartLogic() {
|
||||
|
||||
restart();
|
||||
|
||||
restartState = FadingOut;
|
||||
restartState = FadingIn;
|
||||
|
||||
break;
|
||||
}
|
||||
case FadingOut: {
|
||||
case FadingIn: {
|
||||
if (!state->isFading()) {
|
||||
restartState = Alive;
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ class PlayerController : public CharacterController {
|
||||
|
||||
enum RestartState {
|
||||
Alive,
|
||||
FadingIn,
|
||||
Restarting,
|
||||
FadingOut,
|
||||
Restarting,
|
||||
FadingIn,
|
||||
} restartState;
|
||||
|
||||
// handles player respawn logic
|
||||
|
@ -105,11 +105,11 @@ GameState::GameState()
|
||||
, policeRestarts{}
|
||||
, hospitalIslandOverride(false)
|
||||
, policeIslandOverride(false)
|
||||
, fadeOut(true)
|
||||
, fadeIn(true)
|
||||
, fadeStart(0.f)
|
||||
, fadeTime(0.f)
|
||||
, fadeSound(false)
|
||||
, fadeColour{}
|
||||
, fadeColour{0.f, 0.f, 0.f}
|
||||
, skipCutscene(false)
|
||||
, isIntroPlaying(false)
|
||||
, currentCutscene(nullptr)
|
||||
@ -206,12 +206,12 @@ const glm::vec4 GameState::getClosestRestart(
|
||||
|
||||
void GameState::fade(float time, bool f) {
|
||||
fadeTime = time;
|
||||
fadeOut = f;
|
||||
fadeIn = f;
|
||||
fadeStart = world->getGameTime();
|
||||
}
|
||||
|
||||
bool GameState::isFading() const {
|
||||
return world->getGameTime() < fadeStart + fadeTime;
|
||||
return world->getGameTime() <= fadeStart + fadeTime;
|
||||
}
|
||||
|
||||
void GameState::setFadeColour(glm::i32vec3 colour) {
|
||||
|
@ -350,7 +350,7 @@ public:
|
||||
const glm::vec4 getClosestRestart(RestartType type,
|
||||
const glm::vec3 playerPosition) const;
|
||||
|
||||
bool fadeOut;
|
||||
bool fadeIn;
|
||||
float fadeStart;
|
||||
float fadeTime;
|
||||
bool fadeSound;
|
||||
|
@ -407,7 +407,7 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera,
|
||||
}
|
||||
|
||||
float fadeTimer = world->getGameTime() - world->state->fadeStart;
|
||||
if ((fadeTimer <= world->state->fadeTime || !world->state->fadeOut) && !world->isPaused()) {
|
||||
if (!world->isPaused()) {
|
||||
/// @todo rewrite this render code to use renderer class
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glUseProgram(ssRectProgram);
|
||||
@ -428,7 +428,7 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera,
|
||||
fadeFrac = std::min(fadeTimer / world->state->fadeTime, 1.f);
|
||||
}
|
||||
|
||||
float a = world->state->fadeOut ? 1.f - fadeFrac : fadeFrac;
|
||||
float a = world->state->fadeIn ? 1.f - fadeFrac : fadeFrac;
|
||||
|
||||
glm::vec4 fadeNormed(fc.r / 255.f, fc.g / 255.f, fc.b / 255.f, a);
|
||||
|
||||
|
@ -3873,10 +3873,10 @@ void opcode_0169(const ScriptArguments& args, ScriptRGB colour) {
|
||||
|
||||
opcode 016a
|
||||
@arg time Time (ms)
|
||||
@arg scriptFade Boolean true/false
|
||||
@arg fadeIn Boolean true/false
|
||||
*/
|
||||
void opcode_016a(const ScriptArguments& args, const ScriptInt time, const ScriptBoolean scriptFade) {
|
||||
args.getState()->fade(time / 1000.f, scriptFade);
|
||||
void opcode_016a(const ScriptArguments& args, const ScriptInt time, const ScriptBoolean fadeIn) {
|
||||
args.getState()->fade(time / 1000.f, fadeIn);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3885,9 +3885,6 @@ void opcode_016a(const ScriptArguments& args, const ScriptInt time, const Script
|
||||
opcode 016b
|
||||
*/
|
||||
bool opcode_016b(const ScriptArguments& args) {
|
||||
if (args.getWorld()->state->skipCutscene) {
|
||||
return false;
|
||||
}
|
||||
return args.getState()->isFading();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user