Preserve sleep when reopening LCDPet
This commit is contained in:
@@ -2577,17 +2577,14 @@ fun Greeting(name: String, modifier: Modifier = Modifier) {
|
||||
LaunchedEffect(saveLoaded, restoredAutoSleep) {
|
||||
if (saveLoaded && restoredAutoSleep && isSleeping && sleepMode == "Auto") {
|
||||
activityMood = "Asleep"
|
||||
roughWakeDarkFlash = true
|
||||
roughWakeDarkFlash = false
|
||||
|
||||
if (framePropAnimation != "Nap") {
|
||||
startFrameAnimation("Nap")
|
||||
}
|
||||
|
||||
delay(if (testingMode) 1_500L else 2_000L)
|
||||
|
||||
if (isSleeping && sleepMode == "Auto") {
|
||||
wakeFromAutoSleep()
|
||||
}
|
||||
// Reopening LCDPet no longer wakes an exhausted sleeping pet.
|
||||
restoredAutoSleep = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2601,46 +2598,16 @@ fun Greeting(name: String, modifier: Modifier = Modifier) {
|
||||
return@LaunchedEffect
|
||||
}
|
||||
|
||||
val wakeAtMs = autoSleepStartedAtMs
|
||||
val napStillActive =
|
||||
wakeAtMs <= 0L || System.currentTimeMillis() < wakeAtMs
|
||||
|
||||
if (!napStillActive) {
|
||||
// The original Nap finished while LCDPet was closed.
|
||||
// Release the gate so the normal Nap completion effect can finish it.
|
||||
restoredManualNap = false
|
||||
return@LaunchedEffect
|
||||
}
|
||||
|
||||
// LCDPet was reopened before the manual Nap was finished.
|
||||
roughWakeDarkFlash = true
|
||||
activityMood = "Asleep"
|
||||
frameProp = ""
|
||||
framePropAnimation = ""
|
||||
framePropStyle = 0
|
||||
|
||||
delay(if (testingMode) 1_500L else 1_200L)
|
||||
|
||||
if (
|
||||
restoredManualNap &&
|
||||
isSleeping &&
|
||||
sleepMode == "Nap"
|
||||
) {
|
||||
isSleeping = false
|
||||
sleepMode = ""
|
||||
autoSleepStartedAtMs = 0L
|
||||
restoredManualNap = false
|
||||
// Reopening during a Nap no longer wakes the pet.
|
||||
// Release the restore gate so the original fixed wake deadline continues.
|
||||
roughWakeDarkFlash = false
|
||||
roughWakeNervousHold = false
|
||||
activityMood = "Asleep"
|
||||
|
||||
status = "Nervous"
|
||||
activityMood = "RoughWake"
|
||||
roughWakeAlert = true
|
||||
frameProp = "!?!"
|
||||
framePropAnimation = ""
|
||||
framePropStyle = 0
|
||||
happiness = (happiness - 1).coerceAtLeast(0)
|
||||
if (framePropAnimation != "Nap") {
|
||||
startFrameAnimation("Nap")
|
||||
}
|
||||
|
||||
restoredManualNap = false
|
||||
}
|
||||
|
||||
LaunchedEffect(
|
||||
|
||||
Reference in New Issue
Block a user