Terraria 1.3.5.3 Source Code
This commit is contained in:
commit
4b21dac4b6
503 changed files with 409032 additions and 0 deletions
33
DataStructures/AnchorData.cs
Normal file
33
DataStructures/AnchorData.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.AnchorData
|
||||
// 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.Enums;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public struct AnchorData
|
||||
{
|
||||
public AnchorType type;
|
||||
public int tileCount;
|
||||
public int checkStart;
|
||||
public static AnchorData Empty;
|
||||
|
||||
public AnchorData(AnchorType type, int count, int start)
|
||||
{
|
||||
this.type = type;
|
||||
this.tileCount = count;
|
||||
this.checkStart = start;
|
||||
}
|
||||
|
||||
public static bool operator ==(AnchorData data1, AnchorData data2) => data1.type == data2.type && data1.tileCount == data2.tileCount && data1.checkStart == data2.checkStart;
|
||||
|
||||
public static bool operator !=(AnchorData data1, AnchorData data2) => data1.type != data2.type || data1.tileCount != data2.tileCount || data1.checkStart != data2.checkStart;
|
||||
|
||||
public override bool Equals(object obj) => obj is AnchorData anchorData && this.type == anchorData.type && this.tileCount == ((AnchorData) obj).tileCount && this.checkStart == ((AnchorData) obj).checkStart;
|
||||
|
||||
public override int GetHashCode() => (int) (ushort) this.type << 16 | (int) (byte) this.tileCount << 8 | (int) (byte) this.checkStart;
|
||||
}
|
||||
}
|
74
DataStructures/BufferPool.cs
Normal file
74
DataStructures/BufferPool.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.BufferPool
|
||||
// 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;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public static class BufferPool
|
||||
{
|
||||
private const int SMALL_BUFFER_SIZE = 32;
|
||||
private const int MEDIUM_BUFFER_SIZE = 256;
|
||||
private const int LARGE_BUFFER_SIZE = 16384;
|
||||
private static object bufferLock = new object();
|
||||
private static Queue<CachedBuffer> SmallBufferQueue = new Queue<CachedBuffer>();
|
||||
private static Queue<CachedBuffer> MediumBufferQueue = new Queue<CachedBuffer>();
|
||||
private static Queue<CachedBuffer> LargeBufferQueue = new Queue<CachedBuffer>();
|
||||
|
||||
public static CachedBuffer Request(int size)
|
||||
{
|
||||
lock (BufferPool.bufferLock)
|
||||
{
|
||||
if (size <= 32)
|
||||
return BufferPool.SmallBufferQueue.Count == 0 ? new CachedBuffer(new byte[32]) : BufferPool.SmallBufferQueue.Dequeue().Activate();
|
||||
if (size <= 256)
|
||||
return BufferPool.MediumBufferQueue.Count == 0 ? new CachedBuffer(new byte[256]) : BufferPool.MediumBufferQueue.Dequeue().Activate();
|
||||
if (size > 16384)
|
||||
return new CachedBuffer(new byte[size]);
|
||||
return BufferPool.LargeBufferQueue.Count == 0 ? new CachedBuffer(new byte[16384]) : BufferPool.LargeBufferQueue.Dequeue().Activate();
|
||||
}
|
||||
}
|
||||
|
||||
public static CachedBuffer Request(byte[] data, int offset, int size)
|
||||
{
|
||||
CachedBuffer cachedBuffer = BufferPool.Request(size);
|
||||
Buffer.BlockCopy((Array) data, offset, (Array) cachedBuffer.Data, 0, size);
|
||||
return cachedBuffer;
|
||||
}
|
||||
|
||||
public static void Recycle(CachedBuffer buffer)
|
||||
{
|
||||
int length = buffer.Length;
|
||||
lock (BufferPool.bufferLock)
|
||||
{
|
||||
if (length <= 32)
|
||||
BufferPool.SmallBufferQueue.Enqueue(buffer);
|
||||
else if (length <= 256)
|
||||
{
|
||||
BufferPool.MediumBufferQueue.Enqueue(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (length > 16384)
|
||||
return;
|
||||
BufferPool.LargeBufferQueue.Enqueue(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void PrintBufferSizes()
|
||||
{
|
||||
lock (BufferPool.bufferLock)
|
||||
{
|
||||
Console.WriteLine("SmallBufferQueue.Count: " + (object) BufferPool.SmallBufferQueue.Count);
|
||||
Console.WriteLine("MediumBufferQueue.Count: " + (object) BufferPool.MediumBufferQueue.Count);
|
||||
Console.WriteLine("LargeBufferQueue.Count: " + (object) BufferPool.LargeBufferQueue.Count);
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
46
DataStructures/CachedBuffer.cs
Normal file
46
DataStructures/CachedBuffer.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.CachedBuffer
|
||||
// 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.IO;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public class CachedBuffer
|
||||
{
|
||||
public readonly byte[] Data;
|
||||
public readonly BinaryWriter Writer;
|
||||
public readonly BinaryReader Reader;
|
||||
private readonly MemoryStream _memoryStream;
|
||||
private bool _isActive = true;
|
||||
|
||||
public int Length => this.Data.Length;
|
||||
|
||||
public bool IsActive => this._isActive;
|
||||
|
||||
public CachedBuffer(byte[] data)
|
||||
{
|
||||
this.Data = data;
|
||||
this._memoryStream = new MemoryStream(data);
|
||||
this.Writer = new BinaryWriter((Stream) this._memoryStream);
|
||||
this.Reader = new BinaryReader((Stream) this._memoryStream);
|
||||
}
|
||||
|
||||
internal CachedBuffer Activate()
|
||||
{
|
||||
this._isActive = true;
|
||||
this._memoryStream.Position = 0L;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Recycle()
|
||||
{
|
||||
if (!this._isActive)
|
||||
return;
|
||||
this._isActive = false;
|
||||
BufferPool.Recycle(this);
|
||||
}
|
||||
}
|
||||
}
|
50
DataStructures/ColorSlidersSet.cs
Normal file
50
DataStructures/ColorSlidersSet.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.ColorSlidersSet
|
||||
// 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.DataStructures
|
||||
{
|
||||
public class ColorSlidersSet
|
||||
{
|
||||
public float Hue;
|
||||
public float Saturation;
|
||||
public float Luminance;
|
||||
public float Alpha = 1f;
|
||||
|
||||
public void SetHSL(Color color)
|
||||
{
|
||||
Vector3 hsl = Main.rgbToHsl(color);
|
||||
this.Hue = hsl.X;
|
||||
this.Saturation = hsl.Y;
|
||||
this.Luminance = hsl.Z;
|
||||
}
|
||||
|
||||
public void SetHSL(Vector3 vector)
|
||||
{
|
||||
this.Hue = vector.X;
|
||||
this.Saturation = vector.Y;
|
||||
this.Luminance = vector.Z;
|
||||
}
|
||||
|
||||
public Color GetColor()
|
||||
{
|
||||
Color rgb = Main.hslToRgb(this.Hue, this.Saturation, this.Luminance);
|
||||
rgb.A = (byte) ((double) this.Alpha * (double) byte.MaxValue);
|
||||
return rgb;
|
||||
}
|
||||
|
||||
public Vector3 GetHSLVector() => new Vector3(this.Hue, this.Saturation, this.Luminance);
|
||||
|
||||
public void ApplyToMainLegacyBars()
|
||||
{
|
||||
Main.hBar = this.Hue;
|
||||
Main.sBar = this.Saturation;
|
||||
Main.lBar = this.Luminance;
|
||||
Main.aBar = this.Alpha;
|
||||
}
|
||||
}
|
||||
}
|
149
DataStructures/DoubleStack`1.cs
Normal file
149
DataStructures/DoubleStack`1.cs
Normal file
|
@ -0,0 +1,149 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.DoubleStack`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 System;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public class DoubleStack<T1>
|
||||
{
|
||||
private T1[][] _segmentList;
|
||||
private readonly int _segmentSize;
|
||||
private int _segmentCount;
|
||||
private readonly int _segmentShiftPosition;
|
||||
private int _start;
|
||||
private int _end;
|
||||
private int _size;
|
||||
private int _last;
|
||||
|
||||
public DoubleStack(int segmentSize = 1024, int initialSize = 0)
|
||||
{
|
||||
if (segmentSize < 16)
|
||||
segmentSize = 16;
|
||||
this._start = segmentSize / 2;
|
||||
this._end = this._start;
|
||||
this._size = 0;
|
||||
this._segmentShiftPosition = segmentSize + this._start;
|
||||
initialSize += this._start;
|
||||
int length = initialSize / segmentSize + 1;
|
||||
this._segmentList = new T1[length][];
|
||||
for (int index = 0; index < length; ++index)
|
||||
this._segmentList[index] = new T1[segmentSize];
|
||||
this._segmentSize = segmentSize;
|
||||
this._segmentCount = length;
|
||||
this._last = this._segmentSize * this._segmentCount - 1;
|
||||
}
|
||||
|
||||
public void PushFront(T1 front)
|
||||
{
|
||||
if (this._start == 0)
|
||||
{
|
||||
T1[][] objArray = new T1[this._segmentCount + 1][];
|
||||
for (int index = 0; index < this._segmentCount; ++index)
|
||||
objArray[index + 1] = this._segmentList[index];
|
||||
objArray[0] = new T1[this._segmentSize];
|
||||
this._segmentList = objArray;
|
||||
++this._segmentCount;
|
||||
this._start += this._segmentSize;
|
||||
this._end += this._segmentSize;
|
||||
this._last += this._segmentSize;
|
||||
}
|
||||
--this._start;
|
||||
this._segmentList[this._start / this._segmentSize][this._start % this._segmentSize] = front;
|
||||
++this._size;
|
||||
}
|
||||
|
||||
public T1 PopFront()
|
||||
{
|
||||
if (this._size == 0)
|
||||
throw new InvalidOperationException("The DoubleStack is empty.");
|
||||
T1[] segment1 = this._segmentList[this._start / this._segmentSize];
|
||||
int index1 = this._start % this._segmentSize;
|
||||
T1 obj = segment1[index1];
|
||||
segment1[index1] = default (T1);
|
||||
++this._start;
|
||||
--this._size;
|
||||
if (this._start >= this._segmentShiftPosition)
|
||||
{
|
||||
T1[] segment2 = this._segmentList[0];
|
||||
for (int index2 = 0; index2 < this._segmentCount - 1; ++index2)
|
||||
this._segmentList[index2] = this._segmentList[index2 + 1];
|
||||
this._segmentList[this._segmentCount - 1] = segment2;
|
||||
this._start -= this._segmentSize;
|
||||
this._end -= this._segmentSize;
|
||||
}
|
||||
if (this._size == 0)
|
||||
{
|
||||
this._start = this._segmentSize / 2;
|
||||
this._end = this._start;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
public T1 PeekFront()
|
||||
{
|
||||
if (this._size == 0)
|
||||
throw new InvalidOperationException("The DoubleStack is empty.");
|
||||
return this._segmentList[this._start / this._segmentSize][this._start % this._segmentSize];
|
||||
}
|
||||
|
||||
public void PushBack(T1 back)
|
||||
{
|
||||
if (this._end == this._last)
|
||||
{
|
||||
T1[][] objArray = new T1[this._segmentCount + 1][];
|
||||
for (int index = 0; index < this._segmentCount; ++index)
|
||||
objArray[index] = this._segmentList[index];
|
||||
objArray[this._segmentCount] = new T1[this._segmentSize];
|
||||
++this._segmentCount;
|
||||
this._segmentList = objArray;
|
||||
this._last += this._segmentSize;
|
||||
}
|
||||
this._segmentList[this._end / this._segmentSize][this._end % this._segmentSize] = back;
|
||||
++this._end;
|
||||
++this._size;
|
||||
}
|
||||
|
||||
public T1 PopBack()
|
||||
{
|
||||
if (this._size == 0)
|
||||
throw new InvalidOperationException("The DoubleStack is empty.");
|
||||
T1[] segment = this._segmentList[this._end / this._segmentSize];
|
||||
int index = this._end % this._segmentSize;
|
||||
T1 obj = segment[index];
|
||||
segment[index] = default (T1);
|
||||
--this._end;
|
||||
--this._size;
|
||||
if (this._size == 0)
|
||||
{
|
||||
this._start = this._segmentSize / 2;
|
||||
this._end = this._start;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
public T1 PeekBack()
|
||||
{
|
||||
if (this._size == 0)
|
||||
throw new InvalidOperationException("The DoubleStack is empty.");
|
||||
return this._segmentList[this._end / this._segmentSize][this._end % this._segmentSize];
|
||||
}
|
||||
|
||||
public void Clear(bool quickClear = false)
|
||||
{
|
||||
if (!quickClear)
|
||||
{
|
||||
for (int index = 0; index < this._segmentCount; ++index)
|
||||
Array.Clear((Array) this._segmentList[index], 0, this._segmentSize);
|
||||
}
|
||||
this._start = this._segmentSize / 2;
|
||||
this._end = this._start;
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
public int Count => this._size;
|
||||
}
|
||||
}
|
25
DataStructures/DrawAnimation.cs
Normal file
25
DataStructures/DrawAnimation.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.DrawAnimation
|
||||
// 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;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public class DrawAnimation
|
||||
{
|
||||
public int Frame;
|
||||
public int FrameCount;
|
||||
public int TicksPerFrame;
|
||||
public int FrameCounter;
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual Rectangle GetFrame(Texture2D texture) => texture.Frame();
|
||||
}
|
||||
}
|
34
DataStructures/DrawAnimationVertical.cs
Normal file
34
DataStructures/DrawAnimationVertical.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.DrawAnimationVertical
|
||||
// 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;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public class DrawAnimationVertical : DrawAnimation
|
||||
{
|
||||
public DrawAnimationVertical(int ticksperframe, int frameCount)
|
||||
{
|
||||
this.Frame = 0;
|
||||
this.FrameCounter = 0;
|
||||
this.FrameCount = frameCount;
|
||||
this.TicksPerFrame = ticksperframe;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (++this.FrameCounter < this.TicksPerFrame)
|
||||
return;
|
||||
this.FrameCounter = 0;
|
||||
if (++this.Frame < this.FrameCount)
|
||||
return;
|
||||
this.Frame = 0;
|
||||
}
|
||||
|
||||
public override Rectangle GetFrame(Texture2D texture) => texture.Frame(verticalFrames: this.FrameCount, frameY: this.Frame);
|
||||
}
|
||||
}
|
178
DataStructures/DrawData.cs
Normal file
178
DataStructures/DrawData.cs
Normal file
|
@ -0,0 +1,178 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.DrawData
|
||||
// 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;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public struct DrawData
|
||||
{
|
||||
public Texture2D texture;
|
||||
public Vector2 position;
|
||||
public Rectangle destinationRectangle;
|
||||
public Rectangle? sourceRect;
|
||||
public Color color;
|
||||
public float rotation;
|
||||
public Vector2 origin;
|
||||
public Vector2 scale;
|
||||
public SpriteEffects effect;
|
||||
public int shader;
|
||||
public bool ignorePlayerRotation;
|
||||
public readonly bool useDestinationRectangle;
|
||||
public static Rectangle? nullRectangle;
|
||||
|
||||
public DrawData(Texture2D texture, Vector2 position, Color color)
|
||||
{
|
||||
this.texture = texture;
|
||||
this.position = position;
|
||||
this.color = color;
|
||||
this.destinationRectangle = new Rectangle();
|
||||
this.sourceRect = DrawData.nullRectangle;
|
||||
this.rotation = 0.0f;
|
||||
this.origin = Vector2.Zero;
|
||||
this.scale = Vector2.One;
|
||||
this.effect = SpriteEffects.None;
|
||||
this.shader = 0;
|
||||
this.ignorePlayerRotation = false;
|
||||
this.useDestinationRectangle = false;
|
||||
}
|
||||
|
||||
public DrawData(Texture2D texture, Vector2 position, Rectangle? sourceRect, Color color)
|
||||
{
|
||||
this.texture = texture;
|
||||
this.position = position;
|
||||
this.color = color;
|
||||
this.destinationRectangle = new Rectangle();
|
||||
this.sourceRect = sourceRect;
|
||||
this.rotation = 0.0f;
|
||||
this.origin = Vector2.Zero;
|
||||
this.scale = Vector2.One;
|
||||
this.effect = SpriteEffects.None;
|
||||
this.shader = 0;
|
||||
this.ignorePlayerRotation = false;
|
||||
this.useDestinationRectangle = false;
|
||||
}
|
||||
|
||||
public DrawData(
|
||||
Texture2D texture,
|
||||
Vector2 position,
|
||||
Rectangle? sourceRect,
|
||||
Color color,
|
||||
float rotation,
|
||||
Vector2 origin,
|
||||
float scale,
|
||||
SpriteEffects effect,
|
||||
int inactiveLayerDepth)
|
||||
{
|
||||
this.texture = texture;
|
||||
this.position = position;
|
||||
this.sourceRect = sourceRect;
|
||||
this.color = color;
|
||||
this.rotation = rotation;
|
||||
this.origin = origin;
|
||||
this.scale = new Vector2(scale, scale);
|
||||
this.effect = effect;
|
||||
this.destinationRectangle = new Rectangle();
|
||||
this.shader = 0;
|
||||
this.ignorePlayerRotation = false;
|
||||
this.useDestinationRectangle = false;
|
||||
}
|
||||
|
||||
public DrawData(
|
||||
Texture2D texture,
|
||||
Vector2 position,
|
||||
Rectangle? sourceRect,
|
||||
Color color,
|
||||
float rotation,
|
||||
Vector2 origin,
|
||||
Vector2 scale,
|
||||
SpriteEffects effect,
|
||||
int inactiveLayerDepth)
|
||||
{
|
||||
this.texture = texture;
|
||||
this.position = position;
|
||||
this.sourceRect = sourceRect;
|
||||
this.color = color;
|
||||
this.rotation = rotation;
|
||||
this.origin = origin;
|
||||
this.scale = scale;
|
||||
this.effect = effect;
|
||||
this.destinationRectangle = new Rectangle();
|
||||
this.shader = 0;
|
||||
this.ignorePlayerRotation = false;
|
||||
this.useDestinationRectangle = false;
|
||||
}
|
||||
|
||||
public DrawData(Texture2D texture, Rectangle destinationRectangle, Color color)
|
||||
{
|
||||
this.texture = texture;
|
||||
this.destinationRectangle = destinationRectangle;
|
||||
this.color = color;
|
||||
this.position = Vector2.Zero;
|
||||
this.sourceRect = DrawData.nullRectangle;
|
||||
this.rotation = 0.0f;
|
||||
this.origin = Vector2.Zero;
|
||||
this.scale = Vector2.One;
|
||||
this.effect = SpriteEffects.None;
|
||||
this.shader = 0;
|
||||
this.ignorePlayerRotation = false;
|
||||
this.useDestinationRectangle = false;
|
||||
}
|
||||
|
||||
public DrawData(
|
||||
Texture2D texture,
|
||||
Rectangle destinationRectangle,
|
||||
Rectangle? sourceRect,
|
||||
Color color)
|
||||
{
|
||||
this.texture = texture;
|
||||
this.destinationRectangle = destinationRectangle;
|
||||
this.color = color;
|
||||
this.position = Vector2.Zero;
|
||||
this.sourceRect = sourceRect;
|
||||
this.rotation = 0.0f;
|
||||
this.origin = Vector2.Zero;
|
||||
this.scale = Vector2.One;
|
||||
this.effect = SpriteEffects.None;
|
||||
this.shader = 0;
|
||||
this.ignorePlayerRotation = false;
|
||||
this.useDestinationRectangle = false;
|
||||
}
|
||||
|
||||
public DrawData(
|
||||
Texture2D texture,
|
||||
Rectangle destinationRectangle,
|
||||
Rectangle? sourceRect,
|
||||
Color color,
|
||||
float rotation,
|
||||
Vector2 origin,
|
||||
SpriteEffects effect,
|
||||
int inactiveLayerDepth)
|
||||
{
|
||||
this.texture = texture;
|
||||
this.destinationRectangle = destinationRectangle;
|
||||
this.sourceRect = sourceRect;
|
||||
this.color = color;
|
||||
this.rotation = rotation;
|
||||
this.origin = origin;
|
||||
this.effect = effect;
|
||||
this.position = Vector2.Zero;
|
||||
this.scale = Vector2.One;
|
||||
this.shader = 0;
|
||||
this.ignorePlayerRotation = false;
|
||||
this.useDestinationRectangle = false;
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch sb)
|
||||
{
|
||||
if (this.useDestinationRectangle)
|
||||
sb.Draw(this.texture, this.destinationRectangle, this.sourceRect, this.color, this.rotation, this.origin, this.effect, 0.0f);
|
||||
else
|
||||
sb.Draw(this.texture, this.position, this.sourceRect, this.color, this.rotation, this.origin, this.scale, this.effect, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
22
DataStructures/DrillDebugDraw.cs
Normal file
22
DataStructures/DrillDebugDraw.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.DrillDebugDraw
|
||||
// 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.DataStructures
|
||||
{
|
||||
public struct DrillDebugDraw
|
||||
{
|
||||
public Vector2 point;
|
||||
public Color color;
|
||||
|
||||
public DrillDebugDraw(Vector2 p, Color c)
|
||||
{
|
||||
this.point = p;
|
||||
this.color = c;
|
||||
}
|
||||
}
|
||||
}
|
46
DataStructures/MethodSequenceListItem.cs
Normal file
46
DataStructures/MethodSequenceListItem.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.MethodSequenceListItem
|
||||
// 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;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public class MethodSequenceListItem
|
||||
{
|
||||
public string Name;
|
||||
public MethodSequenceListItem Parent;
|
||||
public Func<bool> Method;
|
||||
public bool Skip;
|
||||
|
||||
public MethodSequenceListItem(string name, Func<bool> method, MethodSequenceListItem parent = null)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Method = method;
|
||||
this.Parent = parent;
|
||||
}
|
||||
|
||||
public bool ShouldAct(List<MethodSequenceListItem> sequence)
|
||||
{
|
||||
if (this.Skip || !sequence.Contains(this))
|
||||
return false;
|
||||
return this.Parent == null || this.Parent.ShouldAct(sequence);
|
||||
}
|
||||
|
||||
public bool Act() => this.Method();
|
||||
|
||||
public static void ExecuteSequence(List<MethodSequenceListItem> sequence)
|
||||
{
|
||||
foreach (MethodSequenceListItem sequenceListItem in sequence)
|
||||
{
|
||||
if (sequenceListItem.ShouldAct(sequence) && !sequenceListItem.Act())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() => "name: " + this.Name + " skip: " + this.Skip.ToString() + " parent: " + (object) this.Parent;
|
||||
}
|
||||
}
|
56
DataStructures/NPCAimedTarget.cs
Normal file
56
DataStructures/NPCAimedTarget.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.NPCAimedTarget
|
||||
// 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.Enums;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public struct NPCAimedTarget
|
||||
{
|
||||
public NPCTargetType Type;
|
||||
public Rectangle Hitbox;
|
||||
public int Width;
|
||||
public int Height;
|
||||
public Vector2 Position;
|
||||
public Vector2 Velocity;
|
||||
|
||||
public bool Invalid => this.Type == NPCTargetType.None;
|
||||
|
||||
public Vector2 Center => this.Position + this.Size / 2f;
|
||||
|
||||
public Vector2 Size => new Vector2((float) this.Width, (float) this.Height);
|
||||
|
||||
public NPCAimedTarget(NPC npc)
|
||||
{
|
||||
this.Type = NPCTargetType.NPC;
|
||||
this.Hitbox = npc.Hitbox;
|
||||
this.Width = npc.width;
|
||||
this.Height = npc.height;
|
||||
this.Position = npc.position;
|
||||
this.Velocity = npc.velocity;
|
||||
}
|
||||
|
||||
public NPCAimedTarget(Player player, bool ignoreTank = true)
|
||||
{
|
||||
this.Type = NPCTargetType.Player;
|
||||
this.Hitbox = player.Hitbox;
|
||||
this.Width = player.width;
|
||||
this.Height = player.height;
|
||||
this.Position = player.position;
|
||||
this.Velocity = player.velocity;
|
||||
if (ignoreTank || player.tankPet <= -1)
|
||||
return;
|
||||
Projectile projectile = Main.projectile[player.tankPet];
|
||||
this.Type = NPCTargetType.PlayerTankPet;
|
||||
this.Hitbox = projectile.Hitbox;
|
||||
this.Width = projectile.width;
|
||||
this.Height = projectile.height;
|
||||
this.Position = projectile.position;
|
||||
this.Velocity = projectile.velocity;
|
||||
}
|
||||
}
|
||||
}
|
40
DataStructures/PlacementHook.cs
Normal file
40
DataStructures/PlacementHook.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.PlacementHook
|
||||
// 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;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public struct PlacementHook
|
||||
{
|
||||
public Func<int, int, int, int, int, int> hook;
|
||||
public int badReturn;
|
||||
public int badResponse;
|
||||
public bool processedCoordinates;
|
||||
public static PlacementHook Empty = new PlacementHook((Func<int, int, int, int, int, int>) null, 0, 0, false);
|
||||
public const int Response_AllInvalid = 0;
|
||||
|
||||
public PlacementHook(
|
||||
Func<int, int, int, int, int, int> hook,
|
||||
int badReturn,
|
||||
int badResponse,
|
||||
bool processedCoordinates)
|
||||
{
|
||||
this.hook = hook;
|
||||
this.badResponse = badResponse;
|
||||
this.badReturn = badReturn;
|
||||
this.processedCoordinates = processedCoordinates;
|
||||
}
|
||||
|
||||
public static bool operator ==(PlacementHook first, PlacementHook second) => first.hook == second.hook && first.badResponse == second.badResponse && first.badReturn == second.badReturn && first.processedCoordinates == second.processedCoordinates;
|
||||
|
||||
public static bool operator !=(PlacementHook first, PlacementHook second) => first.hook != second.hook || first.badResponse != second.badResponse || first.badReturn != second.badReturn || first.processedCoordinates != second.processedCoordinates;
|
||||
|
||||
public override bool Equals(object obj) => obj is PlacementHook placementHook && this == placementHook;
|
||||
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
}
|
||||
}
|
129
DataStructures/PlayerDeathReason.cs
Normal file
129
DataStructures/PlayerDeathReason.cs
Normal file
|
@ -0,0 +1,129 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.PlayerDeathReason
|
||||
// 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.IO;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public class PlayerDeathReason
|
||||
{
|
||||
private int SourcePlayerIndex = -1;
|
||||
private int SourceNPCIndex = -1;
|
||||
private int SourceProjectileIndex = -1;
|
||||
private int SourceOtherIndex = -1;
|
||||
private int SourceProjectileType;
|
||||
private int SourceItemType;
|
||||
private int SourceItemPrefix;
|
||||
private string SourceCustomReason;
|
||||
|
||||
public static PlayerDeathReason LegacyEmpty() => new PlayerDeathReason()
|
||||
{
|
||||
SourceOtherIndex = 254
|
||||
};
|
||||
|
||||
public static PlayerDeathReason LegacyDefault() => new PlayerDeathReason()
|
||||
{
|
||||
SourceOtherIndex = (int) byte.MaxValue
|
||||
};
|
||||
|
||||
public static PlayerDeathReason ByNPC(int index) => new PlayerDeathReason()
|
||||
{
|
||||
SourceNPCIndex = index
|
||||
};
|
||||
|
||||
public static PlayerDeathReason ByCustomReason(string reasonInEnglish) => new PlayerDeathReason()
|
||||
{
|
||||
SourceCustomReason = reasonInEnglish
|
||||
};
|
||||
|
||||
public static PlayerDeathReason ByPlayer(int index) => new PlayerDeathReason()
|
||||
{
|
||||
SourcePlayerIndex = index,
|
||||
SourceItemType = Main.player[index].inventory[Main.player[index].selectedItem].type,
|
||||
SourceItemPrefix = (int) Main.player[index].inventory[Main.player[index].selectedItem].prefix
|
||||
};
|
||||
|
||||
public static PlayerDeathReason ByOther(int type) => new PlayerDeathReason()
|
||||
{
|
||||
SourceOtherIndex = type
|
||||
};
|
||||
|
||||
public static PlayerDeathReason ByProjectile(
|
||||
int playerIndex,
|
||||
int projectileIndex)
|
||||
{
|
||||
PlayerDeathReason playerDeathReason = new PlayerDeathReason()
|
||||
{
|
||||
SourcePlayerIndex = playerIndex,
|
||||
SourceProjectileIndex = projectileIndex,
|
||||
SourceProjectileType = Main.projectile[projectileIndex].type
|
||||
};
|
||||
if (playerIndex >= 0 && playerIndex <= (int) byte.MaxValue)
|
||||
{
|
||||
playerDeathReason.SourceItemType = Main.player[playerIndex].inventory[Main.player[playerIndex].selectedItem].type;
|
||||
playerDeathReason.SourceItemPrefix = (int) Main.player[playerIndex].inventory[Main.player[playerIndex].selectedItem].prefix;
|
||||
}
|
||||
return playerDeathReason;
|
||||
}
|
||||
|
||||
public NetworkText GetDeathText(string deadPlayerName) => this.SourceCustomReason != null ? NetworkText.FromLiteral(this.SourceCustomReason) : Lang.CreateDeathMessage(deadPlayerName, this.SourcePlayerIndex, this.SourceNPCIndex, this.SourceProjectileIndex, this.SourceOtherIndex, this.SourceProjectileType, this.SourceItemType);
|
||||
|
||||
public void WriteSelfTo(BinaryWriter writer)
|
||||
{
|
||||
BitsByte bitsByte = (BitsByte) (byte) 0;
|
||||
bitsByte[0] = this.SourcePlayerIndex != -1;
|
||||
bitsByte[1] = this.SourceNPCIndex != -1;
|
||||
bitsByte[2] = this.SourceProjectileIndex != -1;
|
||||
bitsByte[3] = this.SourceOtherIndex != -1;
|
||||
bitsByte[4] = (uint) this.SourceProjectileType > 0U;
|
||||
bitsByte[5] = (uint) this.SourceItemType > 0U;
|
||||
bitsByte[6] = (uint) this.SourceItemPrefix > 0U;
|
||||
bitsByte[7] = this.SourceCustomReason != null;
|
||||
writer.Write((byte) bitsByte);
|
||||
if (bitsByte[0])
|
||||
writer.Write((short) this.SourcePlayerIndex);
|
||||
if (bitsByte[1])
|
||||
writer.Write((short) this.SourceNPCIndex);
|
||||
if (bitsByte[2])
|
||||
writer.Write((short) this.SourceProjectileIndex);
|
||||
if (bitsByte[3])
|
||||
writer.Write((byte) this.SourceOtherIndex);
|
||||
if (bitsByte[4])
|
||||
writer.Write((short) this.SourceProjectileType);
|
||||
if (bitsByte[5])
|
||||
writer.Write((short) this.SourceItemType);
|
||||
if (bitsByte[6])
|
||||
writer.Write((byte) this.SourceItemPrefix);
|
||||
if (!bitsByte[7])
|
||||
return;
|
||||
writer.Write(this.SourceCustomReason);
|
||||
}
|
||||
|
||||
public static PlayerDeathReason FromReader(BinaryReader reader)
|
||||
{
|
||||
PlayerDeathReason playerDeathReason = new PlayerDeathReason();
|
||||
BitsByte bitsByte = (BitsByte) reader.ReadByte();
|
||||
if (bitsByte[0])
|
||||
playerDeathReason.SourcePlayerIndex = (int) reader.ReadInt16();
|
||||
if (bitsByte[1])
|
||||
playerDeathReason.SourceNPCIndex = (int) reader.ReadInt16();
|
||||
if (bitsByte[2])
|
||||
playerDeathReason.SourceProjectileIndex = (int) reader.ReadInt16();
|
||||
if (bitsByte[3])
|
||||
playerDeathReason.SourceOtherIndex = (int) reader.ReadByte();
|
||||
if (bitsByte[4])
|
||||
playerDeathReason.SourceProjectileType = (int) reader.ReadInt16();
|
||||
if (bitsByte[5])
|
||||
playerDeathReason.SourceItemType = (int) reader.ReadInt16();
|
||||
if (bitsByte[6])
|
||||
playerDeathReason.SourceItemPrefix = (int) reader.ReadByte();
|
||||
if (bitsByte[7])
|
||||
playerDeathReason.SourceCustomReason = reader.ReadString();
|
||||
return playerDeathReason;
|
||||
}
|
||||
}
|
||||
}
|
56
DataStructures/Point16.cs
Normal file
56
DataStructures/Point16.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.Point16
|
||||
// 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.DataStructures
|
||||
{
|
||||
public struct Point16
|
||||
{
|
||||
public readonly short X;
|
||||
public readonly short Y;
|
||||
public static Point16 Zero = new Point16(0, 0);
|
||||
public static Point16 NegativeOne = new Point16(-1, -1);
|
||||
|
||||
public Point16(Point point)
|
||||
{
|
||||
this.X = (short) point.X;
|
||||
this.Y = (short) point.Y;
|
||||
}
|
||||
|
||||
public Point16(int X, int Y)
|
||||
{
|
||||
this.X = (short) X;
|
||||
this.Y = (short) Y;
|
||||
}
|
||||
|
||||
public Point16(short X, short Y)
|
||||
{
|
||||
this.X = X;
|
||||
this.Y = Y;
|
||||
}
|
||||
|
||||
public static Point16 Max(int firstX, int firstY, int secondX, int secondY) => new Point16(firstX > secondX ? firstX : secondX, firstY > secondY ? firstY : secondY);
|
||||
|
||||
public Point16 Max(int compareX, int compareY) => new Point16((int) this.X > compareX ? (int) this.X : compareX, (int) this.Y > compareY ? (int) this.Y : compareY);
|
||||
|
||||
public Point16 Max(Point16 compareTo) => new Point16((int) this.X > (int) compareTo.X ? this.X : compareTo.X, (int) this.Y > (int) compareTo.Y ? this.Y : compareTo.Y);
|
||||
|
||||
public static bool operator ==(Point16 first, Point16 second) => (int) first.X == (int) second.X && (int) first.Y == (int) second.Y;
|
||||
|
||||
public static bool operator !=(Point16 first, Point16 second) => (int) first.X != (int) second.X || (int) first.Y != (int) second.Y;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
Point16 point16 = (Point16) obj;
|
||||
return (int) this.X == (int) point16.X && (int) this.Y == (int) point16.Y;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => (int) this.X << 16 | (int) (ushort) this.Y;
|
||||
|
||||
public override string ToString() => string.Format("{{{0}, {1}}}", (object) this.X, (object) this.Y);
|
||||
}
|
||||
}
|
15
DataStructures/SoundPlaySet.cs
Normal file
15
DataStructures/SoundPlaySet.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.SoundPlaySet
|
||||
// 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.DataStructures
|
||||
{
|
||||
public class SoundPlaySet
|
||||
{
|
||||
public int IntendedCooldown;
|
||||
public int SoundType;
|
||||
public int SoundStyle;
|
||||
}
|
||||
}
|
123
DataStructures/TileEntity.cs
Normal file
123
DataStructures/TileEntity.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.TileEntity
|
||||
// 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.IO;
|
||||
using Terraria.GameContent.Tile_Entities;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public abstract class TileEntity
|
||||
{
|
||||
public const int MaxEntitiesPerChunk = 1000;
|
||||
public static Dictionary<int, TileEntity> ByID = new Dictionary<int, TileEntity>();
|
||||
public static Dictionary<Point16, TileEntity> ByPosition = new Dictionary<Point16, TileEntity>();
|
||||
public static int TileEntitiesNextID = 0;
|
||||
public int ID;
|
||||
public Point16 Position;
|
||||
public byte type;
|
||||
|
||||
public static int AssignNewID() => TileEntity.TileEntitiesNextID++;
|
||||
|
||||
public static event Action _UpdateStart;
|
||||
|
||||
public static event Action _UpdateEnd;
|
||||
|
||||
public static event Action<int, int, int> _NetPlaceEntity;
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
TileEntity.ByID.Clear();
|
||||
TileEntity.ByPosition.Clear();
|
||||
TileEntity.TileEntitiesNextID = 0;
|
||||
}
|
||||
|
||||
public static void UpdateStart()
|
||||
{
|
||||
if (TileEntity._UpdateStart == null)
|
||||
return;
|
||||
TileEntity._UpdateStart();
|
||||
}
|
||||
|
||||
public static void UpdateEnd()
|
||||
{
|
||||
if (TileEntity._UpdateEnd == null)
|
||||
return;
|
||||
TileEntity._UpdateEnd();
|
||||
}
|
||||
|
||||
public static void InitializeAll()
|
||||
{
|
||||
TETrainingDummy.Initialize();
|
||||
TEItemFrame.Initialize();
|
||||
TELogicSensor.Initialize();
|
||||
}
|
||||
|
||||
public static void PlaceEntityNet(int x, int y, int type)
|
||||
{
|
||||
if (!WorldGen.InWorld(x, y) || TileEntity.ByPosition.ContainsKey(new Point16(x, y)) || TileEntity._NetPlaceEntity == null)
|
||||
return;
|
||||
TileEntity._NetPlaceEntity(x, y, type);
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Write(BinaryWriter writer, TileEntity ent, bool networkSend = false)
|
||||
{
|
||||
writer.Write(ent.type);
|
||||
ent.WriteInner(writer, networkSend);
|
||||
}
|
||||
|
||||
public static TileEntity Read(BinaryReader reader, bool networkSend = false)
|
||||
{
|
||||
TileEntity tileEntity = (TileEntity) null;
|
||||
byte num = reader.ReadByte();
|
||||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
tileEntity = (TileEntity) new TETrainingDummy();
|
||||
break;
|
||||
case 1:
|
||||
tileEntity = (TileEntity) new TEItemFrame();
|
||||
break;
|
||||
case 2:
|
||||
tileEntity = (TileEntity) new TELogicSensor();
|
||||
break;
|
||||
}
|
||||
tileEntity.type = num;
|
||||
tileEntity.ReadInner(reader, networkSend);
|
||||
return tileEntity;
|
||||
}
|
||||
|
||||
private void WriteInner(BinaryWriter writer, bool networkSend)
|
||||
{
|
||||
if (!networkSend)
|
||||
writer.Write(this.ID);
|
||||
writer.Write(this.Position.X);
|
||||
writer.Write(this.Position.Y);
|
||||
this.WriteExtraData(writer, networkSend);
|
||||
}
|
||||
|
||||
private void ReadInner(BinaryReader reader, bool networkSend)
|
||||
{
|
||||
if (!networkSend)
|
||||
this.ID = reader.ReadInt32();
|
||||
this.Position = new Point16(reader.ReadInt16(), reader.ReadInt16());
|
||||
this.ReadExtraData(reader, networkSend);
|
||||
}
|
||||
|
||||
public virtual void WriteExtraData(BinaryWriter writer, bool networkSend)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void ReadExtraData(BinaryReader reader, bool networkSend)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
175
DataStructures/TileObjectPreviewData.cs
Normal file
175
DataStructures/TileObjectPreviewData.cs
Normal file
|
@ -0,0 +1,175 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.DataStructures.TileObjectPreviewData
|
||||
// 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;
|
||||
|
||||
namespace Terraria.DataStructures
|
||||
{
|
||||
public class TileObjectPreviewData
|
||||
{
|
||||
private ushort _type;
|
||||
private short _style;
|
||||
private int _alternate;
|
||||
private int _random;
|
||||
private bool _active;
|
||||
private Point16 _size;
|
||||
private Point16 _coordinates;
|
||||
private Point16 _objectStart;
|
||||
private int[,] _data;
|
||||
private Point16 _dataSize;
|
||||
private float _percentValid;
|
||||
public static TileObjectPreviewData placementCache;
|
||||
public static TileObjectPreviewData randomCache;
|
||||
public const int None = 0;
|
||||
public const int ValidSpot = 1;
|
||||
public const int InvalidSpot = 2;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this._active = false;
|
||||
this._size = Point16.Zero;
|
||||
this._coordinates = Point16.Zero;
|
||||
this._objectStart = Point16.Zero;
|
||||
this._percentValid = 0.0f;
|
||||
this._type = (ushort) 0;
|
||||
this._style = (short) 0;
|
||||
this._alternate = -1;
|
||||
this._random = -1;
|
||||
if (this._data == null)
|
||||
return;
|
||||
Array.Clear((Array) this._data, 0, (int) this._dataSize.X * (int) this._dataSize.Y);
|
||||
}
|
||||
|
||||
public void CopyFrom(TileObjectPreviewData copy)
|
||||
{
|
||||
this._type = copy._type;
|
||||
this._style = copy._style;
|
||||
this._alternate = copy._alternate;
|
||||
this._random = copy._random;
|
||||
this._active = copy._active;
|
||||
this._size = copy._size;
|
||||
this._coordinates = copy._coordinates;
|
||||
this._objectStart = copy._objectStart;
|
||||
this._percentValid = copy._percentValid;
|
||||
if (this._data == null)
|
||||
{
|
||||
this._data = new int[(int) copy._dataSize.X, (int) copy._dataSize.Y];
|
||||
this._dataSize = copy._dataSize;
|
||||
}
|
||||
else
|
||||
Array.Clear((Array) this._data, 0, this._data.Length);
|
||||
if ((int) this._dataSize.X < (int) copy._dataSize.X || (int) this._dataSize.Y < (int) copy._dataSize.Y)
|
||||
{
|
||||
int X = (int) copy._dataSize.X > (int) this._dataSize.X ? (int) copy._dataSize.X : (int) this._dataSize.X;
|
||||
int Y = (int) copy._dataSize.Y > (int) this._dataSize.Y ? (int) copy._dataSize.Y : (int) this._dataSize.Y;
|
||||
this._data = new int[X, Y];
|
||||
this._dataSize = new Point16(X, Y);
|
||||
}
|
||||
for (int index1 = 0; index1 < (int) copy._dataSize.X; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < (int) copy._dataSize.Y; ++index2)
|
||||
this._data[index1, index2] = copy._data[index1, index2];
|
||||
}
|
||||
}
|
||||
|
||||
public bool Active
|
||||
{
|
||||
get => this._active;
|
||||
set => this._active = value;
|
||||
}
|
||||
|
||||
public ushort Type
|
||||
{
|
||||
get => this._type;
|
||||
set => this._type = value;
|
||||
}
|
||||
|
||||
public short Style
|
||||
{
|
||||
get => this._style;
|
||||
set => this._style = value;
|
||||
}
|
||||
|
||||
public int Alternate
|
||||
{
|
||||
get => this._alternate;
|
||||
set => this._alternate = value;
|
||||
}
|
||||
|
||||
public int Random
|
||||
{
|
||||
get => this._random;
|
||||
set => this._random = value;
|
||||
}
|
||||
|
||||
public Point16 Size
|
||||
{
|
||||
get => this._size;
|
||||
set
|
||||
{
|
||||
if (value.X <= (short) 0 || value.Y <= (short) 0)
|
||||
throw new FormatException("PlacementData.Size was set to a negative value.");
|
||||
if ((int) value.X > (int) this._dataSize.X || (int) value.Y > (int) this._dataSize.Y)
|
||||
{
|
||||
int X = (int) value.X > (int) this._dataSize.X ? (int) value.X : (int) this._dataSize.X;
|
||||
int Y = (int) value.Y > (int) this._dataSize.Y ? (int) value.Y : (int) this._dataSize.Y;
|
||||
int[,] numArray = new int[X, Y];
|
||||
if (this._data != null)
|
||||
{
|
||||
for (int index1 = 0; index1 < (int) this._dataSize.X; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < (int) this._dataSize.Y; ++index2)
|
||||
numArray[index1, index2] = this._data[index1, index2];
|
||||
}
|
||||
}
|
||||
this._data = numArray;
|
||||
this._dataSize = new Point16(X, Y);
|
||||
}
|
||||
this._size = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Point16 Coordinates
|
||||
{
|
||||
get => this._coordinates;
|
||||
set => this._coordinates = value;
|
||||
}
|
||||
|
||||
public Point16 ObjectStart
|
||||
{
|
||||
get => this._objectStart;
|
||||
set => this._objectStart = value;
|
||||
}
|
||||
|
||||
public void AllInvalid()
|
||||
{
|
||||
for (int index1 = 0; index1 < (int) this._size.X; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < (int) this._size.Y; ++index2)
|
||||
{
|
||||
if (this._data[index1, index2] != 0)
|
||||
this._data[index1, index2] = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int this[int x, int y]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (x < 0 || y < 0 || x >= (int) this._size.X || y >= (int) this._size.Y)
|
||||
throw new IndexOutOfRangeException();
|
||||
return this._data[x, y];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (x < 0 || y < 0 || x >= (int) this._size.X || y >= (int) this._size.Y)
|
||||
throw new IndexOutOfRangeException();
|
||||
this._data[x, y] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue