Terraria 1.3.5.3 Source Code
This commit is contained in:
commit
4b21dac4b6
503 changed files with 409032 additions and 0 deletions
351
World/Generation/Actions.cs
Normal file
351
World/Generation/Actions.cs
Normal file
|
@ -0,0 +1,351 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.Actions
|
||||
// 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 Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public static class Actions
|
||||
{
|
||||
public static GenAction Chain(params GenAction[] actions)
|
||||
{
|
||||
for (int index = 0; index < actions.Length - 1; ++index)
|
||||
actions[index].NextAction = actions[index + 1];
|
||||
return actions[0];
|
||||
}
|
||||
|
||||
public static GenAction Continue(GenAction action) => (GenAction) new Actions.ContinueWrapper(action);
|
||||
|
||||
public class ContinueWrapper : GenAction
|
||||
{
|
||||
private GenAction _action;
|
||||
|
||||
public ContinueWrapper(GenAction action) => this._action = action;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
this._action.Apply(origin, x, y, args);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class Count : GenAction
|
||||
{
|
||||
private Ref<int> _count;
|
||||
|
||||
public Count(Ref<int> count) => this._count = count;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
++this._count.Value;
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class Scanner : GenAction
|
||||
{
|
||||
private Ref<int> _count;
|
||||
|
||||
public Scanner(Ref<int> count) => this._count = count;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
++this._count.Value;
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class TileScanner : GenAction
|
||||
{
|
||||
private ushort[] _tileIds;
|
||||
private Dictionary<ushort, int> _tileCounts;
|
||||
|
||||
public TileScanner(params ushort[] tiles)
|
||||
{
|
||||
this._tileIds = tiles;
|
||||
this._tileCounts = new Dictionary<ushort, int>();
|
||||
for (int index = 0; index < tiles.Length; ++index)
|
||||
this._tileCounts[this._tileIds[index]] = 0;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
Tile tile = GenBase._tiles[x, y];
|
||||
if (tile.active() && this._tileCounts.ContainsKey(tile.type))
|
||||
this._tileCounts[tile.type]++;
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
|
||||
public Actions.TileScanner Output(Dictionary<ushort, int> resultsOutput)
|
||||
{
|
||||
this._tileCounts = resultsOutput;
|
||||
for (int index = 0; index < this._tileIds.Length; ++index)
|
||||
{
|
||||
if (!this._tileCounts.ContainsKey(this._tileIds[index]))
|
||||
this._tileCounts[this._tileIds[index]] = 0;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Dictionary<ushort, int> GetResults() => this._tileCounts;
|
||||
|
||||
public int GetCount(ushort tileId) => !this._tileCounts.ContainsKey(tileId) ? -1 : this._tileCounts[tileId];
|
||||
}
|
||||
|
||||
public class Blank : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args) => this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
|
||||
public class Custom : GenAction
|
||||
{
|
||||
private GenBase.CustomPerUnitAction _perUnit;
|
||||
|
||||
public Custom(GenBase.CustomPerUnitAction perUnit) => this._perUnit = perUnit;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args) => this._perUnit(x, y, args) | this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
|
||||
public class ClearMetadata : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
GenBase._tiles[x, y].ClearMetadata();
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class Clear : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
GenBase._tiles[x, y].ClearEverything();
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class ClearTile : GenAction
|
||||
{
|
||||
private bool _frameNeighbors;
|
||||
|
||||
public ClearTile(bool frameNeighbors = false) => this._frameNeighbors = frameNeighbors;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
WorldUtils.ClearTile(x, y, this._frameNeighbors);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class ClearWall : GenAction
|
||||
{
|
||||
private bool _frameNeighbors;
|
||||
|
||||
public ClearWall(bool frameNeighbors = false) => this._frameNeighbors = frameNeighbors;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
WorldUtils.ClearWall(x, y, this._frameNeighbors);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class HalfBlock : GenAction
|
||||
{
|
||||
private bool _value;
|
||||
|
||||
public HalfBlock(bool value = true) => this._value = value;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
GenBase._tiles[x, y].halfBrick(this._value);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class SetTile : GenAction
|
||||
{
|
||||
private ushort _type;
|
||||
private bool _doFraming;
|
||||
private bool _doNeighborFraming;
|
||||
|
||||
public SetTile(ushort type, bool setSelfFrames = false, bool setNeighborFrames = true)
|
||||
{
|
||||
this._type = type;
|
||||
this._doFraming = setSelfFrames;
|
||||
this._doNeighborFraming = setNeighborFrames;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
GenBase._tiles[x, y].ResetToType(this._type);
|
||||
if (this._doFraming)
|
||||
WorldUtils.TileFrame(x, y, this._doNeighborFraming);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class DebugDraw : GenAction
|
||||
{
|
||||
private Color _color;
|
||||
private SpriteBatch _spriteBatch;
|
||||
|
||||
public DebugDraw(SpriteBatch spriteBatch, Color color = default (Color))
|
||||
{
|
||||
this._spriteBatch = spriteBatch;
|
||||
this._color = color;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
this._spriteBatch.Draw(Main.magicPixel, new Microsoft.Xna.Framework.Rectangle((x << 4) - (int) Main.screenPosition.X, (y << 4) - (int) Main.screenPosition.Y, 16, 16), this._color);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class SetSlope : GenAction
|
||||
{
|
||||
private int _slope;
|
||||
|
||||
public SetSlope(int slope) => this._slope = slope;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
WorldGen.SlopeTile(x, y, this._slope);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class SetHalfTile : GenAction
|
||||
{
|
||||
private bool _halfTile;
|
||||
|
||||
public SetHalfTile(bool halfTile) => this._halfTile = halfTile;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
GenBase._tiles[x, y].halfBrick(this._halfTile);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class PlaceTile : GenAction
|
||||
{
|
||||
private ushort _type;
|
||||
private int _style;
|
||||
|
||||
public PlaceTile(ushort type, int style = 0)
|
||||
{
|
||||
this._type = type;
|
||||
this._style = style;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
WorldGen.PlaceTile(x, y, (int) this._type, true, style: this._style);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class RemoveWall : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
GenBase._tiles[x, y].wall = (byte) 0;
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class PlaceWall : GenAction
|
||||
{
|
||||
private byte _type;
|
||||
private bool _neighbors;
|
||||
|
||||
public PlaceWall(byte type, bool neighbors = true)
|
||||
{
|
||||
this._type = type;
|
||||
this._neighbors = neighbors;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
GenBase._tiles[x, y].wall = this._type;
|
||||
WorldGen.SquareWallFrame(x, y);
|
||||
if (this._neighbors)
|
||||
{
|
||||
WorldGen.SquareWallFrame(x + 1, y);
|
||||
WorldGen.SquareWallFrame(x - 1, y);
|
||||
WorldGen.SquareWallFrame(x, y - 1);
|
||||
WorldGen.SquareWallFrame(x, y + 1);
|
||||
}
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class SetLiquid : GenAction
|
||||
{
|
||||
private int _type;
|
||||
private byte _value;
|
||||
|
||||
public SetLiquid(int type = 0, byte value = 255)
|
||||
{
|
||||
this._value = value;
|
||||
this._type = type;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
GenBase._tiles[x, y].liquidType(this._type);
|
||||
GenBase._tiles[x, y].liquid = this._value;
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class SwapSolidTile : GenAction
|
||||
{
|
||||
private ushort _type;
|
||||
|
||||
public SwapSolidTile(ushort type) => this._type = type;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
Tile tile = GenBase._tiles[x, y];
|
||||
if (!WorldGen.SolidTile(tile))
|
||||
return this.Fail();
|
||||
tile.ResetToType(this._type);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class SetFrames : GenAction
|
||||
{
|
||||
private bool _frameNeighbors;
|
||||
|
||||
public SetFrames(bool frameNeighbors = false) => this._frameNeighbors = frameNeighbors;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
WorldUtils.TileFrame(x, y, this._frameNeighbors);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class Smooth : GenAction
|
||||
{
|
||||
private bool _applyToNeighbors;
|
||||
|
||||
public Smooth(bool applyToNeighbors = false) => this._applyToNeighbors = applyToNeighbors;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
Tile.SmoothSlope(x, y, this._applyToNeighbors);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
World/Generation/BiomeCollection.cs
Normal file
15
World/Generation/BiomeCollection.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.BiomeCollection
|
||||
// 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.Collections.Generic;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
internal static class BiomeCollection
|
||||
{
|
||||
public static List<MicroBiome> Biomes = new List<MicroBiome>();
|
||||
}
|
||||
}
|
28
World/Generation/Biomes`1.cs
Normal file
28
World/Generation/Biomes`1.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.Biomes`1
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public static class Biomes<T> where T : MicroBiome, new()
|
||||
{
|
||||
private static T _microBiome = Biomes<T>.CreateInstance();
|
||||
|
||||
public static bool Place(int x, int y, StructureMap structures) => Biomes<T>._microBiome.Place(new Point(x, y), structures);
|
||||
|
||||
public static bool Place(Point origin, StructureMap structures) => Biomes<T>._microBiome.Place(origin, structures);
|
||||
|
||||
public static T Get() => Biomes<T>._microBiome;
|
||||
|
||||
private static T CreateInstance()
|
||||
{
|
||||
T obj = new T();
|
||||
BiomeCollection.Biomes.Add((MicroBiome) obj);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
46
World/Generation/Conditions.cs
Normal file
46
World/Generation/Conditions.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.Conditions
|
||||
// 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
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public static class Conditions
|
||||
{
|
||||
public class IsTile : GenCondition
|
||||
{
|
||||
private ushort[] _types;
|
||||
|
||||
public IsTile(params ushort[] types) => this._types = types;
|
||||
|
||||
protected override bool CheckValidity(int x, int y)
|
||||
{
|
||||
if (GenBase._tiles[x, y].active())
|
||||
{
|
||||
for (int index = 0; index < this._types.Length; ++index)
|
||||
{
|
||||
if ((int) GenBase._tiles[x, y].type == (int) this._types[index])
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class Continue : GenCondition
|
||||
{
|
||||
protected override bool CheckValidity(int x, int y) => false;
|
||||
}
|
||||
|
||||
public class IsSolid : GenCondition
|
||||
{
|
||||
protected override bool CheckValidity(int x, int y) => GenBase._tiles[x, y].active() && Main.tileSolid[(int) GenBase._tiles[x, y].type];
|
||||
}
|
||||
|
||||
public class HasLava : GenCondition
|
||||
{
|
||||
protected override bool CheckValidity(int x, int y) => GenBase._tiles[x, y].liquid > (byte) 0 && GenBase._tiles[x, y].liquidType() == (byte) 1;
|
||||
}
|
||||
}
|
||||
}
|
40
World/Generation/GenAction.cs
Normal file
40
World/Generation/GenAction.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.GenAction
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public abstract class GenAction : GenBase
|
||||
{
|
||||
public GenAction NextAction;
|
||||
public ShapeData OutputData;
|
||||
private bool _returnFalseOnFailure = true;
|
||||
|
||||
public abstract bool Apply(Point origin, int x, int y, params object[] args);
|
||||
|
||||
protected bool UnitApply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
if (this.OutputData != null)
|
||||
this.OutputData.Add(x - origin.X, y - origin.Y);
|
||||
return this.NextAction == null || this.NextAction.Apply(origin, x, y, args);
|
||||
}
|
||||
|
||||
public GenAction IgnoreFailures()
|
||||
{
|
||||
this._returnFalseOnFailure = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected bool Fail() => !this._returnFalseOnFailure;
|
||||
|
||||
public GenAction Output(ShapeData data)
|
||||
{
|
||||
this.OutputData = data;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
23
World/Generation/GenBase.cs
Normal file
23
World/Generation/GenBase.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.GenBase
|
||||
// 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.Utilities;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public class GenBase
|
||||
{
|
||||
protected static UnifiedRandom _random => WorldGen.genRand;
|
||||
|
||||
protected static Tile[,] _tiles => Main.tile;
|
||||
|
||||
protected static int _worldWidth => Main.maxTilesX;
|
||||
|
||||
protected static int _worldHeight => Main.maxTilesY;
|
||||
|
||||
public delegate bool CustomPerUnitAction(int x, int y, params object[] args);
|
||||
}
|
||||
}
|
78
World/Generation/GenCondition.cs
Normal file
78
World/Generation/GenCondition.cs
Normal file
|
@ -0,0 +1,78 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.GenCondition
|
||||
// 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
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public abstract class GenCondition : GenBase
|
||||
{
|
||||
private bool InvertResults;
|
||||
private int _width;
|
||||
private int _height;
|
||||
private GenCondition.AreaType _areaType = GenCondition.AreaType.None;
|
||||
|
||||
public bool IsValid(int x, int y)
|
||||
{
|
||||
switch (this._areaType)
|
||||
{
|
||||
case GenCondition.AreaType.And:
|
||||
for (int x1 = x; x1 < x + this._width; ++x1)
|
||||
{
|
||||
for (int y1 = y; y1 < y + this._height; ++y1)
|
||||
{
|
||||
if (!this.CheckValidity(x1, y1))
|
||||
return this.InvertResults;
|
||||
}
|
||||
}
|
||||
return !this.InvertResults;
|
||||
case GenCondition.AreaType.Or:
|
||||
for (int x2 = x; x2 < x + this._width; ++x2)
|
||||
{
|
||||
for (int y2 = y; y2 < y + this._height; ++y2)
|
||||
{
|
||||
if (this.CheckValidity(x2, y2))
|
||||
return !this.InvertResults;
|
||||
}
|
||||
}
|
||||
return this.InvertResults;
|
||||
case GenCondition.AreaType.None:
|
||||
return this.CheckValidity(x, y) ^ this.InvertResults;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public GenCondition Not()
|
||||
{
|
||||
this.InvertResults = !this.InvertResults;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenCondition AreaOr(int width, int height)
|
||||
{
|
||||
this._areaType = GenCondition.AreaType.Or;
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenCondition AreaAnd(int width, int height)
|
||||
{
|
||||
this._areaType = GenCondition.AreaType.And;
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected abstract bool CheckValidity(int x, int y);
|
||||
|
||||
private enum AreaType
|
||||
{
|
||||
And,
|
||||
Or,
|
||||
None,
|
||||
}
|
||||
}
|
||||
}
|
15
World/Generation/GenModShape.cs
Normal file
15
World/Generation/GenModShape.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.GenModShape
|
||||
// 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
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public abstract class GenModShape : GenShape
|
||||
{
|
||||
protected ShapeData _data;
|
||||
|
||||
public GenModShape(ShapeData data) => this._data = data;
|
||||
}
|
||||
}
|
22
World/Generation/GenPass.cs
Normal file
22
World/Generation/GenPass.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.GenPass
|
||||
// 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
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public abstract class GenPass : GenBase
|
||||
{
|
||||
public string Name;
|
||||
public float Weight;
|
||||
|
||||
public GenPass(string name, float loadWeight)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Weight = loadWeight;
|
||||
}
|
||||
|
||||
public abstract void Apply(GenerationProgress progress);
|
||||
}
|
||||
}
|
41
World/Generation/GenSearch.cs
Normal file
41
World/Generation/GenSearch.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.GenSearch
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public abstract class GenSearch : GenBase
|
||||
{
|
||||
public static Point NOT_FOUND = new Point(int.MaxValue, int.MaxValue);
|
||||
private bool _requireAll = true;
|
||||
private GenCondition[] _conditions;
|
||||
|
||||
public GenSearch Conditions(params GenCondition[] conditions)
|
||||
{
|
||||
this._conditions = conditions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract Point Find(Point origin);
|
||||
|
||||
protected bool Check(int x, int y)
|
||||
{
|
||||
for (int index = 0; index < this._conditions.Length; ++index)
|
||||
{
|
||||
if (this._requireAll ^ this._conditions[index].IsValid(x, y))
|
||||
return !this._requireAll;
|
||||
}
|
||||
return this._requireAll;
|
||||
}
|
||||
|
||||
public GenSearch RequireAll(bool mode)
|
||||
{
|
||||
this._requireAll = mode;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
37
World/Generation/GenShape.cs
Normal file
37
World/Generation/GenShape.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.GenShape
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public abstract class GenShape : GenBase
|
||||
{
|
||||
private ShapeData _outputData;
|
||||
protected bool _quitOnFail;
|
||||
|
||||
public abstract bool Perform(Point origin, GenAction action);
|
||||
|
||||
protected bool UnitApply(GenAction action, Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
if (this._outputData != null)
|
||||
this._outputData.Add(x - origin.X, y - origin.Y);
|
||||
return action.Apply(origin, x, y, args);
|
||||
}
|
||||
|
||||
public GenShape Output(ShapeData outputData)
|
||||
{
|
||||
this._outputData = outputData;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenShape QuitOnFail(bool value = true)
|
||||
{
|
||||
this._quitOnFail = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
15
World/Generation/GenStructure.cs
Normal file
15
World/Generation/GenStructure.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.GenStructure
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public abstract class GenStructure : GenBase
|
||||
{
|
||||
public abstract bool Place(Point origin, StructureMap structures);
|
||||
}
|
||||
}
|
41
World/Generation/GenerationProgress.cs
Normal file
41
World/Generation/GenerationProgress.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.GenerationProgress
|
||||
// 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
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public class GenerationProgress
|
||||
{
|
||||
private string _message = "";
|
||||
private float _value;
|
||||
private float _totalProgress;
|
||||
public float TotalWeight;
|
||||
public float CurrentPassWeight = 1f;
|
||||
|
||||
public string Message
|
||||
{
|
||||
get => string.Format(this._message, (object) this.Value);
|
||||
set => this._message = value.Replace("%", "{0:0.0%}");
|
||||
}
|
||||
|
||||
public float Value
|
||||
{
|
||||
set => this._value = Utils.Clamp<float>(value, 0.0f, 1f);
|
||||
get => this._value;
|
||||
}
|
||||
|
||||
public float TotalProgress => (double) this.TotalWeight == 0.0 ? 0.0f : (this.Value * this.CurrentPassWeight + this._totalProgress) / this.TotalWeight;
|
||||
|
||||
public void Set(float value) => this.Value = value;
|
||||
|
||||
public void Start(float weight)
|
||||
{
|
||||
this.CurrentPassWeight = weight;
|
||||
this._value = 0.0f;
|
||||
}
|
||||
|
||||
public void End() => this._totalProgress += this.CurrentPassWeight;
|
||||
}
|
||||
}
|
21
World/Generation/MicroBiome.cs
Normal file
21
World/Generation/MicroBiome.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.MicroBiome
|
||||
// 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
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public abstract class MicroBiome : GenStructure
|
||||
{
|
||||
public virtual void Reset()
|
||||
{
|
||||
}
|
||||
|
||||
public static void ResetAll()
|
||||
{
|
||||
foreach (MicroBiome biome in BiomeCollection.Biomes)
|
||||
biome.Reset();
|
||||
}
|
||||
}
|
||||
}
|
130
World/Generation/ModShapes.cs
Normal file
130
World/Generation/ModShapes.cs
Normal file
|
@ -0,0 +1,130 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.ModShapes
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public static class ModShapes
|
||||
{
|
||||
public class All : GenModShape
|
||||
{
|
||||
public All(ShapeData data)
|
||||
: base(data)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
foreach (Point16 point16 in this._data.GetData())
|
||||
{
|
||||
if (!this.UnitApply(action, origin, (int) point16.X + origin.X, (int) point16.Y + origin.Y) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class OuterOutline : GenModShape
|
||||
{
|
||||
private static readonly int[] POINT_OFFSETS = new int[16]
|
||||
{
|
||||
1,
|
||||
0,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
-1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
-1,
|
||||
-1,
|
||||
1,
|
||||
-1,
|
||||
-1
|
||||
};
|
||||
private bool _useDiagonals;
|
||||
private bool _useInterior;
|
||||
|
||||
public OuterOutline(ShapeData data, bool useDiagonals = true, bool useInterior = false)
|
||||
: base(data)
|
||||
{
|
||||
this._useDiagonals = useDiagonals;
|
||||
this._useInterior = useInterior;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
int num = this._useDiagonals ? 16 : 8;
|
||||
foreach (Point16 point16 in this._data.GetData())
|
||||
{
|
||||
if (this._useInterior && !this.UnitApply(action, origin, (int) point16.X + origin.X, (int) point16.Y + origin.Y) && this._quitOnFail)
|
||||
return false;
|
||||
for (int index = 0; index < num; index += 2)
|
||||
{
|
||||
if (!this._data.Contains((int) point16.X + ModShapes.OuterOutline.POINT_OFFSETS[index], (int) point16.Y + ModShapes.OuterOutline.POINT_OFFSETS[index + 1]) && !this.UnitApply(action, origin, origin.X + (int) point16.X + ModShapes.OuterOutline.POINT_OFFSETS[index], origin.Y + (int) point16.Y + ModShapes.OuterOutline.POINT_OFFSETS[index + 1]) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class InnerOutline : GenModShape
|
||||
{
|
||||
private static readonly int[] POINT_OFFSETS = new int[16]
|
||||
{
|
||||
1,
|
||||
0,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
-1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
-1,
|
||||
-1,
|
||||
1,
|
||||
-1,
|
||||
-1
|
||||
};
|
||||
private bool _useDiagonals;
|
||||
|
||||
public InnerOutline(ShapeData data, bool useDiagonals = true)
|
||||
: base(data)
|
||||
{
|
||||
this._useDiagonals = useDiagonals;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
int num = this._useDiagonals ? 16 : 8;
|
||||
foreach (Point16 point16 in this._data.GetData())
|
||||
{
|
||||
bool flag = false;
|
||||
for (int index = 0; index < num; index += 2)
|
||||
{
|
||||
if (!this._data.Contains((int) point16.X + ModShapes.InnerOutline.POINT_OFFSETS[index], (int) point16.Y + ModShapes.InnerOutline.POINT_OFFSETS[index + 1]))
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag && !this.UnitApply(action, origin, (int) point16.X + origin.X, (int) point16.Y + origin.Y) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
451
World/Generation/Modifiers.cs
Normal file
451
World/Generation/Modifiers.cs
Normal file
|
@ -0,0 +1,451 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.Modifiers
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public static class Modifiers
|
||||
{
|
||||
public class ShapeScale : GenAction
|
||||
{
|
||||
private int _scale;
|
||||
|
||||
public ShapeScale(int scale) => this._scale = scale;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
bool flag = false;
|
||||
for (int index1 = 0; index1 < this._scale; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < this._scale; ++index2)
|
||||
flag |= !this.UnitApply(origin, (x - origin.X << 1) + index1 + origin.X, (y - origin.Y << 1) + index2 + origin.Y);
|
||||
}
|
||||
return !flag;
|
||||
}
|
||||
}
|
||||
|
||||
public class Expand : GenAction
|
||||
{
|
||||
private int _xExpansion;
|
||||
private int _yExpansion;
|
||||
|
||||
public Expand(int expansion)
|
||||
{
|
||||
this._xExpansion = expansion;
|
||||
this._yExpansion = expansion;
|
||||
}
|
||||
|
||||
public Expand(int xExpansion, int yExpansion)
|
||||
{
|
||||
this._xExpansion = xExpansion;
|
||||
this._yExpansion = yExpansion;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
bool flag = false;
|
||||
for (int index1 = -this._xExpansion; index1 <= this._xExpansion; ++index1)
|
||||
{
|
||||
for (int index2 = -this._yExpansion; index2 <= this._yExpansion; ++index2)
|
||||
flag |= !this.UnitApply(origin, x + index1, y + index2, args);
|
||||
}
|
||||
return !flag;
|
||||
}
|
||||
}
|
||||
|
||||
public class RadialDither : GenAction
|
||||
{
|
||||
private float _innerRadius;
|
||||
private float _outerRadius;
|
||||
|
||||
public RadialDither(float innerRadius, float outerRadius)
|
||||
{
|
||||
this._innerRadius = innerRadius;
|
||||
this._outerRadius = outerRadius;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
Vector2 vector2 = new Vector2((float) origin.X, (float) origin.Y);
|
||||
float num = Math.Max(0.0f, Math.Min(1f, (float) (((double) Vector2.Distance(new Vector2((float) x, (float) y), vector2) - (double) this._innerRadius) / ((double) this._outerRadius - (double) this._innerRadius))));
|
||||
return GenBase._random.NextDouble() > (double) num ? this.UnitApply(origin, x, y, args) : this.Fail();
|
||||
}
|
||||
}
|
||||
|
||||
public class Blotches : GenAction
|
||||
{
|
||||
private int _minX;
|
||||
private int _minY;
|
||||
private int _maxX;
|
||||
private int _maxY;
|
||||
private double _chance;
|
||||
|
||||
public Blotches(int scale = 2, double chance = 0.3)
|
||||
{
|
||||
this._minX = scale;
|
||||
this._minY = scale;
|
||||
this._maxX = scale;
|
||||
this._maxY = scale;
|
||||
this._chance = chance;
|
||||
}
|
||||
|
||||
public Blotches(int xScale, int yScale, double chance = 0.3)
|
||||
{
|
||||
this._minX = xScale;
|
||||
this._maxX = xScale;
|
||||
this._minY = yScale;
|
||||
this._maxY = yScale;
|
||||
this._chance = chance;
|
||||
}
|
||||
|
||||
public Blotches(int leftScale, int upScale, int rightScale, int downScale, double chance = 0.3)
|
||||
{
|
||||
this._minX = leftScale;
|
||||
this._maxX = rightScale;
|
||||
this._minY = upScale;
|
||||
this._maxY = downScale;
|
||||
this._chance = chance;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
GenBase._random.NextDouble();
|
||||
if (GenBase._random.NextDouble() >= this._chance)
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
bool flag = false;
|
||||
int num1 = GenBase._random.Next(1 - this._minX, 1);
|
||||
int num2 = GenBase._random.Next(0, this._maxX);
|
||||
int num3 = GenBase._random.Next(1 - this._minY, 1);
|
||||
int num4 = GenBase._random.Next(0, this._maxY);
|
||||
for (int index1 = num1; index1 <= num2; ++index1)
|
||||
{
|
||||
for (int index2 = num3; index2 <= num4; ++index2)
|
||||
flag |= !this.UnitApply(origin, x + index1, y + index2, args);
|
||||
}
|
||||
return !flag;
|
||||
}
|
||||
}
|
||||
|
||||
public class Conditions : GenAction
|
||||
{
|
||||
private GenCondition[] _conditions;
|
||||
|
||||
public Conditions(params GenCondition[] conditions) => this._conditions = conditions;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
bool flag = true;
|
||||
for (int index = 0; index < this._conditions.Length; ++index)
|
||||
flag &= this._conditions[index].IsValid(x, y);
|
||||
return flag ? this.UnitApply(origin, x, y, args) : this.Fail();
|
||||
}
|
||||
}
|
||||
|
||||
public class OnlyWalls : GenAction
|
||||
{
|
||||
private byte[] _types;
|
||||
|
||||
public OnlyWalls(params byte[] types) => this._types = types;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
for (int index = 0; index < this._types.Length; ++index)
|
||||
{
|
||||
if ((int) GenBase._tiles[x, y].wall == (int) this._types[index])
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
return this.Fail();
|
||||
}
|
||||
}
|
||||
|
||||
public class OnlyTiles : GenAction
|
||||
{
|
||||
private ushort[] _types;
|
||||
|
||||
public OnlyTiles(params ushort[] types) => this._types = types;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
if (!GenBase._tiles[x, y].active())
|
||||
return this.Fail();
|
||||
for (int index = 0; index < this._types.Length; ++index)
|
||||
{
|
||||
if ((int) GenBase._tiles[x, y].type == (int) this._types[index])
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
return this.Fail();
|
||||
}
|
||||
}
|
||||
|
||||
public class IsTouching : GenAction
|
||||
{
|
||||
private static readonly int[] DIRECTIONS = new int[16]
|
||||
{
|
||||
0,
|
||||
-1,
|
||||
1,
|
||||
0,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
-1,
|
||||
-1,
|
||||
1,
|
||||
-1,
|
||||
-1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
};
|
||||
private bool _useDiagonals;
|
||||
private ushort[] _tileIds;
|
||||
|
||||
public IsTouching(bool useDiagonals, params ushort[] tileIds)
|
||||
{
|
||||
this._useDiagonals = useDiagonals;
|
||||
this._tileIds = tileIds;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
int num = this._useDiagonals ? 16 : 8;
|
||||
for (int index1 = 0; index1 < num; index1 += 2)
|
||||
{
|
||||
Tile tile = GenBase._tiles[x + Modifiers.IsTouching.DIRECTIONS[index1], y + Modifiers.IsTouching.DIRECTIONS[index1 + 1]];
|
||||
if (tile.active())
|
||||
{
|
||||
for (int index2 = 0; index2 < this._tileIds.Length; ++index2)
|
||||
{
|
||||
if ((int) tile.type == (int) this._tileIds[index2])
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.Fail();
|
||||
}
|
||||
}
|
||||
|
||||
public class NotTouching : GenAction
|
||||
{
|
||||
private static readonly int[] DIRECTIONS = new int[16]
|
||||
{
|
||||
0,
|
||||
-1,
|
||||
1,
|
||||
0,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
-1,
|
||||
-1,
|
||||
1,
|
||||
-1,
|
||||
-1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
};
|
||||
private bool _useDiagonals;
|
||||
private ushort[] _tileIds;
|
||||
|
||||
public NotTouching(bool useDiagonals, params ushort[] tileIds)
|
||||
{
|
||||
this._useDiagonals = useDiagonals;
|
||||
this._tileIds = tileIds;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
int num = this._useDiagonals ? 16 : 8;
|
||||
for (int index1 = 0; index1 < num; index1 += 2)
|
||||
{
|
||||
Tile tile = GenBase._tiles[x + Modifiers.NotTouching.DIRECTIONS[index1], y + Modifiers.NotTouching.DIRECTIONS[index1 + 1]];
|
||||
if (tile.active())
|
||||
{
|
||||
for (int index2 = 0; index2 < this._tileIds.Length; ++index2)
|
||||
{
|
||||
if ((int) tile.type == (int) this._tileIds[index2])
|
||||
return this.Fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class IsTouchingAir : GenAction
|
||||
{
|
||||
private static readonly int[] DIRECTIONS = new int[16]
|
||||
{
|
||||
0,
|
||||
-1,
|
||||
1,
|
||||
0,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
-1,
|
||||
-1,
|
||||
1,
|
||||
-1,
|
||||
-1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
};
|
||||
private bool _useDiagonals;
|
||||
|
||||
public IsTouchingAir(bool useDiagonals = false) => this._useDiagonals = useDiagonals;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
int num = this._useDiagonals ? 16 : 8;
|
||||
for (int index = 0; index < num; index += 2)
|
||||
{
|
||||
if (!GenBase._tiles[x + Modifiers.IsTouchingAir.DIRECTIONS[index], y + Modifiers.IsTouchingAir.DIRECTIONS[index + 1]].active())
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
return this.Fail();
|
||||
}
|
||||
}
|
||||
|
||||
public class SkipTiles : GenAction
|
||||
{
|
||||
private ushort[] _types;
|
||||
|
||||
public SkipTiles(params ushort[] types) => this._types = types;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
if (!GenBase._tiles[x, y].active())
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
for (int index = 0; index < this._types.Length; ++index)
|
||||
{
|
||||
if ((int) GenBase._tiles[x, y].type == (int) this._types[index])
|
||||
return this.Fail();
|
||||
}
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class HasLiquid : GenAction
|
||||
{
|
||||
private int _liquidType;
|
||||
private int _liquidLevel;
|
||||
|
||||
public HasLiquid(int liquidLevel = -1, int liquidType = -1)
|
||||
{
|
||||
this._liquidLevel = liquidLevel;
|
||||
this._liquidType = liquidType;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
Tile tile = GenBase._tiles[x, y];
|
||||
return (this._liquidType == -1 || this._liquidType == (int) tile.liquidType()) && (this._liquidLevel == -1 && tile.liquid != (byte) 0 || this._liquidLevel == (int) tile.liquid) ? this.UnitApply(origin, x, y, args) : this.Fail();
|
||||
}
|
||||
}
|
||||
|
||||
public class SkipWalls : GenAction
|
||||
{
|
||||
private byte[] _types;
|
||||
|
||||
public SkipWalls(params byte[] types) => this._types = types;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
for (int index = 0; index < this._types.Length; ++index)
|
||||
{
|
||||
if ((int) GenBase._tiles[x, y].wall == (int) this._types[index])
|
||||
return this.Fail();
|
||||
}
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class IsEmpty : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args) => !GenBase._tiles[x, y].active() ? this.UnitApply(origin, x, y, args) : this.Fail();
|
||||
}
|
||||
|
||||
public class IsSolid : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args) => GenBase._tiles[x, y].active() && WorldGen.SolidTile(x, y) ? this.UnitApply(origin, x, y, args) : this.Fail();
|
||||
}
|
||||
|
||||
public class IsNotSolid : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args) => !GenBase._tiles[x, y].active() || !WorldGen.SolidTile(x, y) ? this.UnitApply(origin, x, y, args) : this.Fail();
|
||||
}
|
||||
|
||||
public class RectangleMask : GenAction
|
||||
{
|
||||
private int _xMin;
|
||||
private int _yMin;
|
||||
private int _xMax;
|
||||
private int _yMax;
|
||||
|
||||
public RectangleMask(int xMin, int xMax, int yMin, int yMax)
|
||||
{
|
||||
this._xMin = xMin;
|
||||
this._yMin = yMin;
|
||||
this._xMax = xMax;
|
||||
this._yMax = yMax;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args) => x >= this._xMin + origin.X && x <= this._xMax + origin.X && y >= this._yMin + origin.Y && y <= this._yMax + origin.Y ? this.UnitApply(origin, x, y, args) : this.Fail();
|
||||
}
|
||||
|
||||
public class Offset : GenAction
|
||||
{
|
||||
private int _xOffset;
|
||||
private int _yOffset;
|
||||
|
||||
public Offset(int x, int y)
|
||||
{
|
||||
this._xOffset = x;
|
||||
this._yOffset = y;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args) => this.UnitApply(origin, x + this._xOffset, y + this._yOffset, args);
|
||||
}
|
||||
|
||||
public class Dither : GenAction
|
||||
{
|
||||
private double _failureChance;
|
||||
|
||||
public Dither(double failureChance = 0.5) => this._failureChance = failureChance;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args) => GenBase._random.NextDouble() >= this._failureChance ? this.UnitApply(origin, x, y, args) : this.Fail();
|
||||
}
|
||||
|
||||
public class Flip : GenAction
|
||||
{
|
||||
private bool _flipX;
|
||||
private bool _flipY;
|
||||
|
||||
public Flip(bool flipX, bool flipY)
|
||||
{
|
||||
this._flipX = flipX;
|
||||
this._flipY = flipY;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
if (this._flipX)
|
||||
x = origin.X * 2 - x;
|
||||
if (this._flipY)
|
||||
y = origin.Y * 2 - y;
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
62
World/Generation/Passes.cs
Normal file
62
World/Generation/Passes.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.Passes
|
||||
// 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
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public static class Passes
|
||||
{
|
||||
public class Clear : GenPass
|
||||
{
|
||||
public Clear()
|
||||
: base("clear", 1f)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Apply(GenerationProgress progress)
|
||||
{
|
||||
for (int index1 = 0; index1 < GenBase._worldWidth; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < GenBase._worldHeight; ++index2)
|
||||
{
|
||||
if (GenBase._tiles[index1, index2] == null)
|
||||
GenBase._tiles[index1, index2] = new Tile();
|
||||
else
|
||||
GenBase._tiles[index1, index2].ClearEverything();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ScatterCustom : GenPass
|
||||
{
|
||||
private GenBase.CustomPerUnitAction _perUnit;
|
||||
private int _count;
|
||||
|
||||
public ScatterCustom(
|
||||
string name,
|
||||
float loadWeight,
|
||||
int count,
|
||||
GenBase.CustomPerUnitAction perUnit = null)
|
||||
: base(name, loadWeight)
|
||||
{
|
||||
this._perUnit = perUnit;
|
||||
this._count = count;
|
||||
}
|
||||
|
||||
public void SetCustomAction(GenBase.CustomPerUnitAction perUnit) => this._perUnit = perUnit;
|
||||
|
||||
public override void Apply(GenerationProgress progress)
|
||||
{
|
||||
int count = this._count;
|
||||
while (count > 0)
|
||||
{
|
||||
if (this._perUnit(GenBase._random.Next(1, GenBase._worldWidth), GenBase._random.Next(1, GenBase._worldHeight), new object[0]))
|
||||
--count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
108
World/Generation/Searches.cs
Normal file
108
World/Generation/Searches.cs
Normal file
|
@ -0,0 +1,108 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.Searches
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public static class Searches
|
||||
{
|
||||
public static GenSearch Chain(GenSearch search, params GenCondition[] conditions) => search.Conditions(conditions);
|
||||
|
||||
public class Left : GenSearch
|
||||
{
|
||||
private int _maxDistance;
|
||||
|
||||
public Left(int maxDistance) => this._maxDistance = maxDistance;
|
||||
|
||||
public override Point Find(Point origin)
|
||||
{
|
||||
for (int index = 0; index < this._maxDistance; ++index)
|
||||
{
|
||||
if (this.Check(origin.X - index, origin.Y))
|
||||
return new Point(origin.X - index, origin.Y);
|
||||
}
|
||||
return GenSearch.NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
public class Right : GenSearch
|
||||
{
|
||||
private int _maxDistance;
|
||||
|
||||
public Right(int maxDistance) => this._maxDistance = maxDistance;
|
||||
|
||||
public override Point Find(Point origin)
|
||||
{
|
||||
for (int index = 0; index < this._maxDistance; ++index)
|
||||
{
|
||||
if (this.Check(origin.X + index, origin.Y))
|
||||
return new Point(origin.X + index, origin.Y);
|
||||
}
|
||||
return GenSearch.NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
public class Down : GenSearch
|
||||
{
|
||||
private int _maxDistance;
|
||||
|
||||
public Down(int maxDistance) => this._maxDistance = maxDistance;
|
||||
|
||||
public override Point Find(Point origin)
|
||||
{
|
||||
for (int index = 0; index < this._maxDistance; ++index)
|
||||
{
|
||||
if (this.Check(origin.X, origin.Y + index))
|
||||
return new Point(origin.X, origin.Y + index);
|
||||
}
|
||||
return GenSearch.NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
public class Up : GenSearch
|
||||
{
|
||||
private int _maxDistance;
|
||||
|
||||
public Up(int maxDistance) => this._maxDistance = maxDistance;
|
||||
|
||||
public override Point Find(Point origin)
|
||||
{
|
||||
for (int index = 0; index < this._maxDistance; ++index)
|
||||
{
|
||||
if (this.Check(origin.X, origin.Y - index))
|
||||
return new Point(origin.X, origin.Y - index);
|
||||
}
|
||||
return GenSearch.NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
public class Rectangle : GenSearch
|
||||
{
|
||||
private int _width;
|
||||
private int _height;
|
||||
|
||||
public Rectangle(int width, int height)
|
||||
{
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
}
|
||||
|
||||
public override Point Find(Point origin)
|
||||
{
|
||||
for (int index1 = 0; index1 < this._width; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < this._height; ++index2)
|
||||
{
|
||||
if (this.Check(origin.X + index1, origin.Y + index2))
|
||||
return new Point(origin.X + index1, origin.Y + index2);
|
||||
}
|
||||
}
|
||||
return GenSearch.NOT_FOUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
68
World/Generation/ShapeData.cs
Normal file
68
World/Generation/ShapeData.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.ShapeData
|
||||
// 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 System.Linq;
|
||||
using Terraria.DataStructures;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public class ShapeData
|
||||
{
|
||||
private HashSet<Point16> _points;
|
||||
|
||||
public int Count => this._points.Count;
|
||||
|
||||
public ShapeData() => this._points = new HashSet<Point16>();
|
||||
|
||||
public ShapeData(ShapeData original) => this._points = new HashSet<Point16>((IEnumerable<Point16>) original._points);
|
||||
|
||||
public void Add(int x, int y) => this._points.Add(new Point16(x, y));
|
||||
|
||||
public void Remove(int x, int y) => this._points.Remove(new Point16(x, y));
|
||||
|
||||
public HashSet<Point16> GetData() => this._points;
|
||||
|
||||
public void Clear() => this._points.Clear();
|
||||
|
||||
public bool Contains(int x, int y) => this._points.Contains(new Point16(x, y));
|
||||
|
||||
public void Add(ShapeData shapeData, Point localOrigin, Point remoteOrigin)
|
||||
{
|
||||
foreach (Point16 point16 in shapeData.GetData())
|
||||
this.Add(remoteOrigin.X - localOrigin.X + (int) point16.X, remoteOrigin.Y - localOrigin.Y + (int) point16.Y);
|
||||
}
|
||||
|
||||
public void Subtract(ShapeData shapeData, Point localOrigin, Point remoteOrigin)
|
||||
{
|
||||
foreach (Point16 point16 in shapeData.GetData())
|
||||
this.Remove(remoteOrigin.X - localOrigin.X + (int) point16.X, remoteOrigin.Y - localOrigin.Y + (int) point16.Y);
|
||||
}
|
||||
|
||||
public static Microsoft.Xna.Framework.Rectangle GetBounds(
|
||||
Point origin,
|
||||
params ShapeData[] shapes)
|
||||
{
|
||||
int val1_1 = (int) shapes[0]._points.First<Point16>().X;
|
||||
int val1_2 = val1_1;
|
||||
int val1_3 = (int) shapes[0]._points.First<Point16>().Y;
|
||||
int val1_4 = val1_3;
|
||||
for (int index = 0; index < shapes.Length; ++index)
|
||||
{
|
||||
foreach (Point16 point in shapes[index]._points)
|
||||
{
|
||||
val1_1 = Math.Max(val1_1, (int) point.X);
|
||||
val1_2 = Math.Min(val1_2, (int) point.X);
|
||||
val1_3 = Math.Max(val1_3, (int) point.Y);
|
||||
val1_4 = Math.Min(val1_4, (int) point.Y);
|
||||
}
|
||||
}
|
||||
return new Microsoft.Xna.Framework.Rectangle(val1_2 + origin.X, val1_4 + origin.Y, val1_1 - val1_2, val1_3 - val1_4);
|
||||
}
|
||||
}
|
||||
}
|
189
World/Generation/Shapes.cs
Normal file
189
World/Generation/Shapes.cs
Normal file
|
@ -0,0 +1,189 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.Shapes
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public static class Shapes
|
||||
{
|
||||
public class Circle : GenShape
|
||||
{
|
||||
private int _verticalRadius;
|
||||
private int _horizontalRadius;
|
||||
|
||||
public Circle(int radius)
|
||||
{
|
||||
this._verticalRadius = radius;
|
||||
this._horizontalRadius = radius;
|
||||
}
|
||||
|
||||
public Circle(int horizontalRadius, int verticalRadius)
|
||||
{
|
||||
this._horizontalRadius = horizontalRadius;
|
||||
this._verticalRadius = verticalRadius;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
int num1 = (this._horizontalRadius + 1) * (this._horizontalRadius + 1);
|
||||
for (int y = origin.Y - this._verticalRadius; y <= origin.Y + this._verticalRadius; ++y)
|
||||
{
|
||||
float num2 = (float) this._horizontalRadius / (float) this._verticalRadius * (float) (y - origin.Y);
|
||||
int num3 = Math.Min(this._horizontalRadius, (int) Math.Sqrt((double) num1 - (double) num2 * (double) num2));
|
||||
for (int x = origin.X - num3; x <= origin.X + num3; ++x)
|
||||
{
|
||||
if (!this.UnitApply(action, origin, x, y) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class HalfCircle : GenShape
|
||||
{
|
||||
private int _radius;
|
||||
|
||||
public HalfCircle(int radius) => this._radius = radius;
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
int num1 = (this._radius + 1) * (this._radius + 1);
|
||||
for (int y = origin.Y - this._radius; y <= origin.Y; ++y)
|
||||
{
|
||||
int num2 = Math.Min(this._radius, (int) Math.Sqrt((double) (num1 - (y - origin.Y) * (y - origin.Y))));
|
||||
for (int x = origin.X - num2; x <= origin.X + num2; ++x)
|
||||
{
|
||||
if (!this.UnitApply(action, origin, x, y) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class Slime : GenShape
|
||||
{
|
||||
private int _radius;
|
||||
private float _xScale;
|
||||
private float _yScale;
|
||||
|
||||
public Slime(int radius)
|
||||
{
|
||||
this._radius = radius;
|
||||
this._xScale = 1f;
|
||||
this._yScale = 1f;
|
||||
}
|
||||
|
||||
public Slime(int radius, float xScale, float yScale)
|
||||
{
|
||||
this._radius = radius;
|
||||
this._xScale = xScale;
|
||||
this._yScale = yScale;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
float radius = (float) this._radius;
|
||||
int num1 = (this._radius + 1) * (this._radius + 1);
|
||||
for (int y = origin.Y - (int) ((double) radius * (double) this._yScale); y <= origin.Y; ++y)
|
||||
{
|
||||
float num2 = (float) (y - origin.Y) / this._yScale;
|
||||
int num3 = (int) Math.Min((float) this._radius * this._xScale, this._xScale * (float) Math.Sqrt((double) num1 - (double) num2 * (double) num2));
|
||||
for (int x = origin.X - num3; x <= origin.X + num3; ++x)
|
||||
{
|
||||
if (!this.UnitApply(action, origin, x, y) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (int y = origin.Y + 1; y <= origin.Y + (int) ((double) radius * (double) this._yScale * 0.5) - 1; ++y)
|
||||
{
|
||||
float num4 = (float) (y - origin.Y) * (2f / this._yScale);
|
||||
int num5 = (int) Math.Min((float) this._radius * this._xScale, this._xScale * (float) Math.Sqrt((double) num1 - (double) num4 * (double) num4));
|
||||
for (int x = origin.X - num5; x <= origin.X + num5; ++x)
|
||||
{
|
||||
if (!this.UnitApply(action, origin, x, y) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class Rectangle : GenShape
|
||||
{
|
||||
private int _width;
|
||||
private int _height;
|
||||
|
||||
public Rectangle(int width, int height)
|
||||
{
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
for (int x = origin.X; x < origin.X + this._width; ++x)
|
||||
{
|
||||
for (int y = origin.Y; y < origin.Y + this._height; ++y)
|
||||
{
|
||||
if (!this.UnitApply(action, origin, x, y) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class Tail : GenShape
|
||||
{
|
||||
private float _width;
|
||||
private Vector2 _endOffset;
|
||||
|
||||
public Tail(float width, Vector2 endOffset)
|
||||
{
|
||||
this._width = width * 16f;
|
||||
this._endOffset = endOffset * 16f;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
Vector2 start = new Vector2((float) (origin.X << 4), (float) (origin.Y << 4));
|
||||
return Utils.PlotTileTale(start, start + this._endOffset, this._width, (Utils.PerLinePoint) ((x, y) => this.UnitApply(action, origin, x, y) || !this._quitOnFail));
|
||||
}
|
||||
}
|
||||
|
||||
public class Mound : GenShape
|
||||
{
|
||||
private int _halfWidth;
|
||||
private int _height;
|
||||
|
||||
public Mound(int halfWidth, int height)
|
||||
{
|
||||
this._halfWidth = halfWidth;
|
||||
this._height = height;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
int height = this._height;
|
||||
float halfWidth = (float) this._halfWidth;
|
||||
for (int index1 = -this._halfWidth; index1 <= this._halfWidth; ++index1)
|
||||
{
|
||||
int num = Math.Min(this._height, (int) (-((double) (this._height + 1) / ((double) halfWidth * (double) halfWidth)) * ((double) index1 + (double) halfWidth) * ((double) index1 - (double) halfWidth)));
|
||||
for (int index2 = 0; index2 < num; ++index2)
|
||||
{
|
||||
if (!this.UnitApply(action, origin, index1 + origin.X, origin.Y - index2) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
91
World/Generation/SimpleStructure.cs
Normal file
91
World/Generation/SimpleStructure.cs
Normal file
|
@ -0,0 +1,91 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.SimpleStructure
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public class SimpleStructure : GenStructure
|
||||
{
|
||||
private int[,] _data;
|
||||
private int _width;
|
||||
private int _height;
|
||||
private GenAction[] _actions;
|
||||
private bool _xMirror;
|
||||
private bool _yMirror;
|
||||
|
||||
public int Width => this._width;
|
||||
|
||||
public int Height => this._height;
|
||||
|
||||
public SimpleStructure(params string[] data) => this.ReadData(data);
|
||||
|
||||
public SimpleStructure(string data) => this.ReadData(data.Split('\n'));
|
||||
|
||||
private void ReadData(string[] lines)
|
||||
{
|
||||
this._height = lines.Length;
|
||||
this._width = lines[0].Length;
|
||||
this._data = new int[this._width, this._height];
|
||||
for (int index1 = 0; index1 < this._height; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < this._width; ++index2)
|
||||
{
|
||||
int num = (int) lines[index1][index2];
|
||||
switch (num)
|
||||
{
|
||||
case 48:
|
||||
case 49:
|
||||
case 50:
|
||||
case 51:
|
||||
case 52:
|
||||
case 53:
|
||||
case 54:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57:
|
||||
this._data[index2, index1] = num - 48;
|
||||
break;
|
||||
default:
|
||||
this._data[index2, index1] = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleStructure SetActions(params GenAction[] actions)
|
||||
{
|
||||
this._actions = actions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleStructure Mirror(bool horizontalMirror, bool verticalMirror)
|
||||
{
|
||||
this._xMirror = horizontalMirror;
|
||||
this._yMirror = verticalMirror;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X, origin.Y, this._width, this._height)))
|
||||
return false;
|
||||
for (int index1 = 0; index1 < this._width; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < this._height; ++index2)
|
||||
{
|
||||
int num1 = this._xMirror ? -index1 : index1;
|
||||
int num2 = this._yMirror ? -index2 : index2;
|
||||
if (this._data[index1, index2] != -1 && !this._actions[this._data[index1, index2]].Apply(origin, num1 + origin.X, num2 + origin.Y))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(origin.X, origin.Y, this._width, this._height));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
47
World/Generation/StructureMap.cs
Normal file
47
World/Generation/StructureMap.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.StructureMap
|
||||
// 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.Collections.Generic;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public class StructureMap
|
||||
{
|
||||
private List<Microsoft.Xna.Framework.Rectangle> _structures = new List<Microsoft.Xna.Framework.Rectangle>(2048);
|
||||
|
||||
public bool CanPlace(Microsoft.Xna.Framework.Rectangle area, int padding = 0) => this.CanPlace(area, TileID.Sets.GeneralPlacementTiles, padding);
|
||||
|
||||
public bool CanPlace(Microsoft.Xna.Framework.Rectangle area, bool[] validTiles, int padding = 0)
|
||||
{
|
||||
if (area.X < 0 || area.Y < 0 || area.X + area.Width > Main.maxTilesX - 1 || area.Y + area.Height > Main.maxTilesY - 1)
|
||||
return false;
|
||||
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(area.X - padding, area.Y - padding, area.Width + padding * 2, area.Height + padding * 2);
|
||||
for (int index = 0; index < this._structures.Count; ++index)
|
||||
{
|
||||
if (rectangle.Intersects(this._structures[index]))
|
||||
return false;
|
||||
}
|
||||
for (int x = rectangle.X; x < rectangle.X + rectangle.Width; ++x)
|
||||
{
|
||||
for (int y = rectangle.Y; y < rectangle.Y + rectangle.Height; ++y)
|
||||
{
|
||||
if (Main.tile[x, y].active())
|
||||
{
|
||||
ushort type = Main.tile[x, y].type;
|
||||
if (!validTiles[(int) type])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddStructure(Microsoft.Xna.Framework.Rectangle area, int padding = 0) => this._structures.Add(new Microsoft.Xna.Framework.Rectangle(area.X - padding, area.Y - padding, area.Width + padding * 2, area.Height + padding * 2));
|
||||
|
||||
public void Reset() => this._structures.Clear();
|
||||
}
|
||||
}
|
52
World/Generation/WorldGenerator.cs
Normal file
52
World/Generation/WorldGenerator.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.WorldGenerator
|
||||
// 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.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Terraria.GameContent.UI.States;
|
||||
using Terraria.UI;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public class WorldGenerator
|
||||
{
|
||||
private List<GenPass> _passes = new List<GenPass>();
|
||||
private float _totalLoadWeight;
|
||||
private int _seed;
|
||||
|
||||
public WorldGenerator(int seed) => this._seed = seed;
|
||||
|
||||
public void Append(GenPass pass)
|
||||
{
|
||||
this._passes.Add(pass);
|
||||
this._totalLoadWeight += pass.Weight;
|
||||
}
|
||||
|
||||
public void GenerateWorld(GenerationProgress progress = null)
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
float num = 0.0f;
|
||||
foreach (GenPass pass in this._passes)
|
||||
num += pass.Weight;
|
||||
if (progress == null)
|
||||
progress = new GenerationProgress();
|
||||
progress.TotalWeight = num;
|
||||
Main.menuMode = 888;
|
||||
Main.MenuUI.SetState((UIState) new UIWorldLoad(progress));
|
||||
foreach (GenPass pass in this._passes)
|
||||
{
|
||||
WorldGen._genRand = new UnifiedRandom(this._seed);
|
||||
Main.rand = new UnifiedRandom(this._seed);
|
||||
stopwatch.Start();
|
||||
progress.Start(pass.Weight);
|
||||
pass.Apply(progress);
|
||||
progress.End();
|
||||
stopwatch.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
105
World/Generation/WorldUtils.cs
Normal file
105
World/Generation/WorldUtils.cs
Normal file
|
@ -0,0 +1,105 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.World.Generation.WorldUtils
|
||||
// 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;
|
||||
|
||||
namespace Terraria.World.Generation
|
||||
{
|
||||
public static class WorldUtils
|
||||
{
|
||||
public static bool Gen(Point origin, GenShape shape, GenAction action) => shape.Perform(origin, action);
|
||||
|
||||
public static bool Find(Point origin, GenSearch search, out Point result)
|
||||
{
|
||||
result = search.Find(origin);
|
||||
return !(result == GenSearch.NOT_FOUND);
|
||||
}
|
||||
|
||||
public static void ClearTile(int x, int y, bool frameNeighbors = false)
|
||||
{
|
||||
Main.tile[x, y].ClearTile();
|
||||
if (!frameNeighbors)
|
||||
return;
|
||||
WorldGen.TileFrame(x + 1, y);
|
||||
WorldGen.TileFrame(x - 1, y);
|
||||
WorldGen.TileFrame(x, y + 1);
|
||||
WorldGen.TileFrame(x, y - 1);
|
||||
}
|
||||
|
||||
public static void ClearWall(int x, int y, bool frameNeighbors = false)
|
||||
{
|
||||
Main.tile[x, y].wall = (byte) 0;
|
||||
if (!frameNeighbors)
|
||||
return;
|
||||
WorldGen.SquareWallFrame(x + 1, y);
|
||||
WorldGen.SquareWallFrame(x - 1, y);
|
||||
WorldGen.SquareWallFrame(x, y + 1);
|
||||
WorldGen.SquareWallFrame(x, y - 1);
|
||||
}
|
||||
|
||||
public static void TileFrame(int x, int y, bool frameNeighbors = false)
|
||||
{
|
||||
WorldGen.TileFrame(x, y, true);
|
||||
if (!frameNeighbors)
|
||||
return;
|
||||
WorldGen.TileFrame(x + 1, y, true);
|
||||
WorldGen.TileFrame(x - 1, y, true);
|
||||
WorldGen.TileFrame(x, y + 1, true);
|
||||
WorldGen.TileFrame(x, y - 1, true);
|
||||
}
|
||||
|
||||
public static void ClearChestLocation(int x, int y)
|
||||
{
|
||||
WorldUtils.ClearTile(x, y, true);
|
||||
WorldUtils.ClearTile(x - 1, y, true);
|
||||
WorldUtils.ClearTile(x, y - 1, true);
|
||||
WorldUtils.ClearTile(x - 1, y - 1, true);
|
||||
}
|
||||
|
||||
public static void WireLine(Point start, Point end)
|
||||
{
|
||||
Point point1 = start;
|
||||
Point point2 = end;
|
||||
if (end.X < start.X)
|
||||
Utils.Swap<int>(ref end.X, ref start.X);
|
||||
if (end.Y < start.Y)
|
||||
Utils.Swap<int>(ref end.Y, ref start.Y);
|
||||
for (int x = start.X; x <= end.X; ++x)
|
||||
WorldGen.PlaceWire(x, point1.Y);
|
||||
for (int y = start.Y; y <= end.Y; ++y)
|
||||
WorldGen.PlaceWire(point2.X, y);
|
||||
}
|
||||
|
||||
public static void DebugRegen()
|
||||
{
|
||||
WorldGen.clearWorld();
|
||||
WorldGen.generateWorld(Main.ActiveWorldFileData.Seed);
|
||||
Main.NewText("World Regen Complete.");
|
||||
}
|
||||
|
||||
public static void DebugRotate()
|
||||
{
|
||||
int num1 = 0;
|
||||
int num2 = 0;
|
||||
int maxTilesY = Main.maxTilesY;
|
||||
for (int index1 = 0; index1 < Main.maxTilesX / Main.maxTilesY; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < maxTilesY / 2; ++index2)
|
||||
{
|
||||
for (int index3 = index2; index3 < maxTilesY - index2; ++index3)
|
||||
{
|
||||
Tile tile = Main.tile[index3 + num1, index2 + num2];
|
||||
Main.tile[index3 + num1, index2 + num2] = Main.tile[index2 + num1, maxTilesY - index3 + num2];
|
||||
Main.tile[index2 + num1, maxTilesY - index3 + num2] = Main.tile[maxTilesY - index3 + num1, maxTilesY - index2 + num2];
|
||||
Main.tile[maxTilesY - index3 + num1, maxTilesY - index2 + num2] = Main.tile[maxTilesY - index2 + num1, index3 + num2];
|
||||
Main.tile[maxTilesY - index2 + num1, index3 + num2] = tile;
|
||||
}
|
||||
}
|
||||
num1 += maxTilesY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue