Files
CalamityModPublic/Tiles/ScoriaBrick.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

90 lines
3.2 KiB
C#

using System.Collections.Generic;
using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.GameContent.Metadata;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles
{
[LegacyName("ChaoticBrick")]
public class ScoriaBrick : ModTile
{
int subsheetHeight = 72;
internal static Texture2D GlowTexture;
public override void SetStaticDefaults()
{
if (!Main.dedServ)
{
GlowTexture = ModContent.Request<Texture2D>("CalamityMod/Tiles/ScoriaBrickGlow", AssetRequestMode.ImmediateLoad).Value;
}
Main.tileLighted[Type] = true;
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
DustType = 105;
AddMapEntry(new Color(85, 87, 101));
HitSound = SoundID.Tink;
this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge");
this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge");
}
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)
{
r = 0.04f;
g = 0.00f;
b = 0.00f;
}
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int yPos = j % 2;
frameYOffset = yPos * subsheetHeight;
}
public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
{
TileFramingSystem.CompactFraming(i, j, resetFrame);
return false;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
// If the cached textures don't exist for some reason, don't bother using them.
if (GlowTexture is null)
return;
Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j);
int xPos = tile.TileFrameX;
int frameOffset = j % 2 * 72;
int yPos = tile.TileFrameY + frameOffset;
Color drawColour = GetDrawColour(i, j, Color.White);
Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowTexture, drawPosition + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), 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;
}
}
}