Question about GameManager.IsPlayingGame()

Discuss coding questions, pull requests, and implementation details.
Post Reply
User avatar
DunnyOfPenwick
Posts: 275
Joined: Wed Apr 14, 2021 1:58 am
Location: Southeast US

Question about GameManager.IsPlayingGame()

Post by DunnyOfPenwick »

I'm adding a lockpicking mini-game to The Penwick Papers and ran into a small problem.

The minigame is a window that pops up when attempting to pick a lock, but it does not pause the game, so time can continue flowing and enemies can target the player.

The problem is that enemies can not attack because GameManager.ClassicUpdate is always false while the lockpicking window is up.

GameManger.ClassicUpdate is false because the top window is not the HUD window, which is checked in the GameManager.IsPlayingGame() method.

What is the purpose of that check, and is there any sort of workaround?

User avatar
Interkarma
Posts: 7247
Joined: Sun Mar 22, 2015 1:51 am

Re: Question about GameManager.IsPlayingGame()

Post by Interkarma »

Updating my reply now I've unpacked this one some more. The internal assumption is that game will be paused when any UI other than HUD is opened (that's just standard Daggerfall). However, I note this logic isn't respecting the PauseWhileOpen flag on user window interface. This is essentially true everywhere in the core game, but might not be the case for mods.

Can you please confirm you set PauseWhileOpen=false in your lockpicking window? I'll look at reworking logic slightly so that IsPlayingGame() respects this flag rather than assuming all windows want to pause game.

I'll do my best to help. But if it just breaks other things and needs any kind of multitouch refactor, I won't spend much time with it this close to release. :)

User avatar
DunnyOfPenwick
Posts: 275
Joined: Wed Apr 14, 2021 1:58 am
Location: Southeast US

Re: Question about GameManager.IsPlayingGame()

Post by DunnyOfPenwick »

Yes, I can verify that PauseWhileOpen is set to false in the LockpickWindow (type DaggerfallPopupWindow) constructor.

I got an enemy to attack me and clicked a door to open the lockpick window. I could see the enemy moving around on screen while the window was up, but they didn't attack until I closed the window.

I put a breakpoint on GameManager line 948 and played for a while, but it never tripped until I opened the lockpicking window.
I'll do my best to help. But if it just breaks other things and needs any kind of multitouch refactor, I won't spend much time with it this close to release
Understood. This is a fairly minor issue, a nice-to-have feature but hardly game breaking.

User avatar
Interkarma
Posts: 7247
Joined: Sun Mar 22, 2015 1:51 am

Re: Question about GameManager.IsPlayingGame()

Post by Interkarma »

Honestly, the classic update pause setup could do with some tidy up. I note that all the classic update logic executes in FixedUpdate, which is frozen when game is paused anyway because Time.timeScale is set to 0 when paused. This means there's no need for a secondary check to switch classic update loop on/off, that happens automatically when time is frozen.

I could likely just remove the ClassicUpdate true/false flag altogether and depend on timeScale to freeze this logic. But classic update spreads over a few different systems and I don't want to risk introducing some subtle issue at this time.

What I'd propose for now is to change GameManager line 947 to the following.

Code: Select all

if (topWindow != null && !(topWindow is DaggerfallHUD) && topWindow.PauseWhileOpen)
    return false;
My reasoning is:
  • This change now respects PauseWhileOpen flag on topWindow if game is otherwise unpaused. That should solve the problem for your mod.
  • However, if a pausing window is lower in stack then game is already paused and that topWindow check never happens anyway.
  • This should never trigger in base game as all core UI windows pause the game, so minimising risk of a regression.
Could you please try the above change in your mod fork and let me know if it will solve the issue for your mod? If so, I'll test some more and merge that change in next release.

User avatar
DunnyOfPenwick
Posts: 275
Joined: Wed Apr 14, 2021 1:58 am
Location: Southeast US

Re: Question about GameManager.IsPlayingGame()

Post by DunnyOfPenwick »

I put the change in and can confirm it fixed the problem, as I was butchered while lockpicking.

User avatar
Interkarma
Posts: 7247
Joined: Sun Mar 22, 2015 1:51 am

Re: Question about GameManager.IsPlayingGame()

Post by Interkarma »

Excellent! I've pushed that change to master now.

Post Reply