Conversation
| namespace Mapify.Patches | ||
| { | ||
| /// <summary> | ||
| /// Something keeps setting the shop scanner inactive. This patch prevents that. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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))] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I'll add a #if DEBUG.
Mapify/AssetCopiers/AssetCopier.cs
Outdated
| } | ||
|
|
||
| Mapify.LogError($"Failed to instantiate asset {asset}"); | ||
| var nothing = new GameObject(); |
There was a problem hiding this comment.
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.
Mapify/Utils/UnityUtils.cs
Outdated
There was a problem hiding this comment.
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;
}
No description provided.