-
Notifications
You must be signed in to change notification settings - Fork 1
/
MultiLure.cs
72 lines (59 loc) · 3.02 KB
/
MultiLure.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
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
// TODO: reset lures if hotkeys/integrations off and item deleted
namespace MultiLure {
public class MultiLure : Mod {
private const string AddLureTexture = "MultiLure/Textures/AddLure";
private const string RemoveLureTexture = "MultiLure/Textures/RemoveLure";
internal const string PermissionName = "ModifyLureCount";
public MultiLure() {
ContentAutoloadingEnabled = true;
}
public override void PostSetupContent() {
Func<string> addTooltip = ()
=> $"Add Lure (Current: " +
$"{Main.CurrentPlayer.GetModPlayer<MultiLurePlayer>().LureCount})";
Func<string> removeTooltip = ()
=> $"Remove Lure (Current: " +
$"{Main.CurrentPlayer.GetModPlayer<MultiLurePlayer>().LureCount})";
MultiLureConfig config = ModContent.GetInstance<MultiLureConfig>();
if(config.EnableCheatSheetIntegration) {
if(ModLoader.TryGetMod("CheatSheet", out Mod cheatSheet) && !Main.dedServ) {
cheatSheet.Call("AddButton_Test",
ModContent.Request<Texture2D>(AddLureTexture),
(Action)delegate { MultiLureSystem.ChangeLures(true); },
addTooltip);
cheatSheet.Call("AddButton_Test",
ModContent.Request<Texture2D>(RemoveLureTexture),
(Action)delegate { MultiLureSystem.ChangeLures(false); },
removeTooltip);
}
}
if(config.EnableHerosModIntegration) {
if(ModLoader.TryGetMod("HEROsMod", out Mod herosMod)) {
herosMod.Call("AddPermission", PermissionName, "Modify Lure Count");
if(!Main.dedServ) {
herosMod.Call("AddSimpleButton", PermissionName, ModContent.Request<Texture2D>(AddLureTexture),
(Action)delegate { MultiLureSystem.ChangeLures(true); },
(Action<bool>)PermissionsChanged,
addTooltip);
herosMod.Call("AddSimpleButton", PermissionName, ModContent.Request<Texture2D>(RemoveLureTexture),
(Action)delegate { MultiLureSystem.ChangeLures(false); },
(Action<bool>)PermissionsChanged,
removeTooltip);
}
}
}
}
public static void PermissionsChanged(bool hasPermission) {
if(!hasPermission) {
MultiLurePlayer player
= Main.CurrentPlayer.GetModPlayer<MultiLurePlayer>();
player.LureMinimum = 1;
player.LureMaximum = 1;
}
}
}
}