Terraria 1.3.5.3 Source Code

This commit is contained in:
MikeyIsBaeYT 2021-10-27 18:03:19 -04:00
commit 4b21dac4b6
503 changed files with 409032 additions and 0 deletions

View file

@ -0,0 +1,67 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.CampsiteBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class CampsiteBiome : MicroBiome
{
public override bool Place(Point origin, StructureMap structures)
{
Ref<int> count1 = new Ref<int>(0);
Ref<int> count2 = new Ref<int>(0);
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(10), Actions.Chain((GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1)));
if (count1.Value < count2.Value - 5)
return false;
int radius = GenBase._random.Next(6, 10);
int num1 = GenBase._random.Next(5);
if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2)))
return false;
ShapeData data = new ShapeData();
WorldUtils.Gen(origin, (GenShape) new Shapes.Slime(radius), Actions.Chain(new Modifiers.Blotches(num1, num1, num1, 1).Output(data), (GenAction) new Modifiers.Offset(0, -2), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 53
}), (GenAction) new Actions.SetTile((ushort) 397, true), (GenAction) new Modifiers.OnlyWalls(new byte[1]), (GenAction) new Actions.PlaceWall((byte) 16)));
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.ClearTile(), (GenAction) new Actions.SetLiquid(value: (byte) 0), (GenAction) new Actions.SetFrames(true), (GenAction) new Modifiers.OnlyWalls(new byte[1]), (GenAction) new Actions.PlaceWall((byte) 16)));
Point result;
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result))
return false;
int j = result.Y - 1;
bool flag = GenBase._random.Next() % 2 == 0;
if (GenBase._random.Next() % 10 != 0)
{
int num2 = GenBase._random.Next(1, 4);
int num3 = flag ? 4 : -(radius >> 1);
for (int index1 = 0; index1 < num2; ++index1)
{
int num4 = GenBase._random.Next(1, 3);
for (int index2 = 0; index2 < num4; ++index2)
WorldGen.PlaceTile(origin.X + num3 - index1, j - index2, 331);
}
}
int num5 = (radius - 3) * (flag ? -1 : 1);
if (GenBase._random.Next() % 10 != 0)
WorldGen.PlaceTile(origin.X + num5, j, 186);
if (GenBase._random.Next() % 10 != 0)
{
WorldGen.PlaceTile(origin.X, j, 215, true);
if (GenBase._tiles[origin.X, j].active() && GenBase._tiles[origin.X, j].type == (ushort) 215)
{
GenBase._tiles[origin.X, j].frameY += (short) 36;
GenBase._tiles[origin.X - 1, j].frameY += (short) 36;
GenBase._tiles[origin.X + 1, j].frameY += (short) 36;
GenBase._tiles[origin.X, j - 1].frameY += (short) 36;
GenBase._tiles[origin.X - 1, j - 1].frameY += (short) 36;
GenBase._tiles[origin.X + 1, j - 1].frameY += (short) 36;
}
}
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 4);
return true;
}
}
}

View file

