-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAAUtils.cs
153 lines (146 loc) · 7.63 KB
/
AAUtils.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
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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;
namespace AAMod
{
public static class ItemUtilities
{
public static void DropLoot(this Entity ent, int type, int stack = 1)
{
Item.NewItem((int)ent.position.X, (int)ent.position.Y, ent.width, ent.height, type, stack);
}
public static void DropLoot(this Entity ent, int type, float chance)
{
if (Main.rand.NextDouble() < chance)
Item.NewItem((int)ent.position.X, (int)ent.position.Y, ent.width, ent.height, type);
}
public static void DropLoot(this Entity ent, int type, int min, int max)
{
Item.NewItem((int)ent.position.X, (int)ent.position.Y, ent.width, ent.height, type, Main.rand.Next(min, max));
}
}
public class AAUtils : ModPlayer
{
public static void DrawNPCGlowMask(SpriteBatch spriteBatch, NPC npc, Texture2D texture)
{
var effects = npc.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
spriteBatch.Draw(texture, npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), npc.frame,
Color.White, npc.rotation, npc.frame.Size() / 2, npc.scale, effects, 0);
}
public static void DrawArmorGlowMask(EquipType type, Texture2D texture, PlayerDrawInfo info)
{
switch (type)
{
case EquipType.Head:
{
//Add if(!drawPlayer.invis) ?
DrawData drawData = new DrawData(texture, new Vector2((int)(info.position.X - Main.screenPosition.X) + ((info.drawPlayer.width - info.drawPlayer.bodyFrame.Width) / 2), (int)(info.position.Y - Main.screenPosition.Y) + info.drawPlayer.height - info.drawPlayer.bodyFrame.Height + 4) + info.drawPlayer.headPosition + info.headOrigin, info.drawPlayer.bodyFrame, info.headGlowMaskColor, info.drawPlayer.headRotation, info.headOrigin, 1f, info.spriteEffects, 0);
drawData.shader = info.headArmorShader;
Main.playerDrawData.Add(drawData);
}
return;
case EquipType.Body:
{
int num2 = 0;//Add in backAcc stuff later
Rectangle bodyFrame = info.drawPlayer.bodyFrame;
int num123 = num2;
bodyFrame.X += num123;
bodyFrame.Width -= num123;
if (info.drawPlayer.direction == -1)
{
num123 = 0;
}
if (!info.drawPlayer.invis)
{
DrawData drawData = new DrawData(texture, new Vector2((int)(info.position.X - Main.screenPosition.X - (info.drawPlayer.bodyFrame.Width / 2) + (info.drawPlayer.width / 2) + num123), ((int)(info.position.Y - Main.screenPosition.Y + info.drawPlayer.height - info.drawPlayer.bodyFrame.Height + 4))) + info.drawPlayer.bodyPosition + new Vector2(info.drawPlayer.bodyFrame.Width / 2, info.drawPlayer.bodyFrame.Height / 2), bodyFrame, info.bodyGlowMaskColor, info.drawPlayer.bodyRotation, info.bodyOrigin, 1f, info.spriteEffects, 0);
drawData.shader = info.bodyArmorShader;
Main.playerDrawData.Add(drawData);
}
}
return;
case EquipType.Legs:
{
if (info.drawPlayer.shoe != 15 || info.drawPlayer.wearsRobe)
{
if (!info.drawPlayer.invis)
{
DrawData drawData = new DrawData(texture, new Vector2((int)(info.position.X - Main.screenPosition.X - (info.drawPlayer.legFrame.Width / 2) + (info.drawPlayer.width / 2)), (int)(info.position.Y - Main.screenPosition.Y + info.drawPlayer.height - info.drawPlayer.legFrame.Height + 4)) + info.drawPlayer.legPosition + info.legOrigin, info.drawPlayer.legFrame, info.legGlowMaskColor, info.drawPlayer.legRotation, info.legOrigin, 1f, info.spriteEffects, 0);
drawData.shader = info.legArmorShader;
Main.playerDrawData.Add(drawData);
}
}
}
return;
}
}
public static void DrawItemGlowMask(Texture2D texture, PlayerDrawInfo info)
{
Item item = info.drawPlayer.HeldItem;
if (info.shadow != 0f || info.drawPlayer.frozen || ((info.drawPlayer.itemAnimation <= 0 || item.useStyle == 0) && (item.holdStyle <= 0 || info.drawPlayer.pulley))/*||item.type<=0*/|| info.drawPlayer.dead || item.noUseGraphic || (info.drawPlayer.wet && item.noWet))
{
return;
}
Vector2 offset = new Vector2();
float rotOffset = 0;
Vector2 origin = new Vector2();
if (item.useStyle == 5)
{
if (Item.staff[item.type])
{
rotOffset = 0.785f * info.drawPlayer.direction;
if (info.drawPlayer.gravDir == -1f) { rotOffset -= 1.57f * info.drawPlayer.direction; }
origin = new Vector2(texture.Width * 0.5f * (1 - info.drawPlayer.direction), (info.drawPlayer.gravDir == -1f) ? 0 : texture.Height);
int num86 = -(int)origin.X;
ItemLoader.HoldoutOrigin(info.drawPlayer, ref origin);
offset = new Vector2(origin.X + num86, 0);
}
else
{
offset = new Vector2(10, texture.Height / 2);
ItemLoader.HoldoutOffset(info.drawPlayer.gravDir, item.type, ref offset);
origin = new Vector2(-offset.X, texture.Height / 2);
if (info.drawPlayer.direction == -1)
{
origin.X = texture.Width + offset.X;
}
offset = new Vector2(texture.Width / 2, offset.Y);
}
}
else
{
origin = new Vector2(texture.Width * 0.5f * (1 - info.drawPlayer.direction), (info.drawPlayer.gravDir == -1f) ? 0 : texture.Height);
}
Main.playerDrawData.Add
(
new DrawData
(
texture,
info.itemLocation - Main.screenPosition + offset,
texture.Bounds,
new Color(250, 250, 250, item.alpha),
info.drawPlayer.itemRotation + rotOffset,
origin,
item.scale, info.spriteEffects, 0
)
);
}
public static void DrawItemGlowMaskWorld(SpriteBatch spriteBatch, Item item, Texture2D texture, float rotation, float scale)
{
Main.spriteBatch.Draw
(
texture,
new Vector2
(
item.position.X - Main.screenPosition.X + (item.width / 2),
item.position.Y - Main.screenPosition.Y + item.height - (texture.Height / 2) + 2f
),
new Rectangle(0, 0, texture.Width, texture.Height),
new Color(250, 250, 250, item.alpha), rotation,
new Vector2(texture.Width / 2, texture.Height / 2),
scale, SpriteEffects.None, 0f
);
}
}
}