-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCustomizerShader.cs
More file actions
37 lines (32 loc) · 1.51 KB
/
CustomizerShader.cs
File metadata and controls
37 lines (32 loc) · 1.51 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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ShaderLib;
using Terraria;
using Terraria.ModLoader;
namespace ItemCustomizer
{
class CustomizerShader : GlobalShader
{
public override int ItemInventoryShader(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) {
// Failsafe for items that haven't been initialized properly, if that's even a thing
if(item.Customizer() is CustomizerItem customizer) return customizer.shaderID.ID;
else return 0;
}
public override int ItemWorldShader(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) {
// Failsafe for items that haven't been initialized properly, if that's even a thing
if(item.Customizer() is CustomizerItem customizer) return customizer.shaderID.ID;
else return 0;
}
public override int ProjectileShader(Projectile projectile, SpriteBatch spriteBatch, Color lightColor) {
// Failsafe for projectiles that haven't been initialized properly, if that's even a thing
if(projectile.Customizer() is CustomizerProjInfo customizer) return customizer.shaderID;
else return 0;
}
public override void HeldItemShader(ref int shaderID, Item item, PlayerDrawInfo drawInfo) {
shaderID = shaderID > 0 ? shaderID : item.Customizer().shaderID.ID;
}
public override int NPCShader(NPC npc, SpriteBatch spriteBatch, Color drawColor) {
return npc.Customizer().shaderID;
}
}
}