@ -0,0 +1,699 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.CaveHouseBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria.GameContent.Generation;
using Terraria.ID;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class CaveHouseBiome : MicroBiome
{
private const int VERTICAL_EXIT_WIDTH = 3;
private static readonly bool[] _blacklistedTiles = TileID.Sets.Factory.CreateBoolSet(true, 225, 41, 43, 44, 226, 203, 112, 25, 151);
private int _sharpenerCount;
private int _extractinatorCount;
private Microsoft.Xna.Framework.Rectangle GetRoom(Point origin)
{
Point result1;
bool flag1 = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Left(25), (GenCondition) new Conditions.IsSolid()), out result1);
Point result2;
int num1 = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Right(25), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0;
if (!flag1)
result1 = new Point(origin.X - 25, origin.Y);
if (num1 == 0)
result2 = new Point(origin.X + 25, origin.Y);
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(origin.X, origin.Y, 0, 0);
if (origin.X - result1.X > result2.X - origin.X)
{
rectangle.X = result1.X;
rectangle.Width = Utils.Clamp<int>(result2.X - result1.X, 15, 30);
}
else
{
rectangle.Width = Utils.Clamp<int>(result2.X - result1.X, 15, 30);
rectangle.X = result2.X - rectangle.Width;
}
Point result3;
bool flag2 = WorldUtils.Find(result1, Searches.Chain((GenSearch) new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result3);
Point result4;
int num2 = WorldUtils.Find(result2, Searches.Chain((GenSearch) new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result4) ? 1 : 0;
if (!flag2)
result3 = new Point(origin.X, origin.Y - 10);
if (num2 == 0)
result4 = new Point(origin.X, origin.Y - 10);
rectangle.Height = Utils.Clamp<int>(Math.Max(origin.Y - result3.Y, origin.Y - result4.Y), 8, 12);
rectangle.Y -= rectangle.Height;
return rectangle;
}
private float RoomSolidPrecentage(Microsoft.Xna.Framework.Rectangle room)
{
float num = (float) (room.Width * room.Height);
Ref<int> count = new Ref<int>(0);
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Count(count)));
return (float) count.Value / num;
}
private bool FindVerticalExit(Microsoft.Xna.Framework.Rectangle wall, bool isUp, out int exitX)
{
Point result;
int num = WorldUtils.Find(new Point(wall.X + wall.Width - 3, wall.Y + (isUp ? -5 : 0)), Searches.Chain((GenSearch) new Searches.Left(wall.Width - 3), new Conditions.IsSolid().Not().AreaOr(3, 5)), out result) ? 1 : 0;
exitX = result.X;
return num != 0;
}
private bool FindSideExit(Microsoft.Xna.Framework.Rectangle wall, bool isLeft, out int exitY)
{
Point result;
int num = WorldUtils.Find(new Point(wall.X + (isLeft ? -4 : 0), wall.Y + wall.Height - 3), Searches.Chain((GenSearch) new Searches.Up(wall.Height - 3), new Conditions.IsSolid().Not().AreaOr(4, 3)), out result) ? 1 : 0;
exitY = result.Y;
return num != 0;
}
private int SortBiomeResults(
Tuple<CaveHouseBiome.BuildData, int> item1,
Tuple<CaveHouseBiome.BuildData, int> item2)
{
return item2.Item2.CompareTo(item1.Item2);
}
public override bool Place(Point origin, StructureMap structures)
{
Point result1;
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(200), (GenCondition) new Conditions.IsSolid()), out result1) || result1 == origin)
return false;
Microsoft.Xna.Framework.Rectangle room1 = this.GetRoom(result1);
Microsoft.Xna.Framework.Rectangle room2 = this.GetRoom(new Point(room1.Center.X, room1.Y + 1));
Microsoft.Xna.Framework.Rectangle room3 = this.GetRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10));
room3.Y = room1.Y + room1.Height - 1;
float num1 = this.RoomSolidPrecentage(room2);
float num2 = this.RoomSolidPrecentage(room3);
room1.Y += 3;
room2.Y += 3;
room3.Y += 3;
List<Microsoft.Xna.Framework.Rectangle> rectangleList1 = new List<Microsoft.Xna.Framework.Rectangle>();
if ((double) GenBase._random.NextFloat() > (double) num1 + 0.200000002980232)
rectangleList1.Add(room2);
else
room2 = room1;
rectangleList1.Add(room1);
if ((double) GenBase._random.NextFloat() > (double) num2 + 0.200000002980232)
rectangleList1.Add(room3);
else
room3 = room1;
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
{
if (rectangle.Y + rectangle.Height > Main.maxTilesY - 220)
return false;
}
Dictionary<ushort, int> resultsOutput = new Dictionary<ushort, int>();
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
WorldUtils.Gen(new Point(rectangle.X - 10, rectangle.Y - 10), (GenShape) new Shapes.Rectangle(rectangle.Width + 20, rectangle.Height + 20), (GenAction) new Actions.TileScanner(new ushort[12]
{
(ushort) 0,
(ushort) 59,
(ushort) 147,
(ushort) 1,
(ushort) 161,
(ushort) 53,
(ushort) 396,
(ushort) 397,
(ushort) 368,
(ushort) 367,
(ushort) 60,
(ushort) 70
}).Output(resultsOutput));
List<Tuple<CaveHouseBiome.BuildData, int>> tupleList1 = new List<Tuple<CaveHouseBiome.BuildData, int>>();
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Default, resultsOutput[(ushort) 0] + resultsOutput[(ushort) 1]));
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Jungle, resultsOutput[(ushort) 59] + resultsOutput[(ushort) 60] * 10));
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Mushroom, resultsOutput[(ushort) 59] + resultsOutput[(ushort) 70] * 10));
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Snow, resultsOutput[(ushort) 147] + resultsOutput[(ushort) 161]));
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Desert, resultsOutput[(ushort) 397] + resultsOutput[(ushort) 396] + resultsOutput[(ushort) 53]));
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Granite, resultsOutput[(ushort) 368]));
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Marble, resultsOutput[(ushort) 367]));
tupleList1.Sort(new Comparison<Tuple<CaveHouseBiome.BuildData, int>>(this.SortBiomeResults));
CaveHouseBiome.BuildData buildData = tupleList1[0].Item1;
foreach (Microsoft.Xna.Framework.Rectangle area in rectangleList1)
{
if (buildData != CaveHouseBiome.BuildData.Granite)
{
if (WorldUtils.Find(new Point(area.X - 2, area.Y - 2), Searches.Chain(new Searches.Rectangle(area.Width + 4, area.Height + 4).RequireAll(false), (GenCondition) new Conditions.HasLava()), out Point _))
return false;
}
if (!structures.CanPlace(area, CaveHouseBiome._blacklistedTiles, 5))
return false;
}
int val1_1 = room1.X;
int val1_2 = room1.X + room1.Width - 1;
List<Microsoft.Xna.Framework.Rectangle> rectangleList2 = new List<Microsoft.Xna.Framework.Rectangle>();
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
{
val1_1 = Math.Min(val1_1, rectangle.X);
val1_2 = Math.Max(val1_2, rectangle.X + rectangle.Width - 1);
}
int num3 = 6;
while (num3 > 4 && (val1_2 - val1_1) % num3 != 0)
--num3;
for (int x = val1_1; x <= val1_2; x += num3)
{
for (int index1 = 0; index1 < rectangleList1.Count; ++index1)
{
Microsoft.Xna.Framework.Rectangle rectangle = rectangleList1[index1];
if (x >= rectangle.X && x < rectangle.X + rectangle.Width)
{
int y = rectangle.Y + rectangle.Height;
int num4 = 50;
for (int index2 = index1 + 1; index2 < rectangleList1.Count; ++index2)
{
if (x >= rectangleList1[index2].X && x < rectangleList1[index2].X + rectangleList1[index2].Width)
num4 = Math.Min(num4, rectangleList1[index2].Y - y);
}
if (num4 > 0)
{
Point result2;
bool flag = WorldUtils.Find(new Point(x, y), Searches.Chain((GenSearch) new Searches.Down(num4), (GenCondition) new Conditions.IsSolid()), out result2);
if (num4 < 50)
{
flag = true;
result2 = new Point(x, y + num4);
}
if (flag)
rectangleList2.Add(new Microsoft.Xna.Framework.Rectangle(x, y, 1, result2.Y - y));
}
}
}
}
List<Point> pointList1 = new List<Point>();
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
{
int exitY;
if (this.FindSideExit(new Microsoft.Xna.Framework.Rectangle(rectangle.X + rectangle.Width, rectangle.Y + 1, 1, rectangle.Height - 2), false, out exitY))
pointList1.Add(new Point(rectangle.X + rectangle.Width - 1, exitY));
if (this.FindSideExit(new Microsoft.Xna.Framework.Rectangle(rectangle.X, rectangle.Y + 1, 1, rectangle.Height - 2), true, out exitY))
pointList1.Add(new Point(rectangle.X, exitY));
}
List<Tuple<Point, Point>> tupleList2 = new List<Tuple<Point, Point>>();
for (int index = 1; index < rectangleList1.Count; ++index)
{
Microsoft.Xna.Framework.Rectangle rectangle1 = rectangleList1[index];
Microsoft.Xna.Framework.Rectangle rectangle2 = rectangleList1[index - 1];
if (rectangle2.X - rectangle1.X > rectangle1.X + rectangle1.Width - (rectangle2.X + rectangle2.Width))
tupleList2.Add(new Tuple<Point, Point>(new Point(rectangle1.X + rectangle1.Width - 1, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Width - rectangle1.Height + 1, rectangle1.Y + rectangle1.Height - 1)));
else
tupleList2.Add(new Tuple<Point, Point>(new Point(rectangle1.X, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Height - 1, rectangle1.Y + rectangle1.Height - 1)));
}
List<Point> pointList2 = new List<Point>();
int exitX;
if (this.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(room2.X + 2, room2.Y, room2.Width - 4, 1), true, out exitX))
pointList2.Add(new Point(exitX, room2.Y));
if (this.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(room3.X + 2, room3.Y + room3.Height - 1, room3.Width - 4, 1), false, out exitX))
pointList2.Add(new Point(exitX, room3.Y + room3.Height - 1));
foreach (Microsoft.Xna.Framework.Rectangle area in rectangleList1)
{
WorldUtils.Gen(new Point(area.X, area.Y), (GenShape) new Shapes.Rectangle(area.Width, area.Height), Actions.Chain((GenAction) new Actions.SetTile(buildData.Tile), (GenAction) new Actions.SetFrames(true)));
WorldUtils.Gen(new Point(area.X + 1, area.Y + 1), (GenShape) new Shapes.Rectangle(area.Width - 2, area.Height - 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall(buildData.Wall)));
structures.AddStructure(area, 8);
}
foreach (Tuple<Point, Point> tuple in tupleList2)
{
Point origin1 = tuple.Item1;
Point point = tuple.Item2;
int num5 = point.X > origin1.X ? 1 : -1;
ShapeData data = new ShapeData();
for (int y = 0; y < point.Y - origin1.Y; ++y)
data.Add(num5 * (y + 1), y);
WorldUtils.Gen(origin1, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.PlaceTile((ushort) 19, buildData.PlatformStyle), (GenAction) new Actions.SetSlope(num5 == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true)));
WorldUtils.Gen(new Point(origin1.X + (num5 == 1 ? 1 : -4), origin1.Y - 1), (GenShape) new Shapes.Rectangle(4, 1), Actions.Chain((GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall(buildData.Wall), (GenAction) new Actions.PlaceTile((ushort) 19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true)));
}
foreach (Point origin2 in pointList1)
{
WorldUtils.Gen(origin2, (GenShape) new Shapes.Rectangle(1, 3), (GenAction) new Actions.ClearTile(true));
WorldGen.PlaceTile(origin2.X, origin2.Y, 10, true, true, style: buildData.DoorStyle);
}
foreach (Point origin3 in pointList2)
{
Shapes.Rectangle rectangle = new Shapes.Rectangle(3, 1);
GenAction action = Actions.Chain((GenAction) new Actions.ClearMetadata(), (GenAction) new Actions.PlaceTile((ushort) 19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true));
WorldUtils.Gen(origin3, (GenShape) rectangle, action);
}
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList2)
{
if (rectangle.Height > 1 && GenBase._tiles[rectangle.X, rectangle.Y - 1].type != (ushort) 19)
{
WorldUtils.Gen(new Point(rectangle.X, rectangle.Y), (GenShape) new Shapes.Rectangle(rectangle.Width, rectangle.Height), Actions.Chain((GenAction) new Actions.SetTile((ushort) 124), (GenAction) new Actions.SetFrames(true)));
Tile tile = GenBase._tiles[rectangle.X, rectangle.Y + rectangle.Height];
tile.slope((byte) 0);
tile.halfBrick(false);
}
}
Point[] pointArray = new Point[7]
{
new Point(14, buildData.TableStyle),
new Point(16, 0),
new Point(18, buildData.WorkbenchStyle),
new Point(86, 0),
new Point(87, buildData.PianoStyle),
new Point(94, 0),
new Point(101, buildData.BookcaseStyle)
};
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
{
int num6 = rectangle.Width / 8;
int num7 = rectangle.Width / (num6 + 1);
int num8 = GenBase._random.Next(2);
for (int index3 = 0; index3 < num6; ++index3)
{
int num9 = (index3 + 1) * num7 + rectangle.X;
switch (index3 + num8 % 2)
{
case 0:
int num10 = rectangle.Y + Math.Min(rectangle.Height / 2, rectangle.Height - 5);
Vector2 vector2 = WorldGen.randHousePicture();
int x = (int) vector2.X;
int y = (int) vector2.Y;
if (!WorldGen.nearPicture(num9, num10))
{
WorldGen.PlaceTile(num9, num10, x, true, style: y);
break;
}
break;
case 1:
int j = rectangle.Y + 1;
WorldGen.PlaceTile(num9, j, 34, true, style: GenBase._random.Next(6));
for (int index4 = -1; index4 < 2; ++index4)
{
for (int index5 = 0; index5 < 3; ++index5)
GenBase._tiles[index4 + num9, index5 + j].frameX += (short) 54;
}
break;
}
}
int num11 = rectangle.Width / 8 + 3;
WorldGen.SetupStatueList();
for (; num11 > 0; --num11)
{
int num12 = GenBase._random.Next(rectangle.Width - 3) + 1 + rectangle.X;
int num13 = rectangle.Y + rectangle.Height - 2;
switch (GenBase._random.Next(4))
{
case 0:
WorldGen.PlaceSmallPile(num12, num13, GenBase._random.Next(31, 34), 1);
break;
case 1:
WorldGen.PlaceTile(num12, num13, 186, true, style: GenBase._random.Next(22, 26));
break;
case 2:
int index = GenBase._random.Next(2, WorldGen.statueList.Length);
WorldGen.PlaceTile(num12, num13, (int) WorldGen.statueList[index].X, true, style: ((int) WorldGen.statueList[index].Y));
if (WorldGen.StatuesWithTraps.Contains(index))
{
WorldGen.PlaceStatueTrap(num12, num13);
break;
}
break;
case 3:
Point point = Utils.SelectRandom<Point>(GenBase._random, pointArray);
WorldGen.PlaceTile(num12, num13, point.X, true, style: point.Y);
break;
}
}
}
foreach (Microsoft.Xna.Framework.Rectangle room4 in rectangleList1)
buildData.ProcessRoom(room4);
bool flag1 = false;
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
{
int j = rectangle.Height - 1 + rectangle.Y;
int Style = j > (int) Main.worldSurface ? buildData.ChestStyle : 0;
int num14 = 0;
while (num14 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X, j, Style: Style)))
++num14;
if (!flag1)
{
int i = rectangle.X + 2;
while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, Style: Style)))
++i;
if (flag1)
break;
}
else
break;
}
if (!flag1)
{
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
{
int j = rectangle.Y - 1;
int Style = j > (int) Main.worldSurface ? buildData.ChestStyle : 0;
int num15 = 0;
while (num15 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X, j, Style: Style)))
++num15;
if (!flag1)
{
int i = rectangle.X + 2;
while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, Style: Style)))
++i;
if (flag1)
break;
}
else
break;
}
}
if (!flag1)
{
for (int index = 0; index < 1000; ++index)
{
int i = GenBase._random.Next(rectangleList1[0].X - 30, rectangleList1[0].X + 30);
int num16 = GenBase._random.Next(rectangleList1[0].Y - 30, rectangleList1[0].Y + 30);
int num17 = num16 > (int) Main.worldSurface ? buildData.ChestStyle : 0;
int j = num16;
int Style = num17;
if (WorldGen.AddBuriedChest(i, j, Style: Style))
break;
}
}
if (buildData == CaveHouseBiome.BuildData.Jungle && this._sharpenerCount < GenBase._random.Next(2, 5))
{
bool flag2 = false;
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
{
int j = rectangle.Height - 2 + rectangle.Y;
for (int index = 0; index < 10; ++index)
{
int i = GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X;
WorldGen.PlaceTile(i, j, 377, true, true);
if (flag2 = GenBase._tiles[i, j].active() && GenBase._tiles[i, j].type == (ushort) 377)
break;
}
if (!flag2)
{
int i = rectangle.X + 2;
while (i <= rectangle.X + rectangle.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 377, true, true)))
++i;
if (flag2)
break;
}
else
break;
}
if (flag2)
++this._sharpenerCount;
}
if (buildData == CaveHouseBiome.BuildData.Desert && this._extractinatorCount < GenBase._random.Next(2, 5))
{
bool flag3 = false;
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
{
int j = rectangle.Height - 2 + rectangle.Y;
for (int index = 0; index < 10; ++index)
{
int i = GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X;
WorldGen.PlaceTile(i, j, 219, true, true);
if (flag3 = GenBase._tiles[i, j].active() && GenBase._tiles[i, j].type == (ushort) 219)
break;
}
if (!flag3)
{
int i = rectangle.X + 2;
while (i <= rectangle.X + rectangle.Width - 2 && !(flag3 = WorldGen.PlaceTile(i, j, 219, true, true)))
++i;
if (flag3)
break;
}
else
break;
}
if (flag3)
++this._extractinatorCount;
}
return true;
}
public override void Reset()
{
this._sharpenerCount = 0;
this._extractinatorCount = 0;
}
internal static void AgeDefaultRoom(Microsoft.Xna.Framework.Rectangle room)
{
for (int index = 0; index < room.Width * room.Height / 16; ++index)
WorldUtils.Gen(new Point(GenBase._random.Next(1, room.Width - 1) + room.X, GenBase._random.Next(1, room.Height - 1) + room.Y), (GenShape) new Shapes.Rectangle(2, 2), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.Blotches(chance: 2.0), (GenAction) new Modifiers.IsEmpty(), (GenAction) new Actions.SetTile((ushort) 51, true)));
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(), (GenAction) new Modifiers.OnlyWalls(new byte[1]
{
CaveHouseBiome.BuildData.Default.Wall
}), (double) room.Y > Main.worldSurface ? (GenAction) new Actions.ClearWall(true) : (GenAction) new Actions.PlaceWall((byte) 2)));
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.949999988079071), (GenAction) new Modifiers.OnlyTiles(new ushort[3]
{
(ushort) 30,
(ushort) 321,
(ushort) 158
}), (GenAction) new Actions.ClearTile(true)));
}
internal static void AgeSnowRoom(Microsoft.Xna.Framework.Rectangle room)
{
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.Blotches(chance: 0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
CaveHouseBiome.BuildData.Snow.Tile
}), (GenAction) new Actions.SetTile((ushort) 161, true), (GenAction) new Modifiers.Dither(0.8), (GenAction) new Actions.SetTile((ushort) 147, true)));
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 161
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 161
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(chance: 0.8), (double) room.Y > Main.worldSurface ? (GenAction) new Actions.ClearWall(true) : (GenAction) new Actions.PlaceWall((byte) 40)));
}
internal static void AgeDesertRoom(Microsoft.Xna.Framework.Rectangle room)
{
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.Blotches(chance: 0.200000002980232), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
CaveHouseBiome.BuildData.Desert.Tile
}), (GenAction) new Actions.SetTile((ushort) 396, true), (GenAction) new Modifiers.Dither(), (GenAction) new Actions.SetTile((ushort) 397, true)));
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[2]
{
(ushort) 397,
(ushort) 396
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[2]
{
(ushort) 397,
(ushort) 396
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.Blotches(), (GenAction) new Modifiers.OnlyWalls(new byte[1]
{
CaveHouseBiome.BuildData.Desert.Wall
}), (GenAction) new Actions.PlaceWall((byte) 216)));
}
internal static void AgeGraniteRoom(Microsoft.Xna.Framework.Rectangle room)
{
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.Blotches(chance: 0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
CaveHouseBiome.BuildData.Granite.Tile
}), (GenAction) new Actions.SetTile((ushort) 368, true)));
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 368
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 368
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(), (GenAction) new Actions.PlaceWall((byte) 180)));
}
internal static void AgeMarbleRoom(Microsoft.Xna.Framework.Rectangle room)
{
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.Blotches(chance: 0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
CaveHouseBiome.BuildData.Marble.Tile
}), (GenAction) new Actions.SetTile((ushort) 367, true)));
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 367
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 367
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(), (GenAction) new Actions.PlaceWall((byte) 178)));
}
internal static void AgeMushroomRoom(Microsoft.Xna.Framework.Rectangle room)
{
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.699999988079071), (GenAction) new Modifiers.Blotches(chance: 0.5), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
CaveHouseBiome.BuildData.Mushroom.Tile
}), (GenAction) new Actions.SetTile((ushort) 70, true)));
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 70
}), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new Actions.SetTile((ushort) 71)));
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 70
}), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new Actions.SetTile((ushort) 71)));
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(), (GenAction) new Actions.ClearWall()));
}
internal static void AgeJungleRoom(Microsoft.Xna.Framework.Rectangle room)
{
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.Blotches(chance: 0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
CaveHouseBiome.BuildData.Jungle.Tile
}), (GenAction) new Actions.SetTile((ushort) 60, true), (GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Actions.SetTile((ushort) 59, true)));
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 60
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, room.Height, 62)));
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 60
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, room.Height, 62)));
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(), (GenAction) new Actions.PlaceWall((byte) 64)));
}
private class BuildData
{
public static CaveHouseBiome.BuildData Snow = CaveHouseBiome.BuildData.CreateSnowData();
public static CaveHouseBiome.BuildData Jungle = CaveHouseBiome.BuildData.CreateJungleData();
public static CaveHouseBiome.BuildData Default = CaveHouseBiome.BuildData.CreateDefaultData();
public static CaveHouseBiome.BuildData Granite = CaveHouseBiome.BuildData.CreateGraniteData();
public static CaveHouseBiome.BuildData Marble = CaveHouseBiome.BuildData.CreateMarbleData();
public static CaveHouseBiome.BuildData Mushroom = CaveHouseBiome.BuildData.CreateMushroomData();
public static CaveHouseBiome.BuildData Desert = CaveHouseBiome.BuildData.CreateDesertData();
public ushort Tile;
public byte Wall;
public int PlatformStyle;
public int DoorStyle;
public int TableStyle;
public int WorkbenchStyle;
public int PianoStyle;
public int BookcaseStyle;
public int ChairStyle;
public int ChestStyle;
public CaveHouseBiome.BuildData.ProcessRoomMethod ProcessRoom;
public static CaveHouseBiome.BuildData CreateSnowData() => new CaveHouseBiome.BuildData()
{
Tile = 321,
Wall = 149,
DoorStyle = 30,
PlatformStyle = 19,
TableStyle = 28,
WorkbenchStyle = 23,
PianoStyle = 23,
BookcaseStyle = 25,
ChairStyle = 30,
ChestStyle = 11,
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeSnowRoom)
};
public static CaveHouseBiome.BuildData CreateDesertData() => new CaveHouseBiome.BuildData()
{
Tile = 396,
Wall = 187,
PlatformStyle = 0,
DoorStyle = 0,
TableStyle = 0,
WorkbenchStyle = 0,
PianoStyle = 0,
BookcaseStyle = 0,
ChairStyle = 0,
ChestStyle = 1,
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeDesertRoom)
};
public static CaveHouseBiome.BuildData CreateJungleData() => new CaveHouseBiome.BuildData()
{
Tile = 158,
Wall = 42,
PlatformStyle = 2,
DoorStyle = 2,
TableStyle = 2,
WorkbenchStyle = 2,
PianoStyle = 2,
BookcaseStyle = 12,
ChairStyle = 3,
ChestStyle = 8,
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeJungleRoom)
};
public static CaveHouseBiome.BuildData CreateGraniteData() => new CaveHouseBiome.BuildData()
{
Tile = 369,
Wall = 181,
PlatformStyle = 28,
DoorStyle = 34,
TableStyle = 33,
WorkbenchStyle = 29,
PianoStyle = 28,
BookcaseStyle = 30,
ChairStyle = 34,
ChestStyle = 50,
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeGraniteRoom)
};
public static CaveHouseBiome.BuildData CreateMarbleData() => new CaveHouseBiome.BuildData()
{
Tile = 357,
Wall = 179,
PlatformStyle = 29,
DoorStyle = 35,
TableStyle = 34,
WorkbenchStyle = 30,
PianoStyle = 29,
BookcaseStyle = 31,
ChairStyle = 35,
ChestStyle = 51,
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeMarbleRoom)
};
public static CaveHouseBiome.BuildData CreateMushroomData() => new CaveHouseBiome.BuildData()
{
Tile = 190,
Wall = 74,
PlatformStyle = 18,
DoorStyle = 6,
TableStyle = 27,
WorkbenchStyle = 7,
PianoStyle = 22,
BookcaseStyle = 24,
ChairStyle = 9,
ChestStyle = 32,
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeMushroomRoom)
};
public static CaveHouseBiome.BuildData CreateDefaultData() => new CaveHouseBiome.BuildData()
{
Tile = 30,
Wall = 27,
PlatformStyle = 0,
DoorStyle = 0,
TableStyle = 0,
WorkbenchStyle = 0,
PianoStyle = 0,
BookcaseStyle = 0,
ChairStyle = 0,
ChestStyle = 1,
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeDefaultRoom)
};
public delegate void ProcessRoomMethod(Microsoft.Xna.Framework.Rectangle room);
}
}
}

