Jump to content

Space Warp [v1.9.5 for KSP2 0.2.1]


cheese3660

Recommended Posts

Question - I had seen that someone had posted a version of Spacewarp onto Curseforge (which had some comments that it was not an authorized / legit uploading of it and has since been removed).  Have you considered also publishing Spacewarp onto the Curseforge platform and allowing them to integrate KSP2 with mods hosted on their platform?  Or would them automating obtaining of it from the project github be an alternative?  Just curious what your thoughts are regarding.

Link to comment
Share on other sites

Hey, I've been trying to setup a reliable subscription to the game's messages system. As you probably already know the GameObjects get destroyed upon exiting to the main menu and this also wipes the subscriptions, so everything is lost and things start to break.

I'm wondering if a recommended method has been established to deal with this yet. I've seen it seeming to affect another mod as well (Reflektor) which breaks after returning to the main menu.

At first I tried using SpaceWarp's system in SpaceWarp.API.Game.Messages with the EnteredMainMenu event. But this was firing before the GameObjects have been destroyed, so it doesn't work for resubscribing.

The method I ended up using is Unity's SceneManager.sceneLoaded, it appears Unity registers a scene change upon returning to the Main Menu from a loaded save game. The scene name is just "f" strangely. Since it registers this scene change very early on in the initial game loading sequence, and also upon return to the main menu after everything is setup, I added the listener in OnInitialized.

public override void OnInitialized() {
	SceneManager.sceneLoaded += OnSceneLoaded;
	ReInitialize();
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
	if (scene.name != "f") return;
	ReInitialize();
}
private void ReInitialize() {
	GameManager.Instance.Game.Messages.Subscribe<UISliderReleasedMessage>(ReleasedUISlider);
	// ... etc
}

If there's not an existing solution in SpaceWarp, it might be worth adding this to your API? As I think many mods will need to use the messages system, and need it to not break upon exiting to main menu.

Link to comment
Share on other sites

1 hour ago, KSRe-dev said:

Hey, I've been trying to setup a reliable subscription to the game's messages system. As you probably already know the GameObjects get destroyed upon exiting to the main menu and this also wipes the subscriptions, so everything is lost and things start to break.

I'm wondering if a recommended method has been established to deal with this yet. I've seen it seeming to affect another mod as well (Reflektor) which breaks after returning to the main menu.

At first I tried using SpaceWarp's system in SpaceWarp.API.Game.Messages with the EnteredMainMenu event. But this was firing before the GameObjects have been destroyed, so it doesn't work for resubscribing.

The method I ended up using is Unity's SceneManager.sceneLoaded, it appears Unity registers a scene change upon returning to the Main Menu from a loaded save game. The scene name is just "f" strangely. Since it registers this scene change very early on in the initial game loading sequence, and also upon return to the main menu after everything is setup, I added the listener in OnInitialized.

public override void OnInitialized() {
	SceneManager.sceneLoaded += OnSceneLoaded;
	ReInitialize();
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
	if (scene.name != "f") return;
	ReInitialize();
}
private void ReInitialize() {
	GameManager.Instance.Game.Messages.Subscribe<UISliderReleasedMessage>(ReleasedUISlider);
	// ... etc
}

If there's not an existing solution in SpaceWarp, it might be worth adding this to your API? As I think many mods will need to use the messages system, and need it to not break upon exiting to main menu.

I'm pretty sure you can circumvent all this trouble by using PersistentSubscribe instead of Subscribe

Link to comment
Share on other sites

SpaceWarp, BepInEx, and UITK are all installed with latest versions using CKAN.  The mods are installed and show in the Mods menu and in the settings, but nothing shows in the AppBar. The following are the only references to the AppBar in the Log file. I'm new to modding in KSP2, so I'm not entirely certain if I did something wrong or this is a bug. I've checked all I can think to check on my own, including reinstalling and checking versions as well as installing manually instead of using CKAN. Everything yields the same results. The game is the latest version, v0.2.1.0 and the mods are for the current version according their docs.

[LOG 20:23:01.889] [System] Loading UI Manager completed in 0.9751s.
[LOG 20:23:01.890] SpaceWarp.UI: App bar creation event started: Flight
[LOG 20:23:01.896] SpaceWarp.UI: App bar creation event started: KSC
[EXC 20:23:02.031] NullReferenceException: Object reference not set to an instance of an object
    KSP.Sim.impl.KerbalBehavior.OnDestroy () (at <c4ea47f19fd14056a3b804ca72110bb1>:0)
[LOG 20:23:02.573] [System] Loading KSP2 missions completed in 0.5402s.
[WRN 20:23:02.577] Unable to get difficulty option definition for StartingScience
[LOG 20:23:02.593] [System] Loading Science Data completed in 0.0181s.
[LOG 20:23:02.994] SpaceWarp.UI: Couldn't find appbar.
[LOG 20:23:02.995] SpaceWarp.UI: Couldn't find appbar.
[LOG 20:23:02.996] SpaceWarp.UI: Couldn't find appbar.
[LOG 20:23:02.996] SpaceWarp.UI: Couldn't find appbar.
[LOG 20:23:02.997] SpaceWarp.UI: Couldn't find appbar.
[EXC 20:23:03.000] NullReferenceException: Object reference not set to an instance of an object
    KSP.Sim.impl.KerbalBehavior.OnDestroy () (at <c4ea47f19fd14056a3b804ca72110bb1>:0)

Link to comment
Share on other sites

  • 1 month later...
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...