فئة ModTile
الفئة الأساسية لإنشاء البلاطات والكتل والأثاث المخصص.
نظرة عامة
تتيح لك فئة ModTile إنشاء كتل قابلة للوضع مخصصة وأثاث وبلاطات تزيينية بسلوكيات مخصصة.
مثال كتلة بسيطة
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
namespace YourMod.Tiles
{
public class ExampleTile : ModTile
{
public override void SetStaticDefaults()
{
Main.tileSolid[Type] = true; // Block is solid
Main.tileMergeDirt[Type] = true; // Merges with dirt
Main.tileBlockLight[Type] = true; // Blocks light
TileID.Sets.Ore[Type] = true; // Ore type (optional)
AddMapEntry(new Color(100, 100, 100)); // Map color
DustType = DustID.Stone;
HitSound = SoundID.Tink;
MinPick = 50; // Requires 50+ pickaxe power
}
}
}
إنشاء أثاث
بلاطات الأثاث أكثر تعقيداً مع قواعد وضع:
public class ExampleChair : ModTile
{
public override void SetStaticDefaults()
{
Main.tileFrameImportant[Type] = true; // Critical for furniture
Main.tileNoAttach[Type] = true;
TileID.Sets.HasOutlines[Type] = true;
TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2);
TileObjectData.newTile.CoordinateHeights = new[] { 16, 18 };
TileObjectData.addTile(Type);
AddMapEntry(new Color(120, 85, 60), "Example Chair");
DustType = DustID.WoodFurniture;
TileID.Sets.DisableSmartCursor[Type] = true;
}
}
خصائص البلاطات الشائعة
tileSolid
الكتلة صلبة (لا يمكن المرور خلالها)
Main.tileSolid[Type] = true;
tileBlockLight
الكتلة تمنع مرور الضوء
Main.tileBlockLight[Type] = true;
MinPick
الحد الأدنى لقوة المعول للتعدين
MinPick = 100;
DustType
تأثير الجسيمات عند التعدين
DustType = DustID.Stone;
للحصول على توثيق ModTile الكامل:
عرض التوثيق الكامل