-
Notifications
You must be signed in to change notification settings - Fork 1
/
BombusApisBee.cs
140 lines (114 loc) · 4.87 KB
/
BombusApisBee.cs
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
global using BombusApisBee.BeeDamageClass;
global using BombusApisBee.Buffs;
global using BombusApisBee.Core;
global using BombusApisBee.Dusts;
global using BombusApisBee.Effects;
global using BombusApisBee.Items.Accessories.BeeKeeperDamageClass;
global using BombusApisBee.Items.Armor.BeeKeeperDamageClass;
global using BombusApisBee.Items.Weapons.BeeKeeperDamageClass;
global using BombusApisBee.PrimitiveDrawing;
global using BombusApisBee.Projectiles;
global using Microsoft.Xna.Framework;
global using Microsoft.Xna.Framework.Graphics;
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;
global using Terraria;
global using Terraria.Audio;
global using Terraria.GameContent;
global using Terraria.Graphics.Effects;
global using Terraria.ID;
global using Terraria.ModLoader;
global using static Terraria.ModLoader.ModContent;
using BombusApisBee.Core.PixelationSystem;
using BombusApisBee.UI;
using ReLogic.Content;
using System.Reflection;
using Terraria.UI;
namespace BombusApisBee
{
public class BombusApisBee : Mod
{
public static Color honeyIncreaseColor = new Color(255, 226, 43);
public static readonly SoundStyle HoneycombWeapon = SoundID.NPCDeath1 with { Pitch = -0.2f, PitchVariance = 0.2f };
public static string BeeWeapon = "BombusApisBee/Items/Weapons/BeeKeeperDamageClass/";
public static string Invisible = "BombusApisBee/ExtraTextures/Invisible";
public static string Palettes = "BombusApisBee/ExtraTextures/Palettes/";
public static ModKeybind HoneyManipulatorHotkey;
public static ModKeybind LihzardianRelicHotkey;
public static ModKeybind BeekeeperStateSwitchHotkey;
public Asset<Texture2D> stinger;
public Asset<Texture2D> bee;
public Asset<Texture2D> giantBee;
public Asset<Texture2D> wasp;
public Asset<Texture2D> beeArrow;
public UserInterface BeeDamageInterface;
public BeePlayerUI BeePlayerUI;
private List<IOrderedLoadable> loadCache;
public static void SetLoadingText(string text)
{
FieldInfo Interface_loadMods = typeof(Mod).Assembly.GetType("Terraria.ModLoader.UI.Interface")!.GetField("loadMods", BindingFlags.NonPublic | BindingFlags.Static)!;
MethodInfo UIProgress_set_SubProgressText = typeof(Mod).Assembly.GetType("Terraria.ModLoader.UI.UIProgress")!.GetProperty("SubProgressText", BindingFlags.Public | BindingFlags.Instance)!.GetSetMethod()!;
UIProgress_set_SubProgressText.Invoke(Interface_loadMods.GetValue(null), new object[] { text });
}
public override void PostSetupContent()
{
NetEasy.NetEasy.Register(this);
}
public override void Load()
{
if (!Main.dedServ)
{
BeeShaders.Load();
//MarkedNPCDrawer.Load();
PlayerRenderTarget.Load();
BombusApisBee_DoIL.Load();
BombusApisBee_DoDetours.Load();
BeeDamageInterface = new UserInterface();
BeePlayerUI = new BeePlayerUI();
BeePlayerUI.Activate();
BeeDamageInterface.SetState(BeePlayerUI);
}
DrawPrimitives.Load();
HoneyManipulatorHotkey = KeybindLoader.RegisterKeybind(this, "Honey Manipulation", "Y");
LihzardianRelicHotkey = KeybindLoader.RegisterKeybind(this, "Lihzardian Hornet Relic", "L");
BeekeeperStateSwitchHotkey = KeybindLoader.RegisterKeybind(this, "Change Beekeeper State", "N");
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();
SetLoadingText("Loading " + loadCache[k].GetType().Name);
}
}
public override void Unload()
{
//MarkedNPCDrawer.Unload();
BombusApisBee_DoIL.Unload();
BombusApisBee_DoDetours.Unload();
HoneyManipulatorHotkey = null;
LihzardianRelicHotkey = null;
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...");
}
}
}
}