View file

@ -0,0 +1,55 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.CorruptionPitBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Terraria.ID;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class CorruptionPitBiome : MicroBiome
{
public static bool[] ValidTiles = TileID.Sets.Factory.CreateBoolSet(true, 21, 31, 26);
public override bool Place(Point origin, StructureMap structures)
{
if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == (byte) 3)
return false;
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(100), (GenCondition) new Conditions.IsSolid()), out origin))
return false;
if (!WorldUtils.Find(new Point(origin.X - 4, origin.Y), Searches.Chain((GenSearch) new Searches.Down(5), new Conditions.IsTile(new ushort[1]
{
(ushort) 25
}).AreaAnd(8, 1)), out Point _))
return false;
ShapeData data1 = new ShapeData();
ShapeData shapeData1 = new ShapeData();
ShapeData shapeData2 = new ShapeData();
for (int index = 0; index < 6; ++index)
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(10, 12) + index), Actions.Chain((GenAction) new Modifiers.Offset(0, 5 * index + 5), new Modifiers.Blotches(3).Output(data1)));
for (int index = 0; index < 6; ++index)
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(5, 7) + index), Actions.Chain((GenAction) new Modifiers.Offset(0, 2 * index + 18), new Modifiers.Blotches(3).Output(shapeData1)));
for (int index = 0; index < 6; ++index)
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(4, 6) + index / 2), Actions.Chain((GenAction) new Modifiers.Offset(0, (int) (7.5 * (double) index) - 10), new Modifiers.Blotches(3).Output(shapeData2)));
ShapeData data2 = new ShapeData(shapeData1);
shapeData1.Subtract(shapeData2, origin, origin);
data2.Subtract(shapeData1, origin, origin);
Microsoft.Xna.Framework.Rectangle bounds = ShapeData.GetBounds(origin, data1, shapeData2);
if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2))
return false;
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.SetTile((ushort) 25, true), (GenAction) new Actions.PlaceWall((byte) 3)));
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData1), (GenAction) new Actions.SetTile((ushort) 0, true));
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData2), (GenAction) new Actions.ClearTile(true));
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData1), Actions.Chain((GenAction) new Modifiers.IsTouchingAir(true), (GenAction) new Modifiers.NotTouching(false, new ushort[1]
{
(ushort) 25
}), (GenAction) new Actions.SetTile((ushort) 23, true)));
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data2), (GenAction) new Actions.PlaceWall((byte) 69));
structures.AddStructure(bounds, 2);
return true;
}
}
}

