Skip to content

Commit 0021910

Browse files
authored
Merge pull request #47 from DekuDesu/development
Development
2 parents 3959a07 + 054c8ad commit 0021910

File tree

7 files changed

+227
-35
lines changed

7 files changed

+227
-35
lines changed

MiniMapLibrary/Basic/Timer.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
#nullable enable
6+
namespace MiniMapLibrary
7+
{
8+
public class Timer
9+
{
10+
public float Duration { get; private set; } = 1.0f;
11+
public float Value { get; set; }
12+
public event Action<object?>? OnFinished;
13+
public object? State { get; set; }
14+
public bool AutoReset { get; set; }
15+
public bool Started { get; set; } = true;
16+
public bool Expired => Value <= 0;
17+
18+
public Timer(float duration, bool autoReset = true)
19+
{
20+
Duration = duration;
21+
this.AutoReset = autoReset;
22+
}
23+
24+
public void Update(float deltaTime)
25+
{
26+
if (Started)
27+
{
28+
Value -= deltaTime;
29+
30+
if (Expired)
31+
{
32+
if (AutoReset)
33+
{
34+
Reset();
35+
}
36+
else
37+
{
38+
Started = false;
39+
}
40+
41+
OnFinished?.Invoke(State);
42+
}
43+
}
44+
}
45+
46+
public void Start() => Started = true;
47+
48+
public void Reset()
49+
{
50+
Value = Duration;
51+
Started = AutoReset;
52+
}
53+
54+
public override string ToString()
55+
{
56+
return $"{typeof(Timer).Name} [{Value}/{Duration}s] [{nameof(AutoReset)}: {AutoReset}] [{nameof(Started)}: {Started}] [{nameof(Expired)}: {Expired}]";
57+
}
58+
}
59+
}

MiniMapLibrary/Interactible/InteractableKind.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public enum InteractableKind
2626
Minion = 1 << 14,
2727
Player = 1 << 15,
2828
Item = 1 << 16,
29-
All = 0xFFFF
29+
Portal = 1 << 17,
30+
Totem = 1 << 18,
31+
Neutral = 1 << 19,
32+
All = int.MaxValue
3033
}
3134
}

MiniMapLibrary/Settings.cs

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,28 @@ public static class Icons
2626
public const string Shrine = "Textures/MiscIcons/texShrineIconOutlined";
2727
public const string Boss = "Textures/MiscIcons/texTeleporterIconOutlined";
2828
public const string Drone = "Textures/MiscIcons/texDroneIconOutlined";
29+
public const string Cross = "Textures/MiscIcons/texCriticallyHurtIcon";
30+
public const string Lock = "Textures/MiscIcons/texUnlockIcon";
31+
public const string Dice = "Textures/MiscIcons/texRuleMapIsRandom";
32+
public const string Cube = "Textures/MiscIcons/texLunarPillarIcon";
33+
public const string Wrench = "Textures/MiscIcons/texWIPIcon";
34+
public const string Attack = "Textures/MiscIcons/texAttackIcon";
35+
public const string Sprint = "Textures/MiscIcons/texSprintIcon";
36+
public const string Arrow = "Textures/MiscIcons/texOptionsArrowLeft";
37+
public const string Pencil = "Textures/MiscIcons/texEditIcon";
38+
public const string Portal = "Textures/MiscIcons/texQuickplay";
39+
}
40+
41+
public static class Colors
42+
{
43+
public static Color Yellow = new Color(255/255.0f, 219 / 255.0f, 88 / 255.0f);
44+
public static Color Purple = new Color(122 / 255.0f, 105 / 255.0f, 244 / 255.0f);
45+
public static Color DarkPurple = new Color(76 / 255.0f, 53 / 255.0f, 244 / 255.0f);
46+
public static Color Teal = new Color(94 / 255.0f, 178 / 255.0f, 242 / 255.0f);
47+
public static Color Pink = new Color(172 / 255.0f, 95 / 255.0f, 243 / 255.0f);
48+
public static Color DarkPink = new Color(146 / 255.0f, 39 / 255.0f, 243 / 255.0f);
49+
public static Color Orange = new Color(255 / 255.0f, 146 / 255.0f, 0 / 255.0f);
50+
public static Color DarkTeal = new Color(94 / 255.0f, 178 / 255.0f, 242 / 255.0f);
2951
}
3052

