120 lines
5.1 KiB
C#
120 lines
5.1 KiB
C#
using CalamityMod.World;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Tiles.Abyss
|
|
{
|
|
public class SulphurousSandstone : ModTile
|
|
{
|
|
public byte[,] tileAdjacency;
|
|
public byte[,] secondTileAdjacency;
|
|
public byte[,] thirdTileAdjacency;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Main.tileSolid[Type] = true;
|
|
Main.tileBlockLight[Type] = true;
|
|
|
|
CalamityUtils.MergeWithGeneral(Type);
|
|
CalamityUtils.MergeWithAbyss(Type);
|
|
|
|
DustType = 32;
|
|
AddMapEntry(new Color(113, 90, 71));
|
|
HitSound = SoundID.Dig;
|
|
|
|
TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency);
|
|
TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency);
|
|
TileFraming.SetUpUniversalMerge(Type, ModContent.TileType<HardenedSulphurousSandstone>(), out thirdTileAdjacency);
|
|
}
|
|
|
|
public override void NumDust(int i, int j, bool fail, ref int num)
|
|
{
|
|
num = fail ? 1 : 3;
|
|
}
|
|
|
|
public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
|
|
{
|
|
if (CalamityUtils.ParanoidTileRetrieval(i, j + 1).HasTile &&
|
|
CalamityUtils.ParanoidTileRetrieval(i, j + 1).TileType == (ushort)ModContent.TileType<SulphurousVines>())
|
|
{
|
|
WorldGen.KillTile(i, j + 1);
|
|
}
|
|
}
|
|
|
|
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
|
|
{
|
|
TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/HardenedSulphurousSandstoneMerge");
|
|
TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge");
|
|
TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge");
|
|
}
|
|
|
|
public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
|
|
{
|
|
TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]);
|
|
TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]);
|
|
TileFraming.GetAdjacencyData(i, j, ModContent.TileType<HardenedSulphurousSandstone>(), out thirdTileAdjacency[i, j]);
|
|
return true;
|
|
}
|
|
|
|
public override void RandomUpdate(int i, int j)
|
|
{
|
|
int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143));
|
|
int nearbyVineCount = 0;
|
|
for (int x = i - 15; x <= i + 15; x++)
|
|
{
|
|
for (int y = j - 15; y <= j + 15; y++)
|
|
{
|
|
if (WorldGen.InWorld(x, y))
|
|
{
|
|
if (CalamityUtils.ParanoidTileRetrieval(x, y).HasTile &&
|
|
CalamityUtils.ParanoidTileRetrieval(x, y).TileType == (ushort)ModContent.TileType<SulphurousVines>())
|
|
{
|
|
nearbyVineCount++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (Main.tile[i, j + 1] != null && nearbyVineCount < 5 && j >= SulphurousSea.VineGrowTopLimit)
|
|
{
|
|
if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != (ushort)ModContent.TileType<SulphurousVines>())
|
|
{
|
|
if (Main.tile[i, j + 1].LiquidAmount == 255 &&
|
|
Main.tile[i, j + 1].LiquidType != LiquidID.Lava)
|
|
{
|
|
bool flag13 = false;
|
|
for (int num52 = num8; num52 > num8 - 10; num52--)
|
|
{
|
|
if (Main.tile[i, num52].BottomSlope)
|
|
{
|
|
flag13 = false;
|
|
break;
|
|
}
|
|
if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope)
|
|
{
|
|
flag13 = true;
|
|
break;
|
|
}
|
|
}
|
|
if (flag13)
|
|
{
|
|
int num53 = i;
|
|
int num54 = j + 1;
|
|
Main.tile[num53, num54].TileType = (ushort)ModContent.TileType<SulphurousVines>();
|
|
Main.tile[num53, num54].Get<TileWallWireStateData>().HasTile = true;
|
|
WorldGen.SquareTileFrame(num53, num54, true);
|
|
if (Main.netMode == NetmodeID.Server)
|
|
NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None);
|
|
}
|
|
Main.tile[i, j].Get<TileWallWireStateData>().Slope = SlopeType.Solid;
|
|
Main.tile[i, j].Get<TileWallWireStateData>().IsHalfBlock = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|