Skip to content

Commit eacf4ab

Browse files
committed
Final Release
1 parent 6f668bc commit eacf4ab

9 files changed

Lines changed: 63 additions & 179 deletions

File tree

MiniMapLibrary/Interactible/InteractableKind.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public enum InteractableKind
1616
Shrine = 1 << 4,
1717
Special = 1 << 5,
1818
Player = 1 << 6,
19+
Drone = 1 << 7,
20+
Barrel = 1 << 8,
1921
All = 0b_1111_1
2022
}
2123
}

MiniMapLibrary/Settings.cs

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using UnityEngine;
67

78
namespace MiniMapLibrary
89
{
@@ -12,24 +13,21 @@ public static class Settings
1213

1314
public static Dimension2D ViewfinderSize { get; set; } = new Dimension2D(10, 100);
1415

15-
public static IDictionary<string, Interactable> InteractableDefinitions { get; } = new Dictionary<string, Interactable>();
16-
1716
public static IDictionary<InteractableKind, Dimension2D> InteractableSizes { get; } = new Dictionary<InteractableKind, Dimension2D>();
1817

1918
private static readonly Dimension2D DefaultUIElementSize = new Dimension2D(10, 10);
2019

20+
public static Color PlayerIconColor { get; set; } = Color.white;
21+
22+
public static Color DefaultIconColor { get; set; } = Color.yellow;
23+
2124
static Settings()
2225
{
2326
InitializeDefaultSettings();
2427
}
2528

2629
private static void InitializeDefaultSettings()
2730
{
28-
void Add(string key, InteractableKind type)
29-
{
30-
InteractableDefinitions.Add(key, new Interactable(key, type));
31-
}
32-
3331
void AddSize(InteractableKind type, float width = -1, float height = -1)
3432
{
3533
Dimension2D size = DefaultUIElementSize;
@@ -46,47 +44,11 @@ void AddSize(InteractableKind type, float width = -1, float height = -1)
4644
AddSize(InteractableKind.Shrine);
4745
AddSize(InteractableKind.Teleporter);
4846
AddSize(InteractableKind.Player);
47+
AddSize(InteractableKind.Barrel, 5, 5);
48+
AddSize(InteractableKind.Drone);
4949
AddSize(InteractableKind.Primary);
5050
AddSize(InteractableKind.Special);
5151
AddSize(InteractableKind.Utility);
52-
53-
Add("ShrineCombat", InteractableKind.Shrine);
54-
Add("ShrineBlood", InteractableKind.Shrine);
55-
Add("ShrineChance", InteractableKind.Shrine);
56-
Add("ShrineBoss", InteractableKind.Shrine);
57-
58-
Add("Teleporter", InteractableKind.Teleporter);
59-
60-
Add("GoldshoresBeacon", InteractableKind.Special);
61-
Add("NullSafeZone", InteractableKind.Special);
62-
63-
Add("TripleShop", InteractableKind.Chest);
64-
Add("LunarChest", InteractableKind.Chest);
65-
Add("Chest", InteractableKind.Chest);
66-
Add("Duplicator", InteractableKind.Chest);
67-
Add("EquipmentBarrel", InteractableKind.Chest);
68-
Add("GoldChest", InteractableKind.Chest);
69-
Add("CategoryChestDamage", InteractableKind.Chest);
70-
Add("CategoryChestHealing", InteractableKind.Chest);
71-
Add("CategoryChestUtility", InteractableKind.Chest);
72-
73-
Add("Scrapper", InteractableKind.Utility);
74-
Add("NewtStatue", InteractableKind.Utility);
75-
Add("Barrel", InteractableKind.Utility);
76-
Add("Drone1Broken", InteractableKind.Utility);
77-
Add("MissleDroneBroken", InteractableKind.Utility);
78-
Add("EquipmentDroneBroken", InteractableKind.Utility);
79-
}
80-
81-
public static InteractableKind GetInteractableType(string Name)
82-
{
83-
84-
if (InteractableDefinitions.ContainsKey(Name))
85-
{
86-
return InteractableDefinitions[Name].InteractableType;
87-
}
88-
89-
return InteractableKind.none;
9052
}
9153

9254
public static Dimension2D GetInteractableSize(InteractableKind type)

MiniMapLibrary/SpriteManager.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ void Add(InteractableKind type, string ResourcePath)
2929
}
3030

3131
Add(InteractableKind.Primary, DefaultResourcePath);
32-
Add(InteractableKind.Shrine, DefaultResourcePath);
32+
Add(InteractableKind.Shrine, "Textures/MiscIcons/texShrineIconOutlined");
3333
Add(InteractableKind.Special, DefaultResourcePath);
34-
Add(InteractableKind.Teleporter, DefaultResourcePath);
35-
Add(InteractableKind.Chest, DefaultResourcePath);
36-
Add(InteractableKind.Utility, DefaultResourcePath);
37-
Add(InteractableKind.Player, DefaultResourcePath);
34+
Add(InteractableKind.Teleporter, "Textures/MiscIcons/texTeleporterIconOutlined");
35+
Add(InteractableKind.Chest, "Textures/MiscIcons/texInventoryIconOutlined");
36+
Add(InteractableKind.Drone, "Textures/MiscIcons/texDroneIconOutlined");
37+
Add(InteractableKind.Utility, "Textures/MiscIcons/texLootIconOutlined");
38+
Add(InteractableKind.Barrel, "Textures/MiscIcons/texBarrelIcon");
39+
Add(InteractableKind.Player, "Textures/MiscIcons/texBarrelIcon");
3840
Add(InteractableKind.All, DefaultResourcePath);
3941
}
4042

