Jump to content

Need some help with onGamePause


linuxgurugamer

Recommended Posts

I need to know when a game is paused, both in flight AND when in the Space Center.

This code:


GameEvents.onGamePause.Add (OnPause);
GameEvents.onGameUnpause.Add (OnResume);

works for in-flight pauses (using the esc key), but doesn't seem to get triggered when in the space center.

Any idea why? I'm guessing that the Space Center isn't considered being played, which is odd since gametime still moves forward when in the Space Center.

Thanks in advance.

Edit:

for now, I've added the following:


private void CallbackLevelWasLoaded (GameScenes scene)
{
Log.Info ("CallbackLevelWasLoaded");
if (HighLogic.LoadedScene == GameScenes.SPACECENTER) {
paused = false;
}
}

...
...
...
GameEvents.onLevelWasLoaded.Add (CallbackLevelWasLoaded);
...
...
...
public void Update ()
{
if (Input.GetKeyDown (KeyCode.Escape)) {
if (HighLogic.LoadedScene == GameScenes.SPACECENTER) {
paused = !paused;
}
}

But this seems a bit unnecessary. I'm kind of hoping there is a different callback for the spacecenter pause.

On a slightly different note, is there any way to pause the game while in one of the non-flight scenes? I realize that game time doesn't pass while in these scenes, but I'm adding functionality to TotalTime to not record time while paused, so would like to do this. This isn't a big deal, since I can simply trap the escape key and put up a pause dialog myself.

Edited by linuxgurugamer
Link to comment
Share on other sites

Adding to my confusion, it seems that the following areas are considered part of the Space Center scene:

Administration building

Research and Development

Astronaut Complex

Mission Control

In these four, the escape key does not do anything, yet in the main Space Center scene, the escape key brings up a menu.

So if nothing else, how can I tell the difference between these 4 scenes and the overall Space Center?

Thanks

Edit: Just found the GameEvents for these four, so this code will do it for me:


GameEvents.onGUIAdministrationFacilitySpawn.Add (CallbackAdminFacility);
GameEvents.onGUIAdministrationFacilityDespawn.Add (CallbackAdminFacility);
GameEvents.onGUIMissionControlSpawn.Add (CallbackAdminFacility);
GameEvents.onGUIMissionControlDespawn.Add (CallbackAdminFacility);
GameEvents.onGUIRnDComplexSpawn.Add (CallbackAdminFacility);
GameEvents.onGUIRnDComplexDespawn.Add (CallbackAdminFacility);
GameEvents.onGUIAstronautComplexSpawn.Add(CallbackAdminFacility);
GameEvents.onGUIAstronautComplexDespawn.Add(CallbackAdminFacility);

Edited by linuxgurugamer
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...