-
Notifications
You must be signed in to change notification settings - Fork 2
/
MiscGlowMasks.cs
68 lines (60 loc) · 2.25 KB
/
MiscGlowMasks.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
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.ModLoader;
namespace GoldensMisc
{
public static class MiscGlowMasks
{
public static Texture2D UndyingSpear;
public static Texture2D UndyingSpearProjectile;
public static Texture2D RodofWarping;
public static bool Loaded;
public static void Load()
{
if (!Loaded)
{
UndyingSpear = ModContent.Request<Texture2D>("GoldensMisc/Items/Weapons/UndyingSpear_Glow", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value;
UndyingSpearProjectile = ModContent.Request<Texture2D>("GoldensMisc/Projectiles/UndyingSpear_Glow", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value;
RodofWarping = ModContent.Request<Texture2D>("GoldensMisc/Items/Tools/RodofWarping_Glow", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value;
Loaded = true;
}
}
public static void Unload()
{
if(Loaded)
{
UndyingSpear = null;
UndyingSpearProjectile = null;
RodofWarping = null;
Loaded = false;
}
}
}
public abstract class GlowingModItem : ModItem
{
[CloneByReference]
public Texture2D GlowMask;
public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
Texture2D glowTexture = GlowMask;
Color color = Color.White;
color.A = 255;
spriteBatch.Draw(glowTexture, position, frame, color, 0f, origin, scale, SpriteEffects.None, 0f);
}
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
{
Texture2D glowTexture = GlowMask;
Color color = Color.White;
color.A = 255;
Rectangle glowTextureSize = new(0, 0, glowTexture.Width, glowTexture.Height);
Vector2 glowTextureOrigin = glowTexture.Size() * .5f;
Vector2 glowOffset = new((float)(Item.width / 2) - glowTextureOrigin.X, (float)(Item.height - glowTexture.Height));
Vector2 glowPosition = Item.position - Main.screenPosition + glowTextureOrigin + glowOffset;
spriteBatch.Draw(glowTexture, glowPosition, glowTextureSize, color, rotation, glowTextureOrigin, scale, SpriteEffects.None, 0f);
}
}
}