@@ -56,9 +58,11 @@ public void Dispose()
5658
{
5759
return GetOrCache(path);
5860
}
61+
62+
throw new Exception($"MissingTextureException: Interactible.{type} does not have a registered texture path to load.");
5963
}
6064

61-
return null;
65+
throw new Exception($"MissingTextureException: Interactible.{type} does not have a registered texture path to load.");
6266
}
6367

6468
private Sprite? GetOrCache(string Path)

MiniMapMod/MiniMapMod.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<ProjectReference Include="..\..\..\..\..\_Programming\Repos\Unity Projects\MiniMapLibrary\MiniMapLibrary.csproj" />
16+
<ProjectReference Include="..\MiniMapLibrary\MiniMapLibrary.csproj" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

MiniMapMod/MiniMapPlugin.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public void Awake()
4141

4242
private void OnCharacterDeath(object o)
4343
{
44-
Minimap.Destroy();
45-
ResetGlobalDimensions();
44+
Reset();
4645
}
4746

4847

@@ -129,6 +128,8 @@ private void Reset()
129128

130129
private void ScanScene()
131130
{
131+
Minimap.DestroyIcons();
132+
132133
ResetGlobalDimensions();
133134

134135
TrackedObjects.Clear();
@@ -151,10 +152,12 @@ private void ScanScene()
151152

152153
RegisterTypes(typeof(ShopTerminalBehavior), InteractableKind.Chest);
153154

154-
RegisterTypes(typeof(BarrelInteraction), InteractableKind.Utility);
155+
RegisterTypes(typeof(BarrelInteraction), InteractableKind.Barrel);
155156

156157
RegisterTypes(typeof(ScrapperController), InteractableKind.Utility);
157158

159+
RegisterTypes(typeof(SummonMasterBehavior), InteractableKind.Drone);
160+
158161
RegisterTypes(typeof(GenericInteraction), InteractableKind.Special);
159162

160163
// set the values used to calculate the scaled positions in the minimap for the items
@@ -199,16 +202,9 @@ private void RegisterObjects(IEnumerable<GameObject> objects, InteractableKind K
199202
{
200203
foreach (var item in objects)
201204
{
202-
InteractableKind type = Kind;
203-
204-
if (Kind == InteractableKind.none)
205-
{
206-
type = Settings.GetInteractableType(item.name);
207-
}
208-
209-
if (type != InteractableKind.none)
205+
if (Kind != InteractableKind.none)
210206
{
211-
TrackedObjects.Add(new TrackedObject(type, item, null));
207+
TrackedObjects.Add(new TrackedObject(Kind, item, null));
212208

213209
CheckPositionConstraints(item.transform.position);
214210
}

MiniMapMod/Minimap.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public void CreateMinimap(SpriteManager spriteManager, GameObject Parent)
3737

3838
gameObject.transform.localScale = new Vector3(1, 1, 1);
3939

40-
CreatePlayerIcon(spriteManager);
41-
4240
CreateIconContainer();
41+
42+
CreatePlayerIcon(spriteManager);
4343
}
4444

4545
public void Destroy()
@@ -58,6 +58,14 @@ public void Destroy()
5858
Created = false;
5959
}
6060

61+
public void DestroyIcons()
62+
{
63+
foreach (Transform child in Container.transform)
64+
{
65+
GameObject.Destroy(child.gameObject);
66+
}
67+
}
68+
6169
public void Zoom(int ZoomLevel)
6270
{
6371
if (ContainerTransform != null)
@@ -118,6 +126,8 @@ private void CreatePlayerIcon(SpriteManager spriteManager)
118126
{
119127
GameObject playerIcon = CreateIcon(InteractableKind.Player, spriteManager.GetSprite(InteractableKind.Player));
120128

129+
playerIcon.GetComponent<Image>().color = Settings.PlayerIconColor;
130+
121131
playerIcon.transform.SetParent(gameObject.transform);
122132

123133
playerIcon.transform.localPosition = new Vector3(0, 0, 0);
@@ -137,7 +147,12 @@ private GameObject CreateIcon(InteractableKind type, Sprite iconTexture)
137147
transform.sizeDelta = new Vector2(size.Width, size.Height);
138148

139149
icon.AddComponent<CanvasRenderer>();
140-
icon.AddComponent<Image>().sprite = iconTexture;
150+
151+
var image = icon.AddComponent<Image>();
152+
153+
image.sprite = iconTexture;
154+
155+
image.color = Settings.DefaultIconColor;
141156
});
142157
}
143158

@@ -152,9 +167,12 @@ private GameObject CreateMask()
152167
newTransform.sizeDelta = new Vector2(Settings.ViewfinderSize.Width, Settings.ViewfinderSize.Height);
153168

154169
mask.AddComponent<CanvasRenderer>();
155-
//mask.AddComponent<Image>();
156170

157-
mask.AddComponent<Mask>();
171+
mask.AddComponent<Image>();
172+
173+
var maskComponent = mask.AddComponent<Mask>();
174+
175+
maskComponent.showMaskGraphic = false;
158176

159177
LayoutElement element = mask.AddComponent<LayoutElement>();
160178

0 commit comments

Comments
 (0)