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
+
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;
+ }
}
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();
}
+ }
}
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);
+ }
+ }
}
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;
}
+ }
}
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;
}
+ }
}
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);
+ }
}
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;
}
+ }
}