diff --git a/Mapify.sln b/Mapify.sln index ddea985f..8c26d1ae 100644 --- a/Mapify.sln +++ b/Mapify.sln @@ -7,11 +7,16 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Release|Any CPU = Release|Any CPU + Debug|Any CPU = Debug|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {57D181A9-9D9D-4EBA-BBDD-9172EEB79983}.Release|Any CPU.ActiveCfg = Release|Any CPU - {57D181A9-9D9D-4EBA-BBDD-9172EEB79983}.Release|Any CPU.Build.0 = Release|Any CPU {57D181A9-9D9D-4EBA-BBDD-9172EEB79984}.Release|Any CPU.ActiveCfg = Release|Any CPU {57D181A9-9D9D-4EBA-BBDD-9172EEB79984}.Release|Any CPU.Build.0 = Release|Any CPU + {57D181A9-9D9D-4EBA-BBDD-9172EEB79984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57D181A9-9D9D-4EBA-BBDD-9172EEB79984}.Debug|Any CPU.Build.0 = Debug|Any CPU + {57D181A9-9D9D-4EBA-BBDD-9172EEB79983}.Release|Any CPU.ActiveCfg = Release|Any CPU + {57D181A9-9D9D-4EBA-BBDD-9172EEB79983}.Release|Any CPU.Build.0 = Release|Any CPU + {57D181A9-9D9D-4EBA-BBDD-9172EEB79983}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57D181A9-9D9D-4EBA-BBDD-9172EEB79983}.Debug|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection EndGlobal diff --git a/Mapify/AssetCopiers/AssetCopier.cs b/Mapify/AssetCopiers/AssetCopier.cs index 168382ce..aa4c4902 100644 --- a/Mapify/AssetCopiers/AssetCopier.cs +++ b/Mapify/AssetCopiers/AssetCopier.cs @@ -18,7 +18,8 @@ public abstract class AssetCopier public static GameObject Instantiate(VanillaAsset asset, bool active = true, bool originShift = true) { - Mapify.LogDebug(() => "Instantiating asset: " + asset); + Mapify.LogDebug("Instantiating asset: " + asset); + var gameObject = GameObject.Instantiate(prefabs[asset], originShift ? WorldMover.OriginShiftParent : null); gameObject.SetActive(active); return gameObject; diff --git a/Mapify/AssetCopiers/GameContentCopier.cs b/Mapify/AssetCopiers/GameContentCopier.cs index b0ed8bd6..8057ad67 100644 --- a/Mapify/AssetCopiers/GameContentCopier.cs +++ b/Mapify/AssetCopiers/GameContentCopier.cs @@ -114,8 +114,7 @@ public class GameContentCopier : AssetCopier foreach (var module in shop.GetComponentsInChildren()) Object.Destroy(module.gameObject); - Object.Destroy(shop.transform.FindChildByName("Stopwatch")); - Object.Destroy(shop.transform.FindChildByName("PosterAnchor")); + Object.Destroy(shop.gameObject.FindChildByName("PosterAnchor")); yield return (VanillaAsset.StoreObject, shop.gameObject); diff --git a/Mapify/Components/Reactivate.cs b/Mapify/Components/Reactivate.cs new file mode 100644 index 00000000..20b3dbc8 --- /dev/null +++ b/Mapify/Components/Reactivate.cs @@ -0,0 +1,20 @@ +using UnityEngine; + +namespace Mapify.Components +{ + /// + /// Force the target Gameobject to stay active + /// + public class Reactivate: MonoBehaviour + { + public GameObject target; + + private void Update() + { + if(target.activeSelf) return; + + target.SetActive(true); + Destroy(this); + } + } +} diff --git a/Mapify/Mapify.cs b/Mapify/Mapify.cs index 068ddac3..5b3fd9c7 100644 --- a/Mapify/Mapify.cs +++ b/Mapify/Mapify.cs @@ -57,12 +57,22 @@ private static void Patch() #region Logging + public static void LogDebugExtreme(object msg) + { + LogDebugExtreme(() => msg); + } + public static void LogDebugExtreme(Func resolver) { if (Settings.ExtremelyVerboseLogging) LogDebug(resolver); } + public static void LogDebug(object msg) + { + LogDebug(() => msg); + } + public static void LogDebug(Func resolver) { if (Settings.VerboseLogging) diff --git a/Mapify/Patches/GlobalShopControllerPatch.cs b/Mapify/Patches/GlobalShopControllerPatch.cs new file mode 100644 index 00000000..c167f7c3 --- /dev/null +++ b/Mapify/Patches/GlobalShopControllerPatch.cs @@ -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); + } + + /// + /// Verify that the ItemType enum is up to date. + /// + 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() + .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 +} diff --git a/Mapify/Patches/ItemLocationForcerPatch.cs b/Mapify/Patches/ItemLocationForcerPatch.cs new file mode 100644 index 00000000..9a0ce3d8 --- /dev/null +++ b/Mapify/Patches/ItemLocationForcerPatch.cs @@ -0,0 +1,39 @@ +using DV; +using DV.Shops; +using HarmonyLib; +using Mapify.Components; +using Mapify.Map; +using VLB; + +namespace Mapify.Patches +{ + /// + /// Something keeps setting the shop scanner inactive. This patch prevents that. + /// + [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(out var shopScanner)) return; + + Mapify.LogDebug($"Forcing scanner at '{shopScanner.gameObject.GetPath()}' active"); + var reactivate = __instance.gameObject.GetOrAddComponent(); + 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(out var reactivate)) return; + reactivate.enabled = false; + } + } + +} diff --git a/Mapify/Patches/PlayerDistanceGameObjectsDisablerPatch.cs b/Mapify/Patches/PlayerDistanceGameObjectsDisablerPatch.cs index 0e883ba9..7bfcec3f 100644 --- a/Mapify/Patches/PlayerDistanceGameObjectsDisablerPatch.cs +++ b/Mapify/Patches/PlayerDistanceGameObjectsDisablerPatch.cs @@ -1,4 +1,5 @@ -using HarmonyLib; +using DV.Optimizers; +using HarmonyLib; using UnityEngine; namespace Mapify.Patches diff --git a/Mapify/Patches/RailwayMeshGeneratorPatch.cs b/Mapify/Patches/RailwayMeshGeneratorPatch.cs index 17801e18..3d2f2c68 100644 --- a/Mapify/Patches/RailwayMeshGeneratorPatch.cs +++ b/Mapify/Patches/RailwayMeshGeneratorPatch.cs @@ -52,25 +52,12 @@ private static bool Prefix(RailwayMeshGenerator __instance, TrackChunk chunk, Li [HarmonyPatch(typeof(RailwayMeshGenerator), nameof(RailwayMeshGenerator.UpdateSleepersData))] public class RailwayMeshGenerator_UpdateSleepersData_Patch { - private static bool Prefix(TrackChunk chunk, ref JobHandle ___sleepersHandle, NativeList ___sleepersAnchorsPositions, NativeList ___sleepersAnchorsTransformBufferData) + private static bool Prefix(TrackChunk chunk) { - if (Maps.IsDefaultMap) - return true; + if (Maps.IsDefaultMap) return true; - Track track = chunk.track.GetComponent(); - if (!track.generateSleepers) - return false; - - ___sleepersHandle = new PlaceSleepersAppendJob( - ___sleepersAnchorsTransformBufferData, - ___sleepersAnchorsPositions, - chunk.pointSet, - chunk.minIndex, - chunk.maxIndex, - chunk.track.baseType.randomizeAnchorDirection, - chunk.track.baseType.sleeperVerticalOffset - ).Schedule(___sleepersHandle); - return false; + var track = chunk.track.GetComponent(); + return track.generateSleepers; } } } diff --git a/Mapify/Patches/ShelfPlacerPatch.cs b/Mapify/Patches/ShelfPlacerPatch.cs new file mode 100644 index 00000000..b5e601c6 --- /dev/null +++ b/Mapify/Patches/ShelfPlacerPatch.cs @@ -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); + } + } +} diff --git a/Mapify/SceneInitializers/GameContent/StoreSetup.cs b/Mapify/SceneInitializers/GameContent/StoreSetup.cs index 90bdfdfa..94d1316d 100644 --- a/Mapify/SceneInitializers/GameContent/StoreSetup.cs +++ b/Mapify/SceneInitializers/GameContent/StoreSetup.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using DV.CashRegister; +using DV.Optimizers; using DV.Printers; using DV.Shops; using DV.Utils; diff --git a/MapifyEditor/Store/ItemType.cs b/MapifyEditor/Store/ItemType.cs index 7a1bf099..9cfdd797 100644 --- a/MapifyEditor/Store/ItemType.cs +++ b/MapifyEditor/Store/ItemType.cs @@ -106,9 +106,6 @@ public enum ItemType PaintCan = 178, PaintCanMuseum = 179, PaintCanSand = 180, - Crate = 181, - CratePlastic = 182, - PaperBox = 183, BeaconAmber = 184, BeaconRed = 185, BeaconBlue = 186, @@ -118,7 +115,7 @@ public enum ItemType SwitchSetter = 190, SwitchAlternating = 191, - //build 99.4 + // build 99.4 ItemContainerBriefcase = 192, ItemContainerFolder = 193, Nameplate = 194, @@ -142,6 +139,9 @@ public enum ItemType ItemContainerFolderBlue = 212, ItemContainerFolderRed = 213, ItemContainerFolderYellow = 214, - ItemContainerRegistrator = 215 + ItemContainerRegistrator = 215, + + // build 99.7 + GooglyEye = 216 } } diff --git a/MapifyEditor/Vanilla/VanillaAsset.cs b/MapifyEditor/Vanilla/VanillaAsset.cs index be2e8fd1..91f0c202 100644 --- a/MapifyEditor/Vanilla/VanillaAsset.cs +++ b/MapifyEditor/Vanilla/VanillaAsset.cs @@ -182,9 +182,6 @@ public enum VanillaAsset StoreItemPaintCan = 178, StoreItemPaintCanMuseum = 179, StoreItemPaintCanSand = 180, - StoreItemCrate = 181, - StoreItemCratePlastic = 182, - StoreItemPaperBox = 183, StoreItemBeaconAmber = 184, StoreItemBeaconRed = 185, StoreItemBeaconBlue = 186, @@ -218,7 +215,10 @@ public enum VanillaAsset StoreItemItemContainerFolderBlue = 212, StoreItemItemContainerFolderRed = 213, StoreItemItemContainerFolderYellow = 214, - StoreItemItemContainerRegistrator = 215 + StoreItemItemContainerRegistrator = 215, + + // build 99.7 + StoreItemGooglyEye = 216 #endregion }