-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathMBAddonLoader.cs
More file actions
75 lines (61 loc) · 2.55 KB
/
MBAddonLoader.cs
File metadata and controls
75 lines (61 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System.Collections.Generic;
//using Terraria.GameContent.Liquid;
using MetroidMod.ID;
using Terraria;
namespace MetroidMod
{
public static class MBAddonLoader
{
internal static readonly List<ModMBAddon> addons = new();
internal static readonly List<GlobalMBAddon> globalAddons = new();
public static int BombsRecipeGroupID => MetroidMod.MorphBallBombsRecipeGroupID;
internal static bool TryGetValue(this IList<ModMBAddon> list, int type, out ModMBAddon modMBAddon) =>
list.TryGetValue(i => i.Type == type, out modMBAddon);
internal static bool TryGetValue(this IList<ModMBAddon> list, string fullName, out ModMBAddon modMBAddon) =>
list.TryGetValue(i => i.FullName == fullName, out modMBAddon);
internal static bool TryGetValue(this IList<ModMBAddon> list, Item item, out ModMBAddon modMBAddon) =>
list.TryGetValue(i => i.ItemType == item.type, out modMBAddon);
public static bool TryGetAddon(Item item, out ModMBAddon modMBAddon) =>
addons.TryGetValue(item, out modMBAddon);
public static bool TryGetAddon(int type, out ModMBAddon modMBAddon) =>
addons.TryGetValue(type, out modMBAddon);
public static bool TryGetAddon(string fullName, out ModMBAddon modMBAddon) =>
addons.TryGetValue(fullName, out modMBAddon);
public static bool TryGetAddon<T>(out ModMBAddon modMBAddon) where T : ModMBAddon =>
addons.TryGetValue(i => i is T, out modMBAddon);
public static int AddonCount => addons.Count;
public static ModMBAddon GetAddon(Item item) =>
addons.TryGetValue(item, out ModMBAddon modMBAddon) ? modMBAddon : null;
public static ModMBAddon GetAddon(int type) =>
addons.TryGetValue(type, out ModMBAddon modMBAddon) ? modMBAddon : null;
public static ModMBAddon GetAddon(string fullName) =>
addons.TryGetValue(fullName, out ModMBAddon modMBAddon) ? modMBAddon : null;
public static ModMBAddon GetAddon<T>() where T : ModMBAddon =>
addons.TryGetValue(i => i is T, out ModMBAddon modMBAddon) ? modMBAddon : null;
public static bool IsAMorphTile(Tile tile)
{
foreach (ModMBAddon addon in addons)
{
if (tile.TileType == addon.TileType) { return true; }
}
return false;
}
public static string GetAddonSlotName(int AddonSlot)
{
return AddonSlot switch
{
MorphBallAddonSlotID.Drill => "Drill",
MorphBallAddonSlotID.Weapon => "Weapon",
MorphBallAddonSlotID.Special => "Special",
MorphBallAddonSlotID.Utility => "Utility",
MorphBallAddonSlotID.Boost => "Boost",
_ => "Unknown"
};
}
internal static void Unload()
{
addons.Clear();
globalAddons.Clear();
}
}
}