Change in DaggerfallStaticBuilding Script

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

Change in DaggerfallStaticBuilding Script

Post by l3lessed »

Okay, I was about to release my finalized and debug version of my compass map, as it was running great in the editor. I compiled it, put it into a 1.1.1 DFU build, and all of a sudden the compass ran, but none of my building markers seemed to generate or work. Everything else was fine. After running through the code using a series of debug.logerrors and pulling up the player.log, I finally tracked it down to this single issue between the editor and the build version. There seems to be a difference in how the DaggerfallStaticBuilding scripts are being ran/used. Here is the exact code:

Code: Select all

            foreach (DaggerfallRMBBlock block in blockArray)
            {
                Vector3 blockPosition = block.transform.position;
                Debug.LogError("Block Position: " + blockPosition);
                //setup a new static buildings object to hold the rmb blocks static buildings object.
                DaggerfallStaticBuildings staticBuildingContainer = block.GetComponentInChildren<DaggerfallStaticBuildings>();
                Debug.LogError("Static Building Container: " + staticBuildingContainer.name);
                //if there are not any buildings in this block, stop code from crashing script and return.
                if (staticBuildingContainer == null)
                    continue;
After pulling the RMBblock from the location, so I can pull the static building script from each rmbblock and use it to start setting up and generating each marker for each building, nothing happens. This is because all of a sudden, despite it working fine in the editor, the build version is getting null pulls from the RMBblock for the DaggerfallStaticBuilding script/component.

I know this because the Debug.LogError("Static Building Container: " + staticBuildingContainer.name); returns a null error in the player.log and my built in null error return catcher stopped the mod from crashing by detecting the null and stopping the marker code from going any further.

Anyone have an idea if there has been any changes related to how the RMBblocks and the DaggerfallStaticBuilding script is working?

I'm going to try and figure out if I can pull it another way, but I'm a little lost, as in the editor, it shows this component/script attached to each RMBBlock under the current location component, but it clearly isn't in the build version.

*EDIT*
I've tried pulling it from the streaming world object, from the location object, and still now luck. So odd it works fine in editor, but not in build version.
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: 1430
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Change in DaggerfallStaticBuilding Script

Post by l3lessed »

I found the issue. Something has changed in how the streaming world is initialized between editor and build version.

With the original null error causing code, I had it running on a mappixel change call like so

Code: Select all

private void PlayerGPS_OnMapPixelChanged(DFPosition mapPixel)
{
my marker generation code here....
}
In the editor this doesn't cause a problem, as it seems the streaming world initializes after this playergps map pixel call. However, in the build version, it seems this call happens before the streaming world initializes or during it causing it to not have the static buildings attached to the blocks yet and causing the null error.

When I move the main code out of the map pixel call, put it into an update loop, and have a boolean trigger tied to the map pixel call with a GameManager.Instance.StreamingWorld.IsInit, it doesn't run into the null error because it doesn't run the code until both the map pixel changes and the update loop checks the streaming world if fully initialized like so

Code: Select all

if (changedLocations && !GameManager.Instance.IsPlayerInside && !GameManager.Instance.StreamingWorld.IsInit && GameManager.Instance.StreamingWorld.IsReady && GameManager.Instance.PlayerGPS != null)
{
my marker generation code here....
}
The odd thing about this, even using a GameManager.Instance.StreamingWorld.IsReady in the map pixel change call lets it run and still hits the null error. This seems odd, as the streaming world isn't actually ready if there are null objects, correct?

I'll just use a numerator and kick it on when the map pixel changes and have it complete/stop once the code executes to save a continual update loop check/call, which was the original purpose of using the map pixel change call.

I'll put in this fix and push the final debugged and improved version tomorrow.
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