Skip to content

Conversation

@t0stiman
Copy link
Collaborator

No description provided.

namespace Mapify.Patches
{
/// <summary>
/// Something keeps setting the shop scanner inactive. This patch prevents that.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should find what's causing this, not add some weird hacky workaround. You should be able to see what's happening by inspecting the stacktrace from the OnEnable/OnDisable methods of something attached to an item.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the stracktrace suggestion, but I still can't figure it out.

private void OnDisable()
        {
            var trace = new System.Diagnostics.StackTrace();
            Mapify.LogDebug($"ForceActive.OnDisable");
            Mapify.LogDebug(trace.ToString());
        }

The only thing triggering this is PlayerDistanceMultipleGameObjectsOptimizer when I walk away from the shop. This is expected.
But if I start the game while already at the shop, nothing triggers OnDisable and the scanner is still inactive.
Even if I set the scanner to active in StoreSetup or ItemLocationForcer_Awake_Patch the scanner is inactive.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the Forceactive class to Reactivate, which sets the target object to active once and then destroys itself.
Can you allow this one hack? Because this PR is blocking all the others 😬


namespace Mapify.Patches
{
[HarmonyPatch(typeof(GlobalShopController), nameof(GlobalShopController.InitializeShopData))]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to be doing this for everyone every time? I assume you use this to know what items to add to the enum, so it should probably be behind an #if DEBUG directive or something similar.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a #if DEBUG.

}

Mapify.LogError($"Failed to instantiate asset {asset}");
var nothing = new GameObject();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this. What's the case where this can even happen? If something isn't in prefabs we have bigger problems, an incompatible map, or a bug somewhere else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we only using InstantiateDisabled with GameObjects from this? It seems quite overkill and could probably be simplified down to something like

GameObject InstantiateDisabled(GameObject prefab)
{
	var wasActive = prefab.activeSelf;
	prefab.SetActive(false);
	var go = Instantiate(prefab);
	prefab.SetActive(wasActive);
	return go;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@t0stiman t0stiman requested a review from Insprill August 17, 2025 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants