Updated Titan Forge.
This commit is contained in:
parent
2f32c4d775
commit
a66c4e48ac
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
@ -1,51 +1,19 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Decimation.Lib.Tiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ObjectData;
|
||||
|
||||
namespace Decimation.Content.Tiles
|
||||
{
|
||||
class TitanForge : ModTile
|
||||
class TitanForge : DecimationMultiTile
|
||||
{
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Main.tileSolidTop[Type] = false;
|
||||
Main.tileFrameImportant[Type] = true;
|
||||
Main.tileNoAttach[Type] = true;
|
||||
TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3);
|
||||
TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 };
|
||||
TileObjectData.addTile(Type);
|
||||
ModTranslation name = CreateMapEntryName();
|
||||
name.SetDefault("Titan Forge");
|
||||
AddMapEntry(new Color(104, 140, 183), name);
|
||||
dustType = DustID.Iron;
|
||||
disableSmartCursor = true;
|
||||
animationFrameHeight = 54;
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num)
|
||||
{
|
||||
num = fail ? 1 : 3;
|
||||
}
|
||||
|
||||
public override void KillMultiTile(int i, int j, int frameX, int frameY)
|
||||
{
|
||||
Item.NewItem(i * 16, j * 16, 48, 48, ModContent.ItemType<Items.Placeable.TitanForge>());
|
||||
}
|
||||
|
||||
public override void AnimateTile(ref int frame, ref int frameCounter)
|
||||
{
|
||||
frameCounter++;
|
||||
if (frameCounter > 5)
|
||||
{
|
||||
frameCounter = 0;
|
||||
frame++;
|
||||
if (frame > 4)
|
||||
{
|
||||
frame = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public override TileObjectData Style => TileObjectData.Style3x3;
|
||||
public override string Name => "Titan Forge";
|
||||
public override Color MapColor => new Color(104, 140, 183);
|
||||
public override int DustType => DustID.Iron;
|
||||
public override int AnimationFrameCount => 8;
|
||||
public override int? AnimationFrameHeight => 54;
|
||||
public override int TileItem => ModContent.ItemType<Items.Placeable.TitanForge>();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 2.8 KiB |
21
Lib/Tiles/DecimationFramedTile.cs
Normal file
21
Lib/Tiles/DecimationFramedTile.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Terraria;
|
||||
|
||||
namespace Decimation.Lib.Tiles
|
||||
{
|
||||
public abstract class DecimationFramedTile : DecimationTile
|
||||
{
|
||||
public override bool Solid => true;
|
||||
public override bool TilesCanAttach => true;
|
||||
|
||||
public virtual bool MergeDirt { get; set; } = true;
|
||||
|
||||
protected sealed override void InitTile()
|
||||
{
|
||||
Main.tileMergeDirt[Type] = MergeDirt;
|
||||
|
||||
InitFramedTile();
|
||||
}
|
||||
|
||||
protected abstract void InitFramedTile();
|
||||
}
|
||||
}
|
||||
61
Lib/Tiles/DecimationMultiTile.cs
Normal file
61
Lib/Tiles/DecimationMultiTile.cs
Normal file
@ -0,0 +1,61 @@
|
||||
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()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
69
Lib/Tiles/DecimationTile.cs
Normal file
69
Lib/Tiles/DecimationTile.cs
Normal file
@ -0,0 +1,69 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user