3153
public static Dimension2D MinimapSize { get; set; } = new Dimension2D(100, 100);
@@ -38,7 +60,7 @@ public static class Icons
3860

3961
public static Color PlayerIconColor { get; set; } = Color.white;
4062

41-
public static Color DefaultActiveColor { get; set; } = Color.yellow;
63+
public static Color DefaultActiveColor { get; set; } = Colors.Yellow;
4264

4365
public static Color DefaultInactiveColor { get; set; } = Color.grey;
4466

@@ -58,13 +80,13 @@ private static void InitializeDefaultSettings()
5880
static void Add(InteractableKind type,
5981
float width = -1,
6082
float height = -1,
61-
Color ActiveColor = default,
62-
Color InactiveColor = default,
83+
Color activeColor = default,
84+
Color inactiveColor = default,
6385
string description = "",
6486
string path = Icons.Default)
6587
{
66-
ActiveColor = ActiveColor == default ? DefaultActiveColor : ActiveColor;
67-
InactiveColor = InactiveColor == default ? DefaultInactiveColor : InactiveColor;
88+
activeColor = activeColor == default ? DefaultActiveColor : activeColor;
89+
inactiveColor = inactiveColor == default ? DefaultInactiveColor : inactiveColor;
6890

6991
Dimension2D size = DefaultUIElementSize;
7092

@@ -75,8 +97,8 @@ static void Add(InteractableKind type,
7597

7698
var setting = new InteractibleSetting()
7799
{
78-
ActiveColor = ActiveColor,
79-
InactiveColor = InactiveColor,
100+
ActiveColor = activeColor,
101+
InactiveColor = inactiveColor,
80102
Dimensions = size
81103
};
82104

@@ -86,83 +108,105 @@ static void Add(InteractableKind type,
86108
InteractibleSettings.Add(type, setting);
87109
}
88110

89-
Add(InteractableKind.Chest, 10, 8,
111+
Add(InteractableKind.Chest, 8, 6,
90112
description: "Chests, Roulette Chests",
91113
path: Icons.Chest);
92114

93-
Add(InteractableKind.Shop, 7, 7,
115+
Add(InteractableKind.Shop, 7, 5,
116+
activeColor: Colors.Teal,
94117
description: "Shops",
95118
path: Icons.Chest);
96119

97120
Add(InteractableKind.Equipment, 8, 6,
121+
activeColor: Colors.Orange,
98122
description: "Equipment Barrels",
99123
path: Icons.Chest);
100124

101125
Add(InteractableKind.Printer, 10, 8,
126+
activeColor: Colors.Purple,
102127
description: "Printers",
103128
path: Icons.Chest);
104129

105-
Add(InteractableKind.Utility,
130+
Add(InteractableKind.Utility, 5, 5,
106131
description: "Scrappers",
107-
path: Icons.LootBag);
132+
path: Icons.Wrench);
108133

109134
Add(InteractableKind.LunarPod, 7, 7,
110135
description: "Lunar pods (chests)",
136+
activeColor: Color.cyan,
111137
path: Icons.LootBag);
112138

113139
Add(InteractableKind.Shrine,
114140
description: "All shrines (excluding Newt)",
115141
path: Icons.Shrine);
116142

117143
Add(InteractableKind.Teleporter, 15, 15,
118-
ActiveColor: Color.white,
119-
InactiveColor: Color.green,
144+
activeColor: Color.white,
145+
inactiveColor: Color.green,
120146
description: "Boss teleporters",
121147
path: Icons.Boss);
122148

123-
Add(InteractableKind.Barrel, 5, 5,
149+
Add(InteractableKind.Barrel, 3, 3,
124150
description: "Barrels",
125151
path: Icons.Circle);
126152

127153
Add(InteractableKind.Drone, 7, 7,
128154
description: "Drones",
129155
path: Icons.Drone);
130156

131-
Add(InteractableKind.Special, 7, 7,
157+
Add(InteractableKind.Special, 5, 5,
132158
description: "Special interactibles such as the landing pod and fans",
133159
path: Icons.Default);
134160

135161
Add(InteractableKind.EnemyMonster, 3, 3,
136-
ActiveColor: Color.red,
162+
activeColor: Color.red,
137163
description: "Enemies",
138164
path: Icons.Circle);
139165

140166
Add(InteractableKind.EnemyLunar, 3, 3,
141-
ActiveColor: Color.red,
167+
activeColor: Color.red,
142168
description: "Lunar enemies",
143169
path: Icons.Circle);
144170

145-
Add(InteractableKind.EnemyVoid, 3, 3,
146-
ActiveColor: Color.magenta,
171+
Add(InteractableKind.EnemyVoid, 12, 12,
172+
activeColor: Color.magenta,
147173
description: "Void touched enemies",
148-
path: Icons.Circle);
174+
path: Icons.Attack);
149175

150176
Add(InteractableKind.Minion, 3, 3,
151-
ActiveColor: Color.green,
177+
activeColor: Color.green,
152178
description: "Minions",
153179
path: Icons.Circle);
154180

155181
Add(InteractableKind.Player, 8, 8,
156-
ActiveColor: PlayerIconColor,
157-
InactiveColor: PlayerIconColor,
182+
activeColor: PlayerIconColor,
183+
inactiveColor: PlayerIconColor,
158184
description: "Player, including friends",
159-
path: Icons.Circle);
185+
path: Icons.Sprint);
160186

161187
Add(InteractableKind.Item, 3, 3,
162-
ActiveColor: Color.cyan,
163-
InactiveColor: Color.cyan,
188+
activeColor: Colors.Teal,
189+
inactiveColor: Color.cyan,
164190
description: "Dropped items and lunar coins",
165191
path: Icons.Circle);
192+
193+
Add(InteractableKind.Portal, 7, 7,
194+
activeColor: DefaultActiveColor,
195+
inactiveColor: DefaultInactiveColor,
196+
description: "Portal markers, or objects that spawn portals when interacted with (excluding newt altar)",
197+
path: Icons.Portal);
198+
199+
Add(InteractableKind.Totem, 7, 7,
200+
activeColor: Colors.DarkTeal,
201+
inactiveColor: DefaultInactiveColor,
202+
description: "Totems, or totem adjacent objects",
203+
path: Icons.Cube);
204+
205+
Add(InteractableKind.Neutral, 4, 4,
206+
activeColor: Color.white,
207+
inactiveColor: DefaultInactiveColor,
208+
description: "Neutral objects or NPCs",
209+
path: Icons.Circle);
166210
}
167211

168212
public static InteractibleSetting GetSetting(InteractableKind type)

MiniMapLibrary/Sprites/SpriteManager.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ public sealed class SpriteManager : IDisposable, ISpriteManager
1212
{
1313
private readonly Dictionary<string, Sprite> SpriteCache = new Dictionary<string, Sprite>();
1414

15+
private readonly ILogger logger;
16+
17+
public SpriteManager(ILogger logger)
18+
{
19+
this.logger = logger;
20+
}
21+
1522
public void Dispose()
1623
{
1724
SpriteCache.Clear();
@@ -49,7 +56,17 @@ public void Dispose()
4956
}
5057
else
5158
{
52-
throw new MissingComponentException($"MissingTextureException: {Path} does not exist within the streaming assets");
59+
loaded = Resources.Load<Sprite>(Settings.Icons.Default);
60+
61+
if (loaded is null)
62+
{
63+
logger.LogError($"Attempted to use default icon for non-existen texture at {Path} but default icon path of {Settings.Icons.Default} also failed to load from the streaming assets path.");
64+
return null;
65+
}
66+
67+
logger.LogWarning($"Attempted to load icon texture at streaming asset path: {Path}, but it was not found, using default [?] instead.");
68+
69+
SpriteCache.Add(Path, loaded);
5370
}
5471

5572
return loaded;

0 commit comments

Comments
 (0)