View file

@ -0,0 +1,460 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.DesertBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class DesertBiome : MicroBiome
{
private void PlaceSand(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
{
int num1 = (int) ((double) scale.X * (double) clusters.Width);
int num2 = (int) ((double) scale.Y * (double) clusters.Height);
int num3 = 5;
int val1 = start.Y + (num2 >> 1);
float num4 = 0.0f;
short[] numArray = new short[num1 + num3 * 2];
for (int index = -num3; index < num1 + num3; ++index)
{
for (int y = 150; y < val1; ++y)
{
if (WorldGen.SolidOrSlopedTile(index + start.X, y))
{
num4 += (float) (y - 1);
numArray[index + num3] = (short) (y - 1);
break;
}
}
}
float num5 = num4 / (float) (num1 + num3 * 2);
int num6 = 0;
for (int index1 = -num3; index1 < num1 + num3; ++index1)
{
float num7 = MathHelper.Clamp((float) ((double) Math.Abs((float) (index1 + num3) / (float) (num1 + num3 * 2)) * 2.0 - 1.0), -1f, 1f);
if (index1 % 3 == 0)
num6 = Utils.Clamp<int>(num6 + GenBase._random.Next(-1, 2), -10, 10);
float num8 = (float) Math.Sqrt(1.0 - (double) num7 * (double) num7 * (double) num7 * (double) num7);
int val2_1 = val1 - (int) ((double) num8 * (double) ((float) val1 - num5)) + num6;
int val2_2 = val1 - (int) ((double) ((float) val1 - num5) * ((double) num8 - 0.150000005960464 / Math.Sqrt(Math.Max(0.01, (double) Math.Abs(8f * num7) - 0.1)) + 0.25));
int num9 = Math.Min(val1, val2_2);
if ((double) Math.Abs(num7) < 0.800000011920929)
{
float num10 = Utils.SmoothStep(0.5f, 0.8f, Math.Abs(num7));
float num11 = num10 * num10 * num10;
int num12 = Math.Min(10 + (int) ((double) num5 - (double) num11 * 20.0) + num6, val2_1);
int num13 = 50;
for (int index2 = num13; (double) index2 < (double) num5; ++index2)
{
int index3 = index1 + start.X;
if (GenBase._tiles[index3, index2].active() && (GenBase._tiles[index3, index2].type == (ushort) 189 || GenBase._tiles[index3, index2].type == (ushort) 196))
num13 = index2 + 5;
}
for (int index4 = num13; index4 < num12; ++index4)
{
int index5 = index1 + start.X;
int index6 = index4;
GenBase._tiles[index5, index6].active(false);
GenBase._tiles[index5, index6].wall = (byte) 0;
}
numArray[index1 + num3] = (short) num12;
}
for (int index7 = val1 - 1; index7 >= val2_1; --index7)
{
int i = index1 + start.X;
int j = index7;
Tile tile1 = GenBase._tiles[i, j];
tile1.liquid = (byte) 0;
Tile tile2 = GenBase._tiles[i, j + 1];
Tile tile3 = GenBase._tiles[i, j + 2];
tile1.type = !WorldGen.SolidTile(tile2) || !WorldGen.SolidTile(tile3) ? (ushort) 397 : (ushort) 53;
if (index7 > val2_1 + 5)
tile1.wall = (byte) 187;
tile1.active(true);
if (tile1.wall != (byte) 187)
tile1.wall = (byte) 0;
if (index7 < num9)
{
if (index7 > val2_1 + 5)
tile1.wall = (byte) 187;
tile1.active(false);
}
WorldGen.SquareWallFrame(i, j);
}
}
}
private void PlaceClusters(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
{
int num1 = (int) ((double) scale.X * (double) clusters.Width);
int num2 = (int) ((double) scale.Y * (double) clusters.Height);
Vector2 vector2_1 = new Vector2((float) num1, (float) num2);
Vector2 vector2_2 = new Vector2((float) clusters.Width, (float) clusters.Height);
for (int index1 = -20; index1 < num1 + 20; ++index1)
{
for (int index2 = -20; index2 < num2 + 20; ++index2)
{
float num3 = 0.0f;
int num4 = -1;
float num5 = 0.0f;
int x = index1 + start.X;
int y = index2 + start.Y;
Vector2 vector2_3 = new Vector2((float) index1, (float) index2) / vector2_1 * vector2_2;
float num6 = (new Vector2((float) index1, (float) index2) / vector2_1 * 2f - Vector2.One).Length();
for (int index3 = 0; index3 < clusters.Count; ++index3)
{
DesertBiome.Cluster cluster = clusters[index3];
if ((double) Math.Abs(cluster[0].Position.X - vector2_3.X) <= 10.0 && (double) Math.Abs(cluster[0].Position.Y - vector2_3.Y) <= 10.0)
{
float num7 = 0.0f;
foreach (DesertBiome.Hub hub in (List<DesertBiome.Hub>) cluster)
num7 += 1f / Vector2.DistanceSquared(hub.Position, vector2_3);
if ((double) num7 > (double) num3)
{
if ((double) num3 > (double) num5)
num5 = num3;
num3 = num7;
num4 = index3;
}
else if ((double) num7 > (double) num5)
num5 = num7;
}
}
float num8 = num3 + num5;
Tile tile = GenBase._tiles[x, y];
bool flag = (double) num6 >= 0.800000011920929;
if ((double) num8 > 3.5)
{
tile.ClearEverything();
tile.wall = (byte) 187;
tile.liquid = (byte) 0;
if (num4 % 15 == 2)
{
tile.ResetToType((ushort) 404);
tile.wall = (byte) 187;
tile.active(true);
}
Tile.SmoothSlope(x, y);
}
else if ((double) num8 > 1.79999995231628)
{
tile.wall = (byte) 187;
if (!flag || tile.active())
{
tile.ResetToType((ushort) 396);
tile.wall = (byte) 187;
tile.active(true);
Tile.SmoothSlope(x, y);
}
tile.liquid = (byte) 0;
}
else if ((double) num8 > 0.699999988079071 || !flag)
{
if (!flag || tile.active())
{
tile.ResetToType((ushort) 397);
tile.active(true);
Tile.SmoothSlope(x, y);
}
tile.liquid = (byte) 0;
tile.wall = (byte) 216;
}
else if ((double) num8 > 0.25)
{
float num9 = (float) (((double) num8 - 0.25) / 0.449999988079071);
if ((double) GenBase._random.NextFloat() < (double) num9)
{
if (tile.active())
{
tile.ResetToType((ushort) 397);
tile.active(true);
Tile.SmoothSlope(x, y);
tile.wall = (byte) 216;
}
tile.liquid = (byte) 0;
tile.wall = (byte) 187;
}
}
}
}
}
private void AddTileVariance(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
{
int num1 = (int) ((double) scale.X * (double) clusters.Width);
int num2 = (int) ((double) scale.Y * (double) clusters.Height);
for (int index1 = -20; index1 < num1 + 20; ++index1)
{
for (int index2 = -20; index2 < num2 + 20; ++index2)
{
int index3 = index1 + start.X;
int index4 = index2 + start.Y;
Tile tile1 = GenBase._tiles[index3, index4];
Tile tile2 = GenBase._tiles[index3, index4 + 1];
Tile tile3 = GenBase._tiles[index3, index4 + 2];
if (tile1.type == (ushort) 53 && (!WorldGen.SolidTile(tile2) || !WorldGen.SolidTile(tile3)))
tile1.type = (ushort) 397;
}
}
for (int index5 = -20; index5 < num1 + 20; ++index5)
{
for (int index6 = -20; index6 < num2 + 20; ++index6)
{
int i = index5 + start.X;
int index7 = index6 + start.Y;
Tile tile = GenBase._tiles[i, index7];
if (tile.active() && tile.type == (ushort) 396)
{
bool flag1 = true;
for (int index8 = -1; index8 >= -3; --index8)
{
if (GenBase._tiles[i, index7 + index8].active())
{
flag1 = false;
break;
}
}
bool flag2 = true;
for (int index9 = 1; index9 <= 3; ++index9)
{
if (GenBase._tiles[i, index7 + index9].active())
{
flag2 = false;
break;
}
}
if (flag1 ^ flag2 && GenBase._random.Next(5) == 0)
WorldGen.PlaceTile(i, index7 + (flag1 ? -1 : 1), 165, true, true);
else if (flag1 && GenBase._random.Next(5) == 0)
WorldGen.PlaceTile(i, index7 - 1, 187, true, true, style: (29 + GenBase._random.Next(6)));
}
}
}
}
private bool FindStart(
Point origin,
Vector2 scale,
int xHubCount,
int yHubCount,
out Point start)
{
start = new Point(0, 0);
int width = (int) ((double) scale.X * (double) xHubCount);
int height = (int) ((double) scale.Y * (double) yHubCount);
origin.X -= width >> 1;
int y = 220;
label_10:
for (int index = -20; index < width + 20; ++index)
{
for (int j = 220; j < Main.maxTilesY; ++j)
{
if (WorldGen.SolidTile(index + origin.X, j))
{
switch (GenBase._tiles[index + origin.X, j].type)
{
case 59:
case 60:
return false;
default:
if (j > y)
{
y = j;
goto label_10;
}
else
goto label_10;
}
}
}
}
WorldGen.UndergroundDesertLocation = new Microsoft.Xna.Framework.Rectangle(origin.X, y, width, height);
start = new Point(origin.X, y);
return true;
}
public override bool Place(Point origin, StructureMap structures)
{
float num1 = (float) Main.maxTilesX / 4200f;
int num2 = (int) (80.0 * (double) num1);
int num3 = (int) (((double) GenBase._random.NextFloat() + 1.0) * 80.0 * (double) num1);
Vector2 scale = new Vector2(4f, 2f);
Point start;
if (!this.FindStart(origin, scale, num2, num3, out start))
return false;
DesertBiome.ClusterGroup clusters = new DesertBiome.ClusterGroup();
clusters.Generate(num2, num3);
this.PlaceSand(clusters, start, scale);
this.PlaceClusters(clusters, start, scale);
this.AddTileVariance(clusters, start, scale);
int num4 = (int) ((double) scale.X * (double) clusters.Width);
int num5 = (int) ((double) scale.Y * (double) clusters.Height);
for (int index1 = -20; index1 < num4 + 20; ++index1)
{
for (int index2 = -20; index2 < num5 + 20; ++index2)
{
if (index1 + start.X > 0 && index1 + start.X < Main.maxTilesX - 1 && index2 + start.Y > 0 && index2 + start.Y < Main.maxTilesY - 1)
{
WorldGen.SquareWallFrame(index1 + start.X, index2 + start.Y);
WorldUtils.TileFrame(index1 + start.X, index2 + start.Y, true);
}
}
}
return true;
}
private struct Hub
{
public Vector2 Position;
public Hub(Vector2 position) => this.Position = position;
public Hub(float x, float y) => this.Position = new Vector2(x, y);
}
private class Cluster : List<DesertBiome.Hub>
{
}
private class ClusterGroup : List<DesertBiome.Cluster>
{
public int Width;
public int Height;
private void SearchForCluster(
bool[,] hubMap,
List<Point> pointCluster,
int x,
int y,
int level = 2)
{
pointCluster.Add(new Point(x, y));
hubMap[x, y] = false;
--level;
if (level == -1)
return;
if (x > 0 && hubMap[x - 1, y])
this.SearchForCluster(hubMap, pointCluster, x - 1, y, level);
if (x < hubMap.GetLength(0) - 1 && hubMap[x + 1, y])
this.SearchForCluster(hubMap, pointCluster, x + 1, y, level);
if (y > 0 && hubMap[x, y - 1])
this.SearchForCluster(hubMap, pointCluster, x, y - 1, level);
if (y >= hubMap.GetLength(1) - 1 || !hubMap[x, y + 1])
return;
this.SearchForCluster(hubMap, pointCluster, x, y + 1, level);
}
private void AttemptClaim(
int x,
int y,
int[,] clusterIndexMap,
List<List<Point>> pointClusters,
int index)
{
int clusterIndex = clusterIndexMap[x, y];
if (clusterIndex == -1 || clusterIndex == index)
return;
int num = WorldGen.genRand.Next(2) == 0 ? -1 : index;
foreach (Point point in pointClusters[clusterIndex])
clusterIndexMap[point.X, point.Y] = num;
}
public void Generate(int width, int height)
{
this.Width = width;
this.Height = height;
this.Clear();
bool[,] hubMap = new bool[width, height];
int num1 = (width >> 1) - 1;
int y1 = (height >> 1) - 1;
int num2 = (num1 + 1) * (num1 + 1);
Point point1 = new Point(num1, y1);
for (int index1 = point1.Y - y1; index1 <= point1.Y + y1; ++index1)
{
float num3 = (float) num1 / (float) y1 * (float) (index1 - point1.Y);
int num4 = Math.Min(num1, (int) Math.Sqrt((double) num2 - (double) num3 * (double) num3));
for (int index2 = point1.X - num4; index2 <= point1.X + num4; ++index2)
hubMap[index2, index1] = WorldGen.genRand.Next(2) == 0;
}
List<List<Point>> pointClusters = new List<List<Point>>();
for (int x = 0; x < hubMap.GetLength(0); ++x)
{
for (int y2 = 0; y2 < hubMap.GetLength(1); ++y2)
{
if (hubMap[x, y2] && WorldGen.genRand.Next(2) == 0)
{
List<Point> pointCluster = new List<Point>();
this.SearchForCluster(hubMap, pointCluster, x, y2);
if (pointCluster.Count > 2)
pointClusters.Add(pointCluster);
}
}
}
int[,] clusterIndexMap = new int[hubMap.GetLength(0), hubMap.GetLength(1)];
for (int index3 = 0; index3 < clusterIndexMap.GetLength(0); ++index3)
{
for (int index4 = 0; index4 < clusterIndexMap.GetLength(1); ++index4)
clusterIndexMap[index3, index4] = -1;
}
for (int index = 0; index < pointClusters.Count; ++index)
{
foreach (Point point2 in pointClusters[index])
clusterIndexMap[point2.X, point2.Y] = index;
}
for (int index5 = 0; index5 < pointClusters.Count; ++index5)
{
foreach (Point point3 in pointClusters[index5])
{
int x = point3.X;
int y3 = point3.Y;
if (clusterIndexMap[x, y3] != -1)
{
int index6 = clusterIndexMap[x, y3];
if (x > 0)
this.AttemptClaim(x - 1, y3, clusterIndexMap, pointClusters, index6);
if (x < clusterIndexMap.GetLength(0) - 1)
this.AttemptClaim(x + 1, y3, clusterIndexMap, pointClusters, index6);
if (y3 > 0)
this.AttemptClaim(x, y3 - 1, clusterIndexMap, pointClusters, index6);
if (y3 < clusterIndexMap.GetLength(1) - 1)
this.AttemptClaim(x, y3 + 1, clusterIndexMap, pointClusters, index6);
}
else
break;
}
}
foreach (List<Point> pointList in pointClusters)
pointList.Clear();
for (int x = 0; x < clusterIndexMap.GetLength(0); ++x)
{
for (int y4 = 0; y4 < clusterIndexMap.GetLength(1); ++y4)
{
if (clusterIndexMap[x, y4] != -1)
pointClusters[clusterIndexMap[x, y4]].Add(new Point(x, y4));
}
}
foreach (List<Point> pointList in pointClusters)
{
if (pointList.Count < 4)
pointList.Clear();
}
foreach (List<Point> pointList in pointClusters)
{
DesertBiome.Cluster cluster = new DesertBiome.Cluster();
if (pointList.Count > 0)
{
foreach (Point point4 in pointList)
cluster.Add(new DesertBiome.Hub((float) point4.X + (float) (((double) WorldGen.genRand.NextFloat() - 0.5) * 0.5), (float) point4.Y + (float) (((double) WorldGen.genRand.NextFloat() - 0.5) * 0.5)));
this.Add(cluster);
}
}
}
}
}
}

View file

@ -0,0 +1,68 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.EnchantedSwordBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using Terraria.GameContent.Generation;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class EnchantedSwordBiome : MicroBiome
{
public override bool Place(Point origin, StructureMap structures)
{
Dictionary<ushort, int> resultsOutput = new Dictionary<ushort, int>();
WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[2]
{
(ushort) 0,
(ushort) 1
}).Output(resultsOutput));
if (resultsOutput[(ushort) 0] + resultsOutput[(ushort) 1] < 1250)
return false;
Point result;
bool flag = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result);
if (WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(origin.Y - result.Y), (GenCondition) new Conditions.IsTile(new ushort[1]
{
(ushort) 53
})), out Point _) || !flag)
return false;
result.Y += 50;
ShapeData data1 = new ShapeData();
ShapeData shapeData = new ShapeData();
Point point1 = new Point(origin.X, origin.Y + 20);
Point point2 = new Point(origin.X, origin.Y + 30);
float xScale = (float) (0.800000011920929 + (double) GenBase._random.NextFloat() * 0.5);
if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(point1.X - (int) (20.0 * (double) xScale), point1.Y - 20, (int) (40.0 * (double) xScale), 40)) || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X, result.Y + 10, 1, origin.Y - result.Y - 9), 2))
return false;
WorldUtils.Gen(point1, (GenShape) new Shapes.Slime(20, xScale, 1f), Actions.Chain((GenAction) new Modifiers.Blotches(chance: 0.4), new Actions.ClearTile(true).Output(data1)));
WorldUtils.Gen(point2, (GenShape) new Shapes.Mound(14, 14), Actions.Chain((GenAction) new Modifiers.Blotches(2, 1, 0.8), (GenAction) new Actions.SetTile((ushort) 0), new Actions.SetFrames(true).Output(shapeData)));
data1.Subtract(shapeData, point1, point2);
WorldUtils.Gen(point1, (GenShape) new ModShapes.InnerOutline(data1), Actions.Chain((GenAction) new Actions.SetTile((ushort) 2), (GenAction) new Actions.SetFrames(true)));
WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Modifiers.RectangleMask(-40, 40, 0, 40), (GenAction) new Modifiers.IsEmpty(), (GenAction) new Actions.SetLiquid()));
WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.PlaceWall((byte) 68), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 2
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, 5)));
ShapeData data2 = new ShapeData();
WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain((GenAction) new Modifiers.Blotches(chance: 0.2), new Actions.ClearTile().Output(data2), (GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 53
}), new Actions.SetTile((ushort) 397).Output(data2)));
WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new ModShapes.All(data2), (GenAction) new Actions.SetFrames(true));
if (GenBase._random.Next(3) == 0)
WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, true, style: 17);
else
WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, true, style: 15);
WorldUtils.Gen(point2, (GenShape) new ModShapes.All(shapeData), Actions.Chain((GenAction) new Modifiers.Offset(0, -1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 2
}), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new ActionGrass()));
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(point1.X - (int) (20.0 * (double) xScale), point1.Y - 20, (int) (40.0 * (double) xScale), 40), 4);
return true;
}
}
}

