Skip to content

Commit cdeb9ed

Browse files
committed
finished migrating to new type registration system
1 parent 8b7f499 commit cdeb9ed

File tree

7 files changed

+238
-181
lines changed

7 files changed

+238
-181
lines changed

MiniMapLibrary/Interactible/InteractableKind.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ public enum InteractableKind
1818
Drone = 1 << 6,
1919
Barrel = 1 << 7,
2020
Enemy = 1 << 8,
21-
Printer = 1 << 9,
22-
LunarPod = 1 << 10,
23-
All = 0b_1111_11
21+
EnemyVoid = 1 << 9,
22+
Ally = 1 << 10,
23+
Printer = 1 << 11,
24+
LunarPod = 1 << 12,
25+
Shop = 1 << 13,
26+
Equipment = 1 << 14,
27+
All = 0xFFFF
2428
}
2529
}

MiniMapLibrary/Scanner/TrackedObjectScanner.cs renamed to MiniMapLibrary/Scanner/MultiKindScanner.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55

66
namespace MiniMapLibrary.Scanner
77
{
8-
public class TrackedObjectScanner<T> : ITrackedObjectScanner
8+
public class MultiKindScanner<T> : ITrackedObjectScanner
99
{
1010
private readonly IScanner<T> scanner;
1111
private readonly IInteractibleSorter<T> sorter;
1212
private readonly bool dynamic;
13+
private readonly Range3D range;
1314

14-
public TrackedObjectScanner(bool dynamic, IScanner<T> scanner, IInteractibleSorter<T> sorter)
15+
public MultiKindScanner(bool dynamic, IScanner<T> scanner, IInteractibleSorter<T> sorter, Range3D range)
1516
{
1617
this.scanner = scanner;
1718
this.sorter = sorter;
1819
this.dynamic = dynamic;
20+
this.range = range;
1921
}
2022

2123
public void ScanScene(IList<ITrackedObject> list)
@@ -31,6 +33,8 @@ public void ScanScene(IList<ITrackedObject> list)
3133
ActiveChecker = activeChecker,
3234
DynamicObject = dynamic
3335
});
36+
37+
range.CheckValue(gameObject.transform.position);
3438
}
3539
}
3640
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using UnityEngine;
5+
6+
#nullable enable
7+
namespace MiniMapLibrary.Scanner
8+
{
9+
public class SingleKindScanner<T> : ITrackedObjectScanner where T : MonoBehaviour
10+
{
11+
private readonly IScanner<T> scanner;
12+
private readonly bool dynamic;
13+
private readonly Func<T, bool> activeChecker;
14+
private readonly Func<T, GameObject> converter;
15+
private readonly Func<T, bool> selector;
16+
private readonly InteractableKind kind;
17+
private readonly Range3D range;
18+
19+
public SingleKindScanner(InteractableKind kind, bool dynamic, IScanner<T> scanner, Range3D range, Func<T, GameObject> converter, Func<T, bool>? activeChecker = null, Func<T, bool>? selector = null)
20+
{
21+
this.scanner = scanner;
22+
this.dynamic = dynamic;
23+
this.kind = kind;
24+
this.converter = converter;
25+
26+
// always return active if nothing is given
27+
this.activeChecker = activeChecker ?? ((x) => true);
28+
29+
// always select if nothing is given
30+
this.selector = selector ?? ((x) => true);
31+
32+
this.range = range;
33+
}
34+
35+
public void ScanScene(IList<ITrackedObject> list)
36+
{
37+
IEnumerable<T> foundObjects = scanner.Scan();
38+
39+
foreach (var item in foundObjects)
40+
{
41+
if (selector(item))
42+
{
43+
GameObject gameObject = converter(item);
44+
45+
list.Add(new TrackedObject<T>(kind, converter(item), null)
46+
{
47+
BackingObject = item,
48+
ActiveChecker = activeChecker,
49+
DynamicObject = dynamic
50+
});
51+
52+
range.CheckValue(gameObject.transform.position);
53+
}
54+
}
55+
}
56+
}
57+
}

MiniMapLibrary/Settings.cs

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ public enum LogLevel {
1515
all
1616
}
1717

