Files
CalamityModPublic/Tiles/AstralBrick.cs
T
Ozzatron ac3c348ae3 1 - Fix memory leak in universal tile merging system.
2 - Re-enable universal tile merging system.
3 - Move all tile framing into a ModSystem for consistent unloading.
4 - Move all recipe management into a ModSystem.
5 - Moved some framing stuff from CalamityGlobalTile into the sealed GlobalTile.
6 - CalamityRecipes and TileFraming no longer exist (they are now RecipeSystem and TileFramingSystem).
2024-06-06 21:18:08 -04:00

82 lines
3.0 KiB
C#

using System.Collections.Generic;
using CalamityMod.Dusts;
using CalamityMod.Systems;
using CalamityMod.Tiles.Astral;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles
{
public class AstralBrick : ModTile
{
private const short subsheetWidth = 324;
private const short subsheetHeight = 90;
public override void SetStaticDefaults()
{
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
HitSound = SoundID.Tink;
AddMapEntry(new Color(128, 128, 158));
this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge");
this.RegisterUniversalMerge(ModContent.TileType<AstralDirt>(), "CalamityMod/Tiles/Merges/AstralDirtMerge");
}
public override bool CreateDust(int i, int j, ref int type)
{
Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType<AstralBasic>(), 0f, 0f, 1, new Color(255, 255, 255), 1f);
return false;
}
public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
{
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
}
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int xPos = i % 2;
int yPos = j % 2;
frameXOffset = xPos * subsheetWidth;
frameYOffset = yPos * subsheetHeight;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
int xOffset = i % 2;
int yOffset = j % 2;
xOffset *= subsheetWidth;
yOffset *= subsheetHeight;
xPos += xOffset;
yPos += yOffset;
Texture2D glowmask = ModContent.Request<Texture2D>("CalamityMod/Tiles/AstralBrickGlow").Value;
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
Color drawColour = GetDrawColour(i, j, new Color(50, 50, 50, 50));
Tile trackTile = Main.tile[i, j];
TileFramingSystem.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
}
}
}