-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHMPlusLib.cs
59 lines (49 loc) · 2.06 KB
/
HMPlusLib.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
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace HMPlus.Lib {
public static class HMPlusLib {
public static int [] evilBrickIDs { get; private set; }
public static int [] evilBarIDs { get; private set; }
public static int [] ironBarIDs { get; private set; }
public static int [] goldBarIDs { get; private set; }
public static int [] tier3SwordIDs { get; private set; }
public static void Init () {
evilBrickIDs = new int [] { ItemID.DemoniteBrick, ItemID.CrimtaneBrick };
evilBarIDs = new int [] { ItemID.DemoniteBar, ItemID.CrimtaneBar };
ironBarIDs = new int [] { ItemID.IronBar, ItemID.LeadBar };
goldBarIDs = new int [] { ItemID.GoldBar, ItemID.PlatinumBar };
tier3SwordIDs = new int [] { ItemID.AdamantiteSword, ItemID.TitaniumSword };
}
public static bool NPCIsMechanicalBoss (Mod mod, NPC npc) {
return npc.type == mod.NPCType ("Mechoraum") || npc.type == 134 || npc.type == 135 || npc.type == 136 || npc.type == 139 || (npc.type >= 125 && npc.type <= 131);
}
public static void NPCDropModItem (Mod mod, NPC npc, string itemName, int amount = 1) {
Item.NewItem ((int) npc.position.X, (int) npc.position.Y, npc.width, npc.height, mod.ItemType (itemName), amount);
}
public static void NPCDropItem (Mod mod, NPC npc, int itemType, int amount = 1) {
Item.NewItem ((int) npc.position.X, (int) npc.position.Y, npc.width, npc.height, itemType, amount);
}
public static bool NPCCannotReceiveDamage (NPC npc) {
return npc == null || npc.immortal || !npc.active || npc.dontTakeDamage || npc.takenDamageMultiplier == 0f;
}
public static bool ModIsInstalled (string name) {
return ModLoader.GetMod (name) != null;
}
}
public class ColorCycle {
public int index { get; private set; }
public int length { get; private set; }
public Color [] colors { get; private set; }
public ColorCycle (Color [] colors) {
index = -1;
length = colors.Length;
this.colors = colors;
}
public Color Next () {
index = (index + 1) % length;
return colors [index];
}
}
}