-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMultiLureSystem.cs
More file actions
131 lines (114 loc) · 5.47 KB
/
MultiLureSystem.cs
File metadata and controls
131 lines (114 loc) · 5.47 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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using System;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace MultiLure {
internal class MultiLureSystem : ModSystem {
internal const string WhiteStringGroup = "MultiLure:WhiteString";
internal const string CopperBarGroup = "MultiLure:CopperBar";
internal const string IronBarGroup = "MultiLure:IronBar";
internal const string SilverBarGroup = "MultiLure:SilverBar";
internal const string GoldBarGroup = "MultiLure:GoldBar";
internal const string CobaltBarGroup = "MultiLure:CobaltBar";
internal const string MythrilBarGroup = "MultiLure:MythrilBar";
internal const string AdamantiteBarGroup = "MultiLure:AdamantiteBar";
public static RepeatHotKey AddLureKey;
public static RepeatHotKey RemoveLureKey;
public override void Load() {
if(ModContent.GetInstance<MultiLureConfig>().EnableHotkeys) {
AddLureKey = new RepeatHotKey(Mod, "AddLure", Keys.OemCloseBrackets.ToString());
RemoveLureKey = new RepeatHotKey(Mod, "RemoveLure", Keys.OemOpenBrackets.ToString());
}
}
public override void AddRecipeGroups() {
var any = Language.GetText("LegacyMisc.37");
RecipeGroup whiteString = new(
() => $"{any} {Language.GetTextValue("ItemName.WhiteString")}",
ItemID.WhiteString, ItemID.BlackString, ItemID.BlueString,
ItemID.BrownString, ItemID.CyanString, ItemID.GreenString,
ItemID.LimeString, ItemID.OrangeString, ItemID.PinkString,
ItemID.PurpleString, ItemID.RainbowString, ItemID.RedString,
ItemID.SkyBlueString, ItemID.TealString, ItemID.VioletString,
ItemID.YellowString);
RecipeGroup copperBar = new(
() => $"{any} {Language.GetText("ItemName.CopperBar")}",
ItemID.CopperBar, ItemID.TinBar);
RecipeGroup ironBar = new(
() => $"{any} {Language.GetText("ItemName.IronBar")}",
ItemID.IronBar, ItemID.LeadBar);
RecipeGroup silverBar = new(
() => $"{any} {Language.GetText("ItemName.SilverBar")}",
ItemID.SilverBar, ItemID.TungstenBar);
RecipeGroup goldBar = new(
() => $"{any} {Language.GetText("ItemName.GoldBar")}",
ItemID.GoldBar, ItemID.PlatinumBar);
RecipeGroup cobaltBar = new(
() => $"{any} {Language.GetText("ItemName.CobaltBar")}",
ItemID.CobaltBar, ItemID.PalladiumBar);
RecipeGroup mythrilBar = new(
() => $"{any} {Language.GetText("ItemName.MythrilBar")}",
ItemID.MythrilBar, ItemID.OrichalcumBar);
RecipeGroup adamantiteBar = new(
() => $"{any} {Language.GetText("ItemName.AdamantiteBar")}",
ItemID.AdamantiteBar, ItemID.TitaniumBar);
RecipeGroup.RegisterGroup(WhiteStringGroup, whiteString);
RecipeGroup.RegisterGroup(CopperBarGroup, copperBar);
RecipeGroup.RegisterGroup(IronBarGroup, ironBar);
RecipeGroup.RegisterGroup(SilverBarGroup, silverBar);
RecipeGroup.RegisterGroup(GoldBarGroup, goldBar);
RecipeGroup.RegisterGroup(CobaltBarGroup, cobaltBar);
RecipeGroup.RegisterGroup(MythrilBarGroup, mythrilBar);
RecipeGroup.RegisterGroup(AdamantiteBarGroup, adamantiteBar);
}
public override void PostUpdateInput() {
if(AddLureKey == null || RemoveLureKey == null)
return;
GameTime time = Main._drawInterfaceGameTime;
if(AddLureKey.Update(time)) {
ChangeLures(true);
}
else if(RemoveLureKey.Update(time)) {
ChangeLures(false);
}
}
public static void ChangeLures(bool increase) {
MultiLurePlayer player = Main.CurrentPlayer.GetModPlayer<MultiLurePlayer>();
if(player.CheatLureMinimum < player.LureMinimum) {
player.CheatLureMinimum = player.LureMinimum;
}
bool success = true;
int count = (increase ? 1 : -1);
if(Main.keyState.PressingShift()) {
count = (increase ? 10 : -10);
}
int cheatMinimum = player.CheatLureMinimum + count;
if(increase && cheatMinimum > player.LureMaximum ||
!increase && cheatMinimum < player.LureMinimum) {
success = false;
}
else {
player.CheatLureMinimum =
Math.Clamp(cheatMinimum, player.LureMinimum, player.LureMaximum);
}
if(success) {
Main.NewText(
Language.GetTextValue(
increase
? "Mods.MultiLure.LuresIncreased"
: "Mods.MultiLure.LuresDecreased",
player.CheatLureMinimum));
}
else {
Main.NewText(
increase
? Language.GetTextValue("Mods.MultiLure.LuresMaximum", player.LureMaximum)
: Language.GetTextValue("Mods.MultiLure.LuresMinimum", player.LureMinimum));
if(increase) AddLureKey.Stop();
else RemoveLureKey.Stop();
}
}
}
}