From 9acc51ea8c1dd73e884a3bdbe2e7138d1dc6bd84 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:28:47 +0700 Subject: [PATCH 01/26] Add files via upload --- AdvancedHighlighting.csproj | 349 +++++++++++++++++++++++++++++ HighlightEnum.cs | 85 +++++++ HighlightingMod.cs | 23 ++ HighlightingMod.cs.test | 28 +++ ImageUtils.cs | 109 +++++++++ OldSettings.cs | 93 ++++++++ Patches/Highlighting_Patch.cs | 248 ++++++++++++++++++++ Patches/PingInstance_Patch.cs | 32 +++ Patches/SaveLoadManager_Patch.cs | 34 +++ Patches/uGUI_OptionsPanel_Patch.cs | 130 +++++++++++ Patches/uGUI_Pings_Patch.cs | 51 +++++ Properties/AssemblyInfo.cs | 36 +++ Properties/Resources.Designer.cs | 90 ++++++++ Properties/Resources.resx | 129 +++++++++++ Qmod.cs.test | 55 +++++ Settings.cs | 68 ++++++ Utils.cs | 169 ++++++++++++++ 17 files changed, 1729 insertions(+) create mode 100644 AdvancedHighlighting.csproj create mode 100644 HighlightEnum.cs create mode 100644 HighlightingMod.cs create mode 100644 HighlightingMod.cs.test create mode 100644 ImageUtils.cs create mode 100644 OldSettings.cs create mode 100644 Patches/Highlighting_Patch.cs create mode 100644 Patches/PingInstance_Patch.cs create mode 100644 Patches/SaveLoadManager_Patch.cs create mode 100644 Patches/uGUI_OptionsPanel_Patch.cs create mode 100644 Patches/uGUI_Pings_Patch.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Qmod.cs.test create mode 100644 Settings.cs create mode 100644 Utils.cs diff --git a/AdvancedHighlighting.csproj b/AdvancedHighlighting.csproj new file mode 100644 index 0000000..714a405 --- /dev/null +++ b/AdvancedHighlighting.csproj @@ -0,0 +1,349 @@ + + + + + Debug + AnyCPU + {ADB59190-BC97-4509-AB62-C64A4D9A93EC} + Library + Properties + AdvancedHighlighting + AdvancedHighlighting + v4.8 + 512 + true + + + + true + full + true + bin\BZ\ + BZ + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + bin\BZ\ + + + bin\SN\ + + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\BepInEx\core\0Harmony20.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Assembly-CSharp.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Assembly-CSharp-firstpass.dll + + + False + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Newtonsoft.Json.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\BepInEx\plugins\QModManager\QModInstaller.dll + + + D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\SMLHelper_BZ\SMLHelper.dll + + + + + + + + + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Addressables.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Burst.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Burst.Unsafe.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Collections.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Formats.Fbx.Runtime.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.InternalAPIEngineBridge.001.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Mathematics.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.MemoryProfiler.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.PlayableGraphVisualizer.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ProBuilder.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ProBuilder.KdTree.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ProBuilder.Poly2Tri.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ProBuilder.Stl.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Recorder.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ResourceManager.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ScriptableBuildPipeline.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.TextMeshPro.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Timeline.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AccessibilityModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AIModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AndroidJNIModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AnimationModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ARModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AssetBundleModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AudioModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ClothModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ClusterInputModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ClusterRendererModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.CoreModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.CrashReportingModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.DirectorModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.DSPGraphModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.GameCenterModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.GridModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.HotReloadModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ImageConversionModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.IMGUIModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.InputLegacyModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.InputModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.JSONSerializeModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.LocalizationModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ParticleSystemModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.PerformanceReportingModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.Physics2DModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.PhysicsModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ProfilerModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ScreenCaptureModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.SharedInternalsModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.SpriteMaskModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.SpriteShapeModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.StreamingModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.SubstanceModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.SubsystemsModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TerrainModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TerrainPhysicsModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TextCoreModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TextRenderingModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TilemapModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TLSModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UI.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UIElementsModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UIModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UmbraModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UNETModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityAnalyticsModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityConnectModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityTestProtocolModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityWebRequestAssetBundleModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityWebRequestModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.VehiclesModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.VFXModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.VideoModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.VRModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.WindModule.dll + + + D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.XRModule.dll + + + + + + + + + + + + + + True + True + Resources.resx + + + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + if $(ConfigurationName) == BZ ( +mkdir "D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\$(TargetName)" +xcopy /Y "$(TargetPath)" "D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\$(TargetName)" +copy /Y "$(ProjectDir)\mod_BZ.json" "D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\$(TargetName)\mod.json" +del "D:\SteamLibrary\steamapps\common\SubnauticaZero\qmodmanager_log-SubnauticaZero.txt" ) + +if $(ConfigurationName) == SN ( +mkdir "D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(TargetName)" +xcopy /Y "$(TargetPath)" "D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(TargetName)" +copy /Y "$(ProjectDir)\mod_SN.json" "D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(TargetName)\mod.json" +del "D:\SteamLibrary\steamapps\common\Subnautica\qmodmanager_log-Subnautica.txt") + + \ No newline at end of file diff --git a/HighlightEnum.cs b/HighlightEnum.cs new file mode 100644 index 0000000..55f2527 --- /dev/null +++ b/HighlightEnum.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +#if SN +#elif BZ +#endif + +namespace AdvancedHighlighting +{ + public enum Highlight + { + ScannableItems, + ScannableFragments, + ScannedFragments, + AnythingElse, + + Pickupable, + PickupableCreatures, + PickupableResource, + BreakableResource, + Interactables, + StoryItems, + JukeboxDisk, + SealedDoor, + GrownPlant, + Bladderfish, + CreatureEgg, + BaseLadder, + LaserCutObject + } + public static class HighlightExtenstions + { + private static readonly Dictionary highlightToText = new Dictionary() + { + [Highlight.ScannableItems] = "Scannable Items", + [Highlight.ScannableFragments] = "Scannable Fragments", + [Highlight.ScannedFragments] = "Already Scanned Fragments", + [Highlight.AnythingElse] = "Anything Else", + + [Highlight.Pickupable] = "Pickupable Items", + [Highlight.PickupableCreatures] = "Pickupable Creatures", + [Highlight.PickupableResource] = "Pickupable Resources", + [Highlight.BreakableResource] = "Breakable Outcrops", + [Highlight.Interactables] = "Interactables", + [Highlight.StoryItems] = "PDA Logs", + [Highlight.JukeboxDisk] = "Jukebox Disks", + [Highlight.SealedDoor] = "Sealed Ship Doors", + [Highlight.GrownPlant] = "Grown Plant", + [Highlight.Bladderfish] = "Bladder Fish", + [Highlight.CreatureEgg] = "Creature Egg", + [Highlight.BaseLadder] = "Base Ladder", + [Highlight.LaserCutObject] = "Laser Cut Object", + }; + private static readonly Dictionary highlightToType = new Dictionary() + { + [Highlight.Pickupable] = typeof(Pickupable), + [Highlight.PickupableCreatures] = typeof(Creature), + [Highlight.PickupableResource] = typeof(ResourceTracker), + [Highlight.BreakableResource] = typeof(BreakableResource), + [Highlight.Interactables] = typeof(HandTarget), + [Highlight.StoryItems] = typeof(StoryHandTarget), + [Highlight.JukeboxDisk] = typeof(JukeboxDisk), + [Highlight.SealedDoor] = typeof(StarshipDoor), + [Highlight.GrownPlant] = typeof(GrownPlant), + [Highlight.Bladderfish] = typeof(Bladderfish), + [Highlight.CreatureEgg] = typeof(CreatureEgg), + [Highlight.BaseLadder] = typeof(BaseLadder), + [Highlight.LaserCutObject] = typeof(Sealed), + }; + private static readonly List notComponentHighlights = new List() + { + Highlight.ScannableItems, + Highlight.ScannableFragments, + Highlight.ScannedFragments, + Highlight.AnythingElse + }; + public static bool IsPressent(this Highlight highlight, UnityEngine.Behaviour behaviour) => + highlight.IsComponent() && behaviour.TryGetComponent(highlight.GetComponentType(), out _); + public static bool IsPressentAndActive(this Highlight highlight, UnityEngine.Behaviour behaviour) => + highlight.IsComponent() && highlight.IsActive() && behaviour.TryGetComponent(highlight.GetComponentType(), out _); + public static bool IsActive(this Highlight highlight) => Settings.GetInstance().IsHighlightActive(highlight); + public static bool IsComponent(this Highlight highlight) => !notComponentHighlights.Contains(highlight); + public static string GetName(this Highlight highlight) => highlightToText.TryGetValue(highlight, out string name) ? name : null; + public static Type GetComponentType(this Highlight highlight) => highlightToType.TryGetValue(highlight, out Type type) ? type : null; + } +} \ No newline at end of file diff --git a/HighlightingMod.cs b/HighlightingMod.cs new file mode 100644 index 0000000..4ea5686 --- /dev/null +++ b/HighlightingMod.cs @@ -0,0 +1,23 @@ +using HarmonyLib; +using QModManager.API.ModLoading; +using SMLHelper.V2.Handlers; +using System; +#if SN +#elif BZ +#endif + +namespace AdvancedHighlighting +{ + [QModCore] + + public static class HighlightingMod + { + [QModPatch] + public static void InitMod() + { + Console.WriteLine("[AdvancedHighlighting] Start Patching..."); + Harmony harmony = new Harmony("net.ogmods.highlighting"); + harmony.PatchAll(); + } + } +} \ No newline at end of file diff --git a/HighlightingMod.cs.test b/HighlightingMod.cs.test new file mode 100644 index 0000000..214c44c --- /dev/null +++ b/HighlightingMod.cs.test @@ -0,0 +1,28 @@ +using HarmonyLib; +using QModManager.API.ModLoading; +using SMLHelper.V2.Handlers; +using System; +#if SN +#elif BZ +#endif + +namespace AdvancedHighlighting +{ + [QModCore] + + public static class HighlightingMod + { + internal static IngameConfigMenu Config { get; private set; } + + [QModPatch] + public static void InitMod() + { + Console.WriteLine("[AdvancedHighlighting] Start Patching..."); + Harmony harmony = new Harmony("net.ogmods.highlighting"); + harmony.PatchAll(); + + //Add the Ingame Config for User + Config = OptionsPanelHandler.Main.RegisterModOptions(); + } + } +} \ No newline at end of file diff --git a/ImageUtils.cs b/ImageUtils.cs new file mode 100644 index 0000000..fd46c66 --- /dev/null +++ b/ImageUtils.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.IO; +using UnityEngine; +#if SN +#elif BZ +#endif + +namespace AdvancedHighlighting +{ + public static class ImageUtils + { + private static Dictionary textureCache = new Dictionary(); + + private static Dictionary spriteCache = new Dictionary(); + public static Sprite LoadSprite(string path, Vector2 pivot = default(Vector2), TextureFormat format = TextureFormat.BC7, float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight) + { + Sprite sprite; + bool flag = ImageUtils.spriteCache.TryGetValue(path, out sprite); + Sprite result; + if (flag) + { + result = sprite; + } + else + { + Texture2D texture2D = ImageUtils.LoadTexture(path, format, 2, 2); + bool flag2 = !texture2D; + if (flag2) + { + result = null; + } + else + { + Sprite sprite2 = ImageUtils.TextureToSprite(texture2D, pivot, pixelsPerUnit, spriteType, default(Vector4)); + ImageUtils.spriteCache.Add(path, sprite2); + result = sprite2; + } + } + return result; + } + + public static Sprite Load9SliceSprite(string path, RectOffset slices, Vector2 pivot = default(Vector2), TextureFormat format = TextureFormat.BC7, float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight) + { + string key = path + slices; + Sprite sprite; + bool flag = ImageUtils.spriteCache.TryGetValue(key, out sprite); + Sprite result; + if (flag) + { + result = sprite; + } + else + { + Texture2D texture2D = ImageUtils.LoadTexture(path, format, 2, 2); + bool flag2 = !texture2D; + if (flag2) + { + result = null; + } + else + { + Vector4 border = new Vector4((float)slices.left, (float)slices.right, (float)slices.top, (float)slices.bottom); + Sprite sprite2 = ImageUtils.TextureToSprite(texture2D, pivot, pixelsPerUnit, spriteType, border); + ImageUtils.spriteCache.Add(key, sprite2); + result = sprite2; + } + } + return result; + } + + public static Texture2D LoadTexture(string path, TextureFormat format = TextureFormat.BC7, int width = 2, int height = 2) + { + Texture2D texture2D; + bool flag = ImageUtils.textureCache.TryGetValue(path, out texture2D); + Texture2D result; + if (flag) + { + result = texture2D; + } + else + { + bool flag2 = File.Exists(path); + if (flag2) + { + byte[] data = File.ReadAllBytes(path); + Texture2D texture2D2 = new Texture2D(width, height, format, false); + bool flag3 = texture2D2.LoadImage(data); + if (flag3) + { + ImageUtils.textureCache.Add(path, texture2D2); + return texture2D2; + } + } + else + { + Console.WriteLine("[ImageUtils] ERROR: File not found " + path); + } + result = null; + } + return result; + } + + public static Sprite TextureToSprite(Texture2D tex, Vector2 pivot = default(Vector2), float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight, Vector4 border = default(Vector4)) + { + return Sprite.Create(tex, new Rect(0f, 0f, (float)tex.width, (float)tex.height), pivot, pixelsPerUnit, 0U, spriteType, border); + } + } +} \ No newline at end of file diff --git a/OldSettings.cs b/OldSettings.cs new file mode 100644 index 0000000..99c464e --- /dev/null +++ b/OldSettings.cs @@ -0,0 +1,93 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +#if SN +#elif BZ +#endif + +namespace AdvancedHighlighting +{ + public class OldSettings + { + private static readonly Dictionary TypeToHighlight = new Dictionary + { + [typeof(Pickupable)] = Highlight.Pickupable, + [typeof(ResourceTracker)] = Highlight.PickupableResource, + [typeof(Creature)] = Highlight.PickupableCreatures, + [typeof(Bladderfish)] = Highlight.Bladderfish, + [typeof(CreatureEgg)] = Highlight.CreatureEgg, + [typeof(BaseLadder)] = Highlight.BaseLadder, + [typeof(BreakableResource)] = Highlight.BreakableResource, + [typeof(HandTarget)] = Highlight.Interactables, + [typeof(GrownPlant)] = Highlight.GrownPlant, + [typeof(StoryHandTarget)] = Highlight.StoryItems, + [typeof(JukeboxDisk)] = Highlight.JukeboxDisk, + [typeof(StarshipDoor)] = Highlight.SealedDoor, + [typeof(Sealed)] = Highlight.LaserCutObject, + [Utils.FragmentsType] = Highlight.ScannableFragments, + [Utils.ScannableType] = Highlight.ScannableItems, + [Utils.EverythingType] = Highlight.AnythingElse, + }; + + public Dictionary enableHighlights; + public Dictionary highlightingColors; + public bool storyNearbyNotification = false; + public bool jukeboxDiskNotification = false; + public bool highlightEverythingExosuit = false; + public bool destoryNull = true; + public bool showPings = false; + public float highlightRadius = 20f; + public float minAlpha = 0f; + public static Settings Load() + { + Console.WriteLine("[AdvancedHighlighting] Loading Settings"); + string path = Path.Combine(Utils.ModDirectory, "settings.json"); + Settings settings = null; + if (File.Exists(path)) + { + try + { + var text = File.ReadAllText(path); + if (text.Contains("PublicKeyToken") || text.Contains("storyNearbyNotification")) + settings = JsonConvert.DeserializeObject(text).ConvertToNewSettings(); + else + settings = JsonConvert.DeserializeObject(text); + } + catch (Exception) { } + } + if (settings == null) settings = new Settings(); + if (settings.HighlightsEnabled == null) settings.HighlightsEnabled = new Dictionary(); + if (settings.HighlightsColor == null) settings.HighlightsColor = new Dictionary(); + foreach (var highlight in Utils.GetHighlights()) + { + if (!settings.HighlightsEnabled.ContainsKey(highlight)) settings.HighlightsEnabled[highlight] = true; + if (!settings.HighlightsColor.ContainsKey(highlight)) settings.HighlightsColor[highlight] = Settings.defaultColor; + } + settings.UpdateActiveHighlights(); + return settings; + } + public Settings ConvertToNewSettings() + { + var settings = new Settings + { + HighlightsEnabled = new Dictionary(), + HighlightsColor = new Dictionary(), + StoryNotification = storyNearbyNotification, + DisksNotification = jukeboxDiskNotification, + ExosuiteHighlightsEnabled = highlightEverythingExosuit, + DestroyNullPings = destoryNull, + ShowPings = showPings, + HighlightSearchDistance = highlightRadius, + MinimumAlpha = minAlpha, + }; + foreach (var highlight in enableHighlights) + if (TypeToHighlight.TryGetValue(highlight.Key, out Highlight val)) + settings.HighlightsEnabled[val] = highlight.Value; + foreach (var highlight in highlightingColors) + if (TypeToHighlight.TryGetValue(highlight.Key, out Highlight val)) + settings.HighlightsColor[val] = highlight.Value; + return settings; + } + } +} \ No newline at end of file diff --git a/Patches/Highlighting_Patch.cs b/Patches/Highlighting_Patch.cs new file mode 100644 index 0000000..79ea5ef --- /dev/null +++ b/Patches/Highlighting_Patch.cs @@ -0,0 +1,248 @@ +using HarmonyLib; +using HighlightingSystem; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using UWE; + +namespace AdvancedHighlighting.Patches +{ + public static class Highlighting_Patch + { + private static MethodInfo updateActiveHighlightersAsyncMethod; + private static readonly FieldInfo highlightersField = typeof(Highlighting).GetField("highlighters", BindingFlags.Instance | BindingFlags.NonPublic); + private static readonly FieldInfo handlersField = typeof(Highlighting).GetField("handlers", BindingFlags.Instance | BindingFlags.NonPublic); + private static readonly FieldInfo updateActiveHighligtersCoroutineField = typeof(Highlighting).GetField("updateActiveHighligtersCoroutine", BindingFlags.Instance | BindingFlags.NonPublic); + public static HashSet GetHighlighters(this Highlighting instance) => + (HashSet)highlightersField.GetValue(instance); + public static Dictionary GetHandlers(this Highlighting instance) => + (Dictionary)handlersField.GetValue(instance); + public static Coroutine GetUpdateActiveHighligtersCoroutine(this Highlighting instance) => + (Coroutine)updateActiveHighligtersCoroutineField.GetValue(instance); + public static void SetUpdateActiveHighligtersCoroutine(this Highlighting instance, Coroutine coroutine) => + updateActiveHighligtersCoroutineField.SetValue(instance, coroutine); + public static System.Collections.IEnumerator InvokeUpdateActiveHighlightersAsync(this Highlighting instance, Vector3 vector) + { + if (updateActiveHighlightersAsyncMethod == null) + updateActiveHighlightersAsyncMethod = typeof(Highlighting).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).Where(x => x.Name == "UpdateActiveHighlightersAsync").FirstOrDefault(); + return (System.Collections.IEnumerator)updateActiveHighlightersAsyncMethod.Invoke(instance, new object[] { vector }); + } + + } + [HarmonyPatch(typeof(Highlighting), "OnUpdate")] + public class Highlighting_OnUpdate_Patch + { + public static readonly Dictionary stories = new Dictionary(); + public static readonly Dictionary pings = new Dictionary(); + public static readonly List notifications = new List(); + private static int lastActiveTargetId = 0; + private static float hoverStart = 0f; + public static bool isLogged = false; + public static bool Prefix(Highlighting __instance) + { + Highlighting.Mode mode = Highlighting.GetMode(); + var settings = Settings.GetInstance(); + if (mode == Highlighting.Mode.None || settings.ActiveHighlights.Count == 0) + { + lastActiveTargetId = 0; + } + else + { + var time = Time.time; + Vector3 vector = MainCamera.camera?.transform.position ?? Vector3.zero; + GameObject gameObject = null; + if (mode == Highlighting.Mode.Exosuit) gameObject = (Player.main.GetVehicle() as Exosuit).GetActiveTarget(); + else if (mode == Highlighting.Mode.Player) gameObject = Player.main?.guiHand?.GetActiveTarget(); + int id = gameObject?.GetInstanceID() ?? 0; + if (lastActiveTargetId != id) + { + hoverStart = time; + lastActiveTargetId = id; + } + if (__instance.GetUpdateActiveHighligtersCoroutine() == null) + { + if (__instance.radiusOuter != settings.HighlightSearchDistance) + __instance.radiusOuter = settings.HighlightSearchDistance; + __instance.SetUpdateActiveHighligtersCoroutine(__instance.StartCoroutine(__instance.InvokeUpdateActiveHighlightersAsync(vector))); + } + + var highlighters = __instance.GetHighlighters(); + if (settings.StoryNotification || settings.DisksNotification || settings.ShowPings) + { + var removed = new List(); + foreach (var key in stories.Keys) + { + if (!highlighters.Any(x => x.GetInstanceID() == key)) + removed.Add(key); + } + foreach (var key in removed) + { + if (notifications.Contains(key)) + { + notifications.Remove(key); + ErrorMessage.AddMessage($"[Advanced Highlighting] {Language.main.Get(stories[key])} is no longer nearby"); + } + if (pings.ContainsKey(key)) + { + var ping = PingManager.Get(pings[key]); + if (ping != null) + UnityEngine.Object.Destroy(ping); + pings.Remove(key); + } + stories.Remove(key); + } + } + var radiusRange = settings.HighlightSearchDistance - __instance.radiusInner; + + if (!settings.PresetApplied && MainCamera.camera != null && MainCamera.camera.TryGetComponent(out HighlightingRenderer renderer)) + { + settings.PresetApplied = true; + if (settings.HighlightingRenderer >= 0 && settings.HighlightingRenderer < Utils.Presets.Count) + renderer.ApplyPreset(Utils.Presets[settings.HighlightingRenderer]); + //Console.WriteLine($"[AdvancedHighlighting] Active {settings.HighlightingRenderer},{Utils.Presets.Count} = [{renderer.name}, {renderer.blurDirections}, {renderer.blurIntensity}, {renderer.blurMinSpread}, {renderer.blurSpread}, {renderer.downsampleFactor}, {renderer.fillAlpha}, {renderer.iterations}]"); + } + foreach (Highlighter highlighter in highlighters) + { + if (highlighter != null) + { + var highlights = highlighter.gameObject.GetHighlightsForObject(out _, out _); + if (highlights.Count > 0) + { + Color highlightingColor = settings.GetHighlightColor(highlights.First()); + if (highlightingColor.a != 0f) + { + float magnitude = (highlighter.bounds.center - vector).magnitude; + float a = Mathf.Max(Mathf.Clamp01(1f - (magnitude - __instance.radiusInner) / radiusRange), settings.MinimumAlpha); + highlightingColor.a = a * a; + highlighter.ConstantOn(highlightingColor, 0f); + highlighter.filterMode = RendererFilterMode.None; + + if (magnitude <= settings.HighlightSearchDistance) + NotifiyAndPing(highlighter); + } + else + highlighter.ConstantOn(highlightingColor, 0f); + } + } + } + if (gameObject != null) + { + GameObject highlightableRoot = null; + Highlighting_GetHighlightableRoot_Patch.Prefix(__instance, ref highlightableRoot, mode, gameObject); + if (highlightableRoot != null) + { + Highlighter highlighter = highlightableRoot.GetComponent(); + if (highlighter != null) + { + Color highlightingColor = highlighter.constantColor; + float a2 = Mathf.Lerp(0.4f, 1f, Mathf.Cos((time - hoverStart) * 2f * Mathf.PI * __instance.hoverFlashingSpeed) * 0.5f + 0.5f); + highlightingColor.a = a2 * a2; + highlighter.Hover(highlightingColor); + } + } + } + } + return false; + } + private static void NotifiyAndPing(Highlighter highlighter) + { + var objId = highlighter.GetInstanceID(); + if (!stories.ContainsKey(objId)) + { + string name = null; + string type = null; + if (highlighter.TryGetComponent(out StoryHandTarget story)) + { + name = Language.main.Get(story.primaryTooltip); + type = "story"; + } + else if (highlighter.TryGetComponent(out JukeboxDisk disk)) + { + name = Language.main.Get(Jukebox.GetInfo(disk.track).label); + type = "disk"; + } + if (name != null) + { + var settings = Settings.GetInstance(); + stories[objId] = name; + if ((type == "story" && settings.StoryNotification) || + (type == "disk" && settings.DisksNotification)) + { + notifications.Add(objId); + ErrorMessage.AddMessage($"[Advanced Highlighting] {name} is nearby"); + } + if (settings.ShowPings) + { + PingInstance ping = highlighter.gameObject.EnsureComponent(); + ping.origin = highlighter.gameObject.transform; + ping.SetFakePosition(highlighter.bounds.center); + ping.SetVisible(true); + ping.SetLabel(name); + ping._id = $"ahping_{type}_{objId}"; + ping.pingType = PingType.Signal; + ping.displayPingInManager = false; + ping.visitable = false; + ping.minDist = 5f; + ping.range = 5f; + ping.enabled = true; + pings[objId] = ping._id; + } + } + } + } + } + + [HarmonyPatch(typeof(Highlighting), "GetHighlightableRoot", new Type[] { typeof(Highlighting.Mode), typeof(GameObject) })] + public static class Highlighting_GetHighlightableRoot_Patch + { + public static bool Prefix(Highlighting __instance, ref GameObject __result, Highlighting.Mode mode, GameObject target) + { + __result = null; + if (mode == Highlighting.Mode.None) + return false; + var settings = Settings.GetInstance(); + if (mode == Highlighting.Mode.Exosuit && !settings.ExosuiteHighlightsEnabled) + { + Exosuit exosuit = Player.main.GetVehicle() as Exosuit; + if (exosuit != null) + __result = exosuit.GetInteractableRoot(target); + return false; + } + else + { + var highlights = target.GetHighlightsForObject(out GameObject result, out Behaviour behaviour); + if (highlights.Count == 0) + return false; + if (highlights.Contains(Highlight.ScannableFragments) || + highlights.Contains(Highlight.ScannedFragments) || + highlights.Contains(Highlight.ScannableItems)) + { + __result = result; + return false; + } + + if (behaviour == null || !behaviour.enabled || behaviour.GetComponentInParent() != null || + behaviour.GetComponentInParent() != null) + { + return false; + } + + var handlers = __instance.GetHandlers(); + if (handlers != null && handlers.TryGetValue(behaviour.GetType(), out Highlighting.Handler handler)) + { + handler(ref behaviour); + if (behaviour == null) + return false; + } + __result = behaviour.gameObject; + } + return false; + } + } + +} \ No newline at end of file diff --git a/Patches/PingInstance_Patch.cs b/Patches/PingInstance_Patch.cs new file mode 100644 index 0000000..c5d0bcf --- /dev/null +++ b/Patches/PingInstance_Patch.cs @@ -0,0 +1,32 @@ +using HarmonyLib; +using System; +using System.Reflection; +using UnityEngine; + +namespace AdvancedHighlighting.Patches +{ + public static class PingInstance_Patch + { + private static readonly FieldInfo fakePositionUsedField = typeof(PingInstance).GetField("fakePositionUsed", BindingFlags.Instance | BindingFlags.NonPublic); + public static bool GetFakePositionUsed(PingInstance instance) => + (bool)fakePositionUsedField.GetValue(instance); + } + [HarmonyPatch(typeof(PingInstance), "GetPosition")] + public static class PingInstance_GetPosition_Patch + { + public static bool Prefix(PingInstance __instance, ref Vector3 __result) + { + if (__instance == null || (__instance.origin == null && !PingInstance_Patch.GetFakePositionUsed(__instance))) + { + if (__instance != null && Settings.GetInstance().DestroyNullPings) + { + UnityEngine.Object.Destroy(__instance); + Console.WriteLine($"[AdvancedHighlighting] Destroying {__instance._id}..."); + } + __result = Vector3.zero; + return false; + } + return true; + } + } +} \ No newline at end of file diff --git a/Patches/SaveLoadManager_Patch.cs b/Patches/SaveLoadManager_Patch.cs new file mode 100644 index 0000000..b2cad82 --- /dev/null +++ b/Patches/SaveLoadManager_Patch.cs @@ -0,0 +1,34 @@ +using HarmonyLib; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdvancedHighlighting.Patches +{ + [HarmonyPatch(typeof(SaveLoadManager), "NotifySaveInProgress", new Type[] { typeof(bool) })] + public static class SaveLoadManager_NotifySaveInProgress_Patch + { + public static void Postfix(SaveLoadManager __instance, bool isInProgress) + { + if (!Settings.GetInstance().ShowPings) + return; + if (isInProgress) + { + foreach (var pingKey in Highlighting_OnUpdate_Patch.pings.Keys) + { + var ping = PingManager.Get(Highlighting_OnUpdate_Patch.pings[pingKey]); + if (ping != null) + UnityEngine.Object.Destroy(ping); + } + Highlighting_OnUpdate_Patch.pings.Clear(); + } + else + { + Highlighting_OnUpdate_Patch.stories.Clear(); + } + } + } +} \ No newline at end of file diff --git a/Patches/uGUI_OptionsPanel_Patch.cs b/Patches/uGUI_OptionsPanel_Patch.cs new file mode 100644 index 0000000..093f2d5 --- /dev/null +++ b/Patches/uGUI_OptionsPanel_Patch.cs @@ -0,0 +1,130 @@ +using HarmonyLib; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.UI; +#if SN +#elif BZ +#endif + +namespace AdvancedHighlighting.Patches +{ + [HarmonyPatch(typeof(uGUI_OptionsPanel), "OnDisable")] + public class uGUI_OptionsPanel_OnDisable_Patch + { + public static void Prefix() + { + Settings.GetInstance().Save(); + } + } + + [HarmonyPatch(typeof(uGUI_OptionsPanel), "AddAccessibilityTab")] + public class uGUI_OptionsPanel_AddAccessibilityTab_Patch + { + private static readonly Dictionary toggleOptions = new Dictionary(); + private static readonly Dictionary colorOptions = new Dictionary(); + private static readonly List options = new List(); + + private static void UpdatePingColors() + { + foreach (var pingKey in Highlighting_OnUpdate_Patch.pings.Keys) + { + var ping = PingManager.Get(Highlighting_OnUpdate_Patch.pings[pingKey]); + if (ping != null) + ping.SetColor(1); + } + } + public static bool Prefix(uGUI_OptionsPanel __instance) + { + var settings = Settings.GetInstance(); + int tabIndex = __instance.AddTab("Accessibility"); + options.Clear(); + toggleOptions.Clear(); + colorOptions.Clear(); + __instance.AddSliderOption(tabIndex, "UIScale", MiscSettings.GetUIScale(DisplayOperationMode.Current), 0.7f, 1.4f, 1f, 0.01f, (value) => + { + MiscSettings.SetUIScale(value, DisplayOperationMode.Current); + }, SliderLabelMode.Float, "0.00"); + __instance.AddToggleOption(tabIndex, "PDAPause", MiscSettings.pdaPause, new UnityAction((val) => MiscSettings.pdaPause = val), null); + __instance.AddToggleOption(tabIndex, "Flashes", MiscSettings.flashes, new UnityAction((val) => MiscSettings.flashes = val), null); + //highlightingColorOption = __instance.AddColorOption(tabIndex, "HighlightingColor", MiscSettings.highlightingColor, new UnityAction((val) => MiscSettings.highlightingColor = val )); + + __instance.AddHeading(tabIndex, "Advanced Highlighting"); + __instance.AddToggleOption(tabIndex, "Enable Highlighting", MiscSettings.highlighting, new UnityAction(OnHighlightingChanged), null); + + options.Add(__instance.AddChoiceOption(tabIndex, "Highlighting Renderer", Utils.Presets.Select(x => x.name).ToArray(), settings.HighlightingRenderer, new UnityAction((val) => + { + settings.HighlightingRenderer = val; + settings.PresetApplied = false; + }), null).gameObject); + //__instance.AddToggleOption(tabIndex, "Destrey Nulls", settings.destoryNull, new UnityAction((val) => settings.destoryNull = val), null); + options.Add(__instance.AddToggleOption(tabIndex, "Notify about nearby PDA Logs", settings.StoryNotification, new UnityAction((val) => settings.StoryNotification = val), null).gameObject); + options.Add(__instance.AddToggleOption(tabIndex, "Notify about nearby Jukebox Disks", settings.DisksNotification, new UnityAction((val) => settings.DisksNotification = val), null).gameObject); + options.Add(__instance.AddToggleOption(tabIndex, "Show pings for PDA Logs and Disks", settings.ShowPings, new UnityAction((val) => + { + settings.ShowPings = val; + TogglePings(); + }), null).gameObject); + + options.Add(__instance.AddToggleOption(tabIndex, "Highlight while in Exosuit", settings.ExosuiteHighlightsEnabled, new UnityAction((val) => settings.ExosuiteHighlightsEnabled = val), null).gameObject); + options.Add(__instance.AddSliderOption(tabIndex, "Highlight search radius", settings.HighlightSearchDistance, 10f, 100f, 20f, 0.5f, (value) => + { + settings.HighlightSearchDistance = value; + }, SliderLabelMode.Float, "0.0")); + options.Add(__instance.AddSliderOption(tabIndex, "Minimum allowed fade value", settings.MinimumAlpha, 0f, 1f, 0f, 0.1f, (value) => + { + settings.MinimumAlpha = value; + }, SliderLabelMode.Float, "0.0")); + foreach (var highlight in Utils.GetHighlights()) + { + toggleOptions[highlight] = __instance.AddToggleOption(tabIndex, $"Highlight {highlight.GetName()}", settings.IsHighlightEnabled(highlight), new UnityAction((val) => + { + settings.HighlightsEnabled[highlight] = val; + if (colorOptions.TryGetValue(highlight, out GameObject color)) + color.SetActive(val); + settings.UpdateActiveHighlights(); + }), null); + colorOptions[highlight] = __instance.AddColorOption(tabIndex, $"{highlight.GetName()} color", settings.GetHighlightColor(highlight), new UnityAction((val) => + { + settings.HighlightsColor[highlight] = ColorUtility.ToHtmlStringRGBA(val); + if ((highlight == Highlight.StoryItems || highlight == Highlight.JukeboxDisk) && settings.ShowPings) + UpdatePingColors(); + })); + } + OnHighlightingChanged(MiscSettings.highlighting); + return false; + } + private static void TogglePings() + { + if (!MiscSettings.highlighting || !Settings.GetInstance().ShowPings) + { + foreach (var pingKey in Highlighting_OnUpdate_Patch.pings.Keys) + { + var ping = PingManager.Get(Highlighting_OnUpdate_Patch.pings[pingKey]); + if (ping != null) + UnityEngine.Object.Destroy(ping); + } + Highlighting_OnUpdate_Patch.pings.Clear(); + } + else + { + Highlighting_OnUpdate_Patch.stories.Clear(); + } + } + private static void OnHighlightingChanged(bool value) + { + MiscSettings.highlighting = value; + TogglePings(); + foreach (var gameObject in options) + if (gameObject != null) + gameObject.SetActive(value); + foreach (var highlight in Utils.GetHighlights()) + { + toggleOptions[highlight].gameObject.SetActive(value); + colorOptions[highlight].SetActive(value && toggleOptions[highlight].isOn); + } + Settings.GetInstance().UpdateActiveHighlights(); + } + } +} \ No newline at end of file diff --git a/Patches/uGUI_Pings_Patch.cs b/Patches/uGUI_Pings_Patch.cs new file mode 100644 index 0000000..8821450 --- /dev/null +++ b/Patches/uGUI_Pings_Patch.cs @@ -0,0 +1,51 @@ +using HarmonyLib; +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using UnityEngine; + +namespace AdvancedHighlighting.Patches +{ + public static class uGUI_Pings_Patch + { + private static readonly FieldInfo pingsField = typeof(uGUI_Pings).GetField("pings", BindingFlags.Instance | BindingFlags.NonPublic); + public static Dictionary GetPings(uGUI_Pings instance) => + (Dictionary)pingsField.GetValue(instance); + } + + [HarmonyPatch(typeof(uGUI_Pings), "OnAdd", new Type[] { typeof(PingInstance) })] + public static class uGUI_Pings_OnAdd_Patch + { + public static void Postfix(uGUI_Pings __instance, PingInstance instance) + { + var id = instance._id; + if (!id.StartsWith("ahping_")) return; + var pings = uGUI_Pings_Patch.GetPings(__instance); + if (pings != null && pings.TryGetValue(id, out uGUI_Ping ping)) + { + //Console.WriteLine($"[AdvancedHighlighting] OnAdd Ping {id} {Utils.GetEyeSprite(out _)}..."); + if (Utils.GetColorForType(id.Split('_')[1], out Color newColor)) + ping.SetColor(newColor); + if (Utils.GetEyeSprite(out Sprite sprite)) + ping.SetIcon(sprite); + } + } + } + + [HarmonyPatch(typeof(uGUI_Pings), "OnColor", new Type[] { typeof(string), typeof(Color) })] + public static class uGUI_Pings_OnColor_Patch + { + public static void Postfix(uGUI_Pings __instance, string id, Color color) + { + if (id.StartsWith("ahping_")) + { + //Console.WriteLine($"[AdvancedHighlighting] OnColor Ping {id}, {pings?.Count}..."); + var pings = uGUI_Pings_Patch.GetPings(__instance); + if (pings != null && pings.TryGetValue(id, out uGUI_Ping ping)) + if (Utils.GetColorForType(id.Split('_')[1], out Color newColor)) + ping.SetColor(newColor); + } + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e3cb5c0 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AdvancedHighlighting")] +[assembly: AssemblyDescription("A mod for Subnautica Below Zero")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("OGMods")] +[assembly: AssemblyProduct("AdvancedHighlighting")] +[assembly: AssemblyCopyright("Copyright OGMods © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("adb59190-bc97-4509-ab62-c64a4d9a93ec")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..e24305e --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AdvancedHighlighting.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AdvancedHighlighting.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to A mod to change the highlighting colors of objects in the game.. + /// + internal static string desc { + get { + return ResourceManager.GetString("desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to AdvancedHighlighting. + /// + internal static string title { + get { + return ResourceManager.GetString("title", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 1.0.0. + /// + internal static string ver { + get { + return ResourceManager.GetString("ver", resourceCulture); + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..9d5fd00 --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + A mod to change the highlighting colors of objects in the game. + + + AdvancedHighlighting + + + 1.0.0 + + \ No newline at end of file diff --git a/Qmod.cs.test b/Qmod.cs.test new file mode 100644 index 0000000..a41a959 --- /dev/null +++ b/Qmod.cs.test @@ -0,0 +1,55 @@ +using SMLHelper.V2.Json; +using SMLHelper.V2.Options.Attributes; +using UnityEngine; + +namespace AdvancedHighlighting +{ + [Menu("Advanced Highlighting", SaveOn = MenuAttribute.SaveEvents.ChangeValue)] + public class IngameConfigMenu : ConfigFile + { + public IngameConfigMenu() : base("config") { } + + [Toggle("Pickupable Items", Tooltip = "Highlight Pickupable Items.", Order = 1)] + public bool Pickupable = true; + + [Choice("Pickupable Color", Tooltip = "Select a color for Pickupable Items.", Options = new string[] {"Red", "16dcff"})] + public string PickupableColor = "fffb16"; + + [Toggle("Pickupable Creatures", Tooltip = "Highlight Pickupable Creatures.", Order = 2)] + public bool PickupableCreatures = true; + + [Toggle("Pickupable Resources", Tooltip = "Highlight Pickupable Resource.", Order = 3)] + public bool PickupableResource = true; + + [Toggle("Breakable Resources", Tooltip = "Highlight Breakable Resource.", Order = 4)] + public bool BreakableResource = true; + + [Toggle("Interactable Items", Tooltip = "Highlight Interactable Items.", Order = 5)] + public bool Interactables = true; + + [Toggle("Story Items", Tooltip = "Highlight Story Items.", Order = 6)] + public bool StoryItems = true; + + [Toggle("Jukebox Disks", Tooltip = "Highlight Jukebox Disks.", Order = 7)] + public bool JukeboxDisk = true; + + [Toggle("Sealed Doors", Tooltip = "Highlight Sealed Doors.", Order = 8)] + public bool SealedDoor = true; + + [Toggle("Grown Plants", Tooltip = "Highlight Grown Plants.", Order = 9)] + public bool GrownPlant = true; + + [Toggle("Bladder Fish", Tooltip = "Highlight Bladder Fish.", Order = 10)] + public bool Bladderfish = true; + + [Toggle("Creature Eggs", Tooltip = "Highlight Creature Eggs.", Order = 11)] + public bool CreatureEgg = true; + + [Toggle("Base Ladders", Tooltip = "Highlight Base Ladders.", Order = 12)] + public bool BaseLadder = true; + + [Toggle("Laser CutObjects", Tooltip = "Highlight Sealed Doors.", Order = 13)] + public bool LaserCutObject = true; + + } +} \ No newline at end of file diff --git a/Settings.cs b/Settings.cs new file mode 100644 index 0000000..def3f1e --- /dev/null +++ b/Settings.cs @@ -0,0 +1,68 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using UnityEngine; +#if SN +#elif BZ +#endif + +namespace AdvancedHighlighting +{ + public class Settings + { + public static readonly string defaultColor = "e0e238"; + public static readonly Color nullColor = new Color(0f, 0f, 0f, 0f); + [JsonIgnore] + public bool PresetApplied = false; + + public bool StoryNotification = false; + public bool DisksNotification = false; + public bool ShowPings = false; + public bool ExosuiteHighlightsEnabled = false; + public bool DestroyNullPings = true; + public float HighlightSearchDistance = 20f; + public float MinimumAlpha = 0f; + public int HighlightingRenderer = 1; + + public Dictionary HighlightsEnabled; + public Dictionary HighlightsColor; + + [JsonIgnore] + public List ActiveHighlights = new List(); + + [JsonIgnore] + private static Settings instance; + public static Settings GetInstance() + { + if (instance == null) + instance = OldSettings.Load(); + return instance; + } + public void Save() + { + Console.WriteLine("[AdvancedHighlighting] Saving Settings"); + File.WriteAllText(Path.Combine(Utils.ModDirectory, "settings.json"), JsonConvert.SerializeObject(this, Formatting.Indented)); + } + public void UpdateActiveHighlights() + { + ActiveHighlights.Clear(); + if (MiscSettings.highlighting) + { + foreach (var highlight in HighlightsEnabled) + if (highlight.Value) + ActiveHighlights.Add(highlight.Key); + //Console.WriteLine($"[AdvancedHighlighting] UpdateActiveHighlights {string.Join(",", ActiveHighlights)}..."); + } + } + + public bool IsHighlightActive(Highlight highlight) => + ActiveHighlights.Contains(highlight); + public bool IsHighlightEnabled(Highlight highlight) => + (HighlightsEnabled.TryGetValue(highlight, out bool e) ? e : MiscSettings.highlighting); + public Color GetHighlightColor(Highlight highlight) => + (HighlightsColor.TryGetValue(highlight, out string h) && ColorUtility.TryParseHtmlString("#" + h, out Color c) ? c : nullColor); + public string GetHtmlColor(Highlight highlight) => + (HighlightsColor.TryGetValue(highlight, out string h) ? h : null); + } +} \ No newline at end of file diff --git a/Utils.cs b/Utils.cs new file mode 100644 index 0000000..0d17216 --- /dev/null +++ b/Utils.cs @@ -0,0 +1,169 @@ +using HighlightingSystem; +using System; +using System.Collections.Generic; +using System.IO; +using UnityEngine; +using static PDAScanner; +#if SN +#elif BZ +#endif + +namespace AdvancedHighlighting +{ + public static class Utils + { + public static readonly Type FragmentsType = typeof(TechFragment); + public static readonly Type ScannableType = typeof(ScannerTarget); + public static readonly Type EverythingType = typeof(Utils); + public static readonly List Presets = new List + { + new HighlightingPreset { name = "Narrow", fillAlpha = 0f, downsampleFactor = 4, iterations = 2, blurMinSpread = 0.65f, blurSpread = 0.25f, blurIntensity = 0.3f, blurDirections = BlurDirections.Diagonal}, + new HighlightingPreset { name = "Wide (Game Default)", fillAlpha = 0f, downsampleFactor = 4, iterations = 4, blurMinSpread = 0.65f, blurSpread = 0.25f, blurIntensity = 0.3f, blurDirections = BlurDirections.Diagonal }, + new HighlightingPreset { name = "Strong", fillAlpha = 0f, downsampleFactor = 4, iterations = 2, blurMinSpread = 0.5f, blurSpread = 0.15f, blurIntensity = 0.325f, blurDirections = BlurDirections.Diagonal }, + new HighlightingPreset { name = "Speed", fillAlpha = 0f, downsampleFactor = 4, iterations = 1, blurMinSpread = 0.75f, blurSpread = 0f, blurIntensity = 0.35f, blurDirections = BlurDirections.Diagonal }, + new HighlightingPreset { name = "Quality", fillAlpha = 0f, downsampleFactor = 2, iterations = 3, blurMinSpread = 0.5f, blurSpread = 0.5f, blurIntensity = 0.28f, blurDirections = BlurDirections.Diagonal }, + new HighlightingPreset { name = "Solid 1px", fillAlpha = 0f, downsampleFactor = 1, iterations = 1, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, + new HighlightingPreset { name = "Solid 2px", fillAlpha = 0f, downsampleFactor = 1, iterations = 2, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, + new HighlightingPreset { name = "Solid 3px", fillAlpha = 0f, downsampleFactor = 1, iterations = 3, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, + new HighlightingPreset { name = "Solid 4px", fillAlpha = 0f, downsampleFactor = 1, iterations = 4, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, + new HighlightingPreset { name = "Solid 5px", fillAlpha = 0f, downsampleFactor = 1, iterations = 5, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All } + }; + public static Highlight[] GetHighlights() => (Highlight[])Enum.GetValues(typeof(Highlight)); + private static Sprite eyeSprite; + public static bool GetEyeSprite(out Sprite sprite) + { + if (eyeSprite == null && File.Exists(Path.Combine(ModDirectory, "Assets", "Eye.png"))) + eyeSprite = ImageUtils.LoadSprite(Path.Combine(ModDirectory, "Assets", "Eye.png"), new Vector2(0.5f, 0.5f), TextureFormat.BC7, 100f, SpriteMeshType.Tight); + sprite = eyeSprite; + return (sprite != null); + } + public static bool GetColorForType(string type, out Color newColor) + { + if (type == "story") + { + newColor = Settings.GetInstance().GetHighlightColor(Highlight.StoryItems); + return true; + } + else if (type == "disk") + { + newColor = Settings.GetInstance().GetHighlightColor(Highlight.JukeboxDisk); + return true; + } + newColor = Settings.nullColor; + return false; + } + public static List GetHighlightsForObject(this GameObject gameObject, out GameObject targetObject, out Behaviour behaviour) + { + var supported = new List(); + targetObject = null; + behaviour = null; + if (gameObject == null) + return supported; + if (Targeting.GetRoot(gameObject, out TechType techType, out GameObject result)) + { + var scannableFragments = Settings.GetInstance().IsHighlightActive(Highlight.ScannableFragments); + targetObject = result; + if (PDAScanner.IsFragment(techType)) + { + if (!PDAScanner.ContainsCompleteEntry(techType)) + { + if (scannableFragments) supported.Add(Highlight.ScannableFragments); + } + else if (techType.GetEntryData(out EntryData data)) + { + if (data.destroyAfterScan && Highlight.ScannedFragments.IsActive()) supported.Add(Highlight.ScannedFragments); + } + } + else if (result != null) + { + if (techType.GetEntryData(out EntryData data) && PDAScanner.CanScan(result)) + { + if (data.blueprint > 0 && scannableFragments) + supported.Add(Highlight.ScannableFragments); + else if (data.blueprint == 0 && Highlight.ScannableItems.IsActive()) + supported.Add(Highlight.ScannableItems); + } + } + } + behaviour = gameObject.GetComponentInParent() as Behaviour; + if (behaviour != null) + { + if (Highlight.BreakableResource.IsPressent(behaviour)) + { + if (Highlight.BreakableResource.IsActive()) supported.Add(Highlight.BreakableResource); + } + else if (Highlight.PickupableResource.IsPressent(behaviour)) + { + if (Highlight.CreatureEgg.IsPressent(behaviour)) + { + if (Highlight.CreatureEgg.IsActive()) supported.Add(Highlight.CreatureEgg); + } + else + { + if (Highlight.PickupableResource.IsActive()) supported.Add(Highlight.PickupableResource); + } + } + else if (Highlight.PickupableCreatures.IsPressent(behaviour)) + { + if (Highlight.Bladderfish.IsPressent(behaviour)) + { + if (Highlight.Bladderfish.IsActive()) supported.Add(Highlight.Bladderfish); + } + else + { + if (Highlight.PickupableCreatures.IsActive()) supported.Add(Highlight.PickupableCreatures); + } + } + else if (Highlight.Pickupable.IsPressent(behaviour)) + { + if (Highlight.Pickupable.IsActive()) supported.Add(Highlight.Pickupable); + } + else if (Highlight.Interactables.IsPressent(behaviour)) + { + if(Highlight.BaseLadder.IsPressent(behaviour)) + { + if (Highlight.BaseLadder.IsActive()) supported.Add(Highlight.BaseLadder); + } + else if (Highlight.GrownPlant.IsPressent(behaviour)) + { + if (Highlight.GrownPlant.IsActive()) supported.Add(Highlight.GrownPlant); + } + else if (Highlight.SealedDoor.IsPressent(behaviour)) + { + if (Highlight.SealedDoor.IsActive()) supported.Add(Highlight.SealedDoor); + } + else if (Highlight.LaserCutObject.IsPressent(behaviour)) + { + if (Highlight.LaserCutObject.IsActive()) supported.Add(Highlight.LaserCutObject); + } + else + { + if (Highlight.Interactables.IsActive()) supported.Add(Highlight.Interactables); + } + } + + if (Highlight.StoryItems.IsPressentAndActive(behaviour)) supported.Add(Highlight.StoryItems); + if (Highlight.JukeboxDisk.IsPressentAndActive(behaviour)) supported.Add(Highlight.JukeboxDisk); + if (supported.Count == 0 && Highlight.AnythingElse.IsActive()) supported.Add(Highlight.AnythingElse); + } + //if (!logged.Contains(gameObject.GetInstanceID())) + //{ + // var types1 = gameObject.GetComponents().Select(x => x.GetType()); + // var types2 = behaviour?.gameObject?.GetComponents().Select(x => x.GetType()); + // Console.WriteLine($"[AdvancedHighlighting] GetSupportedComponentsTypes ([{gameObject.GetInstanceID()}] {gameObject.name},[{behaviour?.gameObject?.GetInstanceID()}] {behaviour?.gameObject?.name}), Supported = ({string.Join(", ", supported)}), Types1 = ({string.Join(", ", types1)}), Types2 = ({(types2 != null ? string.Join(", ", types2) : "")})"); + // logged.Add(gameObject.GetInstanceID()); + //} + return supported; + } + //private static readonly List logged = new List(); + public static string ModDirectory + { + get => Environment.CurrentDirectory + "\\QMods\\AdvancedHighlighting\\"; + } + public static bool GetEntryData(this TechType tech, out EntryData data) + { + data = PDAScanner.GetEntryData(tech); + return data != null; + } + } +} \ No newline at end of file From 9f9dbd4dcf54fc7fe8db40e1df1ee765cd8287a7 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:36:47 +0700 Subject: [PATCH 02/26] Update HighlightEnum.cs Added new highlighting. GrownPlant CreatureEgg BaseLadder LaserCutObject Fixed not highlighting SealedDoor (previously StarshipDoor) BladderFish (previously OxygenFish) --- AdvancedHighlighting/HighlightEnum.cs | 144 ++++++++++++++------------ 1 file changed, 78 insertions(+), 66 deletions(-) diff --git a/AdvancedHighlighting/HighlightEnum.cs b/AdvancedHighlighting/HighlightEnum.cs index d9c0254..73f1a72 100644 --- a/AdvancedHighlighting/HighlightEnum.cs +++ b/AdvancedHighlighting/HighlightEnum.cs @@ -1,73 +1,85 @@ -using System; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +#if SN +#elif BZ +#endif namespace AdvancedHighlighting { - public enum Highlight + public enum Highlight + { + ScannableItems, + ScannableFragments, + ScannedFragments, + AnythingElse, + + Pickupable, + PickupableCreatures, + PickupableResource, + BreakableResource, + Interactables, + StoryItems, + JukeboxDisk, + SealedDoor, + GrownPlant, + Bladderfish, + CreatureEgg, + BaseLadder, + LaserCutObject + } + public static class HighlightExtenstions + { + private static readonly Dictionary highlightToText = new Dictionary() + { + [Highlight.ScannableItems] = "Scannable Items", + [Highlight.ScannableFragments] = "Scannable Fragments", + [Highlight.ScannedFragments] = "Already Scanned Fragments", + [Highlight.AnythingElse] = "Anything Else", + + [Highlight.Pickupable] = "Pickupable Items", + [Highlight.PickupableCreatures] = "Pickupable Creatures", + [Highlight.PickupableResource] = "Pickupable Resources", + [Highlight.BreakableResource] = "Breakable Outcrops", + [Highlight.Interactables] = "Interactables", + [Highlight.StoryItems] = "PDA Logs", + [Highlight.JukeboxDisk] = "Jukebox Disks", + [Highlight.SealedDoor] = "Sealed Ship Doors", + [Highlight.GrownPlant] = "Grown Plant", + [Highlight.Bladderfish] = "Bladder Fish", + [Highlight.CreatureEgg] = "Creature Egg", + [Highlight.BaseLadder] = "Base Ladder", + [Highlight.LaserCutObject] = "Laser Cut Object", + }; + private static readonly Dictionary highlightToType = new Dictionary() { - Pickupable, - PickupableCreatures, - PickupableResource, - BreakableResource, - ScannableItems, - ScannableFragments, - ScannedFragments, - Interactables, - StoryItems, - DiskItems, - SealedDoor, - FruitAndVeg, - OxygenFish, - AnythingElse - } - public static class HighlightExtenstions + [Highlight.Pickupable] = typeof(Pickupable), + [Highlight.PickupableCreatures] = typeof(Creature), + [Highlight.PickupableResource] = typeof(ResourceTracker), + [Highlight.BreakableResource] = typeof(BreakableResource), + [Highlight.Interactables] = typeof(HandTarget), + [Highlight.StoryItems] = typeof(StoryHandTarget), + [Highlight.JukeboxDisk] = typeof(JukeboxDisk), + [Highlight.SealedDoor] = typeof(StarshipDoor), + [Highlight.GrownPlant] = typeof(GrownPlant), + [Highlight.Bladderfish] = typeof(Bladderfish), + [Highlight.CreatureEgg] = typeof(CreatureEgg), + [Highlight.BaseLadder] = typeof(BaseLadder), + [Highlight.LaserCutObject] = typeof(Sealed), + }; + private static readonly List notComponentHighlights = new List() { - private static readonly Dictionary highlightToText = new Dictionary() - { - [Highlight.Pickupable] = "Pickupable Items", - [Highlight.PickupableCreatures] = "Pickupable Creatures", - [Highlight.PickupableResource] = "Pickupable Resources", - [Highlight.BreakableResource] = "Breakable Outcrops", - [Highlight.ScannableItems] = "Scannable Items", - [Highlight.ScannableFragments] = "Scannable Fragments", - [Highlight.ScannedFragments] = "Already Scanned Fragments", - [Highlight.Interactables] = "Interactables", - [Highlight.StoryItems] = "PDA Logs", - [Highlight.DiskItems] = "Jukebox Disks", - [Highlight.SealedDoor] = "Sealed Ship Doors", - [Highlight.FruitAndVeg] = "Fruits and Vegetables", - [Highlight.OxygenFish] = "Oxygen Fish", - [Highlight.AnythingElse] = "Anything Else", - }; - private static readonly Dictionary highlightToType = new Dictionary() { - [Highlight.Pickupable] = typeof(Pickupable), - [Highlight.PickupableCreatures] = typeof(Creature), - [Highlight.PickupableResource] = typeof(ResourceTracker), - [Highlight.BreakableResource] = typeof(BreakableResource), - [Highlight.Interactables] = typeof(GenericHandTarget), - [Highlight.StoryItems] = typeof(StoryHandTarget), - [Highlight.DiskItems] = typeof(JukeboxDisk), - [Highlight.SealedDoor] = typeof(StarshipDoor), - [Highlight.FruitAndVeg] = typeof(PickPrefab), - [Highlight.OxygenFish] = typeof(TitanHolefishOxygen), - }; - private static readonly List notComponentHighlights = new List() - { - Highlight.ScannableItems, - Highlight.ScannableFragments, - Highlight.ScannedFragments, - Highlight.AnythingElse - }; - public static bool IsPressent(this Highlight highlight, UnityEngine.Behaviour behaviour) => - highlight.IsComponent() && behaviour.TryGetComponent(highlight.GetComponentType(), out _); - public static bool IsPressentAndActive(this Highlight highlight, UnityEngine.Behaviour behaviour) => - highlight.IsComponent() && highlight.IsActive() && behaviour.TryGetComponent(highlight.GetComponentType(), out _); - public static bool IsActive(this Highlight highlight) => Settings.GetInstance().IsHighlightActive(highlight); - public static bool IsComponent(this Highlight highlight) => !notComponentHighlights.Contains(highlight); - public static string GetName(this Highlight highlight) => highlightToText.TryGetValue(highlight, out string name) ? name : null; - public static Type GetComponentType(this Highlight highlight) => highlightToType.TryGetValue(highlight, out Type type) ? type : null; - } + Highlight.ScannableItems, + Highlight.ScannableFragments, + Highlight.ScannedFragments, + Highlight.AnythingElse + }; + public static bool IsPressent(this Highlight highlight, UnityEngine.Behaviour behaviour) => + highlight.IsComponent() && behaviour.TryGetComponent(highlight.GetComponentType(), out _); + public static bool IsPressentAndActive(this Highlight highlight, UnityEngine.Behaviour behaviour) => + highlight.IsComponent() && highlight.IsActive() && behaviour.TryGetComponent(highlight.GetComponentType(), out _); + public static bool IsActive(this Highlight highlight) => Settings.GetInstance().IsHighlightActive(highlight); + public static bool IsComponent(this Highlight highlight) => !notComponentHighlights.Contains(highlight); + public static string GetName(this Highlight highlight) => highlightToText.TryGetValue(highlight, out string name) ? name : null; + public static Type GetComponentType(this Highlight highlight) => highlightToType.TryGetValue(highlight, out Type type) ? type : null; + } } From b655d6c0faf597f6e59f0a6c9c1a0c84df04b946 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:37:57 +0700 Subject: [PATCH 03/26] Update OldSettings.cs --- AdvancedHighlighting/OldSettings.cs | 159 ++++++++++++++-------------- 1 file changed, 81 insertions(+), 78 deletions(-) diff --git a/AdvancedHighlighting/OldSettings.cs b/AdvancedHighlighting/OldSettings.cs index 22d7a21..d4c4c90 100644 --- a/AdvancedHighlighting/OldSettings.cs +++ b/AdvancedHighlighting/OldSettings.cs @@ -1,90 +1,93 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +#if SN +#elif BZ +#endif namespace AdvancedHighlighting { - public class OldSettings + public class OldSettings + { + private static readonly Dictionary TypeToHighlight = new Dictionary { - private static readonly Dictionary TypeToHighlight = new Dictionary - { - [typeof(Pickupable)] = Highlight.Pickupable, - [typeof(ResourceTracker)] = Highlight.PickupableResource, - [typeof(Creature)] = Highlight.PickupableCreatures, - [typeof(TitanHolefishOxygen)] = Highlight.OxygenFish, - [typeof(BreakableResource)] = Highlight.BreakableResource, - [typeof(PickPrefab)] = Highlight.FruitAndVeg, - [typeof(GenericHandTarget)] = Highlight.Interactables, - [typeof(StoryHandTarget)] = Highlight.StoryItems, - [typeof(JukeboxDisk)] = Highlight.DiskItems, - [typeof(StarshipDoor)] = Highlight.SealedDoor, - [Utils.FragmentsType] = Highlight.ScannableFragments, - [Utils.ScannableType] = Highlight.ScannableItems, - [Utils.EverythingType] = Highlight.AnythingElse, - }; + [typeof(Pickupable)] = Highlight.Pickupable, + [typeof(ResourceTracker)] = Highlight.PickupableResource, + [typeof(Creature)] = Highlight.PickupableCreatures, + [typeof(Bladderfish)] = Highlight.Bladderfish, + [typeof(CreatureEgg)] = Highlight.CreatureEgg, + [typeof(BaseLadder)] = Highlight.BaseLadder, + [typeof(BreakableResource)] = Highlight.BreakableResource, + [typeof(HandTarget)] = Highlight.Interactables, + [typeof(GrownPlant)] = Highlight.GrownPlant, + [typeof(StoryHandTarget)] = Highlight.StoryItems, + [typeof(JukeboxDisk)] = Highlight.JukeboxDisk, + [typeof(StarshipDoor)] = Highlight.SealedDoor, + [typeof(Sealed)] = Highlight.LaserCutObject, + [Utils.FragmentsType] = Highlight.ScannableFragments, + [Utils.ScannableType] = Highlight.ScannableItems, + [Utils.EverythingType] = Highlight.AnythingElse, + }; - public Dictionary enableHighlights; - public Dictionary highlightingColors; - public bool storyNearbyNotification = false; - public bool jukeboxDiskNotification = false; - public bool highlightEverythingExosuit = false; - public bool destoryNull = true; - public bool showPings = false; - public float highlightRadius = 20f; - public float minAlpha = 0f; - public static Settings Load() - { - Console.WriteLine("[AdvancedHighlighting] Loading Settings"); - string path = Path.Combine(Utils.ModDirectory, "settings.json"); - Settings settings = null; - if (File.Exists(path)) - { - try - { - var text = File.ReadAllText(path); - if (text.Contains("PublicKeyToken") || text.Contains("storyNearbyNotification")) - settings = JsonConvert.DeserializeObject(text).ConvertToNewSettings(); - else - settings = JsonConvert.DeserializeObject(text); - } - catch (Exception) { } - } - if (settings == null) settings = new Settings(); - if (settings.HighlightsEnabled == null) settings.HighlightsEnabled = new Dictionary(); - if (settings.HighlightsColor == null) settings.HighlightsColor = new Dictionary(); - foreach (var highlight in Utils.GetHighlights()) - { - if (!settings.HighlightsEnabled.ContainsKey(highlight)) settings.HighlightsEnabled[highlight] = true; - if (!settings.HighlightsColor.ContainsKey(highlight)) settings.HighlightsColor[highlight] = Settings.defaultColor; - } - settings.UpdateActiveHighlights(); - return settings; - } - public Settings ConvertToNewSettings() + public Dictionary enableHighlights; + public Dictionary highlightingColors; + public bool storyNearbyNotification = false; + public bool jukeboxDiskNotification = false; + public bool highlightEverythingExosuit = false; + public bool destoryNull = true; + public bool showPings = false; + public float highlightRadius = 20f; + public float minAlpha = 0f; + public static Settings Load() + { + Console.WriteLine("[AdvancedHighlighting] Loading Settings"); + string path = Path.Combine(Utils.ModDirectory, "settings.json"); + Settings settings = null; + if (File.Exists(path)) + { + try { - var settings = new Settings - { - HighlightsEnabled = new Dictionary(), - HighlightsColor = new Dictionary(), - StoryNotification = storyNearbyNotification, - DisksNotification = jukeboxDiskNotification, - ExosuiteHighlightsEnabled = highlightEverythingExosuit, - DestroyNullPings = destoryNull, - ShowPings = showPings, - HighlightSearchDistance = highlightRadius, - MinimumAlpha = minAlpha, - }; - foreach (var highlight in enableHighlights) - if (TypeToHighlight.TryGetValue(highlight.Key, out Highlight val)) - settings.HighlightsEnabled[val] = highlight.Value; - foreach (var highlight in highlightingColors) - if (TypeToHighlight.TryGetValue(highlight.Key, out Highlight val)) - settings.HighlightsColor[val] = highlight.Value; - return settings; + var text = File.ReadAllText(path); + if (text.Contains("PublicKeyToken") || text.Contains("storyNearbyNotification")) + settings = JsonConvert.DeserializeObject(text).ConvertToNewSettings(); + else + settings = JsonConvert.DeserializeObject(text); } + catch (Exception) { } + } + if (settings == null) settings = new Settings(); + if (settings.HighlightsEnabled == null) settings.HighlightsEnabled = new Dictionary(); + if (settings.HighlightsColor == null) settings.HighlightsColor = new Dictionary(); + foreach (var highlight in Utils.GetHighlights()) + { + if (!settings.HighlightsEnabled.ContainsKey(highlight)) settings.HighlightsEnabled[highlight] = true; + if (!settings.HighlightsColor.ContainsKey(highlight)) settings.HighlightsColor[highlight] = Settings.defaultColor; + } + settings.UpdateActiveHighlights(); + return settings; + } + public Settings ConvertToNewSettings() + { + var settings = new Settings + { + HighlightsEnabled = new Dictionary(), + HighlightsColor = new Dictionary(), + StoryNotification = storyNearbyNotification, + DisksNotification = jukeboxDiskNotification, + ExosuiteHighlightsEnabled = highlightEverythingExosuit, + DestroyNullPings = destoryNull, + ShowPings = showPings, + HighlightSearchDistance = highlightRadius, + MinimumAlpha = minAlpha, + }; + foreach (var highlight in enableHighlights) + if (TypeToHighlight.TryGetValue(highlight.Key, out Highlight val)) + settings.HighlightsEnabled[val] = highlight.Value; + foreach (var highlight in highlightingColors) + if (TypeToHighlight.TryGetValue(highlight.Key, out Highlight val)) + settings.HighlightsColor[val] = highlight.Value; + return settings; } + } } From c9de51dfd13c8dfc48a9c946ebae3db4f0602e41 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:38:43 +0700 Subject: [PATCH 04/26] Update Settings.cs --- AdvancedHighlighting/Settings.cs | 108 ++++++++++++++++--------------- 1 file changed, 55 insertions(+), 53 deletions(-) diff --git a/AdvancedHighlighting/Settings.cs b/AdvancedHighlighting/Settings.cs index d1e5141..5ff4de1 100644 --- a/AdvancedHighlighting/Settings.cs +++ b/AdvancedHighlighting/Settings.cs @@ -1,66 +1,68 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; -using System.Linq; using UnityEngine; +#if SN +#elif BZ +#endif namespace AdvancedHighlighting { - public class Settings - { - public static readonly string defaultColor = "FF8000FF"; - public static readonly Color nullColor = new Color(0f, 0f, 0f, 0f); - [JsonIgnore] - public bool PresetApplied = false; - - public bool StoryNotification = false; - public bool DisksNotification = false; - public bool ShowPings = false; - public bool ExosuiteHighlightsEnabled = false; - public bool DestroyNullPings = true; - public float HighlightSearchDistance = 20f; - public float MinimumAlpha = 0f; - public int HighlightingRenderer = 1; + public class Settings + { + public static readonly string defaultColor = "e0e238"; + public static readonly Color nullColor = new Color(0f, 0f, 0f, 0f); + [JsonIgnore] + public bool PresetApplied = false; - public Dictionary HighlightsEnabled; - public Dictionary HighlightsColor; + public bool StoryNotification = false; + public bool DisksNotification = false; + public bool ShowPings = false; + public bool ExosuiteHighlightsEnabled = false; + public bool DestroyNullPings = true; + public float HighlightSearchDistance = 20f; + public float MinimumAlpha = 0f; + public int HighlightingRenderer = 1; - [JsonIgnore] - public List ActiveHighlights = new List(); + public Dictionary HighlightsEnabled; + public Dictionary HighlightsColor; - [JsonIgnore] - private static Settings instance; - public static Settings GetInstance() - { - if (instance == null) - instance = OldSettings.Load(); - return instance; - } - public void Save() - { - Console.WriteLine("[AdvancedHighlighting] Saving Settings"); - File.WriteAllText(Path.Combine(Utils.ModDirectory, "settings.json"), JsonConvert.SerializeObject(this, Formatting.Indented)); - } - public void UpdateActiveHighlights() - { - ActiveHighlights.Clear(); - if (MiscSettings.highlighting) - { - foreach (var highlight in HighlightsEnabled) - if(highlight.Value) - ActiveHighlights.Add(highlight.Key); - //Console.WriteLine($"[AdvancedHighlighting] UpdateActiveHighlights {string.Join(",", ActiveHighlights)}..."); - } - } + [JsonIgnore] + public List ActiveHighlights = new List(); - public bool IsHighlightActive(Highlight highlight) => - ActiveHighlights.Contains(highlight); - public bool IsHighlightEnabled(Highlight highlight) => - (HighlightsEnabled.TryGetValue(highlight, out bool e) ? e : MiscSettings.highlighting); - public Color GetHighlightColor(Highlight highlight) => - (HighlightsColor.TryGetValue(highlight, out string h) && ColorUtility.TryParseHtmlString("#" + h, out Color c) ? c : nullColor); - public string GetHtmlColor(Highlight highlight) => - (HighlightsColor.TryGetValue(highlight, out string h) ? h : null); + [JsonIgnore] + private static Settings instance; + public static Settings GetInstance() + { + if (instance == null) + instance = OldSettings.Load(); + return instance; + } + public void Save() + { + Console.WriteLine("[AdvancedHighlighting] Saving Settings"); + File.WriteAllText(Path.Combine(Utils.ModDirectory, "settings.json"), JsonConvert.SerializeObject(this, Formatting.Indented)); + } + public void UpdateActiveHighlights() + { + ActiveHighlights.Clear(); + if (MiscSettings.highlighting) + { + foreach (var highlight in HighlightsEnabled) + if (highlight.Value) + ActiveHighlights.Add(highlight.Key); + //Console.WriteLine($"[AdvancedHighlighting] UpdateActiveHighlights {string.Join(",", ActiveHighlights)}..."); + } } + + public bool IsHighlightActive(Highlight highlight) => + ActiveHighlights.Contains(highlight); + public bool IsHighlightEnabled(Highlight highlight) => + (HighlightsEnabled.TryGetValue(highlight, out bool e) ? e : MiscSettings.highlighting); + public Color GetHighlightColor(Highlight highlight) => + (HighlightsColor.TryGetValue(highlight, out string h) && ColorUtility.TryParseHtmlString("#" + h, out Color c) ? c : nullColor); + public string GetHtmlColor(Highlight highlight) => + (HighlightsColor.TryGetValue(highlight, out string h) ? h : null); + } } From d96406c48cc08703034edbce49c72d09608a36f3 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:39:36 +0700 Subject: [PATCH 05/26] Update Utils.cs --- AdvancedHighlighting/Utils.cs | 264 +++++++++++++++++++--------------- 1 file changed, 147 insertions(+), 117 deletions(-) diff --git a/AdvancedHighlighting/Utils.cs b/AdvancedHighlighting/Utils.cs index b109ef9..8a9107e 100644 --- a/AdvancedHighlighting/Utils.cs +++ b/AdvancedHighlighting/Utils.cs @@ -1,139 +1,169 @@ -using HighlightingSystem; +using HighlightingSystem; using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; using UnityEngine; using static PDAScanner; +#if SN +#elif BZ +#endif namespace AdvancedHighlighting { - public static class Utils + public static class Utils + { + public static readonly Type FragmentsType = typeof(TechFragment); + public static readonly Type ScannableType = typeof(ScannerTarget); + public static readonly Type EverythingType = typeof(Utils); + public static readonly List Presets = new List { - public static readonly Type FragmentsType = typeof(TechFragment); - public static readonly Type ScannableType = typeof(ScannerTarget); - public static readonly Type EverythingType = typeof(Utils); - public static readonly List Presets = new List + new HighlightingPreset { name = "Narrow", fillAlpha = 0f, downsampleFactor = 4, iterations = 2, blurMinSpread = 0.65f, blurSpread = 0.25f, blurIntensity = 0.3f, blurDirections = BlurDirections.Diagonal}, + new HighlightingPreset { name = "Wide (Game Default)", fillAlpha = 0f, downsampleFactor = 4, iterations = 4, blurMinSpread = 0.65f, blurSpread = 0.25f, blurIntensity = 0.3f, blurDirections = BlurDirections.Diagonal }, + new HighlightingPreset { name = "Strong", fillAlpha = 0f, downsampleFactor = 4, iterations = 2, blurMinSpread = 0.5f, blurSpread = 0.15f, blurIntensity = 0.325f, blurDirections = BlurDirections.Diagonal }, + new HighlightingPreset { name = "Speed", fillAlpha = 0f, downsampleFactor = 4, iterations = 1, blurMinSpread = 0.75f, blurSpread = 0f, blurIntensity = 0.35f, blurDirections = BlurDirections.Diagonal }, + new HighlightingPreset { name = "Quality", fillAlpha = 0f, downsampleFactor = 2, iterations = 3, blurMinSpread = 0.5f, blurSpread = 0.5f, blurIntensity = 0.28f, blurDirections = BlurDirections.Diagonal }, + new HighlightingPreset { name = "Solid 1px", fillAlpha = 0f, downsampleFactor = 1, iterations = 1, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, + new HighlightingPreset { name = "Solid 2px", fillAlpha = 0f, downsampleFactor = 1, iterations = 2, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, + new HighlightingPreset { name = "Solid 3px", fillAlpha = 0f, downsampleFactor = 1, iterations = 3, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, + new HighlightingPreset { name = "Solid 4px", fillAlpha = 0f, downsampleFactor = 1, iterations = 4, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, + new HighlightingPreset { name = "Solid 5px", fillAlpha = 0f, downsampleFactor = 1, iterations = 5, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All } + }; + public static Highlight[] GetHighlights() => (Highlight[])Enum.GetValues(typeof(Highlight)); + private static Sprite eyeSprite; + public static bool GetEyeSprite(out Sprite sprite) + { + if (eyeSprite == null && File.Exists(Path.Combine(ModDirectory, "Assets", "Eye.png"))) + eyeSprite = ImageUtils.LoadSprite(Path.Combine(ModDirectory, "Assets", "Eye.png"), new Vector2(0.5f, 0.5f), TextureFormat.BC7, 100f, SpriteMeshType.Tight); + sprite = eyeSprite; + return (sprite != null); + } + public static bool GetColorForType(string type, out Color newColor) + { + if (type == "story") + { + newColor = Settings.GetInstance().GetHighlightColor(Highlight.StoryItems); + return true; + } + else if (type == "disk") + { + newColor = Settings.GetInstance().GetHighlightColor(Highlight.JukeboxDisk); + return true; + } + newColor = Settings.nullColor; + return false; + } + public static List GetHighlightsForObject(this GameObject gameObject, out GameObject targetObject, out Behaviour behaviour) + { + var supported = new List(); + targetObject = null; + behaviour = null; + if (gameObject == null) + return supported; + if (Targeting.GetRoot(gameObject, out TechType techType, out GameObject result)) + { + var scannableFragments = Settings.GetInstance().IsHighlightActive(Highlight.ScannableFragments); + targetObject = result; + if (PDAScanner.IsFragment(techType)) { - new HighlightingPreset { name = "Narrow", fillAlpha = 0f, downsampleFactor = 4, iterations = 2, blurMinSpread = 0.65f, blurSpread = 0.25f, blurIntensity = 0.3f, blurDirections = BlurDirections.Diagonal}, - new HighlightingPreset { name = "Wide (Game Default)", fillAlpha = 0f, downsampleFactor = 4, iterations = 4, blurMinSpread = 0.65f, blurSpread = 0.25f, blurIntensity = 0.3f, blurDirections = BlurDirections.Diagonal }, - new HighlightingPreset { name = "Strong", fillAlpha = 0f, downsampleFactor = 4, iterations = 2, blurMinSpread = 0.5f, blurSpread = 0.15f, blurIntensity = 0.325f, blurDirections = BlurDirections.Diagonal }, - new HighlightingPreset { name = "Speed", fillAlpha = 0f, downsampleFactor = 4, iterations = 1, blurMinSpread = 0.75f, blurSpread = 0f, blurIntensity = 0.35f, blurDirections = BlurDirections.Diagonal }, - new HighlightingPreset { name = "Quality", fillAlpha = 0f, downsampleFactor = 2, iterations = 3, blurMinSpread = 0.5f, blurSpread = 0.5f, blurIntensity = 0.28f, blurDirections = BlurDirections.Diagonal }, - new HighlightingPreset { name = "Solid 1px", fillAlpha = 0f, downsampleFactor = 1, iterations = 1, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, - new HighlightingPreset { name = "Solid 2px", fillAlpha = 0f, downsampleFactor = 1, iterations = 2, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, - new HighlightingPreset { name = "Solid 3px", fillAlpha = 0f, downsampleFactor = 1, iterations = 3, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, - new HighlightingPreset { name = "Solid 4px", fillAlpha = 0f, downsampleFactor = 1, iterations = 4, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, - new HighlightingPreset { name = "Solid 5px", fillAlpha = 0f, downsampleFactor = 1, iterations = 5, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All } - }; - public static Highlight[] GetHighlights() => (Highlight[])Enum.GetValues(typeof(Highlight)); - private static Sprite eyeSprite; - public static bool GetEyeSprite(out Sprite sprite) + if (!PDAScanner.ContainsCompleteEntry(techType)) + { + if (scannableFragments) supported.Add(Highlight.ScannableFragments); + } + else if (techType.GetEntryData(out EntryData data)) + { + if (data.destroyAfterScan && Highlight.ScannedFragments.IsActive()) supported.Add(Highlight.ScannedFragments); + } + } + else if (result != null) { - if (eyeSprite == null && File.Exists(Path.Combine(ModDirectory, "Assets", "Eye.png"))) - eyeSprite = ImageUtils.LoadSprite(Path.Combine(ModDirectory, "Assets", "Eye.png"), new Vector2(0.5f, 0.5f), TextureFormat.BC7, 100f, SpriteMeshType.Tight); - sprite = eyeSprite; - return (sprite != null); + if (techType.GetEntryData(out EntryData data) && PDAScanner.CanScan(result)) + { + if (data.blueprint > 0 && scannableFragments) + supported.Add(Highlight.ScannableFragments); + else if (data.blueprint == 0 && Highlight.ScannableItems.IsActive()) + supported.Add(Highlight.ScannableItems); + } } - public static bool GetColorForType(string type, out Color newColor) + } + behaviour = gameObject.GetComponentInParent() as Behaviour; + if (behaviour != null) + { + if (Highlight.BreakableResource.IsPressent(behaviour)) { - if (type == "story") - { - newColor = Settings.GetInstance().GetHighlightColor(Highlight.StoryItems); - return true; - } - else if (type == "disk") - { - newColor = Settings.GetInstance().GetHighlightColor(Highlight.DiskItems); - return true; - } - newColor = Settings.nullColor; - return false; + if (Highlight.BreakableResource.IsActive()) supported.Add(Highlight.BreakableResource); } - public static List GetHighlightsForObject(this GameObject gameObject, out GameObject targetObject, out Behaviour behaviour) + else if (Highlight.PickupableResource.IsPressent(behaviour)) { - var supported = new List(); - targetObject = null; - behaviour = null; - if (gameObject == null) - return supported; - if (Targeting.GetRoot(gameObject, out TechType techType, out GameObject result)) - { - var scannableFragments = Settings.GetInstance().IsHighlightActive(Highlight.ScannableFragments); - targetObject = result; - if (PDAScanner.IsFragment(techType)) - { - if (!PDAScanner.ContainsCompleteEntry(techType)) - { - if (scannableFragments) supported.Add(Highlight.ScannableFragments); - } - else if (techType.GetEntryData(out EntryData data)) - { - if (data.destroyAfterScan && Highlight.ScannedFragments.IsActive()) supported.Add(Highlight.ScannedFragments); - } - } - else if (result != null) - { - if (techType.GetEntryData(out EntryData data) && PDAScanner.CanScan(result)) - { - if (data.blueprint > 0 && scannableFragments) - supported.Add(Highlight.ScannableFragments); - else if (data.blueprint == 0 && Highlight.ScannableItems.IsActive()) - supported.Add(Highlight.ScannableItems); - } - } - } - behaviour = gameObject.GetComponentInParent() as Behaviour; - if (behaviour != null) - { - - if (Highlight.BreakableResource.IsPressent(behaviour)) - { - if (Highlight.BreakableResource.IsActive()) supported.Add(Highlight.BreakableResource); - } - else if (Highlight.PickupableResource.IsPressent(behaviour)) - { - if (Highlight.PickupableResource.IsActive()) supported.Add(Highlight.PickupableResource); - } - else if (Highlight.PickupableCreatures.IsPressent(behaviour)) - { - if (Highlight.PickupableCreatures.IsActive()) supported.Add(Highlight.PickupableCreatures); - } - else if (Highlight.Pickupable.IsPressent(behaviour)) - { - if (Highlight.Pickupable.IsActive()) supported.Add(Highlight.Pickupable); - } - - if (Highlight.StoryItems.IsPressentAndActive(behaviour)) supported.Add(Highlight.StoryItems); - if (Highlight.DiskItems.IsPressentAndActive(behaviour)) supported.Add(Highlight.DiskItems); - if (Highlight.Interactables.IsPressentAndActive(behaviour)) supported.Add(Highlight.Interactables); - if (Highlight.SealedDoor.IsPressentAndActive(behaviour)) supported.Add(Highlight.SealedDoor); - if (Highlight.FruitAndVeg.IsPressentAndActive(behaviour)) supported.Add(Highlight.FruitAndVeg); - if (Highlight.OxygenFish.IsPressentAndActive(behaviour)) supported.Add(Highlight.OxygenFish); - - if (supported.Count == 0 && Highlight.AnythingElse.IsActive()) supported.Add(Highlight.AnythingElse); - } - //if (!logged.Contains(gameObject.GetInstanceID())) - //{ - // var types1 = gameObject.GetComponents().Select(x => x.GetType()); - // var types2 = behaviour?.gameObject?.GetComponents().Select(x => x.GetType()); - // Console.WriteLine($"[AdvancedHighlighting] GetSupportedComponentsTypes ([{gameObject.GetInstanceID()}] {gameObject.name},[{behaviour?.gameObject?.GetInstanceID()}] {behaviour?.gameObject?.name}), Supported = ({string.Join(", ", supported)}), Types1 = ({string.Join(", ", types1)}), Types2 = ({(types2 != null ? string.Join(", ", types2) : "")})"); - // logged.Add(gameObject.GetInstanceID()); - //} - return supported; + if (Highlight.CreatureEgg.IsPressent(behaviour)) + { + if (Highlight.CreatureEgg.IsActive()) supported.Add(Highlight.CreatureEgg); + } + else + { + if (Highlight.PickupableResource.IsActive()) supported.Add(Highlight.PickupableResource); + } + } + else if (Highlight.PickupableCreatures.IsPressent(behaviour)) + { + if (Highlight.Bladderfish.IsPressent(behaviour)) + { + if (Highlight.Bladderfish.IsActive()) supported.Add(Highlight.Bladderfish); + } + else + { + if (Highlight.PickupableCreatures.IsActive()) supported.Add(Highlight.PickupableCreatures); + } } - //private static readonly List logged = new List(); - public static string ModDirectory + else if (Highlight.Pickupable.IsPressent(behaviour)) { - get => Environment.CurrentDirectory + "\\QMods\\AdvancedHighlighting\\"; + if (Highlight.Pickupable.IsActive()) supported.Add(Highlight.Pickupable); } - public static bool GetEntryData(this TechType tech, out EntryData data) + else if (Highlight.Interactables.IsPressent(behaviour)) { - data = PDAScanner.GetEntryData(tech); - return data != null; + if(Highlight.BaseLadder.IsPressent(behaviour)) + { + if (Highlight.BaseLadder.IsActive()) supported.Add(Highlight.BaseLadder); + } + else if (Highlight.GrownPlant.IsPressent(behaviour)) + { + if (Highlight.GrownPlant.IsActive()) supported.Add(Highlight.GrownPlant); + } + else if (Highlight.SealedDoor.IsPressent(behaviour)) + { + if (Highlight.SealedDoor.IsActive()) supported.Add(Highlight.SealedDoor); + } + else if (Highlight.LaserCutObject.IsPressent(behaviour)) + { + if (Highlight.LaserCutObject.IsActive()) supported.Add(Highlight.LaserCutObject); + } + else + { + if (Highlight.Interactables.IsActive()) supported.Add(Highlight.Interactables); + } } + + if (Highlight.StoryItems.IsPressentAndActive(behaviour)) supported.Add(Highlight.StoryItems); + if (Highlight.JukeboxDisk.IsPressentAndActive(behaviour)) supported.Add(Highlight.JukeboxDisk); + if (supported.Count == 0 && Highlight.AnythingElse.IsActive()) supported.Add(Highlight.AnythingElse); + } + //if (!logged.Contains(gameObject.GetInstanceID())) + //{ + // var types1 = gameObject.GetComponents().Select(x => x.GetType()); + // var types2 = behaviour?.gameObject?.GetComponents().Select(x => x.GetType()); + // Console.WriteLine($"[AdvancedHighlighting] GetSupportedComponentsTypes ([{gameObject.GetInstanceID()}] {gameObject.name},[{behaviour?.gameObject?.GetInstanceID()}] {behaviour?.gameObject?.name}), Supported = ({string.Join(", ", supported)}), Types1 = ({string.Join(", ", types1)}), Types2 = ({(types2 != null ? string.Join(", ", types2) : "")})"); + // logged.Add(gameObject.GetInstanceID()); + //} + return supported; + } + //private static readonly List logged = new List(); + public static string ModDirectory + { + get => Environment.CurrentDirectory + "\\QMods\\AdvancedHighlighting\\"; + } + public static bool GetEntryData(this TechType tech, out EntryData data) + { + data = PDAScanner.GetEntryData(tech); + return data != null; } + } } From 12f83b3ce1feea1a77490891edcf4872d173a0ee Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:41:08 +0700 Subject: [PATCH 06/26] Update AdvancedHighlighting.csproj Added Post Build options. Need to change for your setup. --- .../AdvancedHighlighting.csproj | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/AdvancedHighlighting/AdvancedHighlighting.csproj b/AdvancedHighlighting/AdvancedHighlighting.csproj index 8a1bb86..9ba1d17 100644 --- a/AdvancedHighlighting/AdvancedHighlighting.csproj +++ b/AdvancedHighlighting/AdvancedHighlighting.csproj @@ -1,4 +1,4 @@ - + @@ -9,18 +9,20 @@ Properties AdvancedHighlighting AdvancedHighlighting - v4.7.2 + v4.8 512 true + true full - false - bin\Debug\ - DEBUG;TRACE + true + bin\BZ\ + BZ prompt 4 + true pdbonly @@ -30,6 +32,12 @@ prompt 4 + + bin\BZ\ + + + bin\SN\ + D:\SteamLibrary\SteamApps\common\SubnauticaZero\BepInEx\core\0Harmony20.dll @@ -47,6 +55,9 @@ D:\SteamLibrary\SteamApps\common\SubnauticaZero\BepInEx\plugins\QModManager\QModInstaller.dll + + D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\SMLHelper_BZ\SMLHelper.dll + @@ -303,6 +314,11 @@ + + True + True + Resources.resx + @@ -310,8 +326,24 @@ + + + ResXFileCodeGenerator + Resources.Designer.cs + + - copy /Y "$(TargetPath)" "D:\SteamLibrary\SteamApps\common\SubnauticaZero\QMods\AdvancedHighlighting\AdvancedHighlighting.dll" + if $(ConfigurationName) == BZ ( +mkdir "D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\$(TargetName)" +xcopy /Y "$(TargetPath)" "D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\$(TargetName)" +copy /Y "$(ProjectDir)\mod_BZ.json" "D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\$(TargetName)\mod.json" +del "D:\SteamLibrary\steamapps\common\SubnauticaZero\qmodmanager_log-SubnauticaZero.txt" ) + +if $(ConfigurationName) == SN ( +mkdir "D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(TargetName)" +xcopy /Y "$(TargetPath)" "D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(TargetName)" +copy /Y "$(ProjectDir)\mod_SN.json" "D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(TargetName)\mod.json" +del "D:\SteamLibrary\steamapps\common\Subnautica\qmodmanager_log-Subnautica.txt") - \ No newline at end of file + From 3b557be5ab94c41710bab5a2b9755b2bf09df171 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:43:21 +0700 Subject: [PATCH 07/26] Update Highlighting_Patch.cs --- .../Patches/Highlighting_Patch.cs | 416 +++++++++--------- 1 file changed, 208 insertions(+), 208 deletions(-) diff --git a/AdvancedHighlighting/Patches/Highlighting_Patch.cs b/AdvancedHighlighting/Patches/Highlighting_Patch.cs index 0d1c936..ca7a166 100644 --- a/AdvancedHighlighting/Patches/Highlighting_Patch.cs +++ b/AdvancedHighlighting/Patches/Highlighting_Patch.cs @@ -1,4 +1,4 @@ -using HarmonyLib; +using HarmonyLib; using HighlightingSystem; using Newtonsoft.Json; using System; @@ -12,237 +12,237 @@ namespace AdvancedHighlighting.Patches { - public static class Highlighting_Patch + public static class Highlighting_Patch + { + private static MethodInfo updateActiveHighlightersAsyncMethod; + private static readonly FieldInfo highlightersField = typeof(Highlighting).GetField("highlighters", BindingFlags.Instance | BindingFlags.NonPublic); + private static readonly FieldInfo handlersField = typeof(Highlighting).GetField("handlers", BindingFlags.Instance | BindingFlags.NonPublic); + private static readonly FieldInfo updateActiveHighligtersCoroutineField = typeof(Highlighting).GetField("updateActiveHighligtersCoroutine", BindingFlags.Instance | BindingFlags.NonPublic); + public static HashSet GetHighlighters(this Highlighting instance) => + (HashSet)highlightersField.GetValue(instance); + public static Dictionary GetHandlers(this Highlighting instance) => + (Dictionary)handlersField.GetValue(instance); + public static Coroutine GetUpdateActiveHighligtersCoroutine(this Highlighting instance) => + (Coroutine)updateActiveHighligtersCoroutineField.GetValue(instance); + public static void SetUpdateActiveHighligtersCoroutine(this Highlighting instance, Coroutine coroutine) => + updateActiveHighligtersCoroutineField.SetValue(instance, coroutine); + public static System.Collections.IEnumerator InvokeUpdateActiveHighlightersAsync(this Highlighting instance, Vector3 vector) { - private static MethodInfo updateActiveHighlightersAsyncMethod; - private static readonly FieldInfo highlightersField = typeof(Highlighting).GetField("highlighters", BindingFlags.Instance | BindingFlags.NonPublic); - private static readonly FieldInfo handlersField = typeof(Highlighting).GetField("handlers", BindingFlags.Instance | BindingFlags.NonPublic); - private static readonly FieldInfo updateActiveHighligtersCoroutineField = typeof(Highlighting).GetField("updateActiveHighligtersCoroutine", BindingFlags.Instance | BindingFlags.NonPublic); - public static HashSet GetHighlighters(this Highlighting instance) => - (HashSet)highlightersField.GetValue(instance); - public static Dictionary GetHandlers(this Highlighting instance) => - (Dictionary)handlersField.GetValue(instance); - public static Coroutine GetUpdateActiveHighligtersCoroutine(this Highlighting instance) => - (Coroutine)updateActiveHighligtersCoroutineField.GetValue(instance); - public static void SetUpdateActiveHighligtersCoroutine(this Highlighting instance, Coroutine coroutine) => - updateActiveHighligtersCoroutineField.SetValue(instance, coroutine); - public static System.Collections.IEnumerator InvokeUpdateActiveHighlightersAsync(this Highlighting instance, Vector3 vector) + if (updateActiveHighlightersAsyncMethod == null) + updateActiveHighlightersAsyncMethod = typeof(Highlighting).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).Where(x => x.Name == "UpdateActiveHighlightersAsync").FirstOrDefault(); + return (System.Collections.IEnumerator)updateActiveHighlightersAsyncMethod.Invoke(instance, new object[] { vector }); + } + + } + [HarmonyPatch(typeof(Highlighting), "OnUpdate")] + public class Highlighting_OnUpdate_Patch + { + public static readonly Dictionary stories = new Dictionary(); + public static readonly Dictionary pings = new Dictionary(); + public static readonly List notifications = new List(); + private static int lastActiveTargetId = 0; + private static float hoverStart = 0f; + public static bool isLogged = false; + public static bool Prefix(Highlighting __instance) + { + Highlighting.Mode mode = Highlighting.GetMode(); + var settings = Settings.GetInstance(); + if (mode == Highlighting.Mode.None || settings.ActiveHighlights.Count == 0) + { + lastActiveTargetId = 0; + } + else + { + var time = Time.time; + Vector3 vector = MainCamera.camera?.transform.position ?? Vector3.zero; + GameObject gameObject = null; + if (mode == Highlighting.Mode.Exosuit) gameObject = (Player.main.GetVehicle() as Exosuit).GetActiveTarget(); + else if (mode == Highlighting.Mode.Player) gameObject = Player.main?.guiHand?.GetActiveTarget(); + int id = gameObject?.GetInstanceID() ?? 0; + if (lastActiveTargetId != id) + { + hoverStart = time; + lastActiveTargetId = id; + } + if (__instance.GetUpdateActiveHighligtersCoroutine() == null) { - if (updateActiveHighlightersAsyncMethod == null) - updateActiveHighlightersAsyncMethod = typeof(Highlighting).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).Where(x => x.Name == "UpdateActiveHighlightersAsync").FirstOrDefault(); - return (System.Collections.IEnumerator)updateActiveHighlightersAsyncMethod.Invoke(instance, new object[] { vector }); + if (__instance.radiusOuter != settings.HighlightSearchDistance) + __instance.radiusOuter = settings.HighlightSearchDistance; + __instance.SetUpdateActiveHighligtersCoroutine(__instance.StartCoroutine(__instance.InvokeUpdateActiveHighlightersAsync(vector))); } - } - [HarmonyPatch(typeof(Highlighting), "OnUpdate")] - public class Highlighting_OnUpdate_Patch - { - public static readonly Dictionary stories = new Dictionary(); - public static readonly Dictionary pings = new Dictionary(); - public static readonly List notifications = new List(); - private static int lastActiveTargetId = 0; - private static float hoverStart = 0f; - public static bool isLogged = false; - public static bool Prefix(Highlighting __instance) + var highlighters = __instance.GetHighlighters(); + if (settings.StoryNotification || settings.DisksNotification || settings.ShowPings) { - Highlighting.Mode mode = Highlighting.GetMode(); - var settings = Settings.GetInstance(); - if (mode == Highlighting.Mode.None || settings.ActiveHighlights.Count == 0) + var removed = new List(); + foreach (var key in stories.Keys) + { + if (!highlighters.Any(x => x.GetInstanceID() == key)) + removed.Add(key); + } + foreach (var key in removed) + { + if (notifications.Contains(key)) { - lastActiveTargetId = 0; + notifications.Remove(key); + ErrorMessage.AddMessage($"[Advanced Highlighting] {Language.main.Get(stories[key])} is no longer nearby"); } - else + if (pings.ContainsKey(key)) { - var time = Time.time; - Vector3 vector = MainCamera.camera?.transform.position ?? Vector3.zero; - GameObject gameObject = null; - if (mode == Highlighting.Mode.Exosuit) gameObject = (Player.main.GetVehicle() as Exosuit).GetActiveTarget(); - else if (mode == Highlighting.Mode.Player) gameObject = Player.main?.guiHand?.GetActiveTarget(); - int id = gameObject?.GetInstanceID() ?? 0; - if (lastActiveTargetId != id) - { - hoverStart = time; - lastActiveTargetId = id; - } - if (__instance.GetUpdateActiveHighligtersCoroutine() == null) - { - if (__instance.radiusOuter != settings.HighlightSearchDistance) - __instance.radiusOuter = settings.HighlightSearchDistance; - __instance.SetUpdateActiveHighligtersCoroutine(__instance.StartCoroutine(__instance.InvokeUpdateActiveHighlightersAsync(vector))); - } + var ping = PingManager.Get(pings[key]); + if (ping != null) + UnityEngine.Object.Destroy(ping); + pings.Remove(key); + } + stories.Remove(key); + } + } + var radiusRange = settings.HighlightSearchDistance - __instance.radiusInner; - var highlighters = __instance.GetHighlighters(); - if (settings.StoryNotification || settings.DisksNotification || settings.ShowPings) - { - var removed = new List(); - foreach (var key in stories.Keys) - { - if (!highlighters.Any(x => x.GetInstanceID() == key)) - removed.Add(key); - } - foreach (var key in removed) - { - if (notifications.Contains(key)) - { - notifications.Remove(key); - ErrorMessage.AddMessage($"[Advanced Highlighting] {Language.main.Get(stories[key])} is no longer nearby"); - } - if (pings.ContainsKey(key)) - { - var ping = PingManager.Get(pings[key]); - if (ping != null) - UnityEngine.Object.Destroy(ping); - pings.Remove(key); - } - stories.Remove(key); - } - } - var radiusRange = settings.HighlightSearchDistance - __instance.radiusInner; + if (!settings.PresetApplied && MainCamera.camera != null && MainCamera.camera.TryGetComponent(out HighlightingRenderer renderer)) + { + settings.PresetApplied = true; + if (settings.HighlightingRenderer >= 0 && settings.HighlightingRenderer < Utils.Presets.Count) + renderer.ApplyPreset(Utils.Presets[settings.HighlightingRenderer]); + //Console.WriteLine($"[AdvancedHighlighting] Active {settings.HighlightingRenderer},{Utils.Presets.Count} = [{renderer.name}, {renderer.blurDirections}, {renderer.blurIntensity}, {renderer.blurMinSpread}, {renderer.blurSpread}, {renderer.downsampleFactor}, {renderer.fillAlpha}, {renderer.iterations}]"); + } + foreach (Highlighter highlighter in highlighters) + { + if (highlighter != null) + { + var highlights = highlighter.gameObject.GetHighlightsForObject(out _, out _); + if (highlights.Count > 0) + { + Color highlightingColor = settings.GetHighlightColor(highlights.First()); + if (highlightingColor.a != 0f) + { + float magnitude = (highlighter.bounds.center - vector).magnitude; + float a = Mathf.Max(Mathf.Clamp01(1f - (magnitude - __instance.radiusInner) / radiusRange), settings.MinimumAlpha); + highlightingColor.a = a * a; + highlighter.ConstantOn(highlightingColor, 0f); + highlighter.filterMode = RendererFilterMode.None; - if (!settings.PresetApplied && MainCamera.camera != null && MainCamera.camera.TryGetComponent(out HighlightingRenderer renderer)) - { - settings.PresetApplied = true; - if (settings.HighlightingRenderer >= 0 && settings.HighlightingRenderer < Utils.Presets.Count) - renderer.ApplyPreset(Utils.Presets[settings.HighlightingRenderer]); - //Console.WriteLine($"[AdvancedHighlighting] Active {settings.HighlightingRenderer},{Utils.Presets.Count} = [{renderer.name}, {renderer.blurDirections}, {renderer.blurIntensity}, {renderer.blurMinSpread}, {renderer.blurSpread}, {renderer.downsampleFactor}, {renderer.fillAlpha}, {renderer.iterations}]"); - } - foreach (Highlighter highlighter in highlighters) - { - if (highlighter != null) - { - var highlights = highlighter.gameObject.GetHighlightsForObject(out _, out _); - if (highlights.Count > 0) - { - Color highlightingColor = settings.GetHighlightColor(highlights.First()); - if (highlightingColor.a != 0f) - { - float magnitude = (highlighter.bounds.center - vector).magnitude; - float a = Mathf.Max(Mathf.Clamp01(1f - (magnitude - __instance.radiusInner) / radiusRange), settings.MinimumAlpha); - highlightingColor.a = a * a; - highlighter.ConstantOn(highlightingColor, 0f); - highlighter.filterMode = RendererFilterMode.None; - - if (magnitude <= settings.HighlightSearchDistance) - NotifiyAndPing(highlighter); - } - else - highlighter.ConstantOn(highlightingColor, 0f); - } - } - } - if (gameObject != null) - { - GameObject highlightableRoot = null; - Highlighting_GetHighlightableRoot_Patch.Prefix(__instance, ref highlightableRoot, mode, gameObject); - if (highlightableRoot != null) - { - Highlighter highlighter = highlightableRoot.GetComponent(); - if (highlighter != null) - { - Color highlightingColor = highlighter.constantColor; - float a2 = Mathf.Lerp(0.4f, 1f, Mathf.Cos((time - hoverStart) * 2f * Mathf.PI * __instance.hoverFlashingSpeed) * 0.5f + 0.5f); - highlightingColor.a = a2 * a2; - highlighter.Hover(highlightingColor); - } - } - } + if (magnitude <= settings.HighlightSearchDistance) + NotifiyAndPing(highlighter); + } + else + highlighter.ConstantOn(highlightingColor, 0f); } - return false; + } } - private static void NotifiyAndPing(Highlighter highlighter) + if (gameObject != null) { - var objId = highlighter.GetInstanceID(); - if (!stories.ContainsKey(objId)) + GameObject highlightableRoot = null; + Highlighting_GetHighlightableRoot_Patch.Prefix(__instance, ref highlightableRoot, mode, gameObject); + if (highlightableRoot != null) + { + Highlighter highlighter = highlightableRoot.GetComponent(); + if (highlighter != null) { - string name = null; - string type = null; - if (highlighter.TryGetComponent(out StoryHandTarget story)) - { - name = Language.main.Get(story.primaryTooltip); - type = "story"; - } - else if (highlighter.TryGetComponent(out JukeboxDisk disk)) - { - name = Language.main.Get(Jukebox.GetInfo(disk.track).label); - type = "disk"; - } - if (name != null) - { - var settings = Settings.GetInstance(); - stories[objId] = name; - if ((type == "story" && settings.StoryNotification) || - (type == "disk" && settings.DisksNotification)) - { - notifications.Add(objId); - ErrorMessage.AddMessage($"[Advanced Highlighting] {name} is nearby"); - } - if (settings.ShowPings) - { - PingInstance ping = highlighter.gameObject.EnsureComponent(); - ping.origin = highlighter.gameObject.transform; - ping.SetFakePosition(highlighter.bounds.center); - ping.SetVisible(true); - ping.SetLabel(name); - ping._id = $"ahping_{type}_{objId}"; - ping.pingType = PingType.Signal; - ping.displayPingInManager = false; - ping.visitable = false; - ping.minDist = 5f; - ping.range = 5f; - ping.enabled = true; - pings[objId] = ping._id; - } - } + Color highlightingColor = highlighter.constantColor; + float a2 = Mathf.Lerp(0.4f, 1f, Mathf.Cos((time - hoverStart) * 2f * Mathf.PI * __instance.hoverFlashingSpeed) * 0.5f + 0.5f); + highlightingColor.a = a2 * a2; + highlighter.Hover(highlightingColor); } + } + } + } + return false; + } + private static void NotifiyAndPing(Highlighter highlighter) + { + var objId = highlighter.GetInstanceID(); + if (!stories.ContainsKey(objId)) + { + string name = null; + string type = null; + if (highlighter.TryGetComponent(out StoryHandTarget story)) + { + name = Language.main.Get(story.primaryTooltip); + type = "story"; + } + else if (highlighter.TryGetComponent(out JukeboxDisk disk)) + { + name = Language.main.Get(Jukebox.GetInfo(disk.track).label); + type = "disk"; + } + if (name != null) + { + var settings = Settings.GetInstance(); + stories[objId] = name; + if ((type == "story" && settings.StoryNotification) || + (type == "disk" && settings.DisksNotification)) + { + notifications.Add(objId); + ErrorMessage.AddMessage($"[Advanced Highlighting] {name} is nearby"); + } + if (settings.ShowPings) + { + PingInstance ping = highlighter.gameObject.EnsureComponent(); + ping.origin = highlighter.gameObject.transform; + ping.SetFakePosition(highlighter.bounds.center); + ping.SetVisible(true); + ping.SetLabel(name); + ping._id = $"ahping_{type}_{objId}"; + ping.pingType = PingType.Signal; + ping.displayPingInManager = false; + ping.visitable = false; + ping.minDist = 5f; + ping.range = 5f; + ping.enabled = true; + pings[objId] = ping._id; + } } + } } + } - [HarmonyPatch(typeof(Highlighting), "GetHighlightableRoot", new Type[] { typeof(Highlighting.Mode), typeof(GameObject) })] - public static class Highlighting_GetHighlightableRoot_Patch + [HarmonyPatch(typeof(Highlighting), "GetHighlightableRoot", new Type[] { typeof(Highlighting.Mode), typeof(GameObject) })] + public static class Highlighting_GetHighlightableRoot_Patch + { + public static bool Prefix(Highlighting __instance, ref GameObject __result, Highlighting.Mode mode, GameObject target) { - public static bool Prefix(Highlighting __instance, ref GameObject __result, Highlighting.Mode mode, GameObject target) + __result = null; + if (mode == Highlighting.Mode.None) + return false; + var settings = Settings.GetInstance(); + if (mode == Highlighting.Mode.Exosuit && !settings.ExosuiteHighlightsEnabled) + { + Exosuit exosuit = Player.main.GetVehicle() as Exosuit; + if (exosuit != null) + __result = exosuit.GetInteractableRoot(target); + return false; + } + else + { + var highlights = target.GetHighlightsForObject(out GameObject result, out Behaviour behaviour); + if (highlights.Count == 0) + return false; + if (highlights.Contains(Highlight.ScannableFragments) || + highlights.Contains(Highlight.ScannedFragments) || + highlights.Contains(Highlight.ScannableItems)) { - __result = null; - if (mode == Highlighting.Mode.None) - return false; - var settings = Settings.GetInstance(); - if (mode == Highlighting.Mode.Exosuit && !settings.ExosuiteHighlightsEnabled) - { - Exosuit exosuit = Player.main.GetVehicle() as Exosuit; - if (exosuit != null) - __result = exosuit.GetInteractableRoot(target); - return false; - } - else - { - var highlights = target.GetHighlightsForObject(out GameObject result, out Behaviour behaviour); - if (highlights.Count == 0) - return false; - if (highlights.Contains(Highlight.ScannableFragments) || - highlights.Contains(Highlight.ScannedFragments) || - highlights.Contains(Highlight.ScannableItems)) - { - __result = result; - return false; - } + __result = result; + return false; + } - if (behaviour == null || !behaviour.enabled || behaviour.GetComponentInParent() != null || - behaviour.GetComponentInParent() != null) - { - return false; - } + if (behaviour == null || !behaviour.enabled || behaviour.GetComponentInParent() != null || + behaviour.GetComponentInParent() != null) + { + return false; + } - var handlers = __instance.GetHandlers(); - if (handlers != null && handlers.TryGetValue(behaviour.GetType(), out Highlighting.Handler handler)) - { - handler(ref behaviour); - if (behaviour == null) - return false; - } - __result = behaviour.gameObject; - } + var handlers = __instance.GetHandlers(); + if (handlers != null && handlers.TryGetValue(behaviour.GetType(), out Highlighting.Handler handler)) + { + handler(ref behaviour); + if (behaviour == null) return false; } + __result = behaviour.gameObject; + } + return false; } + } } From a435f39d1dee892c274095f7524d7be1516f172e Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:45:41 +0700 Subject: [PATCH 08/26] Update HighlightingMod.cs --- AdvancedHighlighting/HighlightingMod.cs | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/AdvancedHighlighting/HighlightingMod.cs b/AdvancedHighlighting/HighlightingMod.cs index 333f176..dd2615f 100644 --- a/AdvancedHighlighting/HighlightingMod.cs +++ b/AdvancedHighlighting/HighlightingMod.cs @@ -1,22 +1,23 @@ -using HarmonyLib; +using HarmonyLib; using QModManager.API.ModLoading; +using SMLHelper.V2.Handlers; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +#if SN +#elif BZ +#endif namespace AdvancedHighlighting { - [QModCore] - public static class HighlightingMod + [QModCore] + + public static class HighlightingMod + { + [QModPatch] + public static void InitMod() { - [QModPatch] - public static void InitMod() - { - Console.WriteLine("[AdvancedHighlighting] Start Patching..."); - Harmony harmony = new Harmony("net.ogmods.highlighting"); - harmony.PatchAll(); - } + Console.WriteLine("[AdvancedHighlighting] Start Patching..."); + Harmony harmony = new Harmony("net.ogmods.highlighting"); + harmony.PatchAll(); } + } } From 8f009bf71ade7d6c0eaaefc9e9e2e9bf500a50be Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:46:25 +0700 Subject: [PATCH 09/26] Update ImageUtils.cs --- AdvancedHighlighting/ImageUtils.cs | 198 ++++++++++++++--------------- 1 file changed, 98 insertions(+), 100 deletions(-) diff --git a/AdvancedHighlighting/ImageUtils.cs b/AdvancedHighlighting/ImageUtils.cs index b9381cf..f1b5af0 100644 --- a/AdvancedHighlighting/ImageUtils.cs +++ b/AdvancedHighlighting/ImageUtils.cs @@ -1,111 +1,109 @@ -using System; +using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; +#if SN +#elif BZ +#endif namespace AdvancedHighlighting { - public static class ImageUtils - { - private static Dictionary textureCache = new Dictionary(); + public static class ImageUtils + { + private static Dictionary textureCache = new Dictionary(); - private static Dictionary spriteCache = new Dictionary(); - public static Sprite LoadSprite(string path, Vector2 pivot = default(Vector2), TextureFormat format = TextureFormat.BC7, float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight) - { - Sprite sprite; - bool flag = ImageUtils.spriteCache.TryGetValue(path, out sprite); - Sprite result; - if (flag) - { - result = sprite; - } - else - { - Texture2D texture2D = ImageUtils.LoadTexture(path, format, 2, 2); - bool flag2 = !texture2D; - if (flag2) - { - result = null; - } - else - { - Sprite sprite2 = ImageUtils.TextureToSprite(texture2D, pivot, pixelsPerUnit, spriteType, default(Vector4)); - ImageUtils.spriteCache.Add(path, sprite2); - result = sprite2; - } - } - return result; - } + private static Dictionary spriteCache = new Dictionary(); + public static Sprite LoadSprite(string path, Vector2 pivot = default(Vector2), TextureFormat format = TextureFormat.BC7, float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight) + { + Sprite sprite; + bool flag = ImageUtils.spriteCache.TryGetValue(path, out sprite); + Sprite result; + if (flag) + { + result = sprite; + } + else + { + Texture2D texture2D = ImageUtils.LoadTexture(path, format, 2, 2); + bool flag2 = !texture2D; + if (flag2) + { + result = null; + } + else + { + Sprite sprite2 = ImageUtils.TextureToSprite(texture2D, pivot, pixelsPerUnit, spriteType, default(Vector4)); + ImageUtils.spriteCache.Add(path, sprite2); + result = sprite2; + } + } + return result; + } - // Token: 0x06000011 RID: 17 RVA: 0x00002408 File Offset: 0x00000608 - public static Sprite Load9SliceSprite(string path, RectOffset slices, Vector2 pivot = default(Vector2), TextureFormat format = TextureFormat.BC7, float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight) - { - string key = path + slices; - Sprite sprite; - bool flag = ImageUtils.spriteCache.TryGetValue(key, out sprite); - Sprite result; - if (flag) - { - result = sprite; - } - else - { - Texture2D texture2D = ImageUtils.LoadTexture(path, format, 2, 2); - bool flag2 = !texture2D; - if (flag2) - { - result = null; - } - else - { - Vector4 border = new Vector4((float)slices.left, (float)slices.right, (float)slices.top, (float)slices.bottom); - Sprite sprite2 = ImageUtils.TextureToSprite(texture2D, pivot, pixelsPerUnit, spriteType, border); - ImageUtils.spriteCache.Add(key, sprite2); - result = sprite2; - } - } - return result; - } + public static Sprite Load9SliceSprite(string path, RectOffset slices, Vector2 pivot = default(Vector2), TextureFormat format = TextureFormat.BC7, float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight) + { + string key = path + slices; + Sprite sprite; + bool flag = ImageUtils.spriteCache.TryGetValue(key, out sprite); + Sprite result; + if (flag) + { + result = sprite; + } + else + { + Texture2D texture2D = ImageUtils.LoadTexture(path, format, 2, 2); + bool flag2 = !texture2D; + if (flag2) + { + result = null; + } + else + { + Vector4 border = new Vector4((float)slices.left, (float)slices.right, (float)slices.top, (float)slices.bottom); + Sprite sprite2 = ImageUtils.TextureToSprite(texture2D, pivot, pixelsPerUnit, spriteType, border); + ImageUtils.spriteCache.Add(key, sprite2); + result = sprite2; + } + } + return result; + } - // Token: 0x06000012 RID: 18 RVA: 0x000024A0 File Offset: 0x000006A0 - public static Texture2D LoadTexture(string path, TextureFormat format = TextureFormat.BC7, int width = 2, int height = 2) - { - Texture2D texture2D; - bool flag = ImageUtils.textureCache.TryGetValue(path, out texture2D); - Texture2D result; - if (flag) - { - result = texture2D; - } - else - { - bool flag2 = File.Exists(path); - if (flag2) - { - byte[] data = File.ReadAllBytes(path); - Texture2D texture2D2 = new Texture2D(width, height, format, false); - bool flag3 = texture2D2.LoadImage(data); - if (flag3) - { - ImageUtils.textureCache.Add(path, texture2D2); - return texture2D2; - } - } - else - { - Console.WriteLine("[ImageUtils] ERROR: File not found " + path); - } - result = null; - } - return result; - } + public static Texture2D LoadTexture(string path, TextureFormat format = TextureFormat.BC7, int width = 2, int height = 2) + { + Texture2D texture2D; + bool flag = ImageUtils.textureCache.TryGetValue(path, out texture2D); + Texture2D result; + if (flag) + { + result = texture2D; + } + else + { + bool flag2 = File.Exists(path); + if (flag2) + { + byte[] data = File.ReadAllBytes(path); + Texture2D texture2D2 = new Texture2D(width, height, format, false); + bool flag3 = texture2D2.LoadImage(data); + if (flag3) + { + ImageUtils.textureCache.Add(path, texture2D2); + return texture2D2; + } + } + else + { + Console.WriteLine("[ImageUtils] ERROR: File not found " + path); + } + result = null; + } + return result; + } - public static Sprite TextureToSprite(Texture2D tex, Vector2 pivot = default(Vector2), float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight, Vector4 border = default(Vector4)) - { - return Sprite.Create(tex, new Rect(0f, 0f, (float)tex.width, (float)tex.height), pivot, pixelsPerUnit, 0U, spriteType, border); - } - } + public static Sprite TextureToSprite(Texture2D tex, Vector2 pivot = default(Vector2), float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight, Vector4 border = default(Vector4)) + { + return Sprite.Create(tex, new Rect(0f, 0f, (float)tex.width, (float)tex.height), pivot, pixelsPerUnit, 0U, spriteType, border); + } + } } From b0c2e4823e9f5d6b65bf3a9495469b514f1fb777 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:47:22 +0700 Subject: [PATCH 10/26] Delete AdvancedHighlighting.csproj --- AdvancedHighlighting.csproj | 349 ------------------------------------ 1 file changed, 349 deletions(-) delete mode 100644 AdvancedHighlighting.csproj diff --git a/AdvancedHighlighting.csproj b/AdvancedHighlighting.csproj deleted file mode 100644 index 714a405..0000000 --- a/AdvancedHighlighting.csproj +++ /dev/null @@ -1,349 +0,0 @@ - - - - - Debug - AnyCPU - {ADB59190-BC97-4509-AB62-C64A4D9A93EC} - Library - Properties - AdvancedHighlighting - AdvancedHighlighting - v4.8 - 512 - true - - - - true - full - true - bin\BZ\ - BZ - prompt - 4 - true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - bin\BZ\ - - - bin\SN\ - - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\BepInEx\core\0Harmony20.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Assembly-CSharp.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Assembly-CSharp-firstpass.dll - - - False - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Newtonsoft.Json.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\BepInEx\plugins\QModManager\QModInstaller.dll - - - D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\SMLHelper_BZ\SMLHelper.dll - - - - - - - - - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Addressables.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Burst.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Burst.Unsafe.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Collections.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Formats.Fbx.Runtime.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.InternalAPIEngineBridge.001.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Mathematics.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.MemoryProfiler.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.PlayableGraphVisualizer.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ProBuilder.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ProBuilder.KdTree.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ProBuilder.Poly2Tri.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ProBuilder.Stl.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Recorder.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ResourceManager.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.ScriptableBuildPipeline.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.TextMeshPro.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Timeline.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AccessibilityModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AIModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AndroidJNIModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AnimationModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ARModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AssetBundleModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.AudioModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ClothModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ClusterInputModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ClusterRendererModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.CoreModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.CrashReportingModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.DirectorModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.DSPGraphModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.GameCenterModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.GridModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.HotReloadModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ImageConversionModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.IMGUIModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.InputLegacyModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.InputModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.JSONSerializeModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.LocalizationModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ParticleSystemModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.PerformanceReportingModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.Physics2DModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.PhysicsModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ProfilerModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.ScreenCaptureModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.SharedInternalsModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.SpriteMaskModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.SpriteShapeModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.StreamingModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.SubstanceModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.SubsystemsModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TerrainModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TerrainPhysicsModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TextCoreModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TextRenderingModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TilemapModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.TLSModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UI.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UIElementsModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UIModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UmbraModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UNETModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityAnalyticsModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityConnectModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityTestProtocolModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityWebRequestAssetBundleModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityWebRequestModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.VehiclesModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.VFXModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.VideoModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.VRModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.WindModule.dll - - - D:\SteamLibrary\SteamApps\common\SubnauticaZero\SubnauticaZero_Data\Managed\UnityEngine.XRModule.dll - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - if $(ConfigurationName) == BZ ( -mkdir "D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\$(TargetName)" -xcopy /Y "$(TargetPath)" "D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\$(TargetName)" -copy /Y "$(ProjectDir)\mod_BZ.json" "D:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\$(TargetName)\mod.json" -del "D:\SteamLibrary\steamapps\common\SubnauticaZero\qmodmanager_log-SubnauticaZero.txt" ) - -if $(ConfigurationName) == SN ( -mkdir "D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(TargetName)" -xcopy /Y "$(TargetPath)" "D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(TargetName)" -copy /Y "$(ProjectDir)\mod_SN.json" "D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(TargetName)\mod.json" -del "D:\SteamLibrary\steamapps\common\Subnautica\qmodmanager_log-Subnautica.txt") - - \ No newline at end of file From 4d96c3d3b149cc8bddf4ecf5bf2057039bfb972b Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:47:34 +0700 Subject: [PATCH 11/26] Delete HighlightEnum.cs --- HighlightEnum.cs | 85 ------------------------------------------------ 1 file changed, 85 deletions(-) delete mode 100644 HighlightEnum.cs diff --git a/HighlightEnum.cs b/HighlightEnum.cs deleted file mode 100644 index 55f2527..0000000 --- a/HighlightEnum.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -#if SN -#elif BZ -#endif - -namespace AdvancedHighlighting -{ - public enum Highlight - { - ScannableItems, - ScannableFragments, - ScannedFragments, - AnythingElse, - - Pickupable, - PickupableCreatures, - PickupableResource, - BreakableResource, - Interactables, - StoryItems, - JukeboxDisk, - SealedDoor, - GrownPlant, - Bladderfish, - CreatureEgg, - BaseLadder, - LaserCutObject - } - public static class HighlightExtenstions - { - private static readonly Dictionary highlightToText = new Dictionary() - { - [Highlight.ScannableItems] = "Scannable Items", - [Highlight.ScannableFragments] = "Scannable Fragments", - [Highlight.ScannedFragments] = "Already Scanned Fragments", - [Highlight.AnythingElse] = "Anything Else", - - [Highlight.Pickupable] = "Pickupable Items", - [Highlight.PickupableCreatures] = "Pickupable Creatures", - [Highlight.PickupableResource] = "Pickupable Resources", - [Highlight.BreakableResource] = "Breakable Outcrops", - [Highlight.Interactables] = "Interactables", - [Highlight.StoryItems] = "PDA Logs", - [Highlight.JukeboxDisk] = "Jukebox Disks", - [Highlight.SealedDoor] = "Sealed Ship Doors", - [Highlight.GrownPlant] = "Grown Plant", - [Highlight.Bladderfish] = "Bladder Fish", - [Highlight.CreatureEgg] = "Creature Egg", - [Highlight.BaseLadder] = "Base Ladder", - [Highlight.LaserCutObject] = "Laser Cut Object", - }; - private static readonly Dictionary highlightToType = new Dictionary() - { - [Highlight.Pickupable] = typeof(Pickupable), - [Highlight.PickupableCreatures] = typeof(Creature), - [Highlight.PickupableResource] = typeof(ResourceTracker), - [Highlight.BreakableResource] = typeof(BreakableResource), - [Highlight.Interactables] = typeof(HandTarget), - [Highlight.StoryItems] = typeof(StoryHandTarget), - [Highlight.JukeboxDisk] = typeof(JukeboxDisk), - [Highlight.SealedDoor] = typeof(StarshipDoor), - [Highlight.GrownPlant] = typeof(GrownPlant), - [Highlight.Bladderfish] = typeof(Bladderfish), - [Highlight.CreatureEgg] = typeof(CreatureEgg), - [Highlight.BaseLadder] = typeof(BaseLadder), - [Highlight.LaserCutObject] = typeof(Sealed), - }; - private static readonly List notComponentHighlights = new List() - { - Highlight.ScannableItems, - Highlight.ScannableFragments, - Highlight.ScannedFragments, - Highlight.AnythingElse - }; - public static bool IsPressent(this Highlight highlight, UnityEngine.Behaviour behaviour) => - highlight.IsComponent() && behaviour.TryGetComponent(highlight.GetComponentType(), out _); - public static bool IsPressentAndActive(this Highlight highlight, UnityEngine.Behaviour behaviour) => - highlight.IsComponent() && highlight.IsActive() && behaviour.TryGetComponent(highlight.GetComponentType(), out _); - public static bool IsActive(this Highlight highlight) => Settings.GetInstance().IsHighlightActive(highlight); - public static bool IsComponent(this Highlight highlight) => !notComponentHighlights.Contains(highlight); - public static string GetName(this Highlight highlight) => highlightToText.TryGetValue(highlight, out string name) ? name : null; - public static Type GetComponentType(this Highlight highlight) => highlightToType.TryGetValue(highlight, out Type type) ? type : null; - } -} \ No newline at end of file From 2c149e32fb4df624ddf6c4f9d9231e74113efda5 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:47:45 +0700 Subject: [PATCH 12/26] Delete HighlightingMod.cs --- HighlightingMod.cs | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 HighlightingMod.cs diff --git a/HighlightingMod.cs b/HighlightingMod.cs deleted file mode 100644 index 4ea5686..0000000 --- a/HighlightingMod.cs +++ /dev/null @@ -1,23 +0,0 @@ -using HarmonyLib; -using QModManager.API.ModLoading; -using SMLHelper.V2.Handlers; -using System; -#if SN -#elif BZ -#endif - -namespace AdvancedHighlighting -{ - [QModCore] - - public static class HighlightingMod - { - [QModPatch] - public static void InitMod() - { - Console.WriteLine("[AdvancedHighlighting] Start Patching..."); - Harmony harmony = new Harmony("net.ogmods.highlighting"); - harmony.PatchAll(); - } - } -} \ No newline at end of file From 6e4e6055d7f8f7e0251b554f678cbe3bfe221bf5 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:47:57 +0700 Subject: [PATCH 13/26] Delete HighlightingMod.cs.test --- HighlightingMod.cs.test | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 HighlightingMod.cs.test diff --git a/HighlightingMod.cs.test b/HighlightingMod.cs.test deleted file mode 100644 index 214c44c..0000000 --- a/HighlightingMod.cs.test +++ /dev/null @@ -1,28 +0,0 @@ -using HarmonyLib; -using QModManager.API.ModLoading; -using SMLHelper.V2.Handlers; -using System; -#if SN -#elif BZ -#endif - -namespace AdvancedHighlighting -{ - [QModCore] - - public static class HighlightingMod - { - internal static IngameConfigMenu Config { get; private set; } - - [QModPatch] - public static void InitMod() - { - Console.WriteLine("[AdvancedHighlighting] Start Patching..."); - Harmony harmony = new Harmony("net.ogmods.highlighting"); - harmony.PatchAll(); - - //Add the Ingame Config for User - Config = OptionsPanelHandler.Main.RegisterModOptions(); - } - } -} \ No newline at end of file From 1904e7780be6de57afafed20face48c18b6ede88 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:48:09 +0700 Subject: [PATCH 14/26] Delete ImageUtils.cs --- ImageUtils.cs | 109 -------------------------------------------------- 1 file changed, 109 deletions(-) delete mode 100644 ImageUtils.cs diff --git a/ImageUtils.cs b/ImageUtils.cs deleted file mode 100644 index fd46c66..0000000 --- a/ImageUtils.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using UnityEngine; -#if SN -#elif BZ -#endif - -namespace AdvancedHighlighting -{ - public static class ImageUtils - { - private static Dictionary textureCache = new Dictionary(); - - private static Dictionary spriteCache = new Dictionary(); - public static Sprite LoadSprite(string path, Vector2 pivot = default(Vector2), TextureFormat format = TextureFormat.BC7, float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight) - { - Sprite sprite; - bool flag = ImageUtils.spriteCache.TryGetValue(path, out sprite); - Sprite result; - if (flag) - { - result = sprite; - } - else - { - Texture2D texture2D = ImageUtils.LoadTexture(path, format, 2, 2); - bool flag2 = !texture2D; - if (flag2) - { - result = null; - } - else - { - Sprite sprite2 = ImageUtils.TextureToSprite(texture2D, pivot, pixelsPerUnit, spriteType, default(Vector4)); - ImageUtils.spriteCache.Add(path, sprite2); - result = sprite2; - } - } - return result; - } - - public static Sprite Load9SliceSprite(string path, RectOffset slices, Vector2 pivot = default(Vector2), TextureFormat format = TextureFormat.BC7, float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight) - { - string key = path + slices; - Sprite sprite; - bool flag = ImageUtils.spriteCache.TryGetValue(key, out sprite); - Sprite result; - if (flag) - { - result = sprite; - } - else - { - Texture2D texture2D = ImageUtils.LoadTexture(path, format, 2, 2); - bool flag2 = !texture2D; - if (flag2) - { - result = null; - } - else - { - Vector4 border = new Vector4((float)slices.left, (float)slices.right, (float)slices.top, (float)slices.bottom); - Sprite sprite2 = ImageUtils.TextureToSprite(texture2D, pivot, pixelsPerUnit, spriteType, border); - ImageUtils.spriteCache.Add(key, sprite2); - result = sprite2; - } - } - return result; - } - - public static Texture2D LoadTexture(string path, TextureFormat format = TextureFormat.BC7, int width = 2, int height = 2) - { - Texture2D texture2D; - bool flag = ImageUtils.textureCache.TryGetValue(path, out texture2D); - Texture2D result; - if (flag) - { - result = texture2D; - } - else - { - bool flag2 = File.Exists(path); - if (flag2) - { - byte[] data = File.ReadAllBytes(path); - Texture2D texture2D2 = new Texture2D(width, height, format, false); - bool flag3 = texture2D2.LoadImage(data); - if (flag3) - { - ImageUtils.textureCache.Add(path, texture2D2); - return texture2D2; - } - } - else - { - Console.WriteLine("[ImageUtils] ERROR: File not found " + path); - } - result = null; - } - return result; - } - - public static Sprite TextureToSprite(Texture2D tex, Vector2 pivot = default(Vector2), float pixelsPerUnit = 100f, SpriteMeshType spriteType = SpriteMeshType.Tight, Vector4 border = default(Vector4)) - { - return Sprite.Create(tex, new Rect(0f, 0f, (float)tex.width, (float)tex.height), pivot, pixelsPerUnit, 0U, spriteType, border); - } - } -} \ No newline at end of file From a55a4796f9e64aca1beb9d2b83eb28e839ff23d2 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:48:19 +0700 Subject: [PATCH 15/26] Delete OldSettings.cs --- OldSettings.cs | 93 -------------------------------------------------- 1 file changed, 93 deletions(-) delete mode 100644 OldSettings.cs diff --git a/OldSettings.cs b/OldSettings.cs deleted file mode 100644 index 99c464e..0000000 --- a/OldSettings.cs +++ /dev/null @@ -1,93 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.IO; -#if SN -#elif BZ -#endif - -namespace AdvancedHighlighting -{ - public class OldSettings - { - private static readonly Dictionary TypeToHighlight = new Dictionary - { - [typeof(Pickupable)] = Highlight.Pickupable, - [typeof(ResourceTracker)] = Highlight.PickupableResource, - [typeof(Creature)] = Highlight.PickupableCreatures, - [typeof(Bladderfish)] = Highlight.Bladderfish, - [typeof(CreatureEgg)] = Highlight.CreatureEgg, - [typeof(BaseLadder)] = Highlight.BaseLadder, - [typeof(BreakableResource)] = Highlight.BreakableResource, - [typeof(HandTarget)] = Highlight.Interactables, - [typeof(GrownPlant)] = Highlight.GrownPlant, - [typeof(StoryHandTarget)] = Highlight.StoryItems, - [typeof(JukeboxDisk)] = Highlight.JukeboxDisk, - [typeof(StarshipDoor)] = Highlight.SealedDoor, - [typeof(Sealed)] = Highlight.LaserCutObject, - [Utils.FragmentsType] = Highlight.ScannableFragments, - [Utils.ScannableType] = Highlight.ScannableItems, - [Utils.EverythingType] = Highlight.AnythingElse, - }; - - public Dictionary enableHighlights; - public Dictionary highlightingColors; - public bool storyNearbyNotification = false; - public bool jukeboxDiskNotification = false; - public bool highlightEverythingExosuit = false; - public bool destoryNull = true; - public bool showPings = false; - public float highlightRadius = 20f; - public float minAlpha = 0f; - public static Settings Load() - { - Console.WriteLine("[AdvancedHighlighting] Loading Settings"); - string path = Path.Combine(Utils.ModDirectory, "settings.json"); - Settings settings = null; - if (File.Exists(path)) - { - try - { - var text = File.ReadAllText(path); - if (text.Contains("PublicKeyToken") || text.Contains("storyNearbyNotification")) - settings = JsonConvert.DeserializeObject(text).ConvertToNewSettings(); - else - settings = JsonConvert.DeserializeObject(text); - } - catch (Exception) { } - } - if (settings == null) settings = new Settings(); - if (settings.HighlightsEnabled == null) settings.HighlightsEnabled = new Dictionary(); - if (settings.HighlightsColor == null) settings.HighlightsColor = new Dictionary(); - foreach (var highlight in Utils.GetHighlights()) - { - if (!settings.HighlightsEnabled.ContainsKey(highlight)) settings.HighlightsEnabled[highlight] = true; - if (!settings.HighlightsColor.ContainsKey(highlight)) settings.HighlightsColor[highlight] = Settings.defaultColor; - } - settings.UpdateActiveHighlights(); - return settings; - } - public Settings ConvertToNewSettings() - { - var settings = new Settings - { - HighlightsEnabled = new Dictionary(), - HighlightsColor = new Dictionary(), - StoryNotification = storyNearbyNotification, - DisksNotification = jukeboxDiskNotification, - ExosuiteHighlightsEnabled = highlightEverythingExosuit, - DestroyNullPings = destoryNull, - ShowPings = showPings, - HighlightSearchDistance = highlightRadius, - MinimumAlpha = minAlpha, - }; - foreach (var highlight in enableHighlights) - if (TypeToHighlight.TryGetValue(highlight.Key, out Highlight val)) - settings.HighlightsEnabled[val] = highlight.Value; - foreach (var highlight in highlightingColors) - if (TypeToHighlight.TryGetValue(highlight.Key, out Highlight val)) - settings.HighlightsColor[val] = highlight.Value; - return settings; - } - } -} \ No newline at end of file From 96d7b1ca9204b119480f0b3a8d76cc191b2555a5 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:48:30 +0700 Subject: [PATCH 16/26] Delete Qmod.cs.test --- Qmod.cs.test | 55 ---------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 Qmod.cs.test diff --git a/Qmod.cs.test b/Qmod.cs.test deleted file mode 100644 index a41a959..0000000 --- a/Qmod.cs.test +++ /dev/null @@ -1,55 +0,0 @@ -using SMLHelper.V2.Json; -using SMLHelper.V2.Options.Attributes; -using UnityEngine; - -namespace AdvancedHighlighting -{ - [Menu("Advanced Highlighting", SaveOn = MenuAttribute.SaveEvents.ChangeValue)] - public class IngameConfigMenu : ConfigFile - { - public IngameConfigMenu() : base("config") { } - - [Toggle("Pickupable Items", Tooltip = "Highlight Pickupable Items.", Order = 1)] - public bool Pickupable = true; - - [Choice("Pickupable Color", Tooltip = "Select a color for Pickupable Items.", Options = new string[] {"Red", "16dcff"})] - public string PickupableColor = "fffb16"; - - [Toggle("Pickupable Creatures", Tooltip = "Highlight Pickupable Creatures.", Order = 2)] - public bool PickupableCreatures = true; - - [Toggle("Pickupable Resources", Tooltip = "Highlight Pickupable Resource.", Order = 3)] - public bool PickupableResource = true; - - [Toggle("Breakable Resources", Tooltip = "Highlight Breakable Resource.", Order = 4)] - public bool BreakableResource = true; - - [Toggle("Interactable Items", Tooltip = "Highlight Interactable Items.", Order = 5)] - public bool Interactables = true; - - [Toggle("Story Items", Tooltip = "Highlight Story Items.", Order = 6)] - public bool StoryItems = true; - - [Toggle("Jukebox Disks", Tooltip = "Highlight Jukebox Disks.", Order = 7)] - public bool JukeboxDisk = true; - - [Toggle("Sealed Doors", Tooltip = "Highlight Sealed Doors.", Order = 8)] - public bool SealedDoor = true; - - [Toggle("Grown Plants", Tooltip = "Highlight Grown Plants.", Order = 9)] - public bool GrownPlant = true; - - [Toggle("Bladder Fish", Tooltip = "Highlight Bladder Fish.", Order = 10)] - public bool Bladderfish = true; - - [Toggle("Creature Eggs", Tooltip = "Highlight Creature Eggs.", Order = 11)] - public bool CreatureEgg = true; - - [Toggle("Base Ladders", Tooltip = "Highlight Base Ladders.", Order = 12)] - public bool BaseLadder = true; - - [Toggle("Laser CutObjects", Tooltip = "Highlight Sealed Doors.", Order = 13)] - public bool LaserCutObject = true; - - } -} \ No newline at end of file From 1042debd4e987b0272d74c98e5f1b1c632fd11bd Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:48:40 +0700 Subject: [PATCH 17/26] Delete Settings.cs --- Settings.cs | 68 ----------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 Settings.cs diff --git a/Settings.cs b/Settings.cs deleted file mode 100644 index def3f1e..0000000 --- a/Settings.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.IO; -using UnityEngine; -#if SN -#elif BZ -#endif - -namespace AdvancedHighlighting -{ - public class Settings - { - public static readonly string defaultColor = "e0e238"; - public static readonly Color nullColor = new Color(0f, 0f, 0f, 0f); - [JsonIgnore] - public bool PresetApplied = false; - - public bool StoryNotification = false; - public bool DisksNotification = false; - public bool ShowPings = false; - public bool ExosuiteHighlightsEnabled = false; - public bool DestroyNullPings = true; - public float HighlightSearchDistance = 20f; - public float MinimumAlpha = 0f; - public int HighlightingRenderer = 1; - - public Dictionary HighlightsEnabled; - public Dictionary HighlightsColor; - - [JsonIgnore] - public List ActiveHighlights = new List(); - - [JsonIgnore] - private static Settings instance; - public static Settings GetInstance() - { - if (instance == null) - instance = OldSettings.Load(); - return instance; - } - public void Save() - { - Console.WriteLine("[AdvancedHighlighting] Saving Settings"); - File.WriteAllText(Path.Combine(Utils.ModDirectory, "settings.json"), JsonConvert.SerializeObject(this, Formatting.Indented)); - } - public void UpdateActiveHighlights() - { - ActiveHighlights.Clear(); - if (MiscSettings.highlighting) - { - foreach (var highlight in HighlightsEnabled) - if (highlight.Value) - ActiveHighlights.Add(highlight.Key); - //Console.WriteLine($"[AdvancedHighlighting] UpdateActiveHighlights {string.Join(",", ActiveHighlights)}..."); - } - } - - public bool IsHighlightActive(Highlight highlight) => - ActiveHighlights.Contains(highlight); - public bool IsHighlightEnabled(Highlight highlight) => - (HighlightsEnabled.TryGetValue(highlight, out bool e) ? e : MiscSettings.highlighting); - public Color GetHighlightColor(Highlight highlight) => - (HighlightsColor.TryGetValue(highlight, out string h) && ColorUtility.TryParseHtmlString("#" + h, out Color c) ? c : nullColor); - public string GetHtmlColor(Highlight highlight) => - (HighlightsColor.TryGetValue(highlight, out string h) ? h : null); - } -} \ No newline at end of file From 2f0e48f2eec0fb6d4ad556e10ebfda65b2d7b9b6 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:48:49 +0700 Subject: [PATCH 18/26] Delete Utils.cs --- Utils.cs | 169 ------------------------------------------------------- 1 file changed, 169 deletions(-) delete mode 100644 Utils.cs diff --git a/Utils.cs b/Utils.cs deleted file mode 100644 index 0d17216..0000000 --- a/Utils.cs +++ /dev/null @@ -1,169 +0,0 @@ -using HighlightingSystem; -using System; -using System.Collections.Generic; -using System.IO; -using UnityEngine; -using static PDAScanner; -#if SN -#elif BZ -#endif - -namespace AdvancedHighlighting -{ - public static class Utils - { - public static readonly Type FragmentsType = typeof(TechFragment); - public static readonly Type ScannableType = typeof(ScannerTarget); - public static readonly Type EverythingType = typeof(Utils); - public static readonly List Presets = new List - { - new HighlightingPreset { name = "Narrow", fillAlpha = 0f, downsampleFactor = 4, iterations = 2, blurMinSpread = 0.65f, blurSpread = 0.25f, blurIntensity = 0.3f, blurDirections = BlurDirections.Diagonal}, - new HighlightingPreset { name = "Wide (Game Default)", fillAlpha = 0f, downsampleFactor = 4, iterations = 4, blurMinSpread = 0.65f, blurSpread = 0.25f, blurIntensity = 0.3f, blurDirections = BlurDirections.Diagonal }, - new HighlightingPreset { name = "Strong", fillAlpha = 0f, downsampleFactor = 4, iterations = 2, blurMinSpread = 0.5f, blurSpread = 0.15f, blurIntensity = 0.325f, blurDirections = BlurDirections.Diagonal }, - new HighlightingPreset { name = "Speed", fillAlpha = 0f, downsampleFactor = 4, iterations = 1, blurMinSpread = 0.75f, blurSpread = 0f, blurIntensity = 0.35f, blurDirections = BlurDirections.Diagonal }, - new HighlightingPreset { name = "Quality", fillAlpha = 0f, downsampleFactor = 2, iterations = 3, blurMinSpread = 0.5f, blurSpread = 0.5f, blurIntensity = 0.28f, blurDirections = BlurDirections.Diagonal }, - new HighlightingPreset { name = "Solid 1px", fillAlpha = 0f, downsampleFactor = 1, iterations = 1, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, - new HighlightingPreset { name = "Solid 2px", fillAlpha = 0f, downsampleFactor = 1, iterations = 2, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, - new HighlightingPreset { name = "Solid 3px", fillAlpha = 0f, downsampleFactor = 1, iterations = 3, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, - new HighlightingPreset { name = "Solid 4px", fillAlpha = 0f, downsampleFactor = 1, iterations = 4, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All }, - new HighlightingPreset { name = "Solid 5px", fillAlpha = 0f, downsampleFactor = 1, iterations = 5, blurMinSpread = 1f, blurSpread = 0f, blurIntensity = 1f, blurDirections = BlurDirections.All } - }; - public static Highlight[] GetHighlights() => (Highlight[])Enum.GetValues(typeof(Highlight)); - private static Sprite eyeSprite; - public static bool GetEyeSprite(out Sprite sprite) - { - if (eyeSprite == null && File.Exists(Path.Combine(ModDirectory, "Assets", "Eye.png"))) - eyeSprite = ImageUtils.LoadSprite(Path.Combine(ModDirectory, "Assets", "Eye.png"), new Vector2(0.5f, 0.5f), TextureFormat.BC7, 100f, SpriteMeshType.Tight); - sprite = eyeSprite; - return (sprite != null); - } - public static bool GetColorForType(string type, out Color newColor) - { - if (type == "story") - { - newColor = Settings.GetInstance().GetHighlightColor(Highlight.StoryItems); - return true; - } - else if (type == "disk") - { - newColor = Settings.GetInstance().GetHighlightColor(Highlight.JukeboxDisk); - return true; - } - newColor = Settings.nullColor; - return false; - } - public static List GetHighlightsForObject(this GameObject gameObject, out GameObject targetObject, out Behaviour behaviour) - { - var supported = new List(); - targetObject = null; - behaviour = null; - if (gameObject == null) - return supported; - if (Targeting.GetRoot(gameObject, out TechType techType, out GameObject result)) - { - var scannableFragments = Settings.GetInstance().IsHighlightActive(Highlight.ScannableFragments); - targetObject = result; - if (PDAScanner.IsFragment(techType)) - { - if (!PDAScanner.ContainsCompleteEntry(techType)) - { - if (scannableFragments) supported.Add(Highlight.ScannableFragments); - } - else if (techType.GetEntryData(out EntryData data)) - { - if (data.destroyAfterScan && Highlight.ScannedFragments.IsActive()) supported.Add(Highlight.ScannedFragments); - } - } - else if (result != null) - { - if (techType.GetEntryData(out EntryData data) && PDAScanner.CanScan(result)) - { - if (data.blueprint > 0 && scannableFragments) - supported.Add(Highlight.ScannableFragments); - else if (data.blueprint == 0 && Highlight.ScannableItems.IsActive()) - supported.Add(Highlight.ScannableItems); - } - } - } - behaviour = gameObject.GetComponentInParent() as Behaviour; - if (behaviour != null) - { - if (Highlight.BreakableResource.IsPressent(behaviour)) - { - if (Highlight.BreakableResource.IsActive()) supported.Add(Highlight.BreakableResource); - } - else if (Highlight.PickupableResource.IsPressent(behaviour)) - { - if (Highlight.CreatureEgg.IsPressent(behaviour)) - { - if (Highlight.CreatureEgg.IsActive()) supported.Add(Highlight.CreatureEgg); - } - else - { - if (Highlight.PickupableResource.IsActive()) supported.Add(Highlight.PickupableResource); - } - } - else if (Highlight.PickupableCreatures.IsPressent(behaviour)) - { - if (Highlight.Bladderfish.IsPressent(behaviour)) - { - if (Highlight.Bladderfish.IsActive()) supported.Add(Highlight.Bladderfish); - } - else - { - if (Highlight.PickupableCreatures.IsActive()) supported.Add(Highlight.PickupableCreatures); - } - } - else if (Highlight.Pickupable.IsPressent(behaviour)) - { - if (Highlight.Pickupable.IsActive()) supported.Add(Highlight.Pickupable); - } - else if (Highlight.Interactables.IsPressent(behaviour)) - { - if(Highlight.BaseLadder.IsPressent(behaviour)) - { - if (Highlight.BaseLadder.IsActive()) supported.Add(Highlight.BaseLadder); - } - else if (Highlight.GrownPlant.IsPressent(behaviour)) - { - if (Highlight.GrownPlant.IsActive()) supported.Add(Highlight.GrownPlant); - } - else if (Highlight.SealedDoor.IsPressent(behaviour)) - { - if (Highlight.SealedDoor.IsActive()) supported.Add(Highlight.SealedDoor); - } - else if (Highlight.LaserCutObject.IsPressent(behaviour)) - { - if (Highlight.LaserCutObject.IsActive()) supported.Add(Highlight.LaserCutObject); - } - else - { - if (Highlight.Interactables.IsActive()) supported.Add(Highlight.Interactables); - } - } - - if (Highlight.StoryItems.IsPressentAndActive(behaviour)) supported.Add(Highlight.StoryItems); - if (Highlight.JukeboxDisk.IsPressentAndActive(behaviour)) supported.Add(Highlight.JukeboxDisk); - if (supported.Count == 0 && Highlight.AnythingElse.IsActive()) supported.Add(Highlight.AnythingElse); - } - //if (!logged.Contains(gameObject.GetInstanceID())) - //{ - // var types1 = gameObject.GetComponents().Select(x => x.GetType()); - // var types2 = behaviour?.gameObject?.GetComponents().Select(x => x.GetType()); - // Console.WriteLine($"[AdvancedHighlighting] GetSupportedComponentsTypes ([{gameObject.GetInstanceID()}] {gameObject.name},[{behaviour?.gameObject?.GetInstanceID()}] {behaviour?.gameObject?.name}), Supported = ({string.Join(", ", supported)}), Types1 = ({string.Join(", ", types1)}), Types2 = ({(types2 != null ? string.Join(", ", types2) : "")})"); - // logged.Add(gameObject.GetInstanceID()); - //} - return supported; - } - //private static readonly List logged = new List(); - public static string ModDirectory - { - get => Environment.CurrentDirectory + "\\QMods\\AdvancedHighlighting\\"; - } - public static bool GetEntryData(this TechType tech, out EntryData data) - { - data = PDAScanner.GetEntryData(tech); - return data != null; - } - } -} \ No newline at end of file From 6d891a16bdbb7db47778714cde74204914889ac9 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:50:46 +0700 Subject: [PATCH 19/26] Delete uGUI_Pings_Patch.cs --- Patches/uGUI_Pings_Patch.cs | 51 ------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 Patches/uGUI_Pings_Patch.cs diff --git a/Patches/uGUI_Pings_Patch.cs b/Patches/uGUI_Pings_Patch.cs deleted file mode 100644 index 8821450..0000000 --- a/Patches/uGUI_Pings_Patch.cs +++ /dev/null @@ -1,51 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using UnityEngine; - -namespace AdvancedHighlighting.Patches -{ - public static class uGUI_Pings_Patch - { - private static readonly FieldInfo pingsField = typeof(uGUI_Pings).GetField("pings", BindingFlags.Instance | BindingFlags.NonPublic); - public static Dictionary GetPings(uGUI_Pings instance) => - (Dictionary)pingsField.GetValue(instance); - } - - [HarmonyPatch(typeof(uGUI_Pings), "OnAdd", new Type[] { typeof(PingInstance) })] - public static class uGUI_Pings_OnAdd_Patch - { - public static void Postfix(uGUI_Pings __instance, PingInstance instance) - { - var id = instance._id; - if (!id.StartsWith("ahping_")) return; - var pings = uGUI_Pings_Patch.GetPings(__instance); - if (pings != null && pings.TryGetValue(id, out uGUI_Ping ping)) - { - //Console.WriteLine($"[AdvancedHighlighting] OnAdd Ping {id} {Utils.GetEyeSprite(out _)}..."); - if (Utils.GetColorForType(id.Split('_')[1], out Color newColor)) - ping.SetColor(newColor); - if (Utils.GetEyeSprite(out Sprite sprite)) - ping.SetIcon(sprite); - } - } - } - - [HarmonyPatch(typeof(uGUI_Pings), "OnColor", new Type[] { typeof(string), typeof(Color) })] - public static class uGUI_Pings_OnColor_Patch - { - public static void Postfix(uGUI_Pings __instance, string id, Color color) - { - if (id.StartsWith("ahping_")) - { - //Console.WriteLine($"[AdvancedHighlighting] OnColor Ping {id}, {pings?.Count}..."); - var pings = uGUI_Pings_Patch.GetPings(__instance); - if (pings != null && pings.TryGetValue(id, out uGUI_Ping ping)) - if (Utils.GetColorForType(id.Split('_')[1], out Color newColor)) - ping.SetColor(newColor); - } - } - } -} From 6c723715dccc009dbf3cfd2a85df670dfff06139 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:50:53 +0700 Subject: [PATCH 20/26] Delete uGUI_OptionsPanel_Patch.cs --- Patches/uGUI_OptionsPanel_Patch.cs | 130 ----------------------------- 1 file changed, 130 deletions(-) delete mode 100644 Patches/uGUI_OptionsPanel_Patch.cs diff --git a/Patches/uGUI_OptionsPanel_Patch.cs b/Patches/uGUI_OptionsPanel_Patch.cs deleted file mode 100644 index 093f2d5..0000000 --- a/Patches/uGUI_OptionsPanel_Patch.cs +++ /dev/null @@ -1,130 +0,0 @@ -using HarmonyLib; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using UnityEngine.Events; -using UnityEngine.UI; -#if SN -#elif BZ -#endif - -namespace AdvancedHighlighting.Patches -{ - [HarmonyPatch(typeof(uGUI_OptionsPanel), "OnDisable")] - public class uGUI_OptionsPanel_OnDisable_Patch - { - public static void Prefix() - { - Settings.GetInstance().Save(); - } - } - - [HarmonyPatch(typeof(uGUI_OptionsPanel), "AddAccessibilityTab")] - public class uGUI_OptionsPanel_AddAccessibilityTab_Patch - { - private static readonly Dictionary toggleOptions = new Dictionary(); - private static readonly Dictionary colorOptions = new Dictionary(); - private static readonly List options = new List(); - - private static void UpdatePingColors() - { - foreach (var pingKey in Highlighting_OnUpdate_Patch.pings.Keys) - { - var ping = PingManager.Get(Highlighting_OnUpdate_Patch.pings[pingKey]); - if (ping != null) - ping.SetColor(1); - } - } - public static bool Prefix(uGUI_OptionsPanel __instance) - { - var settings = Settings.GetInstance(); - int tabIndex = __instance.AddTab("Accessibility"); - options.Clear(); - toggleOptions.Clear(); - colorOptions.Clear(); - __instance.AddSliderOption(tabIndex, "UIScale", MiscSettings.GetUIScale(DisplayOperationMode.Current), 0.7f, 1.4f, 1f, 0.01f, (value) => - { - MiscSettings.SetUIScale(value, DisplayOperationMode.Current); - }, SliderLabelMode.Float, "0.00"); - __instance.AddToggleOption(tabIndex, "PDAPause", MiscSettings.pdaPause, new UnityAction((val) => MiscSettings.pdaPause = val), null); - __instance.AddToggleOption(tabIndex, "Flashes", MiscSettings.flashes, new UnityAction((val) => MiscSettings.flashes = val), null); - //highlightingColorOption = __instance.AddColorOption(tabIndex, "HighlightingColor", MiscSettings.highlightingColor, new UnityAction((val) => MiscSettings.highlightingColor = val )); - - __instance.AddHeading(tabIndex, "Advanced Highlighting"); - __instance.AddToggleOption(tabIndex, "Enable Highlighting", MiscSettings.highlighting, new UnityAction(OnHighlightingChanged), null); - - options.Add(__instance.AddChoiceOption(tabIndex, "Highlighting Renderer", Utils.Presets.Select(x => x.name).ToArray(), settings.HighlightingRenderer, new UnityAction((val) => - { - settings.HighlightingRenderer = val; - settings.PresetApplied = false; - }), null).gameObject); - //__instance.AddToggleOption(tabIndex, "Destrey Nulls", settings.destoryNull, new UnityAction((val) => settings.destoryNull = val), null); - options.Add(__instance.AddToggleOption(tabIndex, "Notify about nearby PDA Logs", settings.StoryNotification, new UnityAction((val) => settings.StoryNotification = val), null).gameObject); - options.Add(__instance.AddToggleOption(tabIndex, "Notify about nearby Jukebox Disks", settings.DisksNotification, new UnityAction((val) => settings.DisksNotification = val), null).gameObject); - options.Add(__instance.AddToggleOption(tabIndex, "Show pings for PDA Logs and Disks", settings.ShowPings, new UnityAction((val) => - { - settings.ShowPings = val; - TogglePings(); - }), null).gameObject); - - options.Add(__instance.AddToggleOption(tabIndex, "Highlight while in Exosuit", settings.ExosuiteHighlightsEnabled, new UnityAction((val) => settings.ExosuiteHighlightsEnabled = val), null).gameObject); - options.Add(__instance.AddSliderOption(tabIndex, "Highlight search radius", settings.HighlightSearchDistance, 10f, 100f, 20f, 0.5f, (value) => - { - settings.HighlightSearchDistance = value; - }, SliderLabelMode.Float, "0.0")); - options.Add(__instance.AddSliderOption(tabIndex, "Minimum allowed fade value", settings.MinimumAlpha, 0f, 1f, 0f, 0.1f, (value) => - { - settings.MinimumAlpha = value; - }, SliderLabelMode.Float, "0.0")); - foreach (var highlight in Utils.GetHighlights()) - { - toggleOptions[highlight] = __instance.AddToggleOption(tabIndex, $"Highlight {highlight.GetName()}", settings.IsHighlightEnabled(highlight), new UnityAction((val) => - { - settings.HighlightsEnabled[highlight] = val; - if (colorOptions.TryGetValue(highlight, out GameObject color)) - color.SetActive(val); - settings.UpdateActiveHighlights(); - }), null); - colorOptions[highlight] = __instance.AddColorOption(tabIndex, $"{highlight.GetName()} color", settings.GetHighlightColor(highlight), new UnityAction((val) => - { - settings.HighlightsColor[highlight] = ColorUtility.ToHtmlStringRGBA(val); - if ((highlight == Highlight.StoryItems || highlight == Highlight.JukeboxDisk) && settings.ShowPings) - UpdatePingColors(); - })); - } - OnHighlightingChanged(MiscSettings.highlighting); - return false; - } - private static void TogglePings() - { - if (!MiscSettings.highlighting || !Settings.GetInstance().ShowPings) - { - foreach (var pingKey in Highlighting_OnUpdate_Patch.pings.Keys) - { - var ping = PingManager.Get(Highlighting_OnUpdate_Patch.pings[pingKey]); - if (ping != null) - UnityEngine.Object.Destroy(ping); - } - Highlighting_OnUpdate_Patch.pings.Clear(); - } - else - { - Highlighting_OnUpdate_Patch.stories.Clear(); - } - } - private static void OnHighlightingChanged(bool value) - { - MiscSettings.highlighting = value; - TogglePings(); - foreach (var gameObject in options) - if (gameObject != null) - gameObject.SetActive(value); - foreach (var highlight in Utils.GetHighlights()) - { - toggleOptions[highlight].gameObject.SetActive(value); - colorOptions[highlight].SetActive(value && toggleOptions[highlight].isOn); - } - Settings.GetInstance().UpdateActiveHighlights(); - } - } -} \ No newline at end of file From 8953bd360b8d3e505a28232d8d2b731bf522cc40 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:51:01 +0700 Subject: [PATCH 21/26] Delete SaveLoadManager_Patch.cs --- Patches/SaveLoadManager_Patch.cs | 34 -------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 Patches/SaveLoadManager_Patch.cs diff --git a/Patches/SaveLoadManager_Patch.cs b/Patches/SaveLoadManager_Patch.cs deleted file mode 100644 index b2cad82..0000000 --- a/Patches/SaveLoadManager_Patch.cs +++ /dev/null @@ -1,34 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AdvancedHighlighting.Patches -{ - [HarmonyPatch(typeof(SaveLoadManager), "NotifySaveInProgress", new Type[] { typeof(bool) })] - public static class SaveLoadManager_NotifySaveInProgress_Patch - { - public static void Postfix(SaveLoadManager __instance, bool isInProgress) - { - if (!Settings.GetInstance().ShowPings) - return; - if (isInProgress) - { - foreach (var pingKey in Highlighting_OnUpdate_Patch.pings.Keys) - { - var ping = PingManager.Get(Highlighting_OnUpdate_Patch.pings[pingKey]); - if (ping != null) - UnityEngine.Object.Destroy(ping); - } - Highlighting_OnUpdate_Patch.pings.Clear(); - } - else - { - Highlighting_OnUpdate_Patch.stories.Clear(); - } - } - } -} \ No newline at end of file From dc1b8d84fded15395c655ef42f0eda99f166da1f Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:51:08 +0700 Subject: [PATCH 22/26] Delete PingInstance_Patch.cs --- Patches/PingInstance_Patch.cs | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 Patches/PingInstance_Patch.cs diff --git a/Patches/PingInstance_Patch.cs b/Patches/PingInstance_Patch.cs deleted file mode 100644 index c5d0bcf..0000000 --- a/Patches/PingInstance_Patch.cs +++ /dev/null @@ -1,32 +0,0 @@ -using HarmonyLib; -using System; -using System.Reflection; -using UnityEngine; - -namespace AdvancedHighlighting.Patches -{ - public static class PingInstance_Patch - { - private static readonly FieldInfo fakePositionUsedField = typeof(PingInstance).GetField("fakePositionUsed", BindingFlags.Instance | BindingFlags.NonPublic); - public static bool GetFakePositionUsed(PingInstance instance) => - (bool)fakePositionUsedField.GetValue(instance); - } - [HarmonyPatch(typeof(PingInstance), "GetPosition")] - public static class PingInstance_GetPosition_Patch - { - public static bool Prefix(PingInstance __instance, ref Vector3 __result) - { - if (__instance == null || (__instance.origin == null && !PingInstance_Patch.GetFakePositionUsed(__instance))) - { - if (__instance != null && Settings.GetInstance().DestroyNullPings) - { - UnityEngine.Object.Destroy(__instance); - Console.WriteLine($"[AdvancedHighlighting] Destroying {__instance._id}..."); - } - __result = Vector3.zero; - return false; - } - return true; - } - } -} \ No newline at end of file From 6f36ba1850b7e9b11d14a5900c1fc689dbaae40f Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:51:17 +0700 Subject: [PATCH 23/26] Delete Highlighting_Patch.cs --- Patches/Highlighting_Patch.cs | 248 ---------------------------------- 1 file changed, 248 deletions(-) delete mode 100644 Patches/Highlighting_Patch.cs diff --git a/Patches/Highlighting_Patch.cs b/Patches/Highlighting_Patch.cs deleted file mode 100644 index 79ea5ef..0000000 --- a/Patches/Highlighting_Patch.cs +++ /dev/null @@ -1,248 +0,0 @@ -using HarmonyLib; -using HighlightingSystem; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; -using UWE; - -namespace AdvancedHighlighting.Patches -{ - public static class Highlighting_Patch - { - private static MethodInfo updateActiveHighlightersAsyncMethod; - private static readonly FieldInfo highlightersField = typeof(Highlighting).GetField("highlighters", BindingFlags.Instance | BindingFlags.NonPublic); - private static readonly FieldInfo handlersField = typeof(Highlighting).GetField("handlers", BindingFlags.Instance | BindingFlags.NonPublic); - private static readonly FieldInfo updateActiveHighligtersCoroutineField = typeof(Highlighting).GetField("updateActiveHighligtersCoroutine", BindingFlags.Instance | BindingFlags.NonPublic); - public static HashSet GetHighlighters(this Highlighting instance) => - (HashSet)highlightersField.GetValue(instance); - public static Dictionary GetHandlers(this Highlighting instance) => - (Dictionary)handlersField.GetValue(instance); - public static Coroutine GetUpdateActiveHighligtersCoroutine(this Highlighting instance) => - (Coroutine)updateActiveHighligtersCoroutineField.GetValue(instance); - public static void SetUpdateActiveHighligtersCoroutine(this Highlighting instance, Coroutine coroutine) => - updateActiveHighligtersCoroutineField.SetValue(instance, coroutine); - public static System.Collections.IEnumerator InvokeUpdateActiveHighlightersAsync(this Highlighting instance, Vector3 vector) - { - if (updateActiveHighlightersAsyncMethod == null) - updateActiveHighlightersAsyncMethod = typeof(Highlighting).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).Where(x => x.Name == "UpdateActiveHighlightersAsync").FirstOrDefault(); - return (System.Collections.IEnumerator)updateActiveHighlightersAsyncMethod.Invoke(instance, new object[] { vector }); - } - - } - [HarmonyPatch(typeof(Highlighting), "OnUpdate")] - public class Highlighting_OnUpdate_Patch - { - public static readonly Dictionary stories = new Dictionary(); - public static readonly Dictionary pings = new Dictionary(); - public static readonly List notifications = new List(); - private static int lastActiveTargetId = 0; - private static float hoverStart = 0f; - public static bool isLogged = false; - public static bool Prefix(Highlighting __instance) - { - Highlighting.Mode mode = Highlighting.GetMode(); - var settings = Settings.GetInstance(); - if (mode == Highlighting.Mode.None || settings.ActiveHighlights.Count == 0) - { - lastActiveTargetId = 0; - } - else - { - var time = Time.time; - Vector3 vector = MainCamera.camera?.transform.position ?? Vector3.zero; - GameObject gameObject = null; - if (mode == Highlighting.Mode.Exosuit) gameObject = (Player.main.GetVehicle() as Exosuit).GetActiveTarget(); - else if (mode == Highlighting.Mode.Player) gameObject = Player.main?.guiHand?.GetActiveTarget(); - int id = gameObject?.GetInstanceID() ?? 0; - if (lastActiveTargetId != id) - { - hoverStart = time; - lastActiveTargetId = id; - } - if (__instance.GetUpdateActiveHighligtersCoroutine() == null) - { - if (__instance.radiusOuter != settings.HighlightSearchDistance) - __instance.radiusOuter = settings.HighlightSearchDistance; - __instance.SetUpdateActiveHighligtersCoroutine(__instance.StartCoroutine(__instance.InvokeUpdateActiveHighlightersAsync(vector))); - } - - var highlighters = __instance.GetHighlighters(); - if (settings.StoryNotification || settings.DisksNotification || settings.ShowPings) - { - var removed = new List(); - foreach (var key in stories.Keys) - { - if (!highlighters.Any(x => x.GetInstanceID() == key)) - removed.Add(key); - } - foreach (var key in removed) - { - if (notifications.Contains(key)) - { - notifications.Remove(key); - ErrorMessage.AddMessage($"[Advanced Highlighting] {Language.main.Get(stories[key])} is no longer nearby"); - } - if (pings.ContainsKey(key)) - { - var ping = PingManager.Get(pings[key]); - if (ping != null) - UnityEngine.Object.Destroy(ping); - pings.Remove(key); - } - stories.Remove(key); - } - } - var radiusRange = settings.HighlightSearchDistance - __instance.radiusInner; - - if (!settings.PresetApplied && MainCamera.camera != null && MainCamera.camera.TryGetComponent(out HighlightingRenderer renderer)) - { - settings.PresetApplied = true; - if (settings.HighlightingRenderer >= 0 && settings.HighlightingRenderer < Utils.Presets.Count) - renderer.ApplyPreset(Utils.Presets[settings.HighlightingRenderer]); - //Console.WriteLine($"[AdvancedHighlighting] Active {settings.HighlightingRenderer},{Utils.Presets.Count} = [{renderer.name}, {renderer.blurDirections}, {renderer.blurIntensity}, {renderer.blurMinSpread}, {renderer.blurSpread}, {renderer.downsampleFactor}, {renderer.fillAlpha}, {renderer.iterations}]"); - } - foreach (Highlighter highlighter in highlighters) - { - if (highlighter != null) - { - var highlights = highlighter.gameObject.GetHighlightsForObject(out _, out _); - if (highlights.Count > 0) - { - Color highlightingColor = settings.GetHighlightColor(highlights.First()); - if (highlightingColor.a != 0f) - { - float magnitude = (highlighter.bounds.center - vector).magnitude; - float a = Mathf.Max(Mathf.Clamp01(1f - (magnitude - __instance.radiusInner) / radiusRange), settings.MinimumAlpha); - highlightingColor.a = a * a; - highlighter.ConstantOn(highlightingColor, 0f); - highlighter.filterMode = RendererFilterMode.None; - - if (magnitude <= settings.HighlightSearchDistance) - NotifiyAndPing(highlighter); - } - else - highlighter.ConstantOn(highlightingColor, 0f); - } - } - } - if (gameObject != null) - { - GameObject highlightableRoot = null; - Highlighting_GetHighlightableRoot_Patch.Prefix(__instance, ref highlightableRoot, mode, gameObject); - if (highlightableRoot != null) - { - Highlighter highlighter = highlightableRoot.GetComponent(); - if (highlighter != null) - { - Color highlightingColor = highlighter.constantColor; - float a2 = Mathf.Lerp(0.4f, 1f, Mathf.Cos((time - hoverStart) * 2f * Mathf.PI * __instance.hoverFlashingSpeed) * 0.5f + 0.5f); - highlightingColor.a = a2 * a2; - highlighter.Hover(highlightingColor); - } - } - } - } - return false; - } - private static void NotifiyAndPing(Highlighter highlighter) - { - var objId = highlighter.GetInstanceID(); - if (!stories.ContainsKey(objId)) - { - string name = null; - string type = null; - if (highlighter.TryGetComponent(out StoryHandTarget story)) - { - name = Language.main.Get(story.primaryTooltip); - type = "story"; - } - else if (highlighter.TryGetComponent(out JukeboxDisk disk)) - { - name = Language.main.Get(Jukebox.GetInfo(disk.track).label); - type = "disk"; - } - if (name != null) - { - var settings = Settings.GetInstance(); - stories[objId] = name; - if ((type == "story" && settings.StoryNotification) || - (type == "disk" && settings.DisksNotification)) - { - notifications.Add(objId); - ErrorMessage.AddMessage($"[Advanced Highlighting] {name} is nearby"); - } - if (settings.ShowPings) - { - PingInstance ping = highlighter.gameObject.EnsureComponent(); - ping.origin = highlighter.gameObject.transform; - ping.SetFakePosition(highlighter.bounds.center); - ping.SetVisible(true); - ping.SetLabel(name); - ping._id = $"ahping_{type}_{objId}"; - ping.pingType = PingType.Signal; - ping.displayPingInManager = false; - ping.visitable = false; - ping.minDist = 5f; - ping.range = 5f; - ping.enabled = true; - pings[objId] = ping._id; - } - } - } - } - } - - [HarmonyPatch(typeof(Highlighting), "GetHighlightableRoot", new Type[] { typeof(Highlighting.Mode), typeof(GameObject) })] - public static class Highlighting_GetHighlightableRoot_Patch - { - public static bool Prefix(Highlighting __instance, ref GameObject __result, Highlighting.Mode mode, GameObject target) - { - __result = null; - if (mode == Highlighting.Mode.None) - return false; - var settings = Settings.GetInstance(); - if (mode == Highlighting.Mode.Exosuit && !settings.ExosuiteHighlightsEnabled) - { - Exosuit exosuit = Player.main.GetVehicle() as Exosuit; - if (exosuit != null) - __result = exosuit.GetInteractableRoot(target); - return false; - } - else - { - var highlights = target.GetHighlightsForObject(out GameObject result, out Behaviour behaviour); - if (highlights.Count == 0) - return false; - if (highlights.Contains(Highlight.ScannableFragments) || - highlights.Contains(Highlight.ScannedFragments) || - highlights.Contains(Highlight.ScannableItems)) - { - __result = result; - return false; - } - - if (behaviour == null || !behaviour.enabled || behaviour.GetComponentInParent() != null || - behaviour.GetComponentInParent() != null) - { - return false; - } - - var handlers = __instance.GetHandlers(); - if (handlers != null && handlers.TryGetValue(behaviour.GetType(), out Highlighting.Handler handler)) - { - handler(ref behaviour); - if (behaviour == null) - return false; - } - __result = behaviour.gameObject; - } - return false; - } - } - -} \ No newline at end of file From e884711640d52e6b7186bf8f2078214e4259cf87 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:51:35 +0700 Subject: [PATCH 24/26] Delete Resources.resx --- Properties/Resources.resx | 129 -------------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 Properties/Resources.resx diff --git a/Properties/Resources.resx b/Properties/Resources.resx deleted file mode 100644 index 9d5fd00..0000000 --- a/Properties/Resources.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - A mod to change the highlighting colors of objects in the game. - - - AdvancedHighlighting - - - 1.0.0 - - \ No newline at end of file From 5d4250e5e562f06cfd940dfc6563ac332adea65e Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:51:42 +0700 Subject: [PATCH 25/26] Delete Resources.Designer.cs --- Properties/Resources.Designer.cs | 90 -------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 Properties/Resources.Designer.cs diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs deleted file mode 100644 index e24305e..0000000 --- a/Properties/Resources.Designer.cs +++ /dev/null @@ -1,90 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace AdvancedHighlighting.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AdvancedHighlighting.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to A mod to change the highlighting colors of objects in the game.. - /// - internal static string desc { - get { - return ResourceManager.GetString("desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AdvancedHighlighting. - /// - internal static string title { - get { - return ResourceManager.GetString("title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 1.0.0. - /// - internal static string ver { - get { - return ResourceManager.GetString("ver", resourceCulture); - } - } - } -} From d7197d500ff7edd78b8f0e082a876e0da05c2fa8 Mon Sep 17 00:00:00 2001 From: vijer Date: Fri, 7 Oct 2022 12:51:49 +0700 Subject: [PATCH 26/26] Delete AssemblyInfo.cs --- Properties/AssemblyInfo.cs | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 Properties/AssemblyInfo.cs diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs deleted file mode 100644 index e3cb5c0..0000000 --- a/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("AdvancedHighlighting")] -[assembly: AssemblyDescription("A mod for Subnautica Below Zero")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("OGMods")] -[assembly: AssemblyProduct("AdvancedHighlighting")] -[assembly: AssemblyCopyright("Copyright OGMods © 2021")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("adb59190-bc97-4509-ab62-c64a4d9a93ec")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")]