-
-
Notifications
You must be signed in to change notification settings - Fork 5
Build 99.7 compatibility #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
e225ea5
0a3b805
77d5607
d734c0d
d3b13d7
d2514c4
0e138ec
d21e7a5
0bcba5f
867d09d
536274c
c910d9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| using UnityEngine; | ||
|
|
||
| namespace Mapify.Components | ||
| { | ||
| /// <summary> | ||
| /// Force the target Gameobject to stay active | ||
| /// </summary> | ||
| public class Reactivate: MonoBehaviour | ||
| { | ||
| public GameObject target; | ||
|
|
||
| private void Update() | ||
| { | ||
| if(target.activeSelf) return; | ||
|
|
||
| target.SetActive(true); | ||
| Destroy(this); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| using System; | ||
| using System.Linq; | ||
| using DV.Shops; | ||
| using HarmonyLib; | ||
|
|
||
| namespace Mapify.Patches | ||
| { | ||
| #if DEBUG | ||
| [HarmonyPatch(typeof(GlobalShopController), nameof(GlobalShopController.InitializeShopData))] | ||
| public class GlobalShopController_InitializeShopData_Patch | ||
| { | ||
| private static void Postfix(GlobalShopController __instance) | ||
| { | ||
| VerifyItemTypeEnum(__instance); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verify that the ItemType enum is up to date. | ||
| /// </summary> | ||
| private static void VerifyItemTypeEnum(GlobalShopController __instance) | ||
| { | ||
| var inGameItems = __instance.shopItemsData.Select(dat => dat.item.itemPrefabName.ToLower().Replace("_", "")).ToArray(); | ||
|
|
||
| var inModItems = Enum.GetValues(typeof(Editor.ItemType)) | ||
| .Cast<Editor.ItemType>() | ||
| .Select(itemEnum => itemEnum.ToString().ToLower()) | ||
| .ToArray(); | ||
|
|
||
| bool verifiedSuccessfully = true; | ||
|
|
||
| foreach (var inModItem in inModItems) | ||
| { | ||
| if(inGameItems.Contains(inModItem)) continue; | ||
|
|
||
| Mapify.LogError($"{nameof(ItemType)} '{inModItem}' does not exist in-game"); | ||
| verifiedSuccessfully = false; | ||
| } | ||
|
|
||
| foreach (var inGameItem in inGameItems) | ||
| { | ||
| if(inModItems.Contains(inGameItem)) continue; | ||
|
|
||
| // the keys are intentionally left out | ||
| if(inGameItem.StartsWith("key")) continue; | ||
|
|
||
| Mapify.LogWarning($"Item '{inGameItem}' does not exist in enum {nameof(ItemType)}"); | ||
| } | ||
|
|
||
| if(verifiedSuccessfully) return; | ||
|
|
||
| Mapify.LogDebug("Items in game:"); | ||
| foreach (var inGameItem in inGameItems) | ||
| { | ||
| Mapify.LogDebug(inGameItem); | ||
| } | ||
| } | ||
| } | ||
| #endif | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| using DV; | ||
| using DV.Shops; | ||
| using HarmonyLib; | ||
| using Mapify.Components; | ||
| using Mapify.Map; | ||
| using VLB; | ||
|
|
||
| namespace Mapify.Patches | ||
| { | ||
| /// <summary> | ||
| /// Something keeps setting the shop scanner inactive. This patch prevents that. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. The only thing triggering this is
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| /// </summary> | ||
| [HarmonyPatch(typeof(ItemLocationForcer), nameof(ItemLocationForcer.Awake))] | ||
| public class ItemLocationForcer_Awake_Patch | ||
| { | ||
| private static void Postfix(ItemLocationForcer __instance) | ||
| { | ||
| if(__instance.itemGO == null || Maps.IsDefaultMap) return; | ||
| if(!__instance.itemGO.TryGetComponent<ShopScanner>(out var shopScanner)) return; | ||
|
|
||
| Mapify.LogDebug($"Forcing scanner at '{shopScanner.gameObject.GetPath()}' active"); | ||
| var reactivate = __instance.gameObject.GetOrAddComponent<Reactivate>(); | ||
| reactivate.enabled = true; | ||
| reactivate.target = shopScanner.gameObject; | ||
| } | ||
| } | ||
|
|
||
| [HarmonyPatch(typeof(ItemLocationForcer), nameof(ItemLocationForcer.OnDisable))] | ||
| public class ItemLocationForcer_OnDisable_Patch | ||
| { | ||
| private static void Postfix(ItemLocationForcer __instance) | ||
| { | ||
| if(__instance.itemGO == null || Maps.IsDefaultMap) return; | ||
| if(!__instance.itemGO.TryGetComponent<Reactivate>(out var reactivate)) return; | ||
| reactivate.enabled = false; | ||
| } | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| using HarmonyLib; | ||
| using DV.Optimizers; | ||
| using HarmonyLib; | ||
| using UnityEngine; | ||
|
|
||
| namespace Mapify.Patches | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using DV.Shops; | ||
| using HarmonyLib; | ||
| using Mapify.Map; | ||
|
|
||
| namespace Mapify.Patches | ||
| { | ||
| [HarmonyPatch(typeof(ShelfPlacer), nameof(ShelfPlacer.TryPlaceOnAnyShelf))] | ||
| public class ShelfPlacer_TryPlaceOnAnyShelf_Patch | ||
| { | ||
| private static void Postfix(ShelfItem item, bool __result) | ||
| { | ||
| if(Maps.IsDefaultMap || !__result) return; | ||
| item.gameObject.SetActive(true); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
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 DEBUGdirective or something similar.There was a problem hiding this comment.
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.