4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Graphics;
9 namespace Loot.Api.Graphics.Shader
18 public int ShaderId {
get;
set; }
20 public Texture2D SubjectTexture {
get;
protected set; }
21 public Texture2D ShaderTexture {
get;
protected set; }
25 : base(subjectIdentity)
28 DrawColor = shaderDrawColor ?? Color.White;
38 if (SubjectTexture == null)
40 SubjectTexture = Main.itemTexture[item.type];
43 if (ShaderTexture == null)
45 ShaderTexture = graphicsContent?.GetPreparedShader(item.type.ToString()) ?? SubjectTexture;
53 Texture2D suppliedShaderTexture = null, Texture2D suppliedSubjectTexture = null, Texture2D suppliedGlowmaskTexture = null)
55 if (Properties.SkipDrawing)
return;
57 TryGettingDrawData(rotation, scale);
58 if (Entity is Item item) LoadAssets(item);
59 else Loot.Logger.Warn(
"Could not identify shader entity identity as item");
61 var useSubjectTexture = suppliedSubjectTexture ?? SubjectTexture;
62 var useShaderTexture = suppliedShaderTexture ?? ShaderTexture;
63 var useGlowmaskTexture = suppliedGlowmaskTexture;
66 if (useSubjectTexture != null && useShaderTexture != null)
71 DoDrawShader(useShaderTexture, spriteBatch, lightColor);
72 DoDrawSubject(useSubjectTexture, spriteBatch, lightColor);
73 DoDrawGlowmask(glowmaskEntity, spriteBatch, lightColor, alphaColor, rotation, scale, Entity.whoAmI, useGlowmaskTexture);
77 DoDrawSubject(useSubjectTexture, spriteBatch, lightColor);
78 DoDrawShader(useShaderTexture, spriteBatch, lightColor);
79 DoDrawGlowmask(glowmaskEntity, spriteBatch, lightColor, alphaColor, rotation, scale, Entity.whoAmI, useGlowmaskTexture);
83 DoDrawSubject(useSubjectTexture, spriteBatch, lightColor);
84 DoDrawGlowmask(glowmaskEntity, spriteBatch, lightColor, alphaColor, rotation, scale, Entity.whoAmI, useGlowmaskTexture);
85 DoDrawShader(useShaderTexture, spriteBatch, lightColor);
89 Properties.SkipUpdatingDrawData =
false;
95 public void DoDrawGlowmask(
GlowmaskEntity glowmaskEntity, SpriteBatch spriteBatch, Color lightColor, Color alphaColor,
float rotation,
float scale,
int whoAmI, Texture2D suppliedGlowmask = null)
97 if (glowmaskEntity == null)
return;
98 glowmaskEntity.
Properties.SkipDrawingGlowmask = Properties.SkipDrawingGlowmask;
99 glowmaskEntity.
DoDrawGlowmask(spriteBatch, lightColor, alphaColor, rotation, scale, whoAmI, suppliedGlowmask);
105 public void DoDrawShader(Texture2D shaderTexture, SpriteBatch spriteBatch, Color lightColor)
107 if (Properties.SkipDrawingShader)
return;
109 var drawDataTexture = DrawData.texture;
110 var drawDataColor = DrawData.color;
112 DrawData.texture = shaderTexture;
113 DrawData.color = lightColor;
114 TryUpdatingDrawData(shaderTexture);
116 spriteBatch.BeginShaderBatch();
117 GameShaders.Armor.Apply(ShaderId, Entity, DrawData);
119 var centerPos = DrawData.position;
120 Properties.ShaderDrawStyle.DrawShader(spriteBatch,
this);
122 DrawData.position = centerPos;
123 DrawData.texture = drawDataTexture;
124 DrawData.color = drawDataColor;
125 spriteBatch.ResetBatch();
131 public void DoDrawSubject(Texture2D subjectTexture, SpriteBatch spriteBatch, Color lightColor)
133 if (Properties.SkipDrawingSubject)
return;
135 var drawDataColor = DrawData.color;
136 var drawDataTexture = DrawData.texture;
138 DrawData.color = lightColor;
139 DrawData.texture = subjectTexture;
140 TryUpdatingDrawData(subjectTexture);
141 DrawEntity(spriteBatch);
143 DrawData.color = drawDataColor;
144 DrawData.texture = drawDataTexture;
void DoDrawGlowmask(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI, Texture2D suppliedGlowmask=null)
Will draw the glowmask texture
static new ShaderGraphicsPropertiesBuilder Builder
void DoDrawSubject(Texture2D subjectTexture, SpriteBatch spriteBatch, Color lightColor)
Will draw the entity's regular sprite
Defines the GraphicsProperties for ShaderEntitys which derives from GlowmaskGraphicsProperties ...
override void LoadAssets(Item item)
void DoDrawGlowmask(GlowmaskEntity glowmaskEntity, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI, Texture2D suppliedGlowmask=null)
Will draw the glowmask
Defines a Shader entity, part of GraphicsEntity<T> The entity defines a particular 'shader' "of" the ...
void DoDrawShader(Texture2D shaderTexture, SpriteBatch spriteBatch, Color lightColor)
Will draw the shader effect
Defines the base abstract of a GraphicsEntity
ShaderEntity(object subjectIdentity, int shaderId, Color?shaderDrawColor=null, short order=0, ShaderGraphicsProperties props=null)
Defines a Glowmask entity, part of GraphicsEntity The entity defines a particular 'glowmask' "of" the...
This class stores glowmask and shader textures that can be looked up during drawing ...
void DoDrawLayeredEntity(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float scale, float rotation, GlowmaskEntity glowmaskEntity=null, Texture2D suppliedShaderTexture=null, Texture2D suppliedSubjectTexture=null, Texture2D suppliedGlowmaskTexture=null)
Will draw all the layers (subject, glowmask, shader) in the proper order