View file

@ -0,0 +1,228 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.GraniteBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class GraniteBiome : MicroBiome
{
private const int MAX_MAGMA_ITERATIONS = 300;
private static GraniteBiome.Magma[,] _sourceMagmaMap = new GraniteBiome.Magma[200, 200];
private static GraniteBiome.Magma[,] _targetMagmaMap = new GraniteBiome.Magma[200, 200];
public override bool Place(Point origin, StructureMap structures)
{
if (GenBase._tiles[origin.X, origin.Y].active())
return false;
int length1 = GraniteBiome._sourceMagmaMap.GetLength(0);
int length2 = GraniteBiome._sourceMagmaMap.GetLength(1);
int index1 = length1 / 2;
int index2 = length2 / 2;
origin.X -= index1;
origin.Y -= index2;
for (int index3 = 0; index3 < length1; ++index3)
{
for (int index4 = 0; index4 < length2; ++index4)
{
int i = index3 + origin.X;
int j = index4 + origin.Y;
GraniteBiome._sourceMagmaMap[index3, index4] = GraniteBiome.Magma.CreateEmpty(WorldGen.SolidTile(i, j) ? 4f : 1f);
GraniteBiome._targetMagmaMap[index3, index4] = GraniteBiome._sourceMagmaMap[index3, index4];
}
}
int max1 = index1;
int min1 = index1;
int max2 = index2;
int min2 = index2;
for (int index5 = 0; index5 < 300; ++index5)
{
for (int index6 = max1; index6 <= min1; ++index6)
{
for (int index7 = max2; index7 <= min2; ++index7)
{
GraniteBiome.Magma sourceMagma1 = GraniteBiome._sourceMagmaMap[index6, index7];
if (sourceMagma1.IsActive)
{
float num1 = 0.0f;
Vector2 zero = Vector2.Zero;
for (int index8 = -1; index8 <= 1; ++index8)
{
for (int index9 = -1; index9 <= 1; ++index9)
{
if (index8 != 0 || index9 != 0)
{
Vector2 vector2 = new Vector2((float) index8, (float) index9);
vector2.Normalize();
GraniteBiome.Magma sourceMagma2 = GraniteBiome._sourceMagmaMap[index6 + index8, index7 + index9];
if ((double) sourceMagma1.Pressure > 0.00999999977648258 && !sourceMagma2.IsActive)
{
if (index8 == -1)
max1 = Utils.Clamp<int>(index6 + index8, 1, max1);
else
min1 = Utils.Clamp<int>(index6 + index8, min1, length1 - 2);
if (index9 == -1)
max2 = Utils.Clamp<int>(index7 + index9, 1, max2);
else
min2 = Utils.Clamp<int>(index7 + index9, min2, length2 - 2);
GraniteBiome._targetMagmaMap[index6 + index8, index7 + index9] = sourceMagma2.ToFlow();
}
float pressure = sourceMagma2.Pressure;
num1 += pressure;
zero += pressure * vector2;
}
}
}
float num2 = num1 / 8f;
if ((double) num2 > (double) sourceMagma1.Resistance)
{
float num3 = zero.Length() / 8f;
float pressure = Math.Max(0.0f, (float) ((double) Math.Max(num2 - num3 - sourceMagma1.Pressure, 0.0f) + (double) num3 + (double) sourceMagma1.Pressure * 0.875) - sourceMagma1.Resistance);
GraniteBiome._targetMagmaMap[index6, index7] = GraniteBiome.Magma.CreateFlow(pressure, Math.Max(0.0f, sourceMagma1.Resistance - pressure * 0.02f));
}
}
}
}
if (index5 < 2)
GraniteBiome._targetMagmaMap[index1, index2] = GraniteBiome.Magma.CreateFlow(25f);
Utils.Swap<GraniteBiome.Magma[,]>(ref GraniteBiome._sourceMagmaMap, ref GraniteBiome._targetMagmaMap);
}
bool flag1 = origin.Y + index2 > WorldGen.lavaLine - 30;
bool flag2 = false;
for (int index10 = -50; index10 < 50 && !flag2; ++index10)
{
for (int index11 = -50; index11 < 50 && !flag2; ++index11)
{
if (GenBase._tiles[origin.X + index1 + index10, origin.Y + index2 + index11].active())
{
switch (GenBase._tiles[origin.X + index1 + index10, origin.Y + index2 + index11].type)
{
case 147:
case 161:
case 162:
case 163:
case 200:
flag1 = false;
flag2 = true;
continue;
default:
continue;
}
}
}
}
for (int index12 = max1; index12 <= min1; ++index12)
{
for (int index13 = max2; index13 <= min2; ++index13)
{
GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index12, index13];
if (sourceMagma.IsActive)
{
Tile tile = GenBase._tiles[origin.X + index12, origin.Y + index13];
if ((double) Math.Max(1f - Math.Max(0.0f, (float) (Math.Sin((double) (origin.Y + index13) * 0.400000005960464) * 0.699999988079071 + 1.20000004768372) * (float) (0.200000002980232 + 0.5 / Math.Sqrt((double) Math.Max(0.0f, sourceMagma.Pressure - sourceMagma.Resistance)))), sourceMagma.Pressure / 15f) > 0.349999994039536 + (WorldGen.SolidTile(origin.X + index12, origin.Y + index13) ? 0.0 : 0.5))
{
if (TileID.Sets.Ore[(int) tile.type])
tile.ResetToType(tile.type);
else
tile.ResetToType((ushort) 368);
tile.wall = (byte) 180;
}
else if ((double) sourceMagma.Resistance < 0.00999999977648258)
{
WorldUtils.ClearTile(origin.X + index12, origin.Y + index13);
tile.wall = (byte) 180;
}
if (tile.liquid > (byte) 0 & flag1)
tile.liquidType(1);
}
}
}
List<Point16> point16List = new List<Point16>();
for (int index14 = max1; index14 <= min1; ++index14)
{
for (int index15 = max2; index15 <= min2; ++index15)
{
if (GraniteBiome._sourceMagmaMap[index14, index15].IsActive)
{
int num4 = 0;
int num5 = index14 + origin.X;
int num6 = index15 + origin.Y;
if (WorldGen.SolidTile(num5, num6))
{
for (int index16 = -1; index16 <= 1; ++index16)
{
for (int index17 = -1; index17 <= 1; ++index17)
{
if (WorldGen.SolidTile(num5 + index16, num6 + index17))
++num4;
}
}
if (num4 < 3)
point16List.Add(new Point16(num5, num6));
}
}
}
}
foreach (Point16 point16 in point16List)
{
int x = (int) point16.X;
int y = (int) point16.Y;
WorldUtils.ClearTile(x, y, true);
GenBase._tiles[x, y].wall = (byte) 180;
}
point16List.Clear();
for (int index18 = max1; index18 <= min1; ++index18)
{
for (int index19 = max2; index19 <= min2; ++index19)
{
GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index18, index19];
int index20 = index18 + origin.X;
int index21 = index19 + origin.Y;
if (sourceMagma.IsActive)
{
WorldUtils.TileFrame(index20, index21);
WorldGen.SquareWallFrame(index20, index21);
if (GenBase._random.Next(8) == 0 && GenBase._tiles[index20, index21].active())
{
if (!GenBase._tiles[index20, index21 + 1].active())
WorldGen.PlaceTight(index20, index21 + 1);
if (!GenBase._tiles[index20, index21 - 1].active())
WorldGen.PlaceTight(index20, index21 - 1);
}
if (GenBase._random.Next(2) == 0)
Tile.SmoothSlope(index20, index21);
}
}
}
return true;
}
private struct Magma
{
public readonly float Pressure;
public readonly float Resistance;
public readonly bool IsActive;
private Magma(float pressure, float resistance, bool active)
{
this.Pressure = pressure;
this.Resistance = resistance;
this.IsActive = active;
}
public GraniteBiome.Magma ToFlow() => new GraniteBiome.Magma(this.Pressure, this.Resistance, true);
public static GraniteBiome.Magma CreateFlow(float pressure, float resistance = 0.0f) => new GraniteBiome.Magma(pressure, resistance, true);
public static GraniteBiome.Magma CreateEmpty(float resistance = 0.0f) => new GraniteBiome.Magma(0.0f, resistance, false);
}
}
}

