Moved the pearls and made then pretty with glints

This commit is contained in:
Heart-Plus-Up committed 2025-08-31 10:19:58 -07:00
1 parent 889d5d5fce
commit bd816c92cc
7 files changed
+353 -23

No files matched your search

+111 -1
View File
@@ -1,7 +1,9 @@
using CalamityMod.Sounds;
using System;
using CalamityMod.Sounds;
using CalamityMod.Systems;
using CalamityMod.Tiles.Abyss;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -16,6 +18,8 @@ namespace CalamityMod.Tiles.SunkenSea
Main.tileBlockLight[Type] = true;
TileID.Sets.HasSlopeFrames[Type] = true;
Main.tileLighted[Type] = true;
Main.tileBlendAll[Type] = true;
CalamityUtils.MergeWithGeneral(Type);
@@ -51,5 +55,111 @@ namespace CalamityMod.Tiles.SunkenSea
{
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
}
private static float GetFade1(int i, int j)
{
return (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f;
}
private static float GetFade2(int i, int j)
{
return (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
//IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's
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;
int frameX = tile.TileFrameX + (i % 1);
int frameY = tile.TileFrameY + (j % 1);
Rectangle sourceRect = new Rectangle(frameX, frameY, 16, 16);
Texture2D GlintTex = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/BlackPearlPile_Glint").Value;
Vector2 glintDir = new Vector2(1f, -1f);
glintDir.Normalize();
Vector2 screenPos = position;
float projection = Vector2.Dot(screenPos, glintDir);
// this sets the length between the glints diagonally
float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), glintDir);
float[] beamCenters = new float[]
{
screenDiagonalLength * 0.05f, // upper glint
screenDiagonalLength * 0.5f, // middle glint
screenDiagonalLength * 1.05f // lower glint
};
float stripeWidth = 100f;
foreach (float bc in beamCenters)
{
float dist = Math.Abs(projection - bc);
float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f);
if (strength > 0f)
{
spriteBatch.Draw(GlintTex, position, sourceRect, (Lighting.GetColor(i, j) * 6) * (strength * 0.4f), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
}
}
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
{
// figure out if the tile is exposed - taken from the coral tiles
if (Main.tile[i, j] == null ||
(Main.tile[i - 1, j].HasTile && Main.tile[i + 1, j].HasTile && Main.tile[i, j - 1].HasTile && Main.tile[i, j + 1].HasTile))
return;
// get in-game lighting color at this tile
Color litColor = Lighting.GetColor(i, j);
// convert to brightness factor (0 = dark, 1 = full bright)
float brightness = (litColor.R + litColor.G + litColor.B) / (3f * 255f);
// flip it so the glow is strongest in the dark
float darknessFactor = 1f - brightness;
// diagonal glint math
Vector2 glintDir = new Vector2(1f, -1f);
glintDir.Normalize();
Vector2 screenPos = new Vector2(i * 16, j * 16) - Main.screenPosition;
float projection = Vector2.Dot(screenPos, glintDir);
float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), glintDir);
float[] beamCenters =
{
screenDiagonalLength * 0.05f,
screenDiagonalLength * 0.5f,
screenDiagonalLength * 1.05f
};
float stripeWidth = 100f;
float maxStrength = 0f;
foreach (float bc in beamCenters)
{
float dist = Math.Abs(projection - bc);
float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f);
if (strength > maxStrength)
maxStrength = strength;
}
if (maxStrength > 0f)
{
// base intensity scaled by glint strength and darkness
float intensity = 0.6f * maxStrength * (0.5f + darknessFactor * 0.5f);
r = (67f / 155f) * intensity;
g = (68f / 155f) * intensity;
b = (87f / 155f) * intensity;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

+114 -1
View File
@@ -1,10 +1,14 @@
using CalamityMod.Sounds;
using System;
using CalamityMod.Sounds;
using CalamityMod.Systems;
using CalamityMod.Tiles.Abyss;
using Microsoft.CodeAnalysis.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static CalamityMod.Projectiles.Rogue.FinalDawnFlame;
namespace CalamityMod.Tiles.SunkenSea
{
@@ -14,6 +18,7 @@ namespace CalamityMod.Tiles.SunkenSea
{
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
Main.tileLighted[Type] = true;
CalamityUtils.MergeWithGeneral(Type);
@@ -46,5 +51,113 @@ namespace CalamityMod.Tiles.SunkenSea
{
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
}
private static float GetFade1(int i, int j)
{
return (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f;
}
private static float GetFade2(int i, int j)
{
return (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
//IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's
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;
int frameX = tile.TileFrameX + (i % 1 );
int frameY = tile.TileFrameY + (j % 1 );
Rectangle sourceRect = new Rectangle(frameX, frameY, 16, 16);
Texture2D GlintTex = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/PinkPearlPile_Glint").Value;
Vector2 glintDir = new Vector2(1f, -1f);
glintDir.Normalize();
Vector2 screenPos = position;
float projection = Vector2.Dot(screenPos, glintDir);
// this sets the length between the glints diagonally
float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), glintDir);
float[] beamCenters = new float[]
{
screenDiagonalLength * 0.05f, // upper glint
screenDiagonalLength * 0.5f, // middle glint
screenDiagonalLength * 1.05f // lower glint
};
float stripeWidth = 100f;
foreach (float bc in beamCenters)
{
float dist = Math.Abs(projection - bc);
float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f);
if (strength > 0f)
{
spriteBatch.Draw(GlintTex, position, sourceRect, (Lighting.GetColor(i, j) * 6 ) * (strength * 0.4f), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
}
}
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
{
// figure out if the tile is exposed - taken from the coral tiles
if (Main.tile[i, j] == null ||
(Main.tile[i - 1, j].HasTile && Main.tile[i + 1, j].HasTile && Main.tile[i, j - 1].HasTile && Main.tile[i, j + 1].HasTile))
return;
// get in-game lighting color at this tile
Color litColor = Lighting.GetColor(i, j);
// convert to brightness factor (0 = dark, 1 = full bright)
float brightness = (litColor.R + litColor.G + litColor.B) / (3f * 255f);
// flip it so the glow is strongest in the dark
float darknessFactor = 1f - brightness;
// diagonal glint math
Vector2 glintDir = new Vector2(1f, -1f);
glintDir.Normalize();
Vector2 screenPos = new Vector2(i * 16, j * 16) - Main.screenPosition;
float projection = Vector2.Dot(screenPos, glintDir);
float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), glintDir);
float[] beamCenters =
{
screenDiagonalLength * 0.05f,
screenDiagonalLength * 0.5f,
screenDiagonalLength * 1.05f
};
float stripeWidth = 100f;
float maxStrength = 0f;
foreach (float bc in beamCenters)
{
float dist = Math.Abs(projection - bc);
float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f);
if (strength > maxStrength)
maxStrength = strength;
}
if (maxStrength > 0f)
{
// base intensity scaled by glint strength and darkness
float intensity = 0.6f * maxStrength * (0.5f + darknessFactor * 0.5f);
r = (172f / 255f) * intensity;
g = (112f / 255f) * intensity;
b = (145f / 255f) * intensity;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

+112 -1
View File
@@ -1,7 +1,9 @@
using CalamityMod.Sounds;
using System;
using CalamityMod.Sounds;
using CalamityMod.Systems;
using CalamityMod.Tiles.Abyss;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -14,6 +16,7 @@ namespace CalamityMod.Tiles.SunkenSea
{
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
Main.tileLighted[Type] = true;
CalamityUtils.MergeWithGeneral(Type);
@@ -47,5 +50,113 @@ namespace CalamityMod.Tiles.SunkenSea
{
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
}
private static float GetFade1(int i, int j)
{
return (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f;
}
private static float GetFade2(int i, int j)
{
return (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
//IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's
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;
int frameX = tile.TileFrameX + (i % 1);
int frameY = tile.TileFrameY + (j % 1);
Rectangle sourceRect = new Rectangle(frameX, frameY, 16, 16);
Texture2D GlintTex = ModContent.Request<Texture2D>("CalamityMod/Tiles/SunkenSea/WhitePearlPile_Glint").Value;
Vector2 glintDir = new Vector2(1f, -1f);
glintDir.Normalize();
Vector2 screenPos = position;
float projection = Vector2.Dot(screenPos, glintDir);
// this sets the length between the glints diagonally
float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), glintDir);
float[] beamCenters = new float[]
{
screenDiagonalLength * 0.05f, // upper glint
screenDiagonalLength * 0.5f, // middle glint
screenDiagonalLength * 1.05f // lower glint
};
float stripeWidth = 100f;
foreach (float bc in beamCenters)
{
float dist = Math.Abs(projection - bc);
float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f);
if (strength > 0f)
{
spriteBatch.Draw(GlintTex, position, sourceRect, (Lighting.GetColor(i, j) * 6) * (strength * 0.4f), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
}
}
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
{
// figure out if the tile is exposed - taken from the coral tiles
if (Main.tile[i, j] == null ||
(Main.tile[i - 1, j].HasTile && Main.tile[i + 1, j].HasTile && Main.tile[i, j - 1].HasTile && Main.tile[i, j + 1].HasTile))
return;
// get in-game lighting color at this tile
Color litColor = Lighting.GetColor(i, j);
// convert to brightness factor (0 = dark, 1 = full bright)
float brightness = (litColor.R + litColor.G + litColor.B) / (3f * 255f);
// flip it so the glow is strongest in the dark
float darknessFactor = 1f - brightness;
// diagonal glint math
Vector2 glintDir = new Vector2(1f, -1f);
glintDir.Normalize();
Vector2 screenPos = new Vector2(i * 16, j * 16) - Main.screenPosition;
float projection = Vector2.Dot(screenPos, glintDir);
float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), glintDir);
float[] beamCenters =
{
screenDiagonalLength * 0.05f,
screenDiagonalLength * 0.5f,
screenDiagonalLength * 1.05f
};
float stripeWidth = 100f;
float maxStrength = 0f;
foreach (float bc in beamCenters)
{
float dist = Math.Abs(projection - bc);
float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f);
if (strength > maxStrength)
maxStrength = strength;
}
if (maxStrength > 0f)
{
// base intensity scaled by glint strength and darkness (min = 0.0f, max = 1.0f)
float intensity = 0.6f * maxStrength * (0.5f + darknessFactor * 0.5f);
//float intensity = ((float)(Math.Pow(10.0, (brightness * 2 - 2))) - 0.01f) / 0.99f; was trying to do something cool, may come back to it later
r = (185f / 255f) * intensity;
g = (164f / 255f) * intensity;
b = (184f / 255f) * intensity;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

+16 -20
View File
@@ -1572,13 +1572,7 @@ namespace CalamityMod.World
{
int RandStyle() => WorldGen.genRand.Next(8);
int style = RandStyle();
if (WorldGen.genRand.NextBool(50) && !Main.tile[X - 1, Y].HasTile)
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(3), Actions.Chain(new GenAction[]
{
new Modifiers.OnlyTiles((ushort)ModContent.TileType<ScarletSeaGrassTile>(),(ushort)ModContent.TileType<PolypSand>()),
new Actions.ClearTile(),
new Actions.PlaceTile((ushort)ModContent.TileType<PinkPearlPile>()),
}));
//BranchCoralsOnSand
if (WorldGen.genRand.NextBool(25))
{
@@ -1650,13 +1644,6 @@ namespace CalamityMod.World
//radiant reefs ambient tiles
if (Main.tile[X, Y].TileType == ModContent.TileType<EutrophicSand>())
{
if (WorldGen.genRand.NextBool(100) && !Main.tile[X - 1, Y].HasTile)
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(7), Actions.Chain(new GenAction[]
{
new Modifiers.OnlyTiles((ushort)ModContent.TileType<EutrophicSand>()),
new Actions.ClearTile(),
new Actions.PlaceTile((ushort)ModContent.TileType<WhitePearlPile>()),
}));
//Driftwood Ambiance
if (WorldGen.genRand.NextBool(15))
{
@@ -1753,26 +1740,35 @@ namespace CalamityMod.World
}
}
// Pearl Autism
if (Main.tile[X, Y].TileType == ModContent.TileType<VolcanicSand>())
if (Main.tile[X, Y].TileType == ModContent.TileType<HardenedEutrophicSand>())
{
if (WorldGen.genRand.NextBool(50) && !Main.tile[X - 1, Y].HasTile)
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(3), Actions.Chain(new GenAction[]
if (WorldGen.genRand.NextBool(60) && !Main.tile[X - 1, Y].HasTile)
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(2), Actions.Chain(new GenAction[]
{
new Modifiers.OnlyTiles((ushort)ModContent.TileType<VolcanicSand>()),
new Modifiers.OnlyTiles((ushort)ModContent.TileType<HardenedEutrophicSand>()),
new Actions.ClearTile(),
new Actions.PlaceTile((ushort)ModContent.TileType<BlackPearlPile>()),
}));
}
if (Main.tile[X, Y].TileType == ModContent.TileType<HardenedEutrophicSand>())
{
if (WorldGen.genRand.NextBool(30) && !Main.tile[X - 1, Y].HasTile)
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(3), Actions.Chain(new GenAction[]
if (WorldGen.genRand.NextBool(60) && !Main.tile[X - 1, Y].HasTile)
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(2), Actions.Chain(new GenAction[]
{
new Modifiers.OnlyTiles((ushort)ModContent.TileType<HardenedEutrophicSand>()),
new Actions.ClearTile(),
new Actions.PlaceTile((ushort)ModContent.TileType<WhitePearlPile>()),
}));
}
if (Main.tile[X, Y].TileType == ModContent.TileType<HardenedEutrophicSand>())
if (WorldGen.genRand.NextBool(60) && !Main.tile[X - 1, Y].HasTile)
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(2), Actions.Chain(new GenAction[]
{
new Modifiers.OnlyTiles((ushort)ModContent.TileType<HardenedEutrophicSand>()),
new Actions.ClearTile(),
new Actions.PlaceTile((ushort)ModContent.TileType<PinkPearlPile>()),
}));
}
}
}