Reverting to Old VoidstoneWall codes
This commit is contained in:
1 parent
dfc8bb2f24
commit
bb67bf91a4
2 files changed
+94
-56
No files matched your search
+46
-28
@@ -33,45 +33,63 @@ namespace CalamityMod.Walls
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool DrawWallGlow(int type, int i, int j, SpriteBatch spriteBatch)
|
||||
public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
if (GlowMask.Texture is null)
|
||||
return true;
|
||||
return;
|
||||
|
||||
spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Main.GameViewMatrix.TransformationMatrix, () =>
|
||||
Tile tile = Main.tile[i, j];
|
||||
int xLength = 32;
|
||||
int xOff = 0;
|
||||
|
||||
int xPos = tile.WallFrameX + xOff;
|
||||
int yPos = tile.WallFrameY;
|
||||
|
||||
Rectangle frame = new Rectangle(xPos, yPos, xLength, 32);
|
||||
Color drawcolor;
|
||||
drawcolor = WorldGen.paintColor(tile.WallColor);
|
||||
drawcolor.A = 255;
|
||||
Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange);
|
||||
|
||||
if (Main.drawToScreen)
|
||||
zero = Vector2.Zero;
|
||||
|
||||
Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero;
|
||||
Color lightColor = Lighting.GetColor(i, j, Color.White);
|
||||
|
||||
spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
|
||||
if (GlowMask.HasContentInFramePos(xPos, yPos))
|
||||
{
|
||||
Tile tile = Main.tile[i, j];
|
||||
Effect tileShader = Main.tileShader;
|
||||
TreePaintingSettings settings = TreePaintSystemData.GetWallSettings(type);
|
||||
int paintColor = tile.WallColor;
|
||||
tileShader.Parameters["leafHueTestOffset"]?.SetValue(settings.HueTestOffset);
|
||||
tileShader.Parameters["leafMinHue"]?.SetValue(settings.SpecialGroupMinimalHueValue);
|
||||
tileShader.Parameters["leafMaxHue"]?.SetValue(settings.SpecialGroupMaximumHueValue);
|
||||
tileShader.Parameters["leafMinSat"]?.SetValue(settings.SpecialGroupMinimumSaturationValue);
|
||||
tileShader.Parameters["leafMaxSat"]?.SetValue(settings.SpecialGroupMaximumSaturationValue);
|
||||
tileShader.Parameters["invertSpecialGroupResult"]?.SetValue(settings.InvertSpecialGroupResult);
|
||||
int index = Main.ConvertPaintIdToTileShaderIndex(paintColor, settings.UseSpecialGroups, settings.UseWallShaderHacks);
|
||||
tileShader.CurrentTechnique.Passes[index].Apply();
|
||||
float brightness = 1f;
|
||||
float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.007f;
|
||||
brightness *= (float)MathF.Sin(i / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
|
||||
brightness *= (float)MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
|
||||
brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
|
||||
brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
|
||||
drawcolor *= brightness;
|
||||
Color glowColor = drawcolor * 0.4f;
|
||||
|
||||
Texture2D sprite = TextureAssets.Wall[type].Value;
|
||||
Vector2 offset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange)) - Vector2.One * 8f;
|
||||
int yPos = tile.WallFrameY;
|
||||
int xPos = tile.WallFrameX;
|
||||
Rectangle frame = new Rectangle(xPos, yPos, 32, 32);
|
||||
Color lightColor = tile.IsWallFullbright ? Color.White : Lighting.GetColor(i, j);
|
||||
if (lightColor.R > glowColor.R) glowColor.R = lightColor.R;
|
||||
if (lightColor.G > glowColor.G) glowColor.G = lightColor.G;
|
||||
if (lightColor.B > glowColor.B) glowColor.B = lightColor.B;
|
||||
|
||||
spriteBatch.Draw(sprite, offset, frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
if (glowColor.R <= 0 && glowColor.G <= 0 && glowColor.B <= 0)
|
||||
return;
|
||||
|
||||
if (GlowMask.HasContentInFramePos(xPos, yPos))
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
Color glowColor = Color.Lerp(lightColor, Color.White, 0.2f + MathF.Sin(Main.GameUpdateCount * 0.007f) * 0.1f);
|
||||
spriteBatch.Draw(GlowMask.Texture, offset, frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
Vector2 offset = new Vector2(Main.rand.NextFloat(-1, 1f), Main.rand.NextFloat(-1, 1f)) * 0.2f * k;
|
||||
spriteBatch.Draw(GlowMask.Texture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => DrawWallGlow(Type, i, j, spriteBatch);
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
DrawWallGlow(Type, i, j, spriteBatch);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
|
||||
}
|
||||
|
||||
@@ -42,45 +42,65 @@ namespace CalamityMod.Walls
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DrawWallGlow(int type, int i, int j, SpriteBatch spriteBatch)
|
||||
public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
if (GlowMask.Texture is null)
|
||||
return true;
|
||||
return;
|
||||
|
||||
spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Main.GameViewMatrix.TransformationMatrix, () =>
|
||||
Tile tile = Main.tile[i, j];
|
||||
int xLength = 32;
|
||||
int xOff = 0;
|
||||
|
||||
int xPos = tile.WallFrameX + xOff;
|
||||
int yPos = tile.WallFrameY;
|
||||
|
||||
Rectangle frame = new Rectangle(xPos, yPos, xLength, 32);
|
||||
Color drawcolor;
|
||||
drawcolor = WorldGen.paintColor(tile.WallColor);
|
||||
drawcolor.A = 255;
|
||||
Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange);
|
||||
|
||||
if (Main.drawToScreen)
|
||||
zero = Vector2.Zero;
|
||||
|
||||
Vector2 pos = new Vector2((i * 16 - (int)Main.screenPosition.X), (j * 16 - (int)Main.screenPosition.Y)) + zero;
|
||||
Color lightColor = Lighting.GetColor(i, j, Color.White);
|
||||
|
||||
spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
|
||||
if (GlowMask.HasContentInFramePos(xPos, yPos))
|
||||
{
|
||||
Tile tile = Main.tile[i, j];
|
||||
Effect tileShader = Main.tileShader;
|
||||
TreePaintingSettings settings = TreePaintSystemData.GetWallSettings(type);
|
||||
int paintColor = tile.WallColor;
|
||||
tileShader.Parameters["leafHueTestOffset"]?.SetValue(settings.HueTestOffset);
|
||||
tileShader.Parameters["leafMinHue"]?.SetValue(settings.SpecialGroupMinimalHueValue);
|
||||
tileShader.Parameters["leafMaxHue"]?.SetValue(settings.SpecialGroupMaximumHueValue);
|
||||
tileShader.Parameters["leafMinSat"]?.SetValue(settings.SpecialGroupMinimumSaturationValue);
|
||||
tileShader.Parameters["leafMaxSat"]?.SetValue(settings.SpecialGroupMaximumSaturationValue);
|
||||
tileShader.Parameters["invertSpecialGroupResult"]?.SetValue(settings.InvertSpecialGroupResult);
|
||||
int index = Main.ConvertPaintIdToTileShaderIndex(paintColor, settings.UseSpecialGroups, settings.UseWallShaderHacks);
|
||||
tileShader.CurrentTechnique.Passes[index].Apply();
|
||||
float brightness = 1f;
|
||||
float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.007f;
|
||||
brightness *= (float)MathF.Sin(i / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
|
||||
brightness *= (float)MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
|
||||
brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
|
||||
brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
|
||||
drawcolor *= brightness;
|
||||
Color glowColor = drawcolor * 0.4f;
|
||||
|
||||
Texture2D sprite = TextureAssets.Wall[type].Value;
|
||||
Vector2 offset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange)) - Vector2.One * 8f;
|
||||
int yPos = tile.WallFrameY;
|
||||
int xPos = tile.WallFrameX;
|
||||
Rectangle frame = new Rectangle(xPos, yPos, 32, 32);
|
||||
Color lightColor = tile.IsWallFullbright ? Color.White : Lighting.GetColor(i, j);
|
||||
if (lightColor.R > glowColor.R) glowColor.R = lightColor.R;
|
||||
if (lightColor.G > glowColor.G) glowColor.G = lightColor.G;
|
||||
if (lightColor.B > glowColor.B) glowColor.B = lightColor.B;
|
||||
|
||||
spriteBatch.Draw(sprite, offset, frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
if (glowColor.R <= 0 && glowColor.G <= 0 && glowColor.B <= 0)
|
||||
return;
|
||||
|
||||
if (GlowMask.HasContentInFramePos(xPos, yPos))
|
||||
// For now checking for glowing frames greatly reducing the bottleneck
|
||||
// But maybe we could squeeze bit more by removing the loop
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
Color glowColor = Color.Lerp(lightColor, Color.White, 0.2f + MathF.Sin(Main.GameUpdateCount * 0.007f) * 0.1f);
|
||||
spriteBatch.Draw(GlowMask.Texture, offset, frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
Vector2 offset = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)) * 0.2f * k;
|
||||
spriteBatch.Draw(GlowMask.Texture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => DrawWallGlow(Type, i, j, spriteBatch);
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
DrawWallGlow(Type, i, j, spriteBatch);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void KillWall(int i, int j, ref bool fail) => fail = true;
|
||||
|
||||
|
||||
Reference in new issue
Block a user