Terraria 1.3.5.3 Source Code
This commit is contained in:
commit
4b21dac4b6
503 changed files with 409032 additions and 0 deletions
22
GameContent/Generation/ActionGrass.cs
Normal file
22
GameContent/Generation/ActionGrass.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ActionGrass
|
||||
// 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.Generation
|
||||
{
|
||||
public class ActionGrass : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
if (GenBase._tiles[x, y].active() || GenBase._tiles[x, y - 1].active())
|
||||
return false;
|
||||
WorldGen.PlaceTile(x, y, (int) Utils.SelectRandom<ushort>(GenBase._random, (ushort) 3, (ushort) 73), true);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
26
GameContent/Generation/ActionPlaceStatue.cs
Normal file
26
GameContent/Generation/ActionPlaceStatue.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ActionPlaceStatue
|
||||
// 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.DataStructures;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class ActionPlaceStatue : GenAction
|
||||
{
|
||||
private int _statueIndex;
|
||||
|
||||
public ActionPlaceStatue(int index = -1) => this._statueIndex = index;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
Point16 point16 = this._statueIndex != -1 ? WorldGen.statueList[this._statueIndex] : WorldGen.statueList[GenBase._random.Next(2, WorldGen.statueList.Length)];
|
||||
WorldGen.PlaceTile(x, y, (int) point16.X, true, style: ((int) point16.Y));
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
20
GameContent/Generation/ActionStalagtite.cs
Normal file
20
GameContent/Generation/ActionStalagtite.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ActionStalagtite
|
||||
// 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.Generation
|
||||
{
|
||||
public class ActionStalagtite : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
WorldGen.PlaceTight(x, y);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
37
GameContent/Generation/ActionVines.cs
Normal file
37
GameContent/Generation/ActionVines.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ActionVines
|
||||
// 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.Generation
|
||||
{
|
||||
public class ActionVines : GenAction
|
||||
{
|
||||
private int _minLength;
|
||||
private int _maxLength;
|
||||
private int _vineId;
|
||||
|
||||
public ActionVines(int minLength = 6, int maxLength = 10, int vineId = 52)
|
||||
{
|
||||
this._minLength = minLength;
|
||||
this._maxLength = maxLength;
|
||||
this._vineId = vineId;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
int num1 = GenBase._random.Next(this._minLength, this._maxLength + 1);
|
||||
int num2;
|
||||
for (num2 = 0; num2 < num1 && !GenBase._tiles[x, y + num2].active(); ++num2)
|
||||
{
|
||||
GenBase._tiles[x, y + num2].type = (ushort) this._vineId;
|
||||
GenBase._tiles[x, y + num2].active(true);
|
||||
}
|
||||
return num2 > 0 && this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
54
GameContent/Generation/PassLegacy.cs
Normal file
54
GameContent/Generation/PassLegacy.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.PassLegacy
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class PassLegacy : GenPass
|
||||
{
|
||||
private static Dictionary<string, float> _weightMap = PassLegacy.GenerateWeightMap();
|
||||
private WorldGenLegacyMethod _method;
|
||||
|
||||
private static Dictionary<string, float> GenerateWeightMap()
|
||||
{
|
||||
Dictionary<string, float> dictionary = new Dictionary<string, float>();
|
||||
char[] chArray1 = new char[1]{ ',' };
|
||||
foreach (string str in "Reset:1.794,Terrain:233.6416,Tunnels:4.6075,Sand:256.211,Mount Caves:28.2501,Dirt Wall Backgrounds:91.1031,Rocks In Dirt:568.933,Dirt In Rocks:612.0777,Clay:99.0829,Small Holes:1080.6658,Dirt Layer Caves:97.6719,Rock Layer Caves:978.5062,Surface Caves:13.8707,Slush Check:40.0098,Grass:14.2435,Jungle:2404.0004,Marble:644.4756,Granite:7445.4057,Mud Caves To Grass:13289.4058,Full Desert:1977.3443,Floating Islands:430.9967,Mushroom Patches:305.0517,Mud To Dirt:135.7024,Silt:76.367,Shinies:106.5187,Webs:22.2261,Underworld:5202.7952,Lakes:12.458,Dungeon:273.1042,Corruption:100.9735,Slush:24.1356,Mud Caves To Grass:8.4174,Beaches:4.4018,Gems:289.1701,Gravitating Sand:207.9566,Clean Up Dirt:459.6188,Pyramids:0.4286,Dirt Rock Wall Runner:18.2315,Living Trees:11.9772,Wood Tree Walls:61.6,Altars:18.7726,Wet Jungle:10.5711,Remove Water From Sand:11.0268,Jungle Temple:140.1556,Hives:2144.6166,Jungle Chests:1.3979,Smooth World:2242.1054,Settle Liquids:4844.7201,Waterfalls:1868.306,Ice:80.3287,Wall Variety:2390.3296,Traps:42.6118,Life Crystals:2.0239,Statues:15.5157,Buried Chests:591.4215,Surface Chests:9.5181,Jungle Chests Placement:1.8203,Water Chests:5.5477,Spider Caves:4979.7116,Gem Caves:41.1786,Moss:2116.5164,Temple:6.6512,Ice Walls:7890.5261,Jungle Trees:230.5412,Floating Island Houses:2.299,Quick Cleanup:417.1482,Pots:515.7405,Hellforge:5.3522,Spreading Grass:47.0313,Piles:160.8168,Moss:11.8533,Spawn Point:0.2951,Grass Wall:293.7116,Guide:4.4433,Sunflowers:4.6765,Planting Trees:203.2509,Herbs:86.5444,Dye Plants:178.949,Webs And Honey:336.4474,Weeds:137.5676,Mud Caves To Grass:179.8629,Jungle Plants:606.4348,Vines:264.2856,Flowers:0.8461,Mushrooms:0.4203,Stalac:347.0403,Gems In Ice Biome:5.491,Random Gems:9.3797,Moss Grass:267.3524,Muds Walls In Jungle:34.8689,Larva:0.6675,Tile Cleanup:675.7305,Lihzahrd Altars:0.2615,Micro Biomes:2734.7864,Final Cleanup:648.6878".Split(chArray1))
|
||||
{
|
||||
char[] chArray2 = new char[1]{ ':' };
|
||||
string[] strArray = str.Split(chArray2);
|
||||
dictionary[strArray[0]] = float.Parse(strArray[1], NumberStyles.AllowDecimalPoint, (IFormatProvider) CultureInfo.InvariantCulture);
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
public PassLegacy(string name, WorldGenLegacyMethod method)
|
||||
: base(name, PassLegacy.GetWeight(name))
|
||||
{
|
||||
this._method = method;
|
||||
}
|
||||
|
||||
public PassLegacy(string name, WorldGenLegacyMethod method, float weight)
|
||||
: base(name, weight)
|
||||
{
|
||||
this._method = method;
|
||||
}
|
||||
|
||||
private static float GetWeight(string name)
|
||||
{
|
||||
float num;
|
||||
if (!PassLegacy._weightMap.TryGetValue(name, out num))
|
||||
num = 1f;
|
||||
return num;
|
||||
}
|
||||
|
||||
public override void Apply(GenerationProgress progress) => this._method(progress);
|
||||
}
|
||||
}
|
69
GameContent/Generation/ShapeBranch.cs
Normal file
69
GameContent/Generation/ShapeBranch.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ShapeBranch
|
||||
// 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.Generation
|
||||
{
|
||||
public class ShapeBranch : GenShape
|
||||
{
|
||||
private Point _offset;
|
||||
private List<Point> _endPoints;
|
||||
|
||||
public ShapeBranch() => this._offset = new Point(10, -5);
|
||||
|
||||
public ShapeBranch(Point offset) => this._offset = offset;
|
||||
|
||||
public ShapeBranch(double angle, double distance) => this._offset = new Point((int) (Math.Cos(angle) * distance), (int) (Math.Sin(angle) * distance));
|
||||
|
||||
private bool PerformSegment(Point origin, GenAction action, Point start, Point end, int size)
|
||||
{
|
||||
size = Math.Max(1, size);
|
||||
for (int index1 = -(size >> 1); index1 < size - (size >> 1); ++index1)
|
||||
{
|
||||
for (int index2 = -(size >> 1); index2 < size - (size >> 1); ++index2)
|
||||
{
|
||||
if (!Utils.PlotLine(new Point(start.X + index1, start.Y + index2), end, (Utils.PerLinePoint) ((tileX, tileY) => this.UnitApply(action, origin, tileX, tileY) || !this._quitOnFail), false))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
float num1 = new Vector2((float) this._offset.X, (float) this._offset.Y).Length();
|
||||
int size = (int) ((double) num1 / 6.0);
|
||||
if (this._endPoints != null)
|
||||
this._endPoints.Add(new Point(origin.X + this._offset.X, origin.Y + this._offset.Y));
|
||||
if (!this.PerformSegment(origin, action, origin, new Point(origin.X + this._offset.X, origin.Y + this._offset.Y), size))
|
||||
return false;
|
||||
int num2 = (int) ((double) num1 / 8.0);
|
||||
for (int index = 0; index < num2; ++index)
|
||||
{
|
||||
float num3 = (float) (((double) index + 1.0) / ((double) num2 + 1.0));
|
||||
Point point1 = new Point((int) ((double) num3 * (double) this._offset.X), (int) ((double) num3 * (double) this._offset.Y));
|
||||
Vector2 spinningpoint = new Vector2((float) (this._offset.X - point1.X), (float) (this._offset.Y - point1.Y));
|
||||
spinningpoint = spinningpoint.RotatedBy((GenBase._random.NextDouble() * 0.5 + 1.0) * (GenBase._random.Next(2) == 0 ? -1.0 : 1.0)) * 0.75f;
|
||||
Point point2 = new Point((int) spinningpoint.X + point1.X, (int) spinningpoint.Y + point1.Y);
|
||||
if (this._endPoints != null)
|
||||
this._endPoints.Add(new Point(point2.X + origin.X, point2.Y + origin.Y));
|
||||
if (!this.PerformSegment(origin, action, new Point(point1.X + origin.X, point1.Y + origin.Y), new Point(point2.X + origin.X, point2.Y + origin.Y), size - 1))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShapeBranch OutputEndpoints(List<Point> endpoints)
|
||||
{
|
||||
this._endPoints = endpoints;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
55
GameContent/Generation/ShapeFloodFill.cs
Normal file
55
GameContent/Generation/ShapeFloodFill.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ShapeFloodFill
|
||||
// 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.DataStructures;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class ShapeFloodFill : GenShape
|
||||
{
|
||||
private int _maximumActions;
|
||||
|
||||
public ShapeFloodFill(int maximumActions = 100) => this._maximumActions = maximumActions;
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
Queue<Point> pointQueue = new Queue<Point>();
|
||||
HashSet<Point16> point16Set = new HashSet<Point16>();
|
||||
pointQueue.Enqueue(origin);
|
||||
int maximumActions = this._maximumActions;
|
||||
while (pointQueue.Count > 0 && maximumActions > 0)
|
||||
{
|
||||
Point point = pointQueue.Dequeue();
|
||||
if (!point16Set.Contains(new Point16(point.X, point.Y)) && this.UnitApply(action, origin, point.X, point.Y))
|
||||
{
|
||||
point16Set.Add(new Point16(point));
|
||||
--maximumActions;
|
||||
if (point.X + 1 < Main.maxTilesX - 1)
|
||||
pointQueue.Enqueue(new Point(point.X + 1, point.Y));
|
||||
if (point.X - 1 >= 1)
|
||||
pointQueue.Enqueue(new Point(point.X - 1, point.Y));
|
||||
if (point.Y + 1 < Main.maxTilesY - 1)
|
||||
pointQueue.Enqueue(new Point(point.X, point.Y + 1));
|
||||
if (point.Y - 1 >= 1)
|
||||
pointQueue.Enqueue(new Point(point.X, point.Y - 1));
|
||||
}
|
||||
}
|
||||
while (pointQueue.Count > 0)
|
||||
{
|
||||
Point point = pointQueue.Dequeue();
|
||||
if (!point16Set.Contains(new Point16(point.X, point.Y)))
|
||||
{
|
||||
pointQueue.Enqueue(point);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pointQueue.Count == 0;
|
||||
}
|
||||
}
|
||||
}
|
59
GameContent/Generation/ShapeRoot.cs
Normal file
59
GameContent/Generation/ShapeRoot.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ShapeRoot
|
||||
// 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.Generation
|
||||
{
|
||||
public class ShapeRoot : GenShape
|
||||
{
|
||||
private float _angle;
|
||||
private float _startingSize;
|
||||
private float _endingSize;
|
||||
private float _distance;
|
||||
|
||||
public ShapeRoot(float angle, float distance = 10f, float startingSize = 4f, float endingSize = 1f)
|
||||
{
|
||||
this._angle = angle;
|
||||
this._distance = distance;
|
||||
this._startingSize = startingSize;
|
||||
this._endingSize = endingSize;
|
||||
}
|
||||
|
||||
private bool DoRoot(
|
||||
Point origin,
|
||||
GenAction action,
|
||||
float angle,
|
||||
float distance,
|
||||
float startingSize)
|
||||
{
|
||||
float x = (float) origin.X;
|
||||
float y = (float) origin.Y;
|
||||
for (float num1 = 0.0f; (double) num1 < (double) distance * 0.850000023841858; ++num1)
|
||||
{
|
||||
float amount = num1 / distance;
|
||||
float num2 = MathHelper.Lerp(startingSize, this._endingSize, amount);
|
||||
x += (float) Math.Cos((double) angle);
|
||||
y += (float) Math.Sin((double) angle);
|
||||
angle += (float) ((double) GenBase._random.NextFloat() - 0.5 + (double) GenBase._random.NextFloat() * ((double) this._angle - 1.57079637050629) * 0.100000001490116 * (1.0 - (double) amount));
|
||||
angle = (float) ((double) angle * 0.400000005960464 + 0.449999988079071 * (double) MathHelper.Clamp(angle, this._angle - (float) (2.0 * (1.0 - 0.5 * (double) amount)), this._angle + (float) (2.0 * (1.0 - 0.5 * (double) amount))) + (double) MathHelper.Lerp(this._angle, 1.570796f, amount) * 0.150000005960464);
|
||||
for (int index1 = 0; index1 < (int) num2; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < (int) num2; ++index2)
|
||||
{
|
||||
if (!this.UnitApply(action, origin, (int) x + index1, (int) y + index2) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action) => this.DoRoot(origin, action, this._angle, this._distance, this._startingSize);
|
||||
}
|
||||
}
|
62
GameContent/Generation/ShapeRunner.cs
Normal file
62
GameContent/Generation/ShapeRunner.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ShapeRunner
|
||||
// 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.Generation
|
||||
{
|
||||
public class ShapeRunner : GenShape
|
||||
{
|
||||
private float _startStrength;
|
||||
private int _steps;
|
||||
private Vector2 _startVelocity;
|
||||
|
||||
public ShapeRunner(float strength, int steps, Vector2 velocity)
|
||||
{
|
||||
this._startStrength = strength;
|
||||
this._steps = steps;
|
||||
this._startVelocity = velocity;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
float num1 = (float) this._steps;
|
||||
float steps = (float) this._steps;
|
||||
double num2 = (double) this._startStrength;
|
||||
Vector2 vector2_1 = new Vector2((float) origin.X, (float) origin.Y);
|
||||
Vector2 vector2_2 = this._startVelocity == Vector2.Zero ? Utils.RandomVector2(GenBase._random, -1f, 1f) : this._startVelocity;
|
||||
while ((double) num1 > 0.0 && num2 > 0.0)
|
||||
{
|
||||
num2 = (double) this._startStrength * ((double) num1 / (double) steps);
|
||||
float num3 = num1 - 1f;
|
||||
int num4 = Math.Max(1, (int) ((double) vector2_1.X - num2 * 0.5));
|
||||
int num5 = Math.Max(1, (int) ((double) vector2_1.Y - num2 * 0.5));
|
||||
int num6 = Math.Min(GenBase._worldWidth, (int) ((double) vector2_1.X + num2 * 0.5));
|
||||
int num7 = Math.Min(GenBase._worldHeight, (int) ((double) vector2_1.Y + num2 * 0.5));
|
||||
for (int x = num4; x < num6; ++x)
|
||||
{
|
||||
for (int y = num5; y < num7; ++y)
|
||||
{
|
||||
if ((double) Math.Abs((float) x - vector2_1.X) + (double) Math.Abs((float) y - vector2_1.Y) < num2 * 0.5 * (1.0 + (double) GenBase._random.Next(-10, 11) * 0.015))
|
||||
this.UnitApply(action, origin, x, y);
|
||||
}
|
||||
}
|
||||
int num8 = (int) (num2 / 50.0) + 1;
|
||||
num1 = num3 - (float) num8;
|
||||
vector2_1 += vector2_2;
|
||||
for (int index = 0; index < num8; ++index)
|
||||
{
|
||||
vector2_1 += vector2_2;
|
||||
vector2_2 += Utils.RandomVector2(GenBase._random, -0.5f, 0.5f);
|
||||
}
|
||||
vector2_2 = Vector2.Clamp(vector2_2 + Utils.RandomVector2(GenBase._random, -0.5f, 0.5f), -Vector2.One, Vector2.One);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
279
GameContent/Generation/TrackGenerator.cs
Normal file
279
GameContent/Generation/TrackGenerator.cs
Normal file
|
@ -0,0 +1,279 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.TrackGenerator
|
||||
// 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.Generation
|
||||
{
|
||||
public class TrackGenerator
|
||||
{
|
||||
private static readonly byte[] INVALID_WALLS = new byte[13]
|
||||
{
|
||||
(byte) 7,
|
||||
(byte) 94,
|
||||
(byte) 95,
|
||||
(byte) 8,
|
||||
(byte) 98,
|
||||
(byte) 99,
|
||||
(byte) 9,
|
||||
(byte) 96,
|
||||
(byte) 97,
|
||||
(byte) 3,
|
||||
(byte) 83,
|
||||
(byte) 87,
|
||||
(byte) 86
|
||||
};
|
||||
private const int TOTAL_TILE_IGNORES = 150;
|
||||
private const int PLAYER_HEIGHT = 6;
|
||||
private const int MAX_RETRIES = 400;
|
||||
private const int MAX_SMOOTH_DISTANCE = 15;
|
||||
private const int MAX_ITERATIONS = 1000000;
|
||||
private TrackGenerator.TrackHistory[] _historyCache = new TrackGenerator.TrackHistory[2048];
|
||||
|
||||
public void Generate(int trackCount, int minimumLength)
|
||||
{
|
||||
int num = trackCount;
|
||||
while (num > 0)
|
||||
{
|
||||
int x = WorldGen.genRand.Next(150, Main.maxTilesX - 150);
|
||||
int y = WorldGen.genRand.Next((int) Main.worldSurface + 25, Main.maxTilesY - 200);
|
||||
if (this.IsLocationEmpty(x, y))
|
||||
{
|
||||
while (this.IsLocationEmpty(x, y + 1))
|
||||
++y;
|
||||
if (this.FindPath(x, y, minimumLength))
|
||||
--num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsLocationEmpty(int x, int y)
|
||||
{
|
||||
if (y > Main.maxTilesY - 200 || x < 0 || y < (int) Main.worldSurface || x > Main.maxTilesX - 5)
|
||||
return false;
|
||||
for (int index = 0; index < 6; ++index)
|
||||
{
|
||||
if (WorldGen.SolidTile(x, y - index))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CanTrackBePlaced(int x, int y)
|
||||
{
|
||||
if (y > Main.maxTilesY - 200 || x < 0 || y < (int) Main.worldSurface || x > Main.maxTilesX - 5)
|
||||
return false;
|
||||
byte wall = Main.tile[x, y].wall;
|
||||
for (int index = 0; index < TrackGenerator.INVALID_WALLS.Length; ++index)
|
||||
{
|
||||
if ((int) wall == (int) TrackGenerator.INVALID_WALLS[index])
|
||||
return false;
|
||||
}
|
||||
for (int index = -1; index <= 1; ++index)
|
||||
{
|
||||
if (Main.tile[x + index, y].active() && (Main.tile[x + index, y].type == (ushort) 314 || !TileID.Sets.GeneralPlacementTiles[(int) Main.tile[x + index, y].type]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SmoothTrack(TrackGenerator.TrackHistory[] history, int length)
|
||||
{
|
||||
int val2 = length - 1;
|
||||
bool flag = false;
|
||||
for (int index1 = length - 1; index1 >= 0; --index1)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
val2 = Math.Min(index1 + 15, val2);
|
||||
if ((int) history[index1].Y >= (int) history[val2].Y)
|
||||
{
|
||||
for (int index2 = index1 + 1; (int) history[index2].Y > (int) history[index1].Y; ++index2)
|
||||
history[index2].Y = history[index1].Y;
|
||||
if ((int) history[index1].Y == (int) history[val2].Y)
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else if ((int) history[index1].Y > (int) history[val2].Y)
|
||||
flag = true;
|
||||
else
|
||||
val2 = index1;
|
||||
}
|
||||
}
|
||||
|
||||
public bool FindPath(int x, int y, int minimumLength, bool debugMode = false)
|
||||
{
|
||||
TrackGenerator.TrackHistory[] historyCache = this._historyCache;
|
||||
int index1 = 0;
|
||||
Tile[,] tile = Main.tile;
|
||||
bool flag1 = true;
|
||||
int num1 = WorldGen.genRand.Next(2) == 0 ? 1 : -1;
|
||||
if (debugMode)
|
||||
num1 = Main.player[Main.myPlayer].direction;
|
||||
int yDirection = 1;
|
||||
int length = 0;
|
||||
int num2 = 400;
|
||||
bool flag2 = false;
|
||||
int num3 = 150;
|
||||
int num4 = 0;
|
||||
for (int index2 = 1000000; index2 > 0 & flag1 && index1 < historyCache.Length - 1; ++index1)
|
||||
{
|
||||
--index2;
|
||||
historyCache[index1] = new TrackGenerator.TrackHistory(x, y, yDirection);
|
||||
bool flag3 = false;
|
||||
int num5 = 1;
|
||||
if (index1 > minimumLength >> 1)
|
||||
num5 = -1;
|
||||
else if (index1 > (minimumLength >> 1) - 5)
|
||||
num5 = 0;
|
||||
if (flag2)
|
||||
{
|
||||
int num6 = 0;
|
||||
int num7 = num3;
|
||||
bool flag4 = false;
|
||||
for (int index3 = Math.Min(1, yDirection + 1); index3 >= Math.Max(-1, yDirection - 1); --index3)
|
||||
{
|
||||
int num8;
|
||||
for (num8 = 0; num8 <= num3; ++num8)
|
||||
{
|
||||
if (this.IsLocationEmpty(x + (num8 + 1) * num1, y + (num8 + 1) * index3 * num5))
|
||||
{
|
||||
flag4 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num8 < num7)
|
||||
{
|
||||
num7 = num8;
|
||||
num6 = index3;
|
||||
}
|
||||
}
|
||||
if (flag4)
|
||||
{
|
||||
yDirection = num6;
|
||||
for (int index4 = 0; index4 < num7 - 1; ++index4)
|
||||
{
|
||||
++index1;
|
||||
x += num1;
|
||||
y += yDirection * num5;
|
||||
historyCache[index1] = new TrackGenerator.TrackHistory(x, y, yDirection);
|
||||
num4 = index1;
|
||||
}
|
||||
x += num1;
|
||||
y += yDirection * num5;
|
||||
length = index1 + 1;
|
||||
flag2 = false;
|
||||
}
|
||||
num3 -= num7;
|
||||
if (num3 < 0)
|
||||
flag1 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index5 = Math.Min(1, yDirection + 1); index5 >= Math.Max(-1, yDirection - 1); --index5)
|
||||
{
|
||||
if (this.IsLocationEmpty(x + num1, y + index5 * num5))
|
||||
{
|
||||
yDirection = index5;
|
||||
flag3 = true;
|
||||
x += num1;
|
||||
y += yDirection * num5;
|
||||
length = index1 + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag3)
|
||||
{
|
||||
while (index1 > num4 && y == (int) historyCache[index1].Y)
|
||||
--index1;
|
||||
x = (int) historyCache[index1].X;
|
||||
y = (int) historyCache[index1].Y;
|
||||
yDirection = (int) historyCache[index1].YDirection - 1;
|
||||
--num2;
|
||||
if (num2 <= 0)
|
||||
{
|
||||
index1 = length;
|
||||
x = (int) historyCache[index1].X;
|
||||
y = (int) historyCache[index1].Y;
|
||||
yDirection = (int) historyCache[index1].YDirection;
|
||||
flag2 = true;
|
||||
num2 = 200;
|
||||
}
|
||||
--index1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(length > minimumLength | debugMode))
|
||||
return false;
|
||||
this.SmoothTrack(historyCache, length);
|
||||
if (!debugMode)
|
||||
{
|
||||
for (int index6 = 0; index6 < length; ++index6)
|
||||
{
|
||||
for (int index7 = -1; index7 < 7; ++index7)
|
||||
{
|
||||
if (!this.CanTrackBePlaced((int) historyCache[index6].X, (int) historyCache[index6].Y - index7))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int index8 = 0; index8 < length; ++index8)
|
||||
{
|
||||
TrackGenerator.TrackHistory trackHistory = historyCache[index8];
|
||||
for (int index9 = 0; index9 < 6; ++index9)
|
||||
Main.tile[(int) trackHistory.X, (int) trackHistory.Y - index9].active(false);
|
||||
}
|
||||
for (int index10 = 0; index10 < length; ++index10)
|
||||
{
|
||||
TrackGenerator.TrackHistory trackHistory = historyCache[index10];
|
||||
Tile.SmoothSlope((int) trackHistory.X, (int) trackHistory.Y + 1);
|
||||
Tile.SmoothSlope((int) trackHistory.X, (int) trackHistory.Y - 6);
|
||||
bool wire = Main.tile[(int) trackHistory.X, (int) trackHistory.Y].wire();
|
||||
Main.tile[(int) trackHistory.X, (int) trackHistory.Y].ResetToType((ushort) 314);
|
||||
Main.tile[(int) trackHistory.X, (int) trackHistory.Y].wire(wire);
|
||||
if (index10 != 0)
|
||||
{
|
||||
for (int index11 = 0; index11 < 6; ++index11)
|
||||
WorldUtils.TileFrame((int) historyCache[index10 - 1].X, (int) historyCache[index10 - 1].Y - index11, true);
|
||||
if (index10 == length - 1)
|
||||
{
|
||||
for (int index12 = 0; index12 < 6; ++index12)
|
||||
WorldUtils.TileFrame((int) trackHistory.X, (int) trackHistory.Y - index12, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Run(int trackCount = 30, int minimumLength = 250) => new TrackGenerator().Generate(trackCount, minimumLength);
|
||||
|
||||
public static void Run(Point start) => new TrackGenerator().FindPath(start.X, start.Y, 250, true);
|
||||
|
||||
private struct TrackHistory
|
||||
{
|
||||
public short X;
|
||||
public short Y;
|
||||
public byte YDirection;
|
||||
|
||||
public TrackHistory(int x, int y, int yDirection)
|
||||
{
|
||||
this.X = (short) x;
|
||||
this.Y = (short) y;
|
||||
this.YDirection = (byte) yDirection;
|
||||
}
|
||||
|
||||
public TrackHistory(short x, short y, byte yDirection)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.YDirection = yDirection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
GameContent/Generation/WorldGenLegacyMethod.cs
Normal file
12
GameContent/Generation/WorldGenLegacyMethod.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.WorldGenLegacyMethod
|
||||
// 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 Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public delegate void WorldGenLegacyMethod(GenerationProgress progress);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue