Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MiniMapLibrary/Interactible/InteractableKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum InteractableKind
Drone = 1 << 7,
Barrel = 1 << 8,
Enemy = 1 << 9,
All = 0b_1111_1
Printer = 1 << 10,
All = 0b_1111_11
}
}
14 changes: 14 additions & 0 deletions MiniMapLibrary/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void AddSize(InteractableKind type, float width = -1, float height = -1, Color A
AddSize(InteractableKind.Special, 7, 7);
AddSize(InteractableKind.Enemy, 3, 3, ActiveColor: Color.red);
AddSize(InteractableKind.Utility);
AddSize(InteractableKind.Printer, 10, 10);
}

public static InteractibleSetting GetSetting(InteractableKind type)
Expand Down Expand Up @@ -100,5 +101,18 @@ public static Dimension2D GetInteractableSize(InteractableKind type)

return DefaultUIElementSize;
}

public static void UpdateSetting(InteractableKind type, float width, float height, Color active, Color inactive)
{
if (InteractibleSettings.ContainsKey(type))
{
var setting = InteractibleSettings[type];

setting.ActiveColor = active;
setting.InactiveColor = inactive;
setting.Dimensions.Height = height;
setting.Dimensions.Width = width;
}
}
}
}
1 change: 1 addition & 0 deletions MiniMapLibrary/SpriteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static void Add(InteractableKind type, string ResourcePath)
Add(InteractableKind.Barrel, "Textures/MiscIcons/texBarrelIcon");
Add(InteractableKind.Enemy, "Textures/MiscIcons/texBarrelIcon");
Add(InteractableKind.Player, "Textures/MiscIcons/texBarrelIcon");
Add(InteractableKind.Printer, "Textures/MiscIcons/texInventoryIconOutlined");
Add(InteractableKind.All, DefaultResourcePath);
}

Expand Down
6 changes: 6 additions & 0 deletions MiniMapMod.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Metadata", "Metadata", "{3A
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniMapLibrary", "MiniMapLibrary\MiniMapLibrary.csproj", "{82C1D748-9C54-4120-B0E5-1A0B494B3082}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AD35E87D-139A-4C74-8352-9C77323F4FB0}"
ProjectSection(SolutionItems) = preProject
manifest.json = manifest.json
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
40 changes: 36 additions & 4 deletions MiniMapMod/MiniMapPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
using System.Collections.Generic;
using System.Linq;
using System;
using BepInEx.Configuration;

namespace MiniMapMod
{
[BepInPlugin("MiniMap", "Mini Map Mod", "3.0.1")]
[BepInPlugin("MiniMap", "Mini Map Mod", "3.1.0")]
public class MiniMapPlugin : BaseUnityPlugin
{
private readonly ISpriteManager SpriteManager = new SpriteManager();
Expand All @@ -23,10 +24,29 @@ public class MiniMapPlugin : BaseUnityPlugin

private bool ScannedStaticObjects = false;

private readonly Dictionary<InteractableKind, ConfigEntry<bool>> ScanOptions = new();

public void Awake()
{
Log.Init(Logger);

// bind options
InteractableKind[] kinds = Enum.GetValues(typeof(InteractableKind)).Cast<InteractableKind>().ToArray();

for (int i = 0; i < kinds.Length; i++)
{
InteractableKind kind = kinds[i];

ScanOptions.Add(kind, Config.Bind<bool>($"Icon.{kind}", "enabled", true, $"Whether or or {kind} should be shown on the minimap"));

ConfigEntry<Color> activeColor = Config.Bind<Color>($"Icon.{kind}", "activeColor", Settings.GetColor(kind, true), "The color the icon should be when it has not been interacted with");
ConfigEntry<Color> inactiveColor = Config.Bind<Color>($"Icon.{kind}", "inactiveColor", Settings.GetColor(kind, false), "The color the icon should be when it has used/bought");
ConfigEntry<float> iconWidth = Config.Bind<float>($"Icon.{kind}", "width", Settings.GetInteractableSize(kind).Width, "Width of the icon");
ConfigEntry<float> iconHeight = Config.Bind<float>($"Icon.{kind}", "height", Settings.GetInteractableSize(kind).Height, "Width of the icon");

Settings.UpdateSetting(kind, iconWidth.Value, iconHeight.Value, activeColor.Value, inactiveColor.Value);
}

Log.LogInfo("MINIMAP: Creating scene scan hooks");

GlobalEventManager.onCharacterDeathGlobal += (x) => ScanScene();
Expand Down Expand Up @@ -181,7 +201,11 @@ private void ScanStaticTypes()

RegisterMonobehaviorType<ShrineRestackBehavior>(InteractableKind.Shrine, dynamicObject: false);

RegisterMonobehaviorType<ShopTerminalBehavior>(InteractableKind.Chest, dynamicObject: false);
// normal shops
RegisterMonobehaviorType<ShopTerminalBehavior>(InteractableKind.Chest, dynamicObject: false, selector: shop => shop.GetComponent<PurchaseInteraction>().contextToken != "DUPLICATOR_CONTEXT");

// duplicators
RegisterMonobehaviorType<ShopTerminalBehavior>(InteractableKind.Printer, dynamicObject: false, selector: shop => shop.GetComponent<PurchaseInteraction>().contextToken == "DUPLICATOR_CONTEXT");

RegisterMonobehaviorType<BarrelInteraction>(InteractableKind.Barrel, barrel => !barrel.Networkopened, dynamicObject: false);

Expand Down Expand Up @@ -220,9 +244,17 @@ private void ClearDynamicTrackedObjects()
}
}

private void RegisterMonobehaviorType<T>(InteractableKind kind, Func<T, bool> ActiveChecker = null, bool dynamicObject = true) where T : MonoBehaviour
private void RegisterMonobehaviorType<T>(InteractableKind kind, Func<T, bool> ActiveChecker = null, bool dynamicObject = true, Func<T, bool> selector = null) where T : MonoBehaviour
{
IEnumerable<T> found = GameObject.FindObjectsOfType(typeof(T)).Select(x => (T)x);
// check to see if it's enabled in the config
if (ScanOptions[kind].Value == false)
{
return;
}

selector ??= (x) => true;

IEnumerable<T> found = GameObject.FindObjectsOfType(typeof(T)).Select(x => (T)x).Where(selector);

RegisterMonobehaviours(found, kind, ActiveChecker, dynamicObject);
}
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Adds a contemporary Minimap to the game.
- Implements a Mini Map In-Game.
- Show interactable items, shrines, teleporters, enemies and more.
- Single and Multiplayer Compatible.
- Plays Nice with 95% of Most Downloaded Mods.
- Every icon is configurable for color, size and can be toggled on/off.

### Showcase

Expand All @@ -26,7 +26,12 @@ Adds a contemporary Minimap to the game.
- Toggle 'M' to hide and show minimap to force a refresh and/or a re-draw if something wonky is happening on the minimap.

### Config
No config applicable at this time
BepInEx Config. Each icon is individually configurable.
- Enabled / Disabled
- Active Color
- Inactive Color
- Icon Width
- Icon Height

### Upcoming Changes
None - Final Release
Expand All @@ -38,6 +43,11 @@ https://www.autism.org/donate-autism-research-institute/
If you have an issue, discover a bug, or have a recommendation please file an issue on my github page.

### Change Log
Major 3.1
- Added config toggle to enable or disable each individual icon
- Added config option to choose color for each individual icon
- Added config option to choose icon height and width for each individual icon

Minor 3.0.1
- un-spammed console

Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "MiniMapMod",
"version_number": "3.0.1",
"version_number": "3.1",
"website_url": "https://github.com/DekuDesu",
"description": "Adds a MiniMap to your game v3.0",
"description": "Adds a MiniMap to your game v3.1",
"dependencies": [
"bbepis-BepInExPack-5.4.9",
"RiskofThunder-HookGenPatcher-1.2.1"
Expand Down
25 changes: 25 additions & 0 deletions post_build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
param([string]$version="NO_VERSION")

$destination = ".\Releases\$version"
$pluginDestination = "C:\Users\user\AppData\Roaming\r2modmanPlus-local\RiskOfRain2\profiles\Modding\BepInEx\plugins\$version"

if(Test-Path $destination)
{
Remove-Item $destination -Recurse
}
if(Test-Path $pluginDestination)
{
Remove-Item $pluginDestination -Recurse
}

New-Item -Path $destination -ItemType Directory

Copy-Item -Path ".\MiniMapMod\obj\Release\netstandard2.1\MiniMapMod.dll" -Destination $destination
Copy-Item -Path ".\MiniMapLibrary\obj\Release\netstandard2.1\MiniMapLibrary.dll" -Destination $destination
Copy-Item -Path ".\README.md" -Destination $destination
Copy-Item -Path ".\icon.png" -Destination $destination
Copy-Item -Path ".\manifest.json" -Destination $destination

Copy-Item -Path $destination $pluginDestination -Recurse

Compress-Archive -Path "$destination\*.*" -DestinationPath "$destination\$version.zip"