-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathStarlightRiver.cs
More file actions
116 lines (96 loc) · 2.52 KB
/
StarlightRiver.cs
File metadata and controls
116 lines (96 loc) · 2.52 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
global using Microsoft.Xna.Framework;
global using Microsoft.Xna.Framework.Graphics;
global using ReLogic.Content;
global using StarlightRiver.Core;
global using StarlightRiver.Helpers;
global using Terraria;
global using Terraria.Localization;
global using Terraria.ModLoader;
using StarlightRiver.Content.Abilities;
using StarlightRiver.Content.Bestiary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Terraria.ID;
namespace StarlightRiver
{
public class StarlightRiver : Mod
{
private List<IOrderedLoadable> loadCache;
public static bool debugMode = false;
public static StarlightRiver Instance { get; set; }
public AbilityHotkeys AbilityKeys { get; private set; }
public StarlightRiver()
{
Instance = this;
}
public override void Load()
{
#if DEBUG
debugMode = true;
#endif
loadCache = new List<IOrderedLoadable>();
foreach (Type type in Code.GetTypes())
{
if (!type.IsAbstract && type.GetInterfaces().Contains(typeof(IOrderedLoadable)))
{
object instance = Activator.CreateInstance(type);
loadCache.Add(instance as IOrderedLoadable);
}
loadCache.Sort((n, t) => n.Priority.CompareTo(t.Priority));
}
for (int k = 0; k < loadCache.Count; k++)
{
loadCache[k].Load();
Terraria.ModLoader.UI.Interface.loadMods.SubProgressText = "Loading " + loadCache[k].GetType().Name;
}
if (!Main.dedServ)
{
//Hotkeys
AbilityKeys = new AbilityHotkeys(this);
AbilityKeys.LoadDefaults();
}
}
public override void Unload()
{
if (loadCache != null)
{
foreach (IOrderedLoadable loadable in loadCache)
{
loadable.Unload();
}
loadCache = null;
}
else
{
Logger.Warn("load cache was null, IOrderedLoadable's may not have been unloaded...");
}
if (!Main.dedServ)
{
Instance ??= null;
AbilityKeys?.Unload();
SLRSpawnConditions.Unload();
}
}
public override void PostSetupContent()
{
Compat.BossChecklist.BossChecklistCalls.CallBossChecklist();
Compat.Wikithis.WikithisWrapper.AddStarlightRiverWikiUrl();
NetEasy.NetEasy.Register(this);
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
{
if (!type.IsAbstract && type.GetInterfaces().Contains(typeof(IPostLoadable)))
{
object toLoad = Activator.CreateInstance(type);
((IPostLoadable)toLoad).PostLoad();
}
}
}
public override void HandlePacket(BinaryReader reader, int whoAmI)
{
NetEasy.NetEasy.HandleModule(reader, whoAmI);
}
}
}