69 lines
2.2 KiB
C#
69 lines
2.2 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace Decimation.Lib.Tiles
|
|
{
|
|
public abstract class DecimationTile : ModTile
|
|
{
|
|
public virtual bool Solid { get; set; } = false;
|
|
public virtual bool SolidTop { get; set; } = false;
|
|
public virtual bool TilesCanAttach { get; set; } = false;
|
|
public virtual bool DisableSmartCursor { get; set; } = false;
|
|
public virtual float MineResistance { get; set; } = 1f;
|
|
public virtual int DustType { get; } = 0;
|
|
public virtual int AnimationFrameCount { get; } = 0;
|
|
public virtual int AnimationFps { get; } = 5;
|
|
public virtual int? AnimationFrameHeight { get; } = null;
|
|
public virtual string Name { get; } = null;
|
|
public virtual int MinimumPickaxePower { get; set; } = 0;
|
|
|
|
public abstract Color MapColor { get; }
|
|
public abstract int TileItem { get; }
|
|
|
|
public sealed override void SetDefaults()
|
|
{
|
|
Main.tileSolid[Type] = Solid;
|
|
Main.tileSolidTop[Type] = SolidTop;
|
|
Main.tileNoAttach[Type] = !TilesCanAttach;
|
|
minPick = MinimumPickaxePower;
|
|
mineResist = MineResistance;
|
|
dustType = DustType;
|
|
drop = TileItem;
|
|
disableSmartCursor = DisableSmartCursor;
|
|
if (AnimationFrameHeight.HasValue) animationFrameHeight = AnimationFrameHeight.Value;
|
|
|
|
if (Name == null)
|
|
{
|
|
AddMapEntry(MapColor);
|
|
}
|
|
else
|
|
{
|
|
ModTranslation translation = CreateMapEntryName();
|
|
translation.SetDefault(Name);
|
|
AddMapEntry(MapColor, translation);
|
|
}
|
|
|
|
InitTile();
|
|
}
|
|
|
|
public override void NumDust(int i, int j, bool fail, ref int num)
|
|
{
|
|
num = fail ? 1 : 3;
|
|
}
|
|
|
|
public override void AnimateTile(ref int frame, ref int frameCounter)
|
|
{
|
|
frameCounter++;
|
|
if (frameCounter > AnimationFps)
|
|
{
|
|
frameCounter = 0;
|
|
frame++;
|
|
|
|
if (frame >= AnimationFrameCount) frame = 0;
|
|
}
|
|
}
|
|
|
|
protected abstract void InitTile();
|
|
}
|
|
} |