View file

@ -0,0 +1,161 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.HiveBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class HiveBiome : MicroBiome
{
public override bool Place(Point origin, StructureMap structures)
{
Ref<int> count1 = new Ref<int>(0);
Ref<int> count2 = new Ref<int>(0);
Ref<int> count3 = new Ref<int>(0);
Ref<int> count4 = new Ref<int>(0);
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(15), Actions.Chain((GenAction) new Actions.Scanner(count3), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.OnlyTiles(new ushort[2]
{
(ushort) 60,
(ushort) 59
}), (GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
{
(ushort) 60
}), (GenAction) new Actions.Scanner(count4)));
if ((double) count2.Value / (double) count1.Value < 0.75 || count4.Value < 2 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100)))
return false;
int x1 = origin.X;
int y1 = origin.Y;
int num1 = 150;
for (int index1 = x1 - num1; index1 < x1 + num1; index1 += 10)
{
if (index1 > 0 && index1 <= Main.maxTilesX - 1)
{
for (int index2 = y1 - num1; index2 < y1 + num1; index2 += 10)
{
if (index2 > 0 && index2 <= Main.maxTilesY - 1 && (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 226 || Main.tile[index1, index2].wall == (byte) 87 || Main.tile[index1, index2].wall == (byte) 3 || Main.tile[index1, index2].wall == (byte) 83))
return false;
}
}
}
int x2 = origin.X;
int y2 = origin.Y;
int index3 = 0;
int[] numArray1 = new int[10];
int[] numArray2 = new int[10];
Vector2 vector2_1 = new Vector2((float) x2, (float) y2);
Vector2 vector2_2 = vector2_1;
int num2 = WorldGen.genRand.Next(2, 5);
for (int index4 = 0; index4 < num2; ++index4)
{
int num3 = WorldGen.genRand.Next(2, 5);
for (int index5 = 0; index5 < num3; ++index5)
vector2_2 = WorldGen.Hive((int) vector2_1.X, (int) vector2_1.Y);
vector2_1 = vector2_2;
numArray1[index3] = (int) vector2_1.X;
numArray2[index3] = (int) vector2_1.Y;
++index3;
}
for (int index6 = 0; index6 < index3; ++index6)
{
int index7 = numArray1[index6];
int index8 = numArray2[index6];
bool flag = false;
int num4 = 1;
if (WorldGen.genRand.Next(2) == 0)
num4 = -1;
while (index7 > 10 && index7 < Main.maxTilesX - 10 && index8 > 10 && index8 < Main.maxTilesY - 10 && (!Main.tile[index7, index8].active() || !Main.tile[index7, index8 + 1].active() || !Main.tile[index7 + 1, index8].active() || !Main.tile[index7 + 1, index8 + 1].active()))
{
index7 += num4;
if (Math.Abs(index7 - numArray1[index6]) > 50)
{
flag = true;
break;
}
}
if (!flag)
{
int i = index7 + num4;
for (int index9 = i - 1; index9 <= i + 2; ++index9)
{
for (int index10 = index8 - 1; index10 <= index8 + 2; ++index10)
{
if (index9 < 10 || index9 > Main.maxTilesX - 10)
flag = true;
else if (Main.tile[index9, index10].active() && Main.tile[index9, index10].type != (ushort) 225)
{
flag = true;
break;
}
}
}
if (!flag)
{
for (int index11 = i - 1; index11 <= i + 2; ++index11)
{
for (int index12 = index8 - 1; index12 <= index8 + 2; ++index12)
{
if (index11 >= i && index11 <= i + 1 && index12 >= index8 && index12 <= index8 + 1)
{
Main.tile[index11, index12].active(false);
Main.tile[index11, index12].liquid = byte.MaxValue;
Main.tile[index11, index12].honey(true);
}
else
{
Main.tile[index11, index12].active(true);
Main.tile[index11, index12].type = (ushort) 225;
}
}
}
int num5 = num4 * -1;
int j = index8 + 1;
int num6 = 0;
while ((num6 < 4 || WorldGen.SolidTile(i, j)) && i > 10 && i < Main.maxTilesX - 10)
{
++num6;
i += num5;
if (WorldGen.SolidTile(i, j))
{
WorldGen.PoundTile(i, j);
if (!Main.tile[i, j + 1].active())
{
Main.tile[i, j + 1].active(true);
Main.tile[i, j + 1].type = (ushort) 225;
}
}
}
}
}
}
WorldGen.larvaX[WorldGen.numLarva] = Utils.Clamp<int>((int) vector2_1.X, 5, Main.maxTilesX - 5);
WorldGen.larvaY[WorldGen.numLarva] = Utils.Clamp<int>((int) vector2_1.Y, 5, Main.maxTilesY - 5);
++WorldGen.numLarva;
int x3 = (int) vector2_1.X;
int y3 = (int) vector2_1.Y;
for (int index13 = x3 - 1; index13 <= x3 + 1 && index13 > 0 && index13 < Main.maxTilesX; ++index13)
{
for (int index14 = y3 - 2; index14 <= y3 + 1 && index14 > 0 && index14 < Main.maxTilesY; ++index14)
{
if (index14 != y3 + 1)
{
Main.tile[index13, index14].active(false);
}
else
{
Main.tile[index13, index14].active(true);
Main.tile[index13, index14].type = (ushort) 225;
Main.tile[index13, index14].slope((byte) 0);
Main.tile[index13, index14].halfBrick(false);
}
}
}
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5);
return true;
}
}
}

