This repository has been archived by the owner on Jan 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathTremorGlowMask.cs
101 lines (96 loc) · 3.48 KB
/
TremorGlowMask.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
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
using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
using Terraria.ModLoader;
namespace Tremor
{
public class TremorGlowMask : ModPlayer
{
private static readonly Dictionary<int, Texture2D> ItemGlowMask = new Dictionary<int, Texture2D>();
internal static void Unload()
{
ItemGlowMask.Clear();
}
public static void AddGlowMask(int itemType, string texturePath)
{
ItemGlowMask[itemType]=ModLoader.GetTexture(texturePath);
}
public override void ModifyDrawLayers(List<PlayerLayer> layers)
{
Texture2D textureLegs;
if (!player.armor[12].IsAir)
{
if (player.armor[12].type >= ItemID.Count && ItemGlowMask.TryGetValue(player.armor[12].type, out textureLegs))//Vanity Legs
{
InsertAfterVanillaLayer(layers, "Legs", new PlayerLayer(mod.Name, "GlowMaskLegs", delegate (PlayerDrawInfo info)
{
TremorUtils.DrawArmorGlowMask(EquipType.Legs, textureLegs, info);
}));
}
}
else if (player.armor[2].type >= ItemID.Count && ItemGlowMask.TryGetValue(player.armor[2].type, out textureLegs))//Legs
{
InsertAfterVanillaLayer(layers, "Legs", new PlayerLayer(mod.Name, "GlowMaskLegs", delegate (PlayerDrawInfo info)
{
TremorUtils.DrawArmorGlowMask(EquipType.Legs, textureLegs, info);
}));
}
Texture2D textureBody;
if (!player.armor[11].IsAir)
{
if (player.armor[11].type >= ItemID.Count && ItemGlowMask.TryGetValue(player.armor[11].type, out textureBody))//Vanity Body
{
InsertAfterVanillaLayer(layers, "Body", new PlayerLayer(mod.Name, "GlowMaskBody", delegate (PlayerDrawInfo info)
{
TremorUtils.DrawArmorGlowMask(EquipType.Body, textureBody, info);
}));
}
}
else if (player.armor[1].type >= ItemID.Count && ItemGlowMask.TryGetValue(player.armor[1].type, out textureBody))//Body
{
InsertAfterVanillaLayer(layers, "Body", new PlayerLayer(mod.Name, "GlowMaskBody", delegate (PlayerDrawInfo info)
{
TremorUtils.DrawArmorGlowMask(EquipType.Body, textureBody, info);
}));
}
Texture2D textureHead;
if (!player.armor[10].IsAir)
{
if (player.armor[10].type >= ItemID.Count && ItemGlowMask.TryGetValue(player.armor[10].type, out textureHead))//Vanity Head
{
InsertAfterVanillaLayer(layers, "Head", new PlayerLayer(mod.Name, "GlowMaskHead", delegate (PlayerDrawInfo info)
{
TremorUtils.DrawArmorGlowMask(EquipType.Head, textureHead, info);
}));
}
}
else if (player.armor[0].type >= ItemID.Count && ItemGlowMask.TryGetValue(player.armor[0].type, out textureHead))//Head
{
InsertAfterVanillaLayer(layers, "Head", new PlayerLayer(mod.Name, "GlowMaskHead", delegate (PlayerDrawInfo info)
{
TremorUtils.DrawArmorGlowMask(EquipType.Head, textureHead, info);
}));
}
Texture2D textureItem;
if (player.HeldItem.type >= ItemID.Count && ItemGlowMask.TryGetValue(player.HeldItem.type, out textureItem))//Held ItemType
{
InsertAfterVanillaLayer(layers, "HeldItem", new PlayerLayer(mod.Name, "GlowMaskHeldItem", delegate (PlayerDrawInfo info)
{
TremorUtils.DrawItemGlowMask(textureItem, info);
}));
}
}
public static void InsertAfterVanillaLayer(List<PlayerLayer> layers, string vanillaLayerName, PlayerLayer newPlayerLayer)
{
for (int i = 0; i < layers.Count; i++)
{
if (layers[i].Name == vanillaLayerName && layers[i].mod == "Terraria")
{
layers.Insert(i + 1, newPlayerLayer);
return;
}
}
layers.Add(newPlayerLayer);
}
}
}