102 lines
4.2 KiB
C#
102 lines
4.2 KiB
C#
using System.Collections.Generic;
|
|
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 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;
|
|
|
|
this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge");
|
|
this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge");
|
|
this.RegisterUniversalMerge(ModContent.TileType<HardenedSulphurousSandstone>(), "CalamityMod/Tiles/Merges/HardenedSulphurousSandstoneMerge");
|
|
}
|
|
|
|
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 RandomUpdate(int i, int j)
|
|
{
|
|
int vineLength = 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 canGrowVine = false;
|
|
for (int k = vineLength; k > vineLength - 10; k--)
|
|
{
|
|
if (Main.tile[i, k].BottomSlope)
|
|
{
|
|
canGrowVine = false;
|
|
break;
|
|
}
|
|
if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope)
|
|
{
|
|
canGrowVine = true;
|
|
break;
|
|
}
|
|
}
|
|
if (canGrowVine)
|
|
{
|
|
int vineX = i;
|
|
int vineY = j + 1;
|
|
Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType<SulphurousVines>();
|
|
Main.tile[vineX, vineY].Get<TileWallWireStateData>().HasTile = true;
|
|
WorldGen.SquareTileFrame(vineX, vineY, true);
|
|
if (Main.netMode == NetmodeID.Server)
|
|
NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None);
|
|
}
|
|
Main.tile[i, j].Get<TileWallWireStateData>().Slope = SlopeType.Solid;
|
|
Main.tile[i, j].Get<TileWallWireStateData>().IsHalfBlock = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|