View file

@ -0,0 +1,34 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.HoneyPatchBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class HoneyPatchBiome : MicroBiome
{
public override bool Place(Point origin, StructureMap structures)
{
if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y))
return false;
Point result;
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out result))
return false;
result.Y += 2;
Ref<int> count = new Ref<int>(0);
WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count)));
if (count.Value < 20 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16)))
return false;
WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.RadialDither(0.0f, 10f), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.SetTile((ushort) 229, true)));
ShapeData data = new ShapeData();
WorldUtils.Gen(result, (GenShape) new Shapes.Circle(4, 3), Actions.Chain((GenAction) new Modifiers.Blotches(), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.ClearTile(true), new Modifiers.RectangleMask(-6, 6, 0, 3).Output(data), (GenAction) new Actions.SetLiquid(2)));
WorldUtils.Gen(new Point(result.X, result.Y + 1), (GenShape) new ModShapes.InnerOutline(data), Actions.Chain((GenAction) new Modifiers.IsEmpty(), (GenAction) new Modifiers.RectangleMask(-6, 6, 1, 3), (GenAction) new Actions.SetTile((ushort) 59, true)));
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16));
return true;
}
}
}

View file

@ -0,0 +1,92 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.MahoganyTreeBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria.GameContent.Generation;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class MahoganyTreeBiome : MicroBiome
{
public override bool Place(Point origin, StructureMap structures)
{
Point result1;
if (!WorldUtils.Find(new Point(origin.X - 3, origin.Y), Searches.Chain((GenSearch) new Searches.Down(200), new Conditions.IsSolid().AreaAnd(6, 1)), out result1))
return false;
Point result2;
if (!WorldUtils.Find(new Point(result1.X, result1.Y - 5), Searches.Chain((GenSearch) new Searches.Up(120), new Conditions.IsSolid().AreaOr(6, 1)), out result2) || result1.Y - 5 - result2.Y > 60 || result1.Y - result2.Y < 30 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(result1.X - 30, result1.Y - 60, 60, 90)))
return false;
Dictionary<ushort, int> resultsOutput = new Dictionary<ushort, int>();
WorldUtils.Gen(new Point(result1.X - 25, result1.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[4]
{
(ushort) 0,
(ushort) 59,
(ushort) 147,
(ushort) 1
}).Output(resultsOutput));
int num1 = resultsOutput[(ushort) 0] + resultsOutput[(ushort) 1];
int num2 = resultsOutput[(ushort) 59];
if (resultsOutput[(ushort) 147] > num2 || num1 > num2 || num2 < 50)
return false;
int num3 = (result1.Y - result2.Y - 9) / 5;
int num4 = num3 * 5;
int num5 = 0;
double num6 = GenBase._random.NextDouble() + 1.0;
double num7 = GenBase._random.NextDouble() + 2.0;
if (GenBase._random.Next(2) == 0)
num7 = -num7;
for (int index = 0; index < num3; ++index)
{
int num8 = (int) (Math.Sin((double) (index + 1) / 12.0 * num6 * 3.14159274101257) * num7);
int num9 = num8 < num5 ? num8 - num5 : 0;
WorldUtils.Gen(new Point(result1.X + num5 + num9, result1.Y - (index + 1) * 5), (GenShape) new Shapes.Rectangle(6 + Math.Abs(num8 - num5), 7), Actions.Chain((GenAction) new Actions.RemoveWall(), (GenAction) new Actions.SetTile((ushort) 383), (GenAction) new Actions.SetFrames()));
WorldUtils.Gen(new Point(result1.X + num5 + num9 + 2, result1.Y - (index + 1) * 5), (GenShape) new Shapes.Rectangle(2 + Math.Abs(num8 - num5), 5), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall((byte) 78)));
WorldUtils.Gen(new Point(result1.X + num5 + 2, result1.Y - index * 5), (GenShape) new Shapes.Rectangle(2, 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall((byte) 78)));
num5 = num8;
}
int num10 = 6;
if (num7 < 0.0)
num10 = 0;
List<Point> endpoints = new List<Point>();
for (int index = 0; index < 2; ++index)
{
double num11 = ((double) index + 1.0) / 3.0;
int num12 = num10 + (int) (Math.Sin((double) num3 * num11 / 12.0 * num6 * 3.14159274101257) * num7);
double angle = GenBase._random.NextDouble() * 0.785398185253143 - 0.785398185253143 - 0.200000002980232;
if (num10 == 0)
angle -= 1.57079637050629;
WorldUtils.Gen(new Point(result1.X + num12, result1.Y - (int) ((double) (num3 * 5) * num11)), (GenShape) new ShapeBranch(angle, (double) GenBase._random.Next(12, 16)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort) 383), (GenAction) new Actions.SetFrames(true)));
num10 = 6 - num10;
}
int num13 = (int) (Math.Sin((double) num3 / 12.0 * num6 * 3.14159274101257) * num7);
WorldUtils.Gen(new Point(result1.X + 6 + num13, result1.Y - num4), (GenShape) new ShapeBranch(-0.685398185253143, (double) GenBase._random.Next(16, 22)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort) 383), (GenAction) new Actions.SetFrames(true)));
WorldUtils.Gen(new Point(result1.X + num13, result1.Y - num4), (GenShape) new ShapeBranch(-2.45619449615479, (double) GenBase._random.Next(16, 22)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort) 383), (GenAction) new Actions.SetFrames(true)));
foreach (Point origin1 in endpoints)
{
Shapes.Circle circle = new Shapes.Circle(4);
GenAction action = Actions.Chain((GenAction) new Modifiers.Blotches(4, 2, 0.3), (GenAction) new Modifiers.SkipTiles(new ushort[1]
{
(ushort) 383
}), (GenAction) new Modifiers.SkipWalls(new byte[1]
{
(byte) 78
}), (GenAction) new Actions.SetTile((ushort) 384), (GenAction) new Actions.SetFrames(true));
WorldUtils.Gen(origin1, (GenShape) circle, action);
}
for (int index = 0; index < 4; ++index)
{
float angle = (float) ((double) index / 3.0 * 2.0 + 0.570749998092651);
WorldUtils.Gen(result1, (GenShape) new ShapeRoot(angle, (float) GenBase._random.Next(40, 60)), (GenAction) new Actions.SetTile((ushort) 383, true));
}
WorldGen.AddBuriedChest(result1.X + 3, result1.Y - 1, GenBase._random.Next(4) == 0 ? 0 : WorldGen.GetNextJungleChestItem(), Style: 10);
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(result1.X - 30, result1.Y - 30, 60, 60));
return true;
}
}
}

View file

