61 lines
2.2 KiB
C#
61 lines
2.2 KiB
C#
using Terraria;
|
|
using Terraria.DataStructures;
|
|
using Terraria.Enums;
|
|
using Terraria.ObjectData;
|
|
|
|
namespace Decimation.Lib.Tiles
|
|
{
|
|
public abstract class DecimationMultiTile : DecimationTile
|
|
{
|
|
public override bool DisableSmartCursor => true;
|
|
|
|
public virtual bool Table { get; set; } = false;
|
|
public virtual Point16 Origin { get; } = new Point16(0, 0);
|
|
public virtual int[] CoordinateHeights { get; set; } = { };
|
|
public virtual int CoordinateWidth { get; } = 16;
|
|
public virtual int CoordinatePadding { get; } = 2;
|
|
public virtual int? Width { get; } = null;
|
|
public virtual int? Height { get; } = null;
|
|
public virtual bool AnchorBottom { get; } = true;
|
|
|
|
public abstract TileObjectData Style { get; }
|
|
|
|
private int _width;
|
|
private int _height;
|
|
|
|
protected sealed override void InitTile()
|
|
{
|
|
Main.tileTable[Type] = Table;
|
|
Main.tileFrameImportant[Type] = true;
|
|
|
|
TileObjectData.newTile.CopyFrom(Style);
|
|
if (Width.HasValue) TileObjectData.newTile.Width = Width.Value;
|
|
if (Height.HasValue) TileObjectData.newTile.Height = Height.Value;
|
|
if (CoordinateHeights.Length <= 0)
|
|
{
|
|
CoordinateHeights = new int[TileObjectData.newTile.Height];
|
|
for (int i = 0; i < TileObjectData.newTile.Height; i++) CoordinateHeights[i] = 16;
|
|
}
|
|
|
|
TileObjectData.newTile.CoordinateHeights = CoordinateHeights;
|
|
TileObjectData.newTile.CoordinateWidth = CoordinateWidth;
|
|
TileObjectData.newTile.CoordinatePadding = CoordinatePadding;
|
|
if (AnchorBottom)
|
|
TileObjectData.newTile.AnchorBottom =
|
|
new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width - 1, 0);
|
|
TileObjectData.addTile(Type);
|
|
|
|
_width = TileObjectData.newTile.Width * 16;
|
|
_height = TileObjectData.newTile.Height * 16;
|
|
}
|
|
|
|
public override void KillMultiTile(int i, int j, int frameX, int frameY)
|
|
{
|
|
Item.NewItem(i * 16, j * 16, _width, _height, TileItem);
|
|
}
|
|
|
|
protected virtual void InitMultiTile()
|
|
{
|
|
}
|
|
}
|
|
} |