18+
public static class Icons
19+
{
20+
public const string Default = "";
21+
public const string LootBag = "Textures/MiscIcons/texLootIconOutlined";
22+
public const string Chest = "Textures/MiscIcons/texInventoryIconOutlined";
23+
public const string Circle = "Textures/MiscIcons/texBarrelIcon";
24+
public const string Shrine = "Textures/MiscIcons/texShrineIconOutlined";
25+
public const string Boss = "Textures/MiscIcons/texTeleporterIconOutlined";
26+
public const string Drone = "Textures/MiscIcons/texDroneIconOutlined";
27+
}
28+
1829
public static class Settings
1930
{
2031
public static Dimension2D MinimapSize { get; set; } = new Dimension2D(100, 100);
@@ -77,52 +88,70 @@ static void Add(InteractableKind type,
7788

7889
Add(InteractableKind.Chest, 10, 8,
7990
description: "Chests, including shops",
80-
path: "Textures/MiscIcons/texInventoryIconOutlined");
91+
path: Icons.Chest);
92+
93+
Add(InteractableKind.Equipment, 8, 6,
94+
description: "Equipment barrels",
95+
path: Icons.Chest);
8196

8297
Add(InteractableKind.Shrine,
8398
description: "All shrines (excluding Newt)",
84-
path: "Textures/MiscIcons/texShrineIconOutlined");
99+
path: Icons.Shrine);
85100

86101
Add(InteractableKind.Teleporter, 15, 15,
87102
ActiveColor: Color.white,
88103
InactiveColor: Color.green,
89104
description: "Boss teleporters",
90-
path: "Textures/MiscIcons/texTeleporterIconOutlined");
105+
path: Icons.Boss);
91106

92107
Add(InteractableKind.Player, 8, 8,
93108
ActiveColor: PlayerIconColor,
94109
InactiveColor: PlayerIconColor,
95-
description: "",
96-
path: "Textures/MiscIcons/texBarrelIcon");
110+
description: "Player, including friends",
111+
path: Icons.Circle);
97112

98113
Add(InteractableKind.Barrel, 5, 5,
99114
description: "Barrels",
100-
path: "Textures/MiscIcons/texBarrelIcon");
115+
path: Icons.Circle);
101116

102117
Add(InteractableKind.Drone, 7, 7,
103118
description: "Drones",
104-
path: "Textures/MiscIcons/texDroneIconOutlined");
119+
path: Icons.Drone);
105120

106121
Add(InteractableKind.Special, 7, 7,
107122
description: "Special interactibles such as the landing pod and fans",
108-
path: DefaultResourcePath);
123+
path: Icons.Default);
109124

110125
Add(InteractableKind.Enemy, 3, 3,
111126
ActiveColor: Color.red,
112127
description: "Enemies",
113-
path: "Textures/MiscIcons/texBarrelIcon");
128+
path: Icons.Circle);
129+
130+
Add(InteractableKind.EnemyVoid, 3, 3,
131+
ActiveColor: Color.magenta,
132+
description: "Void touched enemies",
133+
path: Icons.Circle);
134+
135+
Add(InteractableKind.Ally, 3, 3,
136+
ActiveColor: Color.green,
137+
description: "Allies and minions",
138+
path: Icons.Circle);
114139

115140
Add(InteractableKind.Utility,
116141
description: "Scrappers",
117-
path: "Textures/MiscIcons/texLootIconOutlined");
142+
path: Icons.LootBag);
118143

119144
Add(InteractableKind.Printer, 10, 8,
120145
description: "Printers",
121-
path: "Textures/MiscIcons/texInventoryIconOutlined");
146+
path: Icons.Chest);
122147

123148
Add(InteractableKind.LunarPod, 7, 7,
124149
description: "Lunar pods (chests)",
125-
path: "Textures/MiscIcons/texLootIconOutlined");
150+
path: Icons.LootBag);
151+
152+
Add(InteractableKind.Shop, 7, 7,
153+
description: "3 item shops",
154+
path: Icons.Chest);
126155
}
127156

128157
public static InteractibleSetting GetSetting(InteractableKind type)

0 commit comments

Comments
 (0)