block resprite
This commit is contained in:
1 parent
8dee94495e
commit
82ff933866
3 files changed
+32
-5
No files matched your search
+32
-5
@@ -1,4 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.GameContent.Metadata;
|
||||
using Terraria.ModLoader;
|
||||
@@ -11,8 +13,13 @@ namespace CalamityMod.Tiles
|
||||
{
|
||||
int subsheetHeight = 72;
|
||||
int subsheetWidth = 216;
|
||||
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;
|
||||
@@ -36,11 +43,8 @@ namespace CalamityMod.Tiles
|
||||
|
||||
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
|
||||
{
|
||||
int xPos = i % 1;
|
||||
int yPos = j % 2;
|
||||
|
||||
frameXOffset = xPos * subsheetWidth;
|
||||
frameYOffset = yPos * subsheetHeight;
|
||||
int frameOffset = (i + j) % 2;
|
||||
frameYOffset = frameOffset * AnimationFrameHeight;
|
||||
}
|
||||
|
||||
public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
|
||||
@@ -48,5 +52,28 @@ namespace CalamityMod.Tiles
|
||||
TileFraming.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 = (i + j) % 2 * AnimationFrameHeight;
|
||||
int yPos = tile.TileFrameY + frameOffset;
|
||||
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;
|
||||
|
||||
if (!tile.IsHalfBlock && tile.Slope == 0)
|
||||
{
|
||||
spriteBatch.Draw(GlowTexture, drawPosition, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
}
|
||||
else if (tile.IsHalfBlock)
|
||||
{
|
||||
spriteBatch.Draw(GlowTexture, drawPosition + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 7.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Reference in new issue
Block a user