Need Assistance With CityNavigator Object

Discuss modding questions and implementation details.
Post Reply
l3lessed
Posts: 1399
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Need Assistance With CityNavigator Object

Post by l3lessed »

I'm so close to finishing the minimap mod, but I am hitting this last road block.

So as recommended to me, I starting playing with the CityNavigator Object and all its connected stuff. This worked in getting the proper position of a city location for placing markers.

However, I have one issue with it. Anytime I try to fast travel some where, the navigator object doesn't activate at the write time and returns a null error when grabbing the position.

This is the code here:

Code: Select all

DaggerfallLocation Dflocation = GameManager.Instance.StreamingWorld.CurrentPlayerLocationObject;
GameManager.Instance.StreamingWorld.GetCurrentCityNavigation().WorldToScenePosition(new DFPosition(Dflocation.Summary.MapPixelX, Dflocation.Summary.MapPixelX)
I tried everything to stop this including the following checks before running it:

Code: Select all

if(GameManager.Instance.StreamingWorld.GetCurrentCityNavigation() == null) return;

Code: Select all

if(Dflocation.GetComponentInChildren<BuildingDirectory>() == null) return;

Code: Select all

if(Dflocation.GetComponentInChildren<BuildingDirectory>() == null) return;

Code: Select all

if(GameManager.Instance.StreamingWorld.CurrentPlayerLocationObject == null) return;

Code: Select all

if(GameManager.Instance.StreamingWorld.CurrentPlayerLocationObject == null) return;

Code: Select all

if(GameManager.Instance.SaveLoadManager.LoadInProgress  || GameManager.Instance.StreamingWorld.IsInit || GameManager.Instance.StreamingWorld.IsRepositioningPlayer) return;
Despite having my update loop stop after all of these null checks to ensure the streaming world is loaded, ready, and initialized, I still get a null error that stops the marker setup. It only happens on fast travel now too (I was able to stop all the other null errors using these checks).
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

l3lessed
Posts: 1399
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Need Assistance With CityNavigator Object

Post by l3lessed »

Got a work around. You can tie an event load to the post fast travel event. I used this to setup a bool to detect if the player fast travelled. If they did, then it checks if the city navigator object is ready. Once it verifies this, it then resets the fast travel check and runs the building setup. Despite this, it would be nice if the city navigator object was smart enough to null error catch itself, no matter the players state.

Code: Select all

        void Start()
        {
            SetupMinimap();
            SaveLoadManager.OnLoad += OnLoadEvent;
            DaggerfallTravelPopUp.OnPostFastTravel += postTravel;
        }

Code: Select all

        void postTravel()
        {
            fastTravelFinished = true;
        }

Code: Select all

            if(fastTravelFinished && GameManager.Instance.StreamingWorld.GetCurrentCityNavigation() != null)
            {
                fastTravelFinished = false;
                SetupBuildingIndicators();
            }
With this, I think the mod is finally long play session stable and release ready. Want to test it some more to be safe though, while I clean up and comment code.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Post Reply