This commit is contained in:
mochi-angel committed 2024-10-22 08:51:24 -07:00
commit 129f2db98d
17 files changed
+115 -446

No files matched your search

+40
View File
@@ -21,6 +21,7 @@ using CalamityMod.Tiles.SunkenSea;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;
@@ -264,6 +265,45 @@ namespace CalamityMod
return PaintID.DeepRedPaint >= paintType && paintType <= PaintID.DeepPinkPaint;
}
/// <summary>
/// Draws placed wall with multiple variants, properly painted.
/// </summary>
/// <param name="spriteBatch">The sprite batch.</param>
/// <param name="type">The type of wall.</param>
/// <param name="i">The x co-ordinate of the wall.</param>
/// <param name="j">The y co-ordinate of the wall.</param>
/// <param name="sheetOffset">The offset within the spritesheet, similar to TileFrame.</param>
/// <returns>Whether or not PreDraw is drawn</returns>
public static bool DrawMultiVariantWall(this SpriteBatch spriteBatch, int type, int i, int j, int[] sheetOffset)
{
if (spriteBatch is null)
return true;
spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Main.GameViewMatrix.TransformationMatrix, () =>
{
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();
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;
Rectangle frame = new Rectangle(sheetOffset[0] + tile.WallFrameX, sheetOffset[1] + tile.WallFrameY, 32, 32);
Color lightColor = Lighting.GetColor(i, j);
spriteBatch.Draw(sprite, offset, frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
});
return false;
}
public static Tile ParanoidTileRetrieval(int x, int y)
{
if (!WorldGen.InWorld(x, y))
+1 -23
View File
@@ -1,7 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
@@ -24,28 +23,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -23
View File
@@ -2,7 +2,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.ModLoader;
namespace CalamityMod.Walls
@@ -23,28 +22,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -23
View File
@@ -1,7 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
@@ -29,28 +28,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -23
View File
@@ -1,7 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
@@ -24,28 +23,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -23
View File
@@ -1,7 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
@@ -24,28 +23,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -22
View File
@@ -24,28 +24,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -22
View File
@@ -24,28 +24,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -22
View File
@@ -25,28 +25,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -22
View File
@@ -25,28 +25,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -22
View File
@@ -24,28 +24,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -22
View File
@@ -26,28 +26,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+1 -22
View File
@@ -18,28 +18,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
+2 -69
View File
@@ -24,80 +24,13 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{
int[] sheetOffset = new int[2] { i % 3, j % 3 };
int xPos = i % 3;
int yPos = j % 3;
switch (yPos)
{
case 0:
switch (xPos)
{
case 0:
sheetOffset = new int[2] { 0, 0 };
break;
case 1:
sheetOffset = new int[2] { 0, 1 };
break;
case 2:
sheetOffset = new int[2] { 0, 2 };
break;
}
break;
case 1:
switch (xPos)
{
case 0:
sheetOffset = new int[2] { 0, 3 };
break;
case 1:
sheetOffset = new int[2] { 0, 4 };
break;
case 2:
sheetOffset = new int[2] { 0, 0 };
break;
}
break;
case 2:
switch (xPos)
{
case 0:
sheetOffset = new int[2] { 0, 1 };
break;
case 1:
sheetOffset = new int[2] { 0, 2 };
break;
case 2:
sheetOffset = new int[2] { 0, 3 };
break;
}
break;
}
sheetOffset[0] = sheetOffset[0] * 468;
int[] sheetOffset = new int[2] { 0, (xPos + yPos * 3) % 5 };
sheetOffset[1] = sheetOffset[1] * 180;
return sheetOffset;
}
+30 -43
View File
@@ -33,59 +33,46 @@ namespace CalamityMod.Walls
return false;
}
public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch)
public static bool DrawWallGlow(int type, int i, int j, SpriteBatch spriteBatch)
{
if (GlowMask.Texture is null)
return;
return true;
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))
spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Main.GameViewMatrix.TransformationMatrix, () =>
{
float brightness = 1f;
float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.007f;
brightness *= MathF.Sin(i / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
drawcolor *= brightness;
Color glowColor = drawcolor * 0.4f;
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();
// 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++)
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 = Lighting.GetColor(i, j);
spriteBatch.Draw(sprite, offset, frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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);
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);
}
}
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
DrawWallGlow(Type, i, j, spriteBatch);
});
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => DrawWallGlow(Type, i, j, spriteBatch);
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
}
}
+30 -43
View File
@@ -42,59 +42,46 @@ namespace CalamityMod.Walls
}
}
public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch)
public static bool DrawWallGlow(int type, int i, int j, SpriteBatch spriteBatch)
{
if (GlowMask.Texture is null)
return;
return true;
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))
spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Main.GameViewMatrix.TransformationMatrix, () =>
{
float brightness = 1f;
float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.007f;
brightness *= MathF.Sin(i / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
drawcolor *= brightness;
Color glowColor = drawcolor * 0.4f;
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();
// 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++)
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 = Lighting.GetColor(i, j);
spriteBatch.Draw(sprite, offset, frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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);
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);
}
}
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
DrawWallGlow(Type, i, j, spriteBatch);
});
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => DrawWallGlow(Type, i, j, spriteBatch);
public override void KillWall(int i, int j, ref bool fail) => fail = true;
public override bool CanExplode(int i, int j) => false;
+1 -22
View File
@@ -23,28 +23,7 @@ namespace CalamityMod.Walls
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = TextureAssets.Wall[Type].Value;
Color lightColor = CalamityUtils.ApplyPaint(Main.tile[i, j].WallColor, Lighting.GetColor(i, j), false);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].WallFrameX, sheetOffset[1] + Main.tile[i, j].WallFrameY, 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => spriteBatch.DrawMultiVariantWall(Type, i, j, CreatePattern(i, j));
private int[] CreatePattern(int i, int j)
{