@ -0,0 +1,193 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.MarbleBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
using Terraria.ID;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class MarbleBiome : MicroBiome
{
private const int SCALE = 3;
private MarbleBiome.Slab[,] _slabs;
private void SmoothSlope(int x, int y)
{
MarbleBiome.Slab slab = this._slabs[x, y];
if (!slab.IsSolid)
return;
int num = this._slabs[x, y - 1].IsSolid ? 1 : 0;
bool isSolid1 = this._slabs[x, y + 1].IsSolid;
bool isSolid2 = this._slabs[x - 1, y].IsSolid;
bool isSolid3 = this._slabs[x + 1, y].IsSolid;
switch ((num != 0 ? 1 : 0) << 3 | (isSolid1 ? 1 : 0) << 2 | (isSolid2 ? 1 : 0) << 1 | (isSolid3 ? 1 : 0))
{
case 4:
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.HalfBrick));
break;
case 5:
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.BottomRightFilled));
break;
case 6:
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.BottomLeftFilled));
break;
case 9:
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.TopRightFilled));
break;
case 10:
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.TopLeftFilled));
break;
default:
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.Solid));
break;
}
}
private void PlaceSlab(MarbleBiome.Slab slab, int originX, int originY, int scale)
{
for (int x = 0; x < scale; ++x)
{
for (int y = 0; y < scale; ++y)
{
Tile tile = GenBase._tiles[originX + x, originY + y];
if (TileID.Sets.Ore[(int) tile.type])
tile.ResetToType(tile.type);
else
tile.ResetToType((ushort) 367);
bool active = slab.State(x, y, scale);
tile.active(active);
if (slab.HasWall)
tile.wall = (byte) 178;
WorldUtils.TileFrame(originX + x, originY + y, true);
WorldGen.SquareWallFrame(originX + x, originY + y);
Tile.SmoothSlope(originX + x, originY + y);
if (WorldGen.SolidTile(originX + x, originY + y - 1) && GenBase._random.Next(4) == 0)
WorldGen.PlaceTight(originX + x, originY + y);
if (WorldGen.SolidTile(originX + x, originY + y) && GenBase._random.Next(4) == 0)
WorldGen.PlaceTight(originX + x, originY + y - 1);
}
}
}
private bool IsGroupSolid(int x, int y, int scale)
{
int num = 0;
for (int index1 = 0; index1 < scale; ++index1)
{
for (int index2 = 0; index2 < scale; ++index2)
{
if (WorldGen.SolidOrSlopedTile(x + index1, y + index2))
++num;
}
}
return num > scale / 4 * 3;
}
public override bool Place(Point origin, StructureMap structures)
{
if (this._slabs == null)
this._slabs = new MarbleBiome.Slab[56, 26];
int num1 = GenBase._random.Next(80, 150) / 3;
int num2 = GenBase._random.Next(40, 60) / 3;
int num3 = (num2 * 3 - GenBase._random.Next(20, 30)) / 3;
origin.X -= num1 * 3 / 2;
origin.Y -= num2 * 3 / 2;
for (int index1 = -1; index1 < num1 + 1; ++index1)
{
float num4 = (float) ((double) (index1 - num1 / 2) / (double) num1 + 0.5);
int num5 = (int) ((0.5 - (double) Math.Abs(num4 - 0.5f)) * 5.0) - 2;
for (int index2 = -1; index2 < num2 + 1; ++index2)
{
bool hasWall = true;
bool flag1 = false;
bool flag2 = this.IsGroupSolid(index1 * 3 + origin.X, index2 * 3 + origin.Y, 3);
int num6 = Math.Abs(index2 - num2 / 2) - num3 / 4 + num5;
if (num6 > 3)
{
flag1 = flag2;
hasWall = false;
}
else if (num6 > 0)
{
flag1 = index2 - num2 / 2 > 0 | flag2;
hasWall = index2 - num2 / 2 < 0 || num6 <= 2;
}
else if (num6 == 0)
flag1 = GenBase._random.Next(2) == 0 && index2 - num2 / 2 > 0 | flag2;
if ((double) Math.Abs(num4 - 0.5f) > 0.349999994039536 + (double) GenBase._random.NextFloat() * 0.100000001490116 && !flag2)
{
hasWall = false;
flag1 = false;
}
this._slabs[index1 + 1, index2 + 1] = MarbleBiome.Slab.Create(flag1 ? new MarbleBiome.SlabState(MarbleBiome.SlabStates.Solid) : new MarbleBiome.SlabState(MarbleBiome.SlabStates.Empty), hasWall);
}
}
for (int index3 = 0; index3 < num1; ++index3)
{
for (int index4 = 0; index4 < num2; ++index4)
this.SmoothSlope(index3 + 1, index4 + 1);
}
int num7 = num1 / 2;
int val1 = num2 / 2;
int num8 = (val1 + 1) * (val1 + 1);
float num9 = (float) ((double) GenBase._random.NextFloat() * 2.0 - 1.0);
float num10 = (float) ((double) GenBase._random.NextFloat() * 2.0 - 1.0);
float num11 = (float) ((double) GenBase._random.NextFloat() * 2.0 - 1.0);
float num12 = 0.0f;
for (int index5 = 0; index5 <= num1; ++index5)
{
float num13 = (float) val1 / (float) num7 * (float) (index5 - num7);
int num14 = Math.Min(val1, (int) Math.Sqrt((double) Math.Max(0.0f, (float) num8 - num13 * num13)));
if (index5 < num1 / 2)
num12 += MathHelper.Lerp(num9, num10, (float) index5 / (float) (num1 / 2));
else
num12 += MathHelper.Lerp(num10, num11, (float) ((double) index5 / (double) (num1 / 2) - 1.0));
for (int index6 = val1 - num14; index6 <= val1 + num14; ++index6)
this.PlaceSlab(this._slabs[index5 + 1, index6 + 1], index5 * 3 + origin.X, index6 * 3 + origin.Y + (int) num12, 3);
}
return true;
}
private delegate bool SlabState(int x, int y, int scale);
private class SlabStates
{
public static bool Empty(int x, int y, int scale) => false;
public static bool Solid(int x, int y, int scale) => true;
public static bool HalfBrick(int x, int y, int scale) => y >= scale / 2;
public static bool BottomRightFilled(int x, int y, int scale) => x >= scale - y;
public static bool BottomLeftFilled(int x, int y, int scale) => x < y;
public static bool TopRightFilled(int x, int y, int scale) => x > y;
public static bool TopLeftFilled(int x, int y, int scale) => x < scale - y;
}
private struct Slab
{
public readonly MarbleBiome.SlabState State;
public readonly bool HasWall;
public bool IsSolid => this.State != new MarbleBiome.SlabState(MarbleBiome.SlabStates.Empty);
private Slab(MarbleBiome.SlabState state, bool hasWall)
{
this.State = state;
this.HasWall = hasWall;
}
public MarbleBiome.Slab WithState(MarbleBiome.SlabState state) => new MarbleBiome.Slab(state, this.HasWall);
public static MarbleBiome.Slab Create(MarbleBiome.SlabState state, bool hasWall) => new MarbleBiome.Slab(state, hasWall);
}
}
}

View file

@ -0,0 +1,68 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.MiningExplosivesBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Terraria.GameContent.Generation;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class MiningExplosivesBiome : MicroBiome
{
public override bool Place(Point origin, StructureMap structures)
{
if (WorldGen.SolidTile(origin.X, origin.Y))
return false;
ushort type = Utils.SelectRandom<ushort>(GenBase._random, WorldGen.goldBar == 19 ? (ushort) 8 : (ushort) 169, WorldGen.silverBar == 21 ? (ushort) 9 : (ushort) 168, WorldGen.ironBar == 22 ? (ushort) 6 : (ushort) 167, WorldGen.copperBar == 20 ? (ushort) 7 : (ushort) 166);
double num1 = GenBase._random.NextDouble() * 2.0 - 1.0;
if (!WorldUtils.Find(origin, Searches.Chain(num1 > 0.0 ? (GenSearch) new Searches.Right(40) : (GenSearch) new Searches.Left(40), (GenCondition) new Conditions.IsSolid()), out origin))
return false;
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out origin))
return false;
ShapeData shapeData = new ShapeData();
Ref<int> count1 = new Ref<int>(0);
Ref<int> count2 = new Ref<int>(0);
WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float) num1, 1f)).Output(shapeData), Actions.Chain((GenAction) new Modifiers.Blotches(), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count2)));
if (count2.Value < count1.Value / 2)
return false;
Microsoft.Xna.Framework.Rectangle area = new Microsoft.Xna.Framework.Rectangle(origin.X - 15, origin.Y - 10, 30, 20);
if (!structures.CanPlace(area))
return false;
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData), (GenAction) new Actions.SetTile(type, true));
WorldUtils.Gen(new Point(origin.X - (int) (num1 * -5.0), origin.Y - 5), (GenShape) new Shapes.Circle(5), Actions.Chain((GenAction) new Modifiers.Blotches(), (GenAction) new Actions.ClearTile(true)));
Point result1;
int num2 = 1 & (WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? 3 : -3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result1) ? 1 : 0);
int num3 = GenBase._random.Next(4) == 0 ? 3 : 7;
Point result2;
int num4 = WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? -num3 : num3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0;
if ((num2 & num4) == 0)
return false;
--result1.Y;
--result2.Y;
Tile tile1 = GenBase._tiles[result1.X, result1.Y + 1];
tile1.slope((byte) 0);
tile1.halfBrick(false);
for (int index = -1; index <= 1; ++index)
{
WorldUtils.ClearTile(result2.X + index, result2.Y);
Tile tile2 = GenBase._tiles[result2.X + index, result2.Y + 1];
if (!WorldGen.SolidOrSlopedTile(tile2))
{
tile2.ResetToType((ushort) 1);
tile2.active(true);
}
tile2.slope((byte) 0);
tile2.halfBrick(false);
WorldUtils.TileFrame(result2.X + index, result2.Y + 1, true);
}
WorldGen.PlaceTile(result1.X, result1.Y, 141);
WorldGen.PlaceTile(result2.X, result2.Y, 411, true, true);
WorldUtils.WireLine(result1, result2);
structures.AddStructure(area, 5);
return true;
}
}
}

View file

@ -0,0 +1,48 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Biomes.ThinIceBiome
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using Terraria.World.Generation;
namespace Terraria.GameContent.Biomes
{
public class ThinIceBiome : MicroBiome
{
public override bool Place(Point origin, StructureMap structures)
{
Dictionary<ushort, int> resultsOutput = new Dictionary<ushort, int>();
WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[4]
{
(ushort) 0,
(ushort) 59,
(ushort) 147,
(ushort) 1
}).Output(resultsOutput));
int num1 = resultsOutput[(ushort) 0] + resultsOutput[(ushort) 1];
int num2 = resultsOutput[(ushort) 59];
int num3 = resultsOutput[(ushort) 147];
if (num3 <= num2 || num3 <= num1)
return false;
int num4 = 0;
for (int radius = GenBase._random.Next(10, 15); radius > 5; --radius)
{
int num5 = GenBase._random.Next(-5, 5);
WorldUtils.Gen(new Point(origin.X + num5, origin.Y + num4), (GenShape) new Shapes.Circle(radius), Actions.Chain((GenAction) new Modifiers.Blotches(4), (GenAction) new Modifiers.OnlyTiles(new ushort[5]
{
(ushort) 147,
(ushort) 161,
(ushort) 224,
(ushort) 0,
(ushort) 1
}), (GenAction) new Actions.SetTile((ushort) 162, true)));
WorldUtils.Gen(new Point(origin.X + num5, origin.Y + num4), (GenShape) new Shapes.Circle(radius), Actions.Chain((GenAction) new Modifiers.Blotches(4), (GenAction) new Modifiers.HasLiquid(), (GenAction) new Actions.SetTile((ushort) 162, true), (GenAction) new Actions.SetLiquid(value: (byte) 0)));
num4 += radius - 2;
}
return true;
}
}
}