+ Sea Prism Walls and Sea Prism Crystals are now utilize the Sea Prism Color Blendign shader
This commit is contained in:
1 parent
ab4d91593f
commit
9969fe5989
8 files changed
+441
-461
No files matched your search
@@ -7,6 +7,7 @@ float time;
|
||||
float2 screenOffset;
|
||||
float2 offscreenOffset;
|
||||
float diagonalScreenLength;
|
||||
bool doGlint;
|
||||
|
||||
float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0, float4 screenPos : VPOS) : COLOR
|
||||
{
|
||||
@@ -28,32 +29,34 @@ float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD
|
||||
result.rgb = lerp(result.rgb, greenColor.rgb, greenColor.a * fade1);
|
||||
result.rgb = lerp(result.rgb, purpleColor.rgb, purpleColor.a * fade2);
|
||||
|
||||
// Calculate glint effect
|
||||
float2 projPos = screenPos.xy - offscreenOffset;
|
||||
float projection = (screenPos.x / 2.0) - (screenPos.y / 2.0);
|
||||
if(doGlint)
|
||||
{
|
||||
// Calculate glint effect
|
||||
float2 projPos = screenPos.xy - offscreenOffset;
|
||||
float projection = (screenPos.x / 2.0) - (screenPos.y / 2.0);
|
||||
|
||||
// Define glint beam centers
|
||||
float beamCenter1 = diagonalScreenLength * 0.05;
|
||||
float beamCenter2 = diagonalScreenLength * 0.5;
|
||||
float beamCenter3 = diagonalScreenLength * 1.05;
|
||||
// Define glint beam centers
|
||||
float beamCenter1 = diagonalScreenLength * 0.05;
|
||||
float beamCenter2 = diagonalScreenLength * 0.5;
|
||||
float beamCenter3 = diagonalScreenLength * 1.05;
|
||||
|
||||
// Calculate glint strength for each beam
|
||||
float dist1 = abs(projection - beamCenter1);
|
||||
float dist2 = abs(projection - beamCenter2);
|
||||
float dist3 = abs(projection - beamCenter3);
|
||||
// Calculate glint strength for each beam
|
||||
float dist1 = abs(projection - beamCenter1);
|
||||
float dist2 = abs(projection - beamCenter2);
|
||||
float dist3 = abs(projection - beamCenter3);
|
||||
|
||||
float strength1 = saturate(1.0 - dist1 / 100.0);
|
||||
float strength2 = saturate(1.0 - dist2 / 100.0);
|
||||
float strength3 = saturate(1.0 - dist3 / 100.0);
|
||||
float strength1 = saturate(1.0 - dist1 / 100.0);
|
||||
float strength2 = saturate(1.0 - dist2 / 100.0);
|
||||
float strength3 = saturate(1.0 - dist3 / 100.0);
|
||||
|
||||
float totalGlintStrength = max(strength1, max(strength2, strength3));
|
||||
float totalGlintStrength = max(strength1, max(strength2, strength3));
|
||||
|
||||
// Apply glint
|
||||
result.rgb = lerp(result.rgb, glintColor.rgb, glintColor.a * totalGlintStrength);
|
||||
// Apply glint
|
||||
result.rgb = lerp(result.rgb, glintColor.rgb, glintColor.a * totalGlintStrength);
|
||||
|
||||
//Additive Blend Version (VERY BRIGHT)
|
||||
//result.rgb = lerp(result.rgb, result.rgb + glintColor.rgb, glintColor.a * totalGlintStrength);
|
||||
|
||||
//Additive Blend Version (VERY BRIGHT)
|
||||
//result.rgb = lerp(result.rgb, result.rgb + glintColor.rgb, glintColor.a * totalGlintStrength);
|
||||
}
|
||||
return result * sampleColor;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,125 +0,0 @@
|
||||
using System;
|
||||
using CalamityMod.Items.Placeables.SunkenSea;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Enums;
|
||||
using Terraria.ObjectData;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using Terraria.GameContent;
|
||||
using CalamityMod.Systems;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
|
||||
namespace CalamityMod.Tiles.SunkenSea
|
||||
{
|
||||
public class MediumSeaPrismCrystal : ModTile
|
||||
{
|
||||
private static Asset<Texture2D> DefaultCrystals;
|
||||
private static Asset<Texture2D> PurpleCrystals;
|
||||
private static Asset<Texture2D> GreenCrystals;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.tileLighted[Type] = true;
|
||||
Main.tileNoFail[Type] = true;
|
||||
Main.tileFrameImportant[Type] = true;
|
||||
Main.tileObsidianKill[Type] = true;
|
||||
Main.tileSpelunker[Type] = true;
|
||||
Main.tileShine[Type] = 5600;
|
||||
Main.tileShine2[Type] = true;
|
||||
|
||||
HitSound = SoundID.Item27;
|
||||
DustType = DustID.IceRod;
|
||||
MinPick = 55;
|
||||
|
||||
AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch);
|
||||
AddMapEntry(new Color(53, 136, 207), CalamityUtils.GetItemName<PrismShard>());
|
||||
|
||||
// Attach to ground
|
||||
TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2);
|
||||
TileObjectData.newTile.StyleHorizontal = true;
|
||||
TileObjectData.newTile.StyleMultiplier = 32; // total 32 frames, all should be same "itemStyle"
|
||||
TileObjectData.newTile.StyleWrapLimit = 8; // only 1 placement alternative per row
|
||||
TileObjectData.newTile.RandomStyleRange = 8; // 8 different style will be selected upon placing
|
||||
TileObjectData.newTile.Origin = new Point16(0, 1);
|
||||
|
||||
// Attach to side (right)
|
||||
TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
|
||||
TileObjectData.newAlternate.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0);
|
||||
TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty;
|
||||
TileObjectData.newAlternate.Origin = new Point16(1, 0);
|
||||
TileObjectData.addAlternate(8);
|
||||
|
||||
// Attach to ceiling
|
||||
TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
|
||||
TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile | AnchorType.SolidBottom, TileObjectData.newTile.Width, 0);
|
||||
TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty;
|
||||
TileObjectData.newAlternate.Origin = new Point16(0, 0);
|
||||
TileObjectData.addAlternate(16);
|
||||
|
||||
// Attach to side (left)
|
||||
TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
|
||||
TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0);
|
||||
TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty;
|
||||
TileObjectData.newAlternate.Origin = new Point16(0, 0);
|
||||
TileObjectData.addAlternate(24);
|
||||
TileObjectData.addTile(Type);
|
||||
|
||||
DefaultCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Blue");
|
||||
PurpleCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Purple");
|
||||
GreenCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Green");
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num)
|
||||
{
|
||||
num = fail ? 1 : 3;
|
||||
}
|
||||
|
||||
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
|
||||
{
|
||||
float fade1 = GetFade1(i, j);
|
||||
float fade2 = GetFade2(i, j);
|
||||
|
||||
Color baseColor = new Color(162, 216, 218); //Blue
|
||||
Color glow1 = new Color(171, 113, 215); //Purple
|
||||
Color glow2 = new Color(56, 174, 117); //Green
|
||||
|
||||
Vector3 blended = baseColor.ToVector3();
|
||||
|
||||
blended = Vector3.Lerp(blended, glow1.ToVector3(), fade1 * 0.5f);
|
||||
blended = Vector3.Lerp(blended, glow2.ToVector3(), fade2 * 0.5f);
|
||||
|
||||
float brightness = 0.6f;
|
||||
blended *= brightness;
|
||||
|
||||
r = blended.X;
|
||||
g = blended.Y;
|
||||
b = blended.Z;
|
||||
}
|
||||
|
||||
private static float GetFade1(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f;
|
||||
|
||||
private static float GetFade2(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f;
|
||||
|
||||
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
Tile tile = Framing.GetTileSafely(i, j);
|
||||
Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
Vector2 position = new Vector2(i * 16, j * 16) - Main.screenPosition + offScreen;
|
||||
|
||||
Rectangle sourceRect = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16);
|
||||
|
||||
spriteBatch.Draw(DefaultCrystals.Value, position, sourceRect, Lighting.GetColor(i, j) * 1.5f);
|
||||
spriteBatch.Draw(PurpleCrystals.Value, position, sourceRect, Lighting.GetColor(i, j) * 1.5f * GetFade1(i, j));
|
||||
spriteBatch.Draw(GreenCrystals.Value, position, sourceRect, Lighting.GetColor(i, j) * 1.5f * GetFade2(i, j));
|
||||
}
|
||||
public override void KillMultiTile(int i, int j, int frameX, int frameY)
|
||||
{
|
||||
Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType<PrismShard>(), 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
+418
-25
@@ -1,12 +1,17 @@
|
||||
using System;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Items.Placeables.SunkenSea;
|
||||
using CalamityMod.Systems;
|
||||
using CalamityMod.Walls;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Enums;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ObjectData;
|
||||
|
||||
namespace CalamityMod.Tiles.SunkenSea
|
||||
{
|
||||
@@ -95,11 +100,260 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => false;
|
||||
}
|
||||
|
||||
public class SeaPrismWall : MultiVariantModWall
|
||||
{
|
||||
public override string Texture => "CalamityMod/Walls/SeaPrismWall";
|
||||
|
||||
internal static FramedMaskTexture GlowMaskBlue;
|
||||
internal static FramedMaskTexture GlowMaskPurple;
|
||||
internal static FramedMaskTexture GlowMaskGreen;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
GlowMaskBlue = new("CalamityMod/Walls/SeaPrismWall_Blue", 36, 36);
|
||||
GlowMaskPurple = new("CalamityMod/Walls/SeaPrismWall_Purple", 36, 36);
|
||||
GlowMaskGreen = new("CalamityMod/Walls/SeaPrismWall_Green", 36, 36);
|
||||
Main.wallHouse[Type] = true;
|
||||
DustType = DustID.RainCloud;
|
||||
|
||||
AddMapEntry(new Color(27, 123, 131));
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
|
||||
|
||||
public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset)
|
||||
{
|
||||
frameXOffset = (i % 8) * 468;
|
||||
frameYOffset = (j % 8) * 180;
|
||||
}
|
||||
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => false;
|
||||
}
|
||||
|
||||
public class UnsafeSeaPrismWall : MultiVariantModWall
|
||||
{
|
||||
public override string Texture => "CalamityMod/Walls/SeaPrismWall";
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.wallHouse[Type] = false;
|
||||
DustType = DustID.RainCloud;
|
||||
|
||||
AddMapEntry(new Color(27, 123, 131));
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
|
||||
|
||||
public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset)
|
||||
{
|
||||
frameXOffset = (i % 8) * 468;
|
||||
frameYOffset = (j % 8) * 180;
|
||||
}
|
||||
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => false;
|
||||
|
||||
public override bool Drop(int i, int j, ref int type) => false;
|
||||
}
|
||||
|
||||
public class SeaPrismCrystals : ModTile
|
||||
{
|
||||
internal static Asset<Texture2D> BlueCrystals;
|
||||
internal static Asset<Texture2D> PurpleCrystals;
|
||||
internal static Asset<Texture2D> GreenCrystals;
|
||||
internal static Asset<Texture2D> Glint;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.tileLighted[Type] = true;
|
||||
Main.tileNoFail[Type] = true;
|
||||
Main.tileFrameImportant[Type] = true;
|
||||
Main.tileObsidianKill[Type] = true;
|
||||
AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch);
|
||||
AddMapEntry(new Color(53, 136, 207), CalamityUtils.GetItemName<PrismShard>());
|
||||
HitSound = SoundID.Item27;
|
||||
DustType = DustID.IceRod;
|
||||
Main.tileSpelunker[Type] = true;
|
||||
MinPick = 55;
|
||||
|
||||
BlueCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals");
|
||||
PurpleCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals_Purple");
|
||||
GreenCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals_Green");
|
||||
Glint = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals_Glint");
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num)
|
||||
{
|
||||
num = fail ? 1 : 3;
|
||||
}
|
||||
|
||||
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
|
||||
{
|
||||
float fade1 = GetFade1(i, j);
|
||||
float fade2 = GetFade2(i, j);
|
||||
|
||||
Color baseColor = new Color(162, 216, 218); //Blue
|
||||
Color glow1 = new Color(171, 113, 215); //Purple
|
||||
Color glow2 = new Color(56, 174, 117); //Green
|
||||
|
||||
Vector3 blended = baseColor.ToVector3();
|
||||
|
||||
blended = Vector3.Lerp(blended, glow1.ToVector3(), fade1 * 0.5f);
|
||||
blended = Vector3.Lerp(blended, glow2.ToVector3(), fade2 * 0.5f);
|
||||
|
||||
float brightness = 0.6f;
|
||||
blended *= brightness;
|
||||
|
||||
r = blended.X;
|
||||
g = blended.Y;
|
||||
b = blended.Z;
|
||||
}
|
||||
|
||||
private static float GetFade1(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f;
|
||||
|
||||
private static float GetFade2(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f;
|
||||
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => false;
|
||||
|
||||
public override bool CanPlace(int i, int j)
|
||||
{
|
||||
Tile belowTile = Main.tile[i, j + 1];
|
||||
Tile aboveTile = Main.tile[i, j - 1];
|
||||
Tile rightTile = Main.tile[i + 1, j];
|
||||
Tile leftTile = Main.tile[i - 1, j];
|
||||
|
||||
if ((belowTile.Slope == SlopeType.Solid && !belowTile.IsHalfBlock && belowTile.HasTile && belowTile.IsTileSolid()) ||
|
||||
(aboveTile.Slope == SlopeType.Solid && !aboveTile.IsHalfBlock && aboveTile.HasTile && aboveTile.IsTileSolid()) ||
|
||||
(rightTile.Slope == SlopeType.Solid && !rightTile.IsHalfBlock && rightTile.HasTile && rightTile.IsTileSolid()) ||
|
||||
(leftTile.Slope == SlopeType.Solid && !leftTile.IsHalfBlock && leftTile.HasTile && leftTile.IsTileSolid()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void PlaceInWorld(int i, int j, Item item)
|
||||
{
|
||||
Tile belowTile = Main.tile[i, j + 1];
|
||||
Tile aboveTile = Main.tile[i, j - 1];
|
||||
Tile rightTile = Main.tile[i + 1, j];
|
||||
Tile leftTile = Main.tile[i - 1, j];
|
||||
|
||||
if (belowTile.Slope == SlopeType.Solid && !belowTile.IsHalfBlock && belowTile.HasTile && belowTile.IsTileSolid())
|
||||
Main.tile[i, j].TileFrameY = 0;
|
||||
else if (aboveTile.Slope == SlopeType.Solid && !aboveTile.IsHalfBlock && aboveTile.HasTile && aboveTile.IsTileSolid())
|
||||
Main.tile[i, j].TileFrameY = 18;
|
||||
else if (rightTile.Slope == SlopeType.Solid && !rightTile.IsHalfBlock && rightTile.HasTile && rightTile.IsTileSolid())
|
||||
Main.tile[i, j].TileFrameY = 36;
|
||||
else if (leftTile.Slope == SlopeType.Solid && !leftTile.IsHalfBlock && leftTile.HasTile && leftTile.IsTileSolid())
|
||||
Main.tile[i, j].TileFrameY = 54;
|
||||
|
||||
Main.tile[i, j].TileFrameX = (short)(WorldGen.genRand.Next(18) * 18);
|
||||
}
|
||||
}
|
||||
|
||||
public class MediumSeaPrismCrystal : ModTile
|
||||
{
|
||||
internal static Asset<Texture2D> BlueCrystals;
|
||||
internal static Asset<Texture2D> PurpleCrystals;
|
||||
internal static Asset<Texture2D> GreenCrystals;
|
||||
internal static Asset<Texture2D> Glint;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.tileLighted[Type] = true;
|
||||
Main.tileNoFail[Type] = true;
|
||||
Main.tileFrameImportant[Type] = true;
|
||||
Main.tileObsidianKill[Type] = true;
|
||||
Main.tileSpelunker[Type] = true;
|
||||
Main.tileShine[Type] = 5600;
|
||||
Main.tileShine2[Type] = true;
|
||||
|
||||
HitSound = SoundID.Item27;
|
||||
DustType = DustID.IceRod;
|
||||
MinPick = 55;
|
||||
|
||||
AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch);
|
||||
AddMapEntry(new Color(53, 136, 207), CalamityUtils.GetItemName<PrismShard>());
|
||||
|
||||
// Attach to ground
|
||||
TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2);
|
||||
TileObjectData.newTile.StyleHorizontal = true;
|
||||
TileObjectData.newTile.StyleMultiplier = 32; // total 32 frames, all should be same "itemStyle"
|
||||
TileObjectData.newTile.StyleWrapLimit = 8; // only 1 placement alternative per row
|
||||
TileObjectData.newTile.RandomStyleRange = 8; // 8 different style will be selected upon placing
|
||||
TileObjectData.newTile.Origin = new Point16(0, 1);
|
||||
|
||||
// Attach to side (right)
|
||||
TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
|
||||
TileObjectData.newAlternate.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0);
|
||||
TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty;
|
||||
TileObjectData.newAlternate.Origin = new Point16(1, 0);
|
||||
TileObjectData.addAlternate(8);
|
||||
|
||||
// Attach to ceiling
|
||||
TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
|
||||
TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile | AnchorType.SolidBottom, TileObjectData.newTile.Width, 0);
|
||||
TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty;
|
||||
TileObjectData.newAlternate.Origin = new Point16(0, 0);
|
||||
TileObjectData.addAlternate(16);
|
||||
|
||||
// Attach to side (left)
|
||||
TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
|
||||
TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0);
|
||||
TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty;
|
||||
TileObjectData.newAlternate.Origin = new Point16(0, 0);
|
||||
TileObjectData.addAlternate(24);
|
||||
TileObjectData.addTile(Type);
|
||||
|
||||
BlueCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Blue");
|
||||
PurpleCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Purple");
|
||||
GreenCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Green");
|
||||
Glint = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Glint");
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num)
|
||||
{
|
||||
num = fail ? 1 : 3;
|
||||
}
|
||||
|
||||
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
|
||||
{
|
||||
float fade1 = GetFade1(i, j);
|
||||
float fade2 = GetFade2(i, j);
|
||||
|
||||
Color baseColor = new Color(162, 216, 218); //Blue
|
||||
Color glow1 = new Color(171, 113, 215); //Purple
|
||||
Color glow2 = new Color(56, 174, 117); //Green
|
||||
|
||||
Vector3 blended = baseColor.ToVector3();
|
||||
|
||||
blended = Vector3.Lerp(blended, glow1.ToVector3(), fade1 * 0.5f);
|
||||
blended = Vector3.Lerp(blended, glow2.ToVector3(), fade2 * 0.5f);
|
||||
|
||||
float brightness = 0.6f;
|
||||
blended *= brightness;
|
||||
|
||||
r = blended.X;
|
||||
g = blended.Y;
|
||||
b = blended.Z;
|
||||
}
|
||||
|
||||
private static float GetFade1(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f;
|
||||
|
||||
private static float GetFade2(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f;
|
||||
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => false;
|
||||
|
||||
public override void KillMultiTile(int i, int j, int frameX, int frameY)
|
||||
{
|
||||
Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType<PrismShard>(), 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SeaPrismShaderDrawing : ModSystem
|
||||
{
|
||||
public override void OnModLoad()
|
||||
{
|
||||
On_Main.DrawTiles += DrawSeaPrisms;
|
||||
On_Main.DrawTiles += DrawSeaPrismsAndCrystals;
|
||||
On_Main.DrawWalls += DrawSeaPrismWalls;
|
||||
}
|
||||
|
||||
private void GetScreenDrawArea(Vector2 screenPosition, Vector2 offSet, out int firstTileX, out int lastTileX, out int firstTileY, out int lastTileY)
|
||||
@@ -126,32 +380,166 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSeaPrisms(On_Main.orig_DrawTiles orig, Main self, bool solidLayer, bool forRenderTargets, bool intoRenderTargets, int waterStyleOverride)
|
||||
private void DrawSeaPrismsAndCrystals(On_Main.orig_DrawTiles orig, Main self, bool solidLayer, bool forRenderTargets, bool intoRenderTargets, int waterStyleOverride)
|
||||
{
|
||||
if(!solidLayer)
|
||||
{
|
||||
orig(self, solidLayer, forRenderTargets, intoRenderTargets, waterStyleOverride);
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 offscreenPosition = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.instance.GraphicsDevice.Textures[1] = SeaPrism.Green.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
|
||||
Main.instance.GraphicsDevice.Textures[2] = SeaPrism.Purple.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearClamp;
|
||||
Main.instance.GraphicsDevice.Textures[3] = SeaPrism.Glint.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearClamp;
|
||||
|
||||
Effect shader = CalamityShaders.SeaPrismColorBlendingShader;
|
||||
shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly);
|
||||
shader.Parameters["screenOffset"].SetValue(Main.screenPosition);
|
||||
shader.Parameters["offscreenOffset"].SetValue(offscreenPosition);
|
||||
shader.Parameters["diagonalScreenLength"].SetValue((Main.screenWidth / 2f) - (Main.screenHeight / 2f));
|
||||
shader.Parameters["doGlint"].SetValue(true);
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, shader, Main.Transform);
|
||||
Vector2 unscaledPosition = Main.Camera.UnscaledPosition;
|
||||
|
||||
GetScreenDrawArea(unscaledPosition, offscreenPosition + (Main.Camera.UnscaledPosition - Main.Camera.ScaledPosition), out var firstTileX, out var lastTileX, out var firstTileY, out var lastTileY);
|
||||
|
||||
if (solidLayer)
|
||||
{
|
||||
Main.instance.GraphicsDevice.Textures[1] = SeaPrism.Green.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
|
||||
Main.instance.GraphicsDevice.Textures[2] = SeaPrism.Purple.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearClamp;
|
||||
Main.instance.GraphicsDevice.Textures[3] = SeaPrism.Glint.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearClamp;
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, shader, Matrix.Identity);
|
||||
|
||||
for (int y = firstTileY; y < lastTileY + 4; y++)
|
||||
{
|
||||
for (int x = firstTileX - 2; x < lastTileX + 2; x++)
|
||||
{
|
||||
if (!WorldGen.InWorld(x, y))
|
||||
continue;
|
||||
|
||||
Tile tile = Main.tile[x, y];
|
||||
if (tile == null)
|
||||
continue;
|
||||
|
||||
int type = tile.TileType;
|
||||
if (type != ModContent.TileType<SeaPrism>())
|
||||
continue;
|
||||
|
||||
Vector2 position = new Vector2(x * 16, y * 16) - Main.screenPosition + offscreenPosition;
|
||||
|
||||
int frameX = tile.TileFrameX + (x % 8 * SeaPrism.subsheetWidth);
|
||||
int frameY = tile.TileFrameY + (y % 8 * SeaPrism.subsheetHeight);
|
||||
|
||||
Rectangle sourceRect = new Rectangle(frameX, frameY, 16, 16);
|
||||
Color light = Lighting.GetColor(x, y) * 1.5f;
|
||||
|
||||
Main.spriteBatch.Draw(SeaPrism.Blue.Value, position, sourceRect, light);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.instance.GraphicsDevice.Textures[1] = SeaPrismCrystals.GreenCrystals.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
|
||||
Main.instance.GraphicsDevice.Textures[2] = SeaPrismCrystals.PurpleCrystals.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearClamp;
|
||||
Main.instance.GraphicsDevice.Textures[3] = SeaPrismCrystals.Glint.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearClamp;
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, shader, Matrix.Identity);
|
||||
|
||||
for (int y = firstTileY; y < lastTileY + 4; y++)
|
||||
{
|
||||
for (int x = firstTileX - 2; x < lastTileX + 2; x++)
|
||||
{
|
||||
if (!WorldGen.InWorld(x, y))
|
||||
continue;
|
||||
|
||||
Tile tile = Main.tile[x, y];
|
||||
if (tile == null)
|
||||
continue;
|
||||
|
||||
int type = tile.TileType;
|
||||
if (type != ModContent.TileType<SeaPrismCrystals>())
|
||||
continue;
|
||||
|
||||
Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
Vector2 position = new Vector2(x * 16, y * 16) - Main.screenPosition + offScreen;
|
||||
|
||||
Rectangle sourceRect = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16);
|
||||
Color light = Lighting.GetColor(x, y) * 1.5f;
|
||||
|
||||
Main.spriteBatch.Draw(SeaPrismCrystals.BlueCrystals.Value, position, sourceRect, light);
|
||||
}
|
||||
}
|
||||
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.instance.GraphicsDevice.Textures[1] = MediumSeaPrismCrystal.GreenCrystals.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
|
||||
Main.instance.GraphicsDevice.Textures[2] = MediumSeaPrismCrystal.PurpleCrystals.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearClamp;
|
||||
Main.instance.GraphicsDevice.Textures[3] = MediumSeaPrismCrystal.Glint.Value;
|
||||
Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearClamp;
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, shader, Matrix.Identity);
|
||||
|
||||
for (int y = firstTileY; y < lastTileY + 4; y++)
|
||||
{
|
||||
for (int x = firstTileX - 2; x < lastTileX + 2; x++)
|
||||
{
|
||||
if (!WorldGen.InWorld(x, y))
|
||||
continue;
|
||||
|
||||
Tile tile = Main.tile[x, y];
|
||||
if (tile == null)
|
||||
continue;
|
||||
|
||||
int type = tile.TileType;
|
||||
if (type != ModContent.TileType<MediumSeaPrismCrystal>())
|
||||
continue;
|
||||
|
||||
Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
Vector2 position = new Vector2(x * 16, y * 16) - Main.screenPosition + offScreen;
|
||||
|
||||
Rectangle sourceRect = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16);
|
||||
Color light = Lighting.GetColor(x, y) * 1.5f;
|
||||
|
||||
Main.spriteBatch.Draw(MediumSeaPrismCrystal.BlueCrystals.Value, position, sourceRect, light);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.instance.GraphicsDevice.Textures[1] = null;
|
||||
Main.instance.GraphicsDevice.Textures[2] = null;
|
||||
Main.instance.GraphicsDevice.Textures[3] = null;
|
||||
|
||||
Main.spriteBatch.Begin();
|
||||
|
||||
orig(self, solidLayer, forRenderTargets, intoRenderTargets, waterStyleOverride);
|
||||
}
|
||||
|
||||
private void DrawSeaPrismWalls(On_Main.orig_DrawWalls orig, Main self)
|
||||
{
|
||||
Vector2 offscreenPosition = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.instance.GraphicsDevice.Textures[1] = SeaPrismWall.GlowMaskGreen.Texture;
|
||||
Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
|
||||
Main.instance.GraphicsDevice.Textures[2] = SeaPrismWall.GlowMaskPurple.Texture;
|
||||
Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearClamp;
|
||||
Main.instance.GraphicsDevice.Textures[3] = null;
|
||||
|
||||
Effect shader = CalamityShaders.SeaPrismColorBlendingShader;
|
||||
shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly);
|
||||
shader.Parameters["screenOffset"].SetValue(Main.screenPosition);
|
||||
shader.Parameters["offscreenOffset"].SetValue(offscreenPosition);
|
||||
shader.Parameters["diagonalScreenLength"].SetValue((Main.screenWidth / 2f) - (Main.screenHeight / 2f));
|
||||
shader.Parameters["doGlint"].SetValue(false);
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, shader, Matrix.Identity);
|
||||
|
||||
Vector2 unscaledPosition = Main.Camera.UnscaledPosition;
|
||||
|
||||
@@ -168,19 +556,24 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
if (tile == null)
|
||||
continue;
|
||||
|
||||
int type = tile.TileType;
|
||||
if (type != ModContent.TileType<SeaPrism>())
|
||||
int type = tile.WallType;
|
||||
if (type != ModContent.WallType<SeaPrismWall>() && type != ModContent.WallType<UnsafeSeaPrismWall>())
|
||||
continue;
|
||||
|
||||
Vector2 position = new Vector2(x * 16, y * 16) - Main.screenPosition + offscreenPosition;
|
||||
|
||||
int frameX = tile.TileFrameX + (x % 8 * SeaPrism.subsheetWidth);
|
||||
int frameY = tile.TileFrameY + (y % 8 * SeaPrism.subsheetHeight);
|
||||
int xLength = 32;
|
||||
|
||||
Rectangle sourceRect = new Rectangle(frameX, frameY, 16, 16);
|
||||
Color light = Lighting.GetColor(x, y) * 1.5f;
|
||||
int frameXOffset = (x % 8) * 468;
|
||||
int frameYOffset = (y % 8) * 180;
|
||||
|
||||
Main.spriteBatch.Draw(SeaPrism.Blue.Value, position, sourceRect, light);
|
||||
int xPos = tile.WallFrameX + frameXOffset;
|
||||
int yPos = tile.WallFrameY + frameYOffset;
|
||||
|
||||
Rectangle frame = new Rectangle(xPos, yPos, xLength, 32);
|
||||
|
||||
if (SeaPrismWall.GlowMaskBlue.HasContentInFramePos(xPos, yPos))
|
||||
Main.spriteBatch.Draw(SeaPrismWall.GlowMaskBlue.Texture, position + new Vector2(-8, -8), frame, Color.White * 1.1f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,9 +583,9 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
Main.instance.GraphicsDevice.Textures[2] = null;
|
||||
Main.instance.GraphicsDevice.Textures[3] = null;
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.Transform);
|
||||
Main.spriteBatch.Begin();
|
||||
|
||||
orig(self, solidLayer, forRenderTargets, intoRenderTargets, waterStyleOverride);
|
||||
orig(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
using System;
|
||||
using CalamityMod.Items.Placeables.SunkenSea;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Tiles.SunkenSea
|
||||
{
|
||||
public class SeaPrismCrystals : ModTile
|
||||
{
|
||||
private static Asset<Texture2D> DefaultCrystals;
|
||||
private static Asset<Texture2D> PurpleCrystals;
|
||||
private static Asset<Texture2D> GreenCrystals;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.tileLighted[Type] = true;
|
||||
Main.tileNoFail[Type] = true;
|
||||
Main.tileFrameImportant[Type] = true;
|
||||
Main.tileObsidianKill[Type] = true;
|
||||
AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch);
|
||||
AddMapEntry(new Color(53, 136, 207), CalamityUtils.GetItemName<PrismShard>());
|
||||
HitSound = SoundID.Item27;
|
||||
DustType = 67;
|
||||
Main.tileSpelunker[Type] = true;
|
||||
MinPick = 55;
|
||||
|
||||
DefaultCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals");
|
||||
PurpleCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals_Purple");
|
||||
GreenCrystals = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals_Green");
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num)
|
||||
{
|
||||
num = fail ? 1 : 3;
|
||||
}
|
||||
|
||||
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
|
||||
{
|
||||
float fade1 = GetFade1(i, j);
|
||||
float fade2 = GetFade2(i, j);
|
||||
|
||||
Color baseColor = new Color(162, 216, 218); //Blue
|
||||
Color glow1 = new Color(171, 113, 215); //Purple
|
||||
Color glow2 = new Color(56, 174, 117); //Green
|
||||
|
||||
Vector3 blended = baseColor.ToVector3();
|
||||
|
||||
blended = Vector3.Lerp(blended, glow1.ToVector3(), fade1 * 0.5f);
|
||||
blended = Vector3.Lerp(blended, glow2.ToVector3(), fade2 * 0.5f);
|
||||
|
||||
float brightness = 0.6f;
|
||||
blended *= brightness;
|
||||
|
||||
r = blended.X;
|
||||
g = blended.Y;
|
||||
b = blended.Z;
|
||||
}
|
||||
|
||||
private static float GetFade1(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f;
|
||||
|
||||
private static float GetFade2(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f;
|
||||
|
||||
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
Tile tile = Framing.GetTileSafely(i, j);
|
||||
Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
Vector2 position = new Vector2(i * 16, j * 16) - Main.screenPosition + offScreen;
|
||||
|
||||
Rectangle sourceRect = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16);
|
||||
|
||||
spriteBatch.Draw(DefaultCrystals.Value, position, sourceRect, Lighting.GetColor(i, j) * 1.5f);
|
||||
spriteBatch.Draw(PurpleCrystals.Value, position, sourceRect, Lighting.GetColor(i, j) * 1.5f * GetFade1(i, j));
|
||||
spriteBatch.Draw(GreenCrystals.Value, position, sourceRect, Lighting.GetColor(i, j) * 1.5f * GetFade2(i, j));
|
||||
}
|
||||
|
||||
public override bool CanPlace(int i, int j)
|
||||
{
|
||||
Tile belowTile = Main.tile[i, j + 1];
|
||||
Tile aboveTile = Main.tile[i, j - 1];
|
||||
Tile rightTile = Main.tile[i + 1, j];
|
||||
Tile leftTile = Main.tile[i - 1, j];
|
||||
|
||||
if ((belowTile.Slope == SlopeType.Solid && !belowTile.IsHalfBlock && belowTile.HasTile && belowTile.IsTileSolid()) ||
|
||||
(aboveTile.Slope == SlopeType.Solid && !aboveTile.IsHalfBlock && aboveTile.HasTile && aboveTile.IsTileSolid()) ||
|
||||
(rightTile.Slope == SlopeType.Solid && !rightTile.IsHalfBlock && rightTile.HasTile && rightTile.IsTileSolid()) ||
|
||||
(leftTile.Slope == SlopeType.Solid && !leftTile.IsHalfBlock && leftTile.HasTile && leftTile.IsTileSolid()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void PlaceInWorld(int i, int j, Item item)
|
||||
{
|
||||
Tile belowTile = Main.tile[i, j + 1];
|
||||
Tile aboveTile = Main.tile[i, j - 1];
|
||||
Tile rightTile = Main.tile[i + 1, j];
|
||||
Tile leftTile = Main.tile[i - 1, j];
|
||||
|
||||
if (belowTile.Slope == SlopeType.Solid && !belowTile.IsHalfBlock && belowTile.HasTile && belowTile.IsTileSolid())
|
||||
Main.tile[i, j].TileFrameY = 0;
|
||||
else if (aboveTile.Slope == SlopeType.Solid && !aboveTile.IsHalfBlock && aboveTile.HasTile && aboveTile.IsTileSolid())
|
||||
Main.tile[i, j].TileFrameY = 18;
|
||||
else if (rightTile.Slope == SlopeType.Solid && !rightTile.IsHalfBlock && rightTile.HasTile && rightTile.IsTileSolid())
|
||||
Main.tile[i, j].TileFrameY = 36;
|
||||
else if (leftTile.Slope == SlopeType.Solid && !leftTile.IsHalfBlock && leftTile.HasTile && leftTile.IsTileSolid())
|
||||
Main.tile[i, j].TileFrameY = 54;
|
||||
|
||||
Main.tile[i, j].TileFrameX = (short)(WorldGen.genRand.Next(18) * 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
@@ -1,85 +0,0 @@
|
||||
using System;
|
||||
using CalamityMod.Tiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Walls
|
||||
{
|
||||
public class SeaPrismWall : MultiVariantModWall
|
||||
{
|
||||
internal static FramedMaskTexture GlowMaskBlue;
|
||||
internal static FramedMaskTexture GlowMaskPurple;
|
||||
internal static FramedMaskTexture GlowMaskGreen;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
GlowMaskBlue = new("CalamityMod/Walls/SeaPrismWall_Blue", 36, 36);
|
||||
GlowMaskPurple = new("CalamityMod/Walls/SeaPrismWall_Purple", 36, 36);
|
||||
GlowMaskGreen = new("CalamityMod/Walls/SeaPrismWall_Green", 36, 36);
|
||||
Main.wallHouse[Type] = true;
|
||||
DustType = 108;
|
||||
|
||||
AddMapEntry(new Color(27, 123, 131));
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
|
||||
|
||||
public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset)
|
||||
{
|
||||
frameXOffset = (i % 8) * 468;
|
||||
frameYOffset = (j % 8) * 180;
|
||||
}
|
||||
private static float GetFade1(int i, int j) =>
|
||||
(MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f;
|
||||
|
||||
private static float GetFade2(int i, int j) =>
|
||||
(MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f;
|
||||
|
||||
public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
Tile tile = Main.tile[i, j];
|
||||
int xLength = 32;
|
||||
|
||||
int frameXOffset = (i % 8) * 468;
|
||||
int frameYOffset = (j % 8) * 180;
|
||||
|
||||
int xPos = tile.WallFrameX + frameXOffset;
|
||||
int yPos = tile.WallFrameY + frameYOffset;
|
||||
|
||||
Rectangle frame = new Rectangle(xPos, yPos, xLength, 32);
|
||||
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero;
|
||||
|
||||
// base wall
|
||||
spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8, -8), frame, Lighting.GetColor(i, j));
|
||||
|
||||
// glow layers
|
||||
float fade1 = GetFade1(i, j);
|
||||
float fade2 = GetFade2(i, j);
|
||||
|
||||
if (GlowMaskBlue.HasContentInFramePos(xPos, yPos))
|
||||
{
|
||||
spriteBatch.Draw(GlowMaskBlue.Texture, pos + new Vector2(-8, -8), frame, (Color.White * 1.1f));
|
||||
}
|
||||
if (GlowMaskPurple.HasContentInFramePos(xPos, yPos))
|
||||
{
|
||||
spriteBatch.Draw(GlowMaskPurple.Texture, pos + new Vector2(-8, -8), frame, Color.White * (fade1 * 1.1f));
|
||||
}
|
||||
if (GlowMaskGreen.HasContentInFramePos(xPos, yPos))
|
||||
{
|
||||
spriteBatch.Draw(GlowMaskGreen.Texture, pos + new Vector2(-8, -8), frame, Color.White * (fade2 * 1.5f));
|
||||
}
|
||||
|
||||
Color wallColor = Lighting.GetColor(i, j) * 1.2f; // brighten a bit
|
||||
wallColor.A = 255;
|
||||
}
|
||||
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
DrawWallGlow(Type, i, j, spriteBatch);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
using System;
|
||||
using CalamityMod.Tiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Walls.UnsafeWalls
|
||||
{
|
||||
public class UnsafeSeaPrismWall : MultiVariantModWall
|
||||
{
|
||||
public override string Texture => "CalamityMod/Walls/SeaPrismWall";
|
||||
internal static FramedMaskTexture GlowMaskBlue;
|
||||
internal static FramedMaskTexture GlowMaskPurple;
|
||||
internal static FramedMaskTexture GlowMaskGreen;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
GlowMaskBlue = new("CalamityMod/Walls/SeaPrismWall_Blue", 36, 36);
|
||||
GlowMaskPurple = new("CalamityMod/Walls/SeaPrismWall_Purple", 36, 36);
|
||||
GlowMaskGreen = new("CalamityMod/Walls/SeaPrismWall_Green", 36, 36);
|
||||
Main.wallHouse[Type] = false;
|
||||
DustType = 108;
|
||||
|
||||
AddMapEntry(new Color(27, 123, 131));
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
|
||||
|
||||
public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset)
|
||||
{
|
||||
frameXOffset = (i % 8) * 468;
|
||||
frameYOffset = (j % 8) * 180;
|
||||
}
|
||||
private static float GetFade1(int i, int j) =>
|
||||
(MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f;
|
||||
|
||||
private static float GetFade2(int i, int j) =>
|
||||
(MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f;
|
||||
|
||||
public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
Tile tile = Main.tile[i, j];
|
||||
int xLength = 32;
|
||||
|
||||
int frameXOffset = (i % 8) * 468;
|
||||
int frameYOffset = (j % 8) * 180;
|
||||
|
||||
int xPos = tile.WallFrameX + frameXOffset;
|
||||
int yPos = tile.WallFrameY + frameYOffset;
|
||||
|
||||
Rectangle frame = new Rectangle(xPos, yPos, xLength, 32);
|
||||
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero;
|
||||
|
||||
// base wall
|
||||
spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8, -8), frame, Lighting.GetColor(i, j));
|
||||
|
||||
// glow layers
|
||||
float fade1 = GetFade1(i, j);
|
||||
float fade2 = GetFade2(i, j);
|
||||
|
||||
if (GlowMaskBlue.HasContentInFramePos(xPos, yPos))
|
||||
{
|
||||
spriteBatch.Draw(GlowMaskBlue.Texture, pos + new Vector2(-8, -8), frame, (Color.White * 1.1f));
|
||||
}
|
||||
if (GlowMaskPurple.HasContentInFramePos(xPos, yPos))
|
||||
{
|
||||
spriteBatch.Draw(GlowMaskPurple.Texture, pos + new Vector2(-8, -8), frame, Color.White * (fade1 * 1.1f));
|
||||
}
|
||||
if (GlowMaskGreen.HasContentInFramePos(xPos, yPos))
|
||||
{
|
||||
spriteBatch.Draw(GlowMaskGreen.Texture, pos + new Vector2(-8, -8), frame, Color.White * (fade2 * 1.5f));
|
||||
}
|
||||
|
||||
Color wallColor = Lighting.GetColor(i, j) * 1.2f; // brighten a bit
|
||||
wallColor.A = 255;
|
||||
}
|
||||
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
DrawWallGlow(Type, i, j, spriteBatch);
|
||||
return false;
|
||||
}
|
||||
public override bool Drop(int i, int j, ref int type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user