forked from RazzSG/ClickerClass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClickerClass.cs
More file actions
158 lines (139 loc) · 3.87 KB
/
ClickerClass.cs
File metadata and controls
158 lines (139 loc) · 3.87 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
using ClickerClass.Core.Netcode;
using ClickerClass.Effects;
using ClickerClass.UI;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using Terraria;
using Terraria.ModLoader;
using Terraria.UI;
namespace ClickerClass
{
public class ClickerClass : Mod
{
public static ModHotKey AutoClickKey;
internal static ClickerClass mod;
/// <summary>
/// Populated by the buffs themselves, includes all buffs that bosses should be immune to (so no more manual npc.buffImmune)
/// </summary>
internal static HashSet<int> BossBuffImmunity;
/// <summary>
/// To prevent certain methods being called when they shouldn't
/// </summary>
internal static bool finalizedRegisterCompat = false;
public override void Load()
{
finalizedRegisterCompat = false;
mod = this;
BossBuffImmunity = new HashSet<int>();
AutoClickKey = RegisterHotKey("Clicker Accessory", "G"); //Can't localize this
ClickerSystem.Load();
ClickEffect.LoadMiscEffects();
NetHandler.Load();
if (!Main.dedServ)
{
LoadClient();
}
}
public override void Unload()
{
finalizedRegisterCompat = false;
ShaderManager.Unload();
ClickerSystem.Unload();
ClickEffect.Unload();
NetHandler.Unload();
ClickerInterfaceResources.Unload();
AutoClickKey = null;
BossBuffImmunity = null;
mod = null;
}
private void LoadClient()
{
ShaderManager.Load();
ClickerInterfaceResources.Load();
}
private GameTime _lastUpdateUIGameTime;
public override void UpdateUI(GameTime gameTime)
{
_lastUpdateUIGameTime = gameTime;
ClickerInterfaceResources.Update(gameTime);
}
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
{
ClickerInterfaceResources.AddDrawLayers(layers);
//Remove Mouse Cursor
if (Main.cursorOverride == -1 && ClickerConfigClient.Instance.ShowCustomCursors)
{
Player player = Main.LocalPlayer;
if (ClickerCursor.CanDrawCursor(player.HeldItem))
{
for (int i = 0; i < layers.Count; i++)
{
if (layers[i].Name.Equals("Vanilla: Cursor"))
{
layers.RemoveAt(i);
break;
}
}
}
}
}
public override object Call(params object[] args)
{
return ClickerModCalls.Call(args);
}
public override void AddRecipes()
{
ClickerRecipes.AddRecipes();
}
public override void PostSetupContent()
{
//Only clicker weapons
RecipeBrowser_AddToCategory("Clickers", "Weapons", "UI/RecipeBrowser_Clickers", (Item item) =>
{
return ClickerSystem.IsClickerWeapon(item);
});
//Every other clicker item
RecipeBrowser_AddToCategory("Clicker Items", "Other", "UI/RecipeBrowser_ClickerItems", (Item item) =>
{
return ClickerSystem.IsClickerItem(item) && !ClickerSystem.IsClickerWeapon(item);
});
}
public override void PostAddRecipes()
{
finalizedRegisterCompat = true;
ClickerSystem.FinalizeLocalization();
}
public override void AddRecipeGroups()
{
ClickerRecipes.AddRecipeGroups();
}
public override void HandlePacket(BinaryReader reader, int whoAmI)
{
NetHandler.HandlePackets(reader, whoAmI);
}
/// <summary>
/// Attempts to add a subcategory to Recipe Browser
/// </summary>
/// <param name="name">The displayed subcategory name</param>
/// <param name="category">The parent category</param>
/// <param name="texture">The 24x24 path to texture within the mod</param>
/// <param name="predicate">The condition at which an item is listed in this subcategory</param>
private void RecipeBrowser_AddToCategory(string name, string category, string texture, Predicate<Item> predicate)
{
Mod recipeBrowser = ModLoader.GetMod("RecipeBrowser");
if (recipeBrowser != null && !Main.dedServ)
{
recipeBrowser.Call(new object[5]
{
"AddItemCategory",
name,
category,
this.GetTexture(texture), // 24x24 icon
predicate
});
}
}
}
}