-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLight.cs
More file actions
165 lines (155 loc) · 5.8 KB
/
Copy pathLight.cs
File metadata and controls
165 lines (155 loc) · 5.8 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
159
160
161
162
163
164
165
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.IO;
using Terraria.GameInput;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using Terraria.DataStructures;
using Terraria.GameContent.UI;
using System;
using System.Linq;
using Light.Items;
using Light.Buffs;
using static Terraria.ModLoader.ModContent;
using Terraria.UI;
using Light.UI;
//lumancy?
namespace Light {
public class Light : Mod {
private readonly HotKey ModeSwitch = new HotKey("Toggle Lumomancy", Keys.BrowserBack);
//private static readonly HotKey Channel = new HotKey("Charge Item", Keys.E);
//public static ModHotKey ChargeKey;
public static ModHotKey ControlModeSwitch;
//public static readonly HotKey Ult = new HotKey("Use Ultimate", Keys.Q);
public static Light Instance { get; private set; }
internal UserInterface UI;
internal static bool forgingHotbarActive;
public static void ApplyLuxBoosts(ref NPC npc) {
npc.npcSlots *= 20f;
npc.damage = (int)(npc.damage*1.56);
npc.defense *= 2;
npc.lifeMax = (int)(npc.lifeMax*2.5);
npc.life = npc.lifeMax;
npc.AddBuff(ModContent.BuffType<Lux>(), 3*npc.life);
npc.value = (int)(2*npc.value);
npc.GivenName = "Lux " + npc.GivenOrTypeName;
npc.rarity = (int)Math.Max(npc.rarity + 1, npc.rarity * 1.5f);
//npc.DisplayName.set("Lux "+npc.DisplayName.Get());
}
public static void ApplyShadeBoosts(ref NPC npc) {
npc.npcSlots *= 20f;
npc.damage = (int)(npc.damage*2.56);
npc.defense += 15;
npc.defense *= 2;
npc.lifeMax = (int)(npc.lifeMax*2.5);
npc.life = npc.lifeMax;
npc.AddBuff(ModContent.BuffType<Umbra>(), 5*npc.life);
npc.value = (int)(3.5*npc.value);
npc.GivenName = "Umbra " + npc.GivenOrTypeName;
npc.rarity = (int)Math.Max(npc.rarity + 2, npc.rarity * 2);
//npc.modNPC.music = MusicID.PumpkinMoon;
if(npc.modNPC != null) {
npc.modNPC.music = MusicID.PumpkinMoon;
}
//npc.music = 0;
//npc.DisplayName.set("Umbra "+npc.DisplayName.Get());
}
public override void Load() {
Instance = this;
LightItem.LightItems = new HashSet<(int, int)>();
ControlModeSwitch = ModeSwitch.Register(this);
if (Main.netMode!=NetmodeID.Server){
UI = new UserInterface();
}
}
public override void Unload() {
LightItem.LightItems = null;
ControlModeSwitch = null;
UI = null;
}
public Light() {
Properties = new ModProperties() {
Autoload = true,
AutoloadGores = true,
AutoloadSounds = true
};
}
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers) {
if(forgingHotbarActive) {
if(Main.playerInventory) {
forgingHotbarActive = false;
return;
}
int hotbarIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Hotbar"));
if (hotbarIndex != -1) {
layers[hotbarIndex] = new LegacyGameInterfaceLayer(
"Light: ForgeHotbarUI",
delegate {
ForgingHotbarUI.Draw();
return true;
},
InterfaceScaleType.UI);
}
}
int inventoryIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Inventory"));
if (inventoryIndex != -1) {
if(!Main.playerInventory && ForgeSelectorUIActive) {
UI.SetState(null);
return;
}
layers.Insert(inventoryIndex + 1, new LegacyGameInterfaceLayer(
"Light: ForgeInventoryUI",
delegate {
// If the current UIState of the UserInterface is null, nothing will draw. We don't need to track a separate .visible value.
UI.Draw(Main.spriteBatch, new GameTime());
return true;
},
InterfaceScaleType.UI)
);
}
}
public bool ForgeSelectorUIActive => UI.CurrentState is ForgingInventoryUI;
public void ToggleForgeSelectorUI() {
if(UI.CurrentState is ForgingInventoryUI) {
UI.SetState(null);
} else {
ForgingInventoryUI forgingUI = new ForgingInventoryUI();
UI.SetState(forgingUI);
}
}
public static bool GetBitFromInt(int data, int position) {
int intReturn = data & (1 << position);
return (intReturn != 0);
}
public static void SetBitToInt(ref int data, int position) {
data |= (1 << position);
}
public static void UnsetBitToInt(ref int data, int position) {
data &= ~(1 << position);
}
public override void AddRecipeGroups() {
RecipeGroup group = new RecipeGroup(() => "Vines", new int[] {
ItemID.Vine,
ItemID.VineRope
});
RecipeGroup.RegisterGroup("Light:Vines", group);
}
public static short SetStaticDefaultsGlowMask(ModItem modItem) {
if (Main.netMode!=NetmodeID.Server) {
Texture2D[] glowMasks = new Texture2D[Main.glowMaskTexture.Length + 1];
for (int i = 0; i < Main.glowMaskTexture.Length; i++) {
glowMasks[i] = Main.glowMaskTexture[i];
}
glowMasks[glowMasks.Length - 1] = Instance.GetTexture("Items/" + modItem.GetType().Name);
Main.glowMaskTexture = glowMasks;
return (short)(glowMasks.Length - 1);
} else return 0;
}
}
}