Skip to content

Commit e792a1e

Browse files
authored
Merge pull request #6 from DekuDesu/development
hotfix- performance
2 parents e06bce2 + 882fe06 commit e792a1e

12 files changed

Lines changed: 364 additions & 113 deletions

File tree

MiniMapLibrary/Interactible/InteractableKind.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public enum InteractableKind
1818
Player = 1 << 6,
1919
Drone = 1 << 7,
2020
Barrel = 1 << 8,
21+
Enemy = 1 << 9,
2122
All = 0b_1111_1
2223
}
2324
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using UnityEngine;
5+
6+
namespace MiniMapLibrary
7+
{
8+
public class InteractibleSetting
9+
{
10+
public Dimension2D Dimensions { get; set; }
11+
public Color ActiveColor { get; set; }
12+
public Color InactiveColor { get; set; }
13+
}
14+
}

MiniMapLibrary/Settings.cs

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ public static class Settings
1313

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

16-
public static IDictionary<InteractableKind, Dimension2D> InteractableSizes { get; } = new Dictionary<InteractableKind, Dimension2D>();
16+
public static IDictionary<InteractableKind, InteractibleSetting> InteractibleSettings { get; } = new Dictionary<InteractableKind, InteractibleSetting>();
1717

1818
private static readonly Dimension2D DefaultUIElementSize = new Dimension2D(10, 10);
1919

2020
public static Color PlayerIconColor { get; set; } = Color.white;
2121

22-
public static Color DefaultIconColor { get; set; } = Color.yellow;
22+
public static Color DefaultActiveColor { get; set; } = Color.yellow;
23+
24+
public static Color DefaultInactiveColor { get; set; } = Color.grey;
2325

2426
static Settings()
2527
{
@@ -28,34 +30,72 @@ static Settings()
2830

2931
private static void InitializeDefaultSettings()
3032
{
31-
void AddSize(InteractableKind type, float width = -1, float height = -1)
33+
void AddSize(InteractableKind type, float width = -1, float height = -1, Color ActiveColor = default, Color InactiveColor = default)
3234
{
35+
ActiveColor = ActiveColor == default ? DefaultActiveColor : ActiveColor;
36+
InactiveColor = InactiveColor == default ? DefaultInactiveColor : InactiveColor;
37+
3338
Dimension2D size = DefaultUIElementSize;
3439

3540
if (width != -1 || height != -1)
3641
{
3742
size = new Dimension2D(width, height);
3843
}
3944

40-
InteractableSizes.Add(type, size);
45+
var setting = new InteractibleSetting()
46+
{
47+
ActiveColor = ActiveColor,
48+
InactiveColor = InactiveColor,
49+
Dimensions = size
50+
};
51+
52+
InteractibleSettings.Add(type, setting);
4153
}
4254

43-
AddSize(InteractableKind.Chest);
55+
AddSize(InteractableKind.Chest, 10, 8);
4456
AddSize(InteractableKind.Shrine);
45-
AddSize(InteractableKind.Teleporter);
46-
AddSize(InteractableKind.Player);
57+
AddSize(InteractableKind.Teleporter, 15, 15, ActiveColor: Color.white, InactiveColor: Color.green);
58+
AddSize(InteractableKind.Player, 8, 8, ActiveColor: PlayerIconColor, InactiveColor: PlayerIconColor);
4759
AddSize(InteractableKind.Barrel, 5, 5);
48-
AddSize(InteractableKind.Drone);
60+
AddSize(InteractableKind.Drone, 7, 7);
4961
AddSize(InteractableKind.Primary);
50-
AddSize(InteractableKind.Special);
62+
AddSize(InteractableKind.Special, 7, 7);
63+
AddSize(InteractableKind.Enemy, 3, 3, ActiveColor: Color.red);
5164
AddSize(InteractableKind.Utility);
5265
}
5366

67+
public static InteractibleSetting GetSetting(InteractableKind type)
68+
{
69+
if (InteractibleSettings.ContainsKey(type))
70+
{
71+
return InteractibleSettings[type];
72+
}
73+
74+
return new InteractibleSetting()
75+
{
76+
Dimensions = DefaultUIElementSize,
77+
ActiveColor = DefaultActiveColor,
78+
InactiveColor = DefaultInactiveColor
79+
};
80+
}
81+
82+
public static Color GetColor(InteractableKind type, bool active)
83+
{
84+
if (InteractibleSettings.ContainsKey(type))
85+
{
86+
var setting = InteractibleSettings[type];
87+
88+
return active ? setting.ActiveColor : setting.InactiveColor;
89+
}
90+
91+
return active ? DefaultActiveColor : DefaultInactiveColor;
92+
}
93+
5494
public static Dimension2D GetInteractableSize(InteractableKind type)
5595
{
56-
if (InteractableSizes.ContainsKey(type))
96+
if (InteractibleSettings.ContainsKey(type))
5797
{
58-
return InteractableSizes[type];
98+
return InteractibleSettings[type].Dimensions ?? DefaultUIElementSize;
5999
}
60100

61101
return DefaultUIElementSize;

MiniMapLibrary/SpriteManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void Add(InteractableKind type, string ResourcePath)
3636
Add(InteractableKind.Drone, "Textures/MiscIcons/texDroneIconOutlined");
3737
Add(InteractableKind.Utility, "Textures/MiscIcons/texLootIconOutlined");
3838
Add(InteractableKind.Barrel, "Textures/MiscIcons/texBarrelIcon");
39+
Add(InteractableKind.Enemy, "Textures/MiscIcons/texBarrelIcon");
3940
Add(InteractableKind.Player, "Textures/MiscIcons/texBarrelIcon");
4041
Add(InteractableKind.All, DefaultResourcePath);
4142
}

MiniMapMod/ITrackedObject.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using MiniMapLibrary;
2+
using UnityEngine;
3+
4+
namespace MiniMapMod
5+
{
6+
public interface ITrackedObject
7+
{
8+
GameObject gameObject { get; set; }
9+
InteractableKind InteractableType { get; set; }
10+
RectTransform MinimapTransform { get; set; }
11+
bool DynamicObject { get; set; }
12+
13+
void CheckActive();
14+
void Destroy();
15+
}
16+
}

0 commit comments

Comments
 (0)