Terraria 1.4.0.5 Source Code

This commit is contained in:
MikeyIsBaeYT 2021-10-26 12:45:26 -04:00
commit 05205f009e
1059 changed files with 563450 additions and 0 deletions

32
Graphics/Camera.cs Normal file
View file

@ -0,0 +1,32 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Camera
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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.Graphics
{
public class Camera
{
public Vector2 UnscaledPosition => Main.screenPosition;
public Vector2 UnscaledSize => new Vector2((float) Main.screenWidth, (float) Main.screenHeight);
public Vector2 ScaledPosition => this.UnscaledPosition + this.GameViewMatrix.Translation;
public Vector2 ScaledSize => this.UnscaledSize - this.GameViewMatrix.Translation * 2f;
public RasterizerState Rasterizer => Main.Rasterizer;
public SamplerState Sampler => Main.DefaultSamplerState;
public SpriteViewMatrix GameViewMatrix => Main.GameViewMatrix;
public SpriteBatch SpriteBatch => Main.spriteBatch;
public Vector2 Center => this.UnscaledPosition + this.UnscaledSize * 0.5f;
}
}

View file

@ -0,0 +1,188 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Capture.CaptureBiome
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.Graphics.Capture
{
public class CaptureBiome
{
public static readonly CaptureBiome DefaultPurity = new CaptureBiome(0, 0);
public static CaptureBiome[] BiomesByWaterStyle = new CaptureBiome[15]
{
null,
null,
new CaptureBiome(1, 2, CaptureBiome.TileColorStyle.Corrupt),
new CaptureBiome(3, 3, CaptureBiome.TileColorStyle.Jungle),
new CaptureBiome(6, 4),
new CaptureBiome(7, 5),
new CaptureBiome(2, 6),
new CaptureBiome(0, 7),
new CaptureBiome(0, 8),
new CaptureBiome(0, 9),
new CaptureBiome(8, 10, CaptureBiome.TileColorStyle.Crimson),
null,
new CaptureBiome(2, 12),
new CaptureBiome(4, 0),
new CaptureBiome(9, 7, CaptureBiome.TileColorStyle.Mushroom)
};
public readonly int WaterStyle;
public readonly int BackgroundIndex;
public readonly CaptureBiome.TileColorStyle TileColor;
public CaptureBiome(
int backgroundIndex,
int waterStyle,
CaptureBiome.TileColorStyle tileColorStyle = CaptureBiome.TileColorStyle.Normal)
{
this.BackgroundIndex = backgroundIndex;
this.WaterStyle = waterStyle;
this.TileColor = tileColorStyle;
}
public static CaptureBiome GetCaptureBiome(int biomeChoice)
{
switch (biomeChoice)
{
case 1:
return CaptureBiome.GetPurityForPlayer();
case 2:
return CaptureBiome.Styles.Corruption;
case 3:
return CaptureBiome.Styles.Jungle;
case 4:
return CaptureBiome.Styles.Hallow;
case 5:
return CaptureBiome.Styles.Snow;
case 6:
return CaptureBiome.Styles.Desert;
case 7:
return CaptureBiome.Styles.DirtLayer;
case 8:
return CaptureBiome.Styles.RockLayer;
case 9:
return CaptureBiome.Styles.BloodMoon;
case 10:
return CaptureBiome.Styles.UndergroundDesert;
case 11:
return CaptureBiome.Styles.Ocean;
case 12:
return CaptureBiome.Styles.Mushroom;
default:
return CaptureBiome.GetBiomeByLocation() ?? CaptureBiome.GetBiomeByWater() ?? CaptureBiome.GetPurityForPlayer();
}
}
private static CaptureBiome GetBiomeByWater()
{
int waterStyle = Main.CalculateWaterStyle(true);
for (int index = 0; index < CaptureBiome.BiomesByWaterStyle.Length; ++index)
{
CaptureBiome captureBiome = CaptureBiome.BiomesByWaterStyle[index];
if (captureBiome != null && captureBiome.WaterStyle == waterStyle)
return captureBiome;
}
return (CaptureBiome) null;
}
private static CaptureBiome GetBiomeByLocation()
{
switch (Main.GetPreferredBGStyleForPlayer())
{
case 0:
return CaptureBiome.Styles.Purity;
case 1:
return CaptureBiome.Styles.Corruption;
case 2:
return CaptureBiome.Styles.Desert;
case 3:
return CaptureBiome.Styles.Jungle;
case 4:
return CaptureBiome.Styles.Ocean;
case 5:
return CaptureBiome.Styles.Desert;
case 6:
return CaptureBiome.Styles.Hallow;
case 7:
return CaptureBiome.Styles.Snow;
case 8:
return CaptureBiome.Styles.Crimson;
case 9:
return CaptureBiome.Styles.Mushroom;
case 10:
return CaptureBiome.Styles.Purity2;
case 11:
return CaptureBiome.Styles.Purity3;
case 12:
return CaptureBiome.Styles.Purity4;
default:
return (CaptureBiome) null;
}
}
private static CaptureBiome GetPurityForPlayer()
{
int num = (int) Main.LocalPlayer.Center.X / 16;
if (num < Main.treeX[0])
return CaptureBiome.Styles.Purity;
if (num < Main.treeX[1])
return CaptureBiome.Styles.Purity2;
return num < Main.treeX[2] ? CaptureBiome.Styles.Purity3 : CaptureBiome.Styles.Purity4;
}
public enum TileColorStyle
{
Normal,
Jungle,
Crimson,
Corrupt,
Mushroom,
}
public class Sets
{
public class WaterStyles
{
public const int BloodMoon = 9;
}
}
public class Styles
{
public static CaptureBiome Purity = new CaptureBiome(0, 0);
public static CaptureBiome Purity2 = new CaptureBiome(10, 0);
public static CaptureBiome Purity3 = new CaptureBiome(11, 0);
public static CaptureBiome Purity4 = new CaptureBiome(12, 0);
public static CaptureBiome Corruption = new CaptureBiome(1, 2, CaptureBiome.TileColorStyle.Corrupt);
public static CaptureBiome Jungle = new CaptureBiome(3, 3, CaptureBiome.TileColorStyle.Jungle);
public static CaptureBiome Hallow = new CaptureBiome(6, 4);
public static CaptureBiome Snow = new CaptureBiome(7, 5);
public static CaptureBiome Desert = new CaptureBiome(2, 6);
public static CaptureBiome DirtLayer = new CaptureBiome(0, 7);
public static CaptureBiome RockLayer = new CaptureBiome(0, 8);
public static CaptureBiome BloodMoon = new CaptureBiome(0, 9);
public static CaptureBiome Crimson = new CaptureBiome(8, 10, CaptureBiome.TileColorStyle.Crimson);
public static CaptureBiome UndergroundDesert = new CaptureBiome(2, 12);
public static CaptureBiome Ocean = new CaptureBiome(4, 0);
public static CaptureBiome Mushroom = new CaptureBiome(9, 7, CaptureBiome.TileColorStyle.Mushroom);
}
private enum BiomeChoiceIndex
{
AutomatedForPlayer = -1, // 0xFFFFFFFF
Purity = 1,
Corruption = 2,
Jungle = 3,
Hallow = 4,
Snow = 5,
Desert = 6,
DirtLayer = 7,
RockLayer = 8,
BloodMoon = 9,
UndergroundDesert = 10, // 0x0000000A
Ocean = 11, // 0x0000000B
Mushroom = 12, // 0x0000000C
}
}
}

View file

@ -0,0 +1,351 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Capture.CaptureCamera
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using Terraria.GameContent.Drawing;
using Terraria.Graphics.Effects;
using Terraria.Localization;
namespace Terraria.Graphics.Capture
{
internal class CaptureCamera
{
private static bool CameraExists;
public const int CHUNK_SIZE = 128;
public const int FRAMEBUFFER_PIXEL_SIZE = 2048;
public const int INNER_CHUNK_SIZE = 126;
public const int MAX_IMAGE_SIZE = 4096;
public const string CAPTURE_DIRECTORY = "Captures";
private RenderTarget2D _frameBuffer;
private RenderTarget2D _scaledFrameBuffer;
private RenderTarget2D _filterFrameBuffer1;
private RenderTarget2D _filterFrameBuffer2;
private GraphicsDevice _graphics;
private readonly object _captureLock = new object();
private bool _isDisposed;
private CaptureSettings _activeSettings;
private Queue<CaptureCamera.CaptureChunk> _renderQueue = new Queue<CaptureCamera.CaptureChunk>();
private SpriteBatch _spriteBatch;
private byte[] _scaledFrameData;
private byte[] _outputData;
private Size _outputImageSize;
private SamplerState _downscaleSampleState;
private float _tilesProcessed;
private float _totalTiles;
public bool IsCapturing
{
get
{
Monitor.Enter(this._captureLock);
int num = this._activeSettings != null ? 1 : 0;
Monitor.Exit(this._captureLock);
return num != 0;
}
}
public CaptureCamera(GraphicsDevice graphics)
{
CaptureCamera.CameraExists = true;
this._graphics = graphics;
this._spriteBatch = new SpriteBatch(graphics);
try
{
this._frameBuffer = new RenderTarget2D(graphics, 2048, 2048, false, graphics.PresentationParameters.BackBufferFormat, DepthFormat.None);
this._filterFrameBuffer1 = new RenderTarget2D(graphics, 2048, 2048, false, graphics.PresentationParameters.BackBufferFormat, DepthFormat.None);
this._filterFrameBuffer2 = new RenderTarget2D(graphics, 2048, 2048, false, graphics.PresentationParameters.BackBufferFormat, DepthFormat.None);
}
catch
{
Main.CaptureModeDisabled = true;
return;
}
this._downscaleSampleState = SamplerState.AnisotropicClamp;
}
~CaptureCamera() => this.Dispose();
public void Capture(CaptureSettings settings)
{
Main.GlobalTimerPaused = true;
Monitor.Enter(this._captureLock);
this._activeSettings = this._activeSettings == null ? settings : throw new InvalidOperationException("Capture called while another capture was already active.");
Microsoft.Xna.Framework.Rectangle area = settings.Area;
float num1 = 1f;
if (settings.UseScaling)
{
if (area.Width * 16 > 4096)
num1 = 4096f / (float) (area.Width * 16);
if (area.Height * 16 > 4096)
num1 = Math.Min(num1, 4096f / (float) (area.Height * 16));
num1 = Math.Min(1f, num1);
this._outputImageSize = new Size((int) MathHelper.Clamp((float) (int) ((double) num1 * (double) (area.Width * 16)), 1f, 4096f), (int) MathHelper.Clamp((float) (int) ((double) num1 * (double) (area.Height * 16)), 1f, 4096f));
this._outputData = new byte[4 * this._outputImageSize.Width * this._outputImageSize.Height];
int num2 = (int) Math.Floor((double) num1 * 2048.0);
this._scaledFrameData = new byte[4 * num2 * num2];
this._scaledFrameBuffer = new RenderTarget2D(this._graphics, num2, num2, false, this._graphics.PresentationParameters.BackBufferFormat, DepthFormat.None);
}
else
this._outputData = new byte[16777216];
this._tilesProcessed = 0.0f;
this._totalTiles = (float) (area.Width * area.Height);
for (int x1 = area.X; x1 < area.X + area.Width; x1 += 126)
{
for (int y1 = area.Y; y1 < area.Y + area.Height; y1 += 126)
{
int width1 = Math.Min(128, area.X + area.Width - x1);
int height1 = Math.Min(128, area.Y + area.Height - y1);
int width2 = (int) Math.Floor((double) num1 * (double) (width1 * 16));
int height2 = (int) Math.Floor((double) num1 * (double) (height1 * 16));
int x2 = (int) Math.Floor((double) num1 * (double) ((x1 - area.X) * 16));
int y2 = (int) Math.Floor((double) num1 * (double) ((y1 - area.Y) * 16));
this._renderQueue.Enqueue(new CaptureCamera.CaptureChunk(new Microsoft.Xna.Framework.Rectangle(x1, y1, width1, height1), new Microsoft.Xna.Framework.Rectangle(x2, y2, width2, height2)));
}
}
Monitor.Exit(this._captureLock);
}
public void DrawTick()
{
Monitor.Enter(this._captureLock);
if (this._activeSettings == null)
return;
bool notRetro = Lighting.NotRetro;
if (this._renderQueue.Count > 0)
{
CaptureCamera.CaptureChunk captureChunk = this._renderQueue.Dequeue();
this._graphics.SetRenderTarget((RenderTarget2D) null);
this._graphics.Clear(Microsoft.Xna.Framework.Color.Transparent);
TileDrawing tilesRenderer = Main.instance.TilesRenderer;
Microsoft.Xna.Framework.Rectangle area = captureChunk.Area;
int left = area.Left;
area = captureChunk.Area;
int right = area.Right;
area = captureChunk.Area;
int top = area.Top;
area = captureChunk.Area;
int bottom = area.Bottom;
tilesRenderer.PrepareForAreaDrawing(left, right, top, bottom, false);
Main.instance.TilePaintSystem.PrepareAllRequests();
this._graphics.SetRenderTarget(this._frameBuffer);
this._graphics.Clear(Microsoft.Xna.Framework.Color.Transparent);
if (notRetro)
{
Microsoft.Xna.Framework.Color clearColor = this._activeSettings.CaptureBackground ? Microsoft.Xna.Framework.Color.Black : Microsoft.Xna.Framework.Color.Transparent;
Filters.Scene.BeginCapture(this._filterFrameBuffer1, clearColor);
Main.instance.DrawCapture(captureChunk.Area, this._activeSettings);
Filters.Scene.EndCapture(this._frameBuffer, this._filterFrameBuffer1, this._filterFrameBuffer2, clearColor);
}
else
Main.instance.DrawCapture(captureChunk.Area, this._activeSettings);
if (this._activeSettings.UseScaling)
{
this._graphics.SetRenderTarget(this._scaledFrameBuffer);
this._graphics.Clear(Microsoft.Xna.Framework.Color.Transparent);
this._spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, this._downscaleSampleState, DepthStencilState.Default, RasterizerState.CullNone);
this._spriteBatch.Draw((Texture2D) this._frameBuffer, new Microsoft.Xna.Framework.Rectangle(0, 0, this._scaledFrameBuffer.Width, this._scaledFrameBuffer.Height), Microsoft.Xna.Framework.Color.White);
this._spriteBatch.End();
this._graphics.SetRenderTarget((RenderTarget2D) null);
this._scaledFrameBuffer.GetData<byte>(this._scaledFrameData, 0, this._scaledFrameBuffer.Width * this._scaledFrameBuffer.Height * 4);
this.DrawBytesToBuffer(this._scaledFrameData, this._outputData, this._scaledFrameBuffer.Width, this._outputImageSize.Width, captureChunk.ScaledArea);
}
else
{
this._graphics.SetRenderTarget((RenderTarget2D) null);
this.SaveImage((Texture2D) this._frameBuffer, captureChunk.ScaledArea.Width, captureChunk.ScaledArea.Height, ImageFormat.Png, this._activeSettings.OutputName, captureChunk.Area.X.ToString() + "-" + (object) captureChunk.Area.Y + ".png");
}
this._tilesProcessed += (float) (captureChunk.Area.Width * captureChunk.Area.Height);
}
if (this._renderQueue.Count == 0)
this.FinishCapture();
Monitor.Exit(this._captureLock);
}
private unsafe void DrawBytesToBuffer(
byte[] sourceBuffer,
byte[] destinationBuffer,
int sourceBufferWidth,
int destinationBufferWidth,
Microsoft.Xna.Framework.Rectangle area)
{
fixed (byte* numPtr1 = &destinationBuffer[0])
fixed (byte* numPtr2 = &sourceBuffer[0])
{
byte* numPtr3 = numPtr2;
byte* numPtr4 = numPtr1 + (destinationBufferWidth * area.Y + area.X << 2);
for (int index1 = 0; index1 < area.Height; ++index1)
{
for (int index2 = 0; index2 < area.Width; ++index2)
{
numPtr4[2] = *numPtr3;
numPtr4[1] = numPtr3[1];
*numPtr4 = numPtr3[2];
numPtr4[3] = numPtr3[3];
numPtr3 += 4;
numPtr4 += 4;
}
numPtr3 += sourceBufferWidth - area.Width << 2;
numPtr4 += destinationBufferWidth - area.Width << 2;
}
}
}
public float GetProgress() => this._tilesProcessed / this._totalTiles;
private bool SaveImage(int width, int height, ImageFormat imageFormat, string filename)
{
string savePath = Main.SavePath;
char directorySeparatorChar = Path.DirectorySeparatorChar;
string str1 = directorySeparatorChar.ToString();
directorySeparatorChar = Path.DirectorySeparatorChar;
string str2 = directorySeparatorChar.ToString();
if (!Utils.TryCreatingDirectory(savePath + str1 + "Captures" + str2))
return false;
try
{
using (Bitmap bitmap = new Bitmap(width, height))
{
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, width, height);
BitmapData bitmapdata = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppPArgb);
Marshal.Copy(this._outputData, 0, bitmapdata.Scan0, width * height * 4);
bitmap.UnlockBits(bitmapdata);
bitmap.Save(filename, imageFormat);
bitmap.Dispose();
}
return true;
}
catch (Exception ex)
{
Console.WriteLine((object) ex);
return false;
}
}
private void SaveImage(
Texture2D texture,
int width,
int height,
ImageFormat imageFormat,
string foldername,
string filename)
{
string str = Main.SavePath + Path.DirectorySeparatorChar.ToString() + "Captures" + Path.DirectorySeparatorChar.ToString() + foldername;
string filename1 = Path.Combine(str, filename);
if (!Utils.TryCreatingDirectory(str))
return;
using (Bitmap bitmap = new Bitmap(width, height))
{
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, width, height);
int elementCount = texture.Width * texture.Height * 4;
texture.GetData<byte>(this._outputData, 0, elementCount);
int index1 = 0;
int index2 = 0;
for (int index3 = 0; index3 < height; ++index3)
{
for (int index4 = 0; index4 < width; ++index4)
{
byte num = this._outputData[index1 + 2];
this._outputData[index2 + 2] = this._outputData[index1];
this._outputData[index2] = num;
this._outputData[index2 + 1] = this._outputData[index1 + 1];
this._outputData[index2 + 3] = this._outputData[index1 + 3];
index1 += 4;
index2 += 4;
}
index1 += texture.Width - width << 2;
}
BitmapData bitmapdata = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppPArgb);
Marshal.Copy(this._outputData, 0, bitmapdata.Scan0, width * height * 4);
bitmap.UnlockBits(bitmapdata);
bitmap.Save(filename1, imageFormat);
}
}
private void FinishCapture()
{
if (this._activeSettings.UseScaling)
{
int num = 0;
do
{
int width = this._outputImageSize.Width;
int height = this._outputImageSize.Height;
ImageFormat png = ImageFormat.Png;
string[] strArray = new string[6];
strArray[0] = Main.SavePath;
char directorySeparatorChar = Path.DirectorySeparatorChar;
strArray[1] = directorySeparatorChar.ToString();
strArray[2] = "Captures";
directorySeparatorChar = Path.DirectorySeparatorChar;
strArray[3] = directorySeparatorChar.ToString();
strArray[4] = this._activeSettings.OutputName;
strArray[5] = ".png";
string filename = string.Concat(strArray);
if (!this.SaveImage(width, height, png, filename))
{
GC.Collect();
Thread.Sleep(5);
++num;
Console.WriteLine(Language.GetTextValue("Error.CaptureError"));
}
else
goto label_5;
}
while (num <= 5);
Console.WriteLine(Language.GetTextValue("Error.UnableToCapture"));
}
label_5:
this._outputData = (byte[]) null;
this._scaledFrameData = (byte[]) null;
Main.GlobalTimerPaused = false;
CaptureInterface.EndCamera();
if (this._scaledFrameBuffer != null)
{
this._scaledFrameBuffer.Dispose();
this._scaledFrameBuffer = (RenderTarget2D) null;
}
this._activeSettings = (CaptureSettings) null;
}
public void Dispose()
{
Monitor.Enter(this._captureLock);
if (this._isDisposed)
return;
this._frameBuffer.Dispose();
this._filterFrameBuffer1.Dispose();
this._filterFrameBuffer2.Dispose();
if (this._scaledFrameBuffer != null)
{
this._scaledFrameBuffer.Dispose();
this._scaledFrameBuffer = (RenderTarget2D) null;
}
CaptureCamera.CameraExists = false;
this._isDisposed = true;
Monitor.Exit(this._captureLock);
}
private class CaptureChunk
{
public readonly Microsoft.Xna.Framework.Rectangle Area;
public readonly Microsoft.Xna.Framework.Rectangle ScaledArea;
public CaptureChunk(Microsoft.Xna.Framework.Rectangle area, Microsoft.Xna.Framework.Rectangle scaledArea)
{
this.Area = area;
this.ScaledArea = scaledArea;
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,57 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Capture.CaptureManager
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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.Graphics.Capture
{
public class CaptureManager
{
public static CaptureManager Instance = new CaptureManager();
private CaptureInterface _interface;
private CaptureCamera _camera;
public bool IsCapturing => this._camera.IsCapturing;
public CaptureManager()
{
this._interface = new CaptureInterface();
this._camera = new CaptureCamera(Main.instance.GraphicsDevice);
}
public bool Active
{
get => this._interface.Active;
set
{
if (Main.CaptureModeDisabled || this._interface.Active == value)
return;
this._interface.ToggleCamera(value);
}
}
public bool UsingMap => this.Active && this._interface.UsingMap();
public void Scrolling() => this._interface.Scrolling();
public void Update() => this._interface.Update();
public void Draw(SpriteBatch sb) => this._interface.Draw(sb);
public float GetProgress() => this._camera.GetProgress();
public void Capture() => this.Capture(new CaptureSettings()
{
Area = new Rectangle(2660, 100, 1000, 1000),
UseScaling = false
});
public void Capture(CaptureSettings settings) => this._camera.Capture(settings);
public void DrawTick() => this._camera.DrawTick();
}
}

View file

@ -0,0 +1,28 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Capture.CaptureSettings
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
namespace Terraria.Graphics.Capture
{
public class CaptureSettings
{
public Rectangle Area;
public bool UseScaling = true;
public string OutputName;
public bool CaptureEntities = true;
public CaptureBiome Biome = CaptureBiome.DefaultPurity;
public bool CaptureMech;
public bool CaptureBackground;
public CaptureSettings()
{
DateTime localTime = DateTime.Now.ToLocalTime();
this.OutputName = "Capture " + localTime.Year.ToString("D4") + "-" + localTime.Month.ToString("D2") + "-" + localTime.Day.ToString("D2") + " " + localTime.Hour.ToString("D2") + "_" + localTime.Minute.ToString("D2") + "_" + localTime.Second.ToString("D2");
}
}
}

View file

@ -0,0 +1,28 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.CustomSky
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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.Graphics.Effects
{
public abstract class CustomSky : GameEffect
{
public abstract void Update(GameTime gameTime);
public abstract void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth);
public abstract bool IsActive();
public abstract void Reset();
public virtual Color OnTileColor(Color inColor) => inColor;
public virtual float GetCloudAlpha() => 1f;
public override bool IsVisible() => true;
}
}

View file

@ -0,0 +1,69 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.EffectManager`1
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System.Collections.Generic;
namespace Terraria.Graphics.Effects
{
public abstract class EffectManager<T> where T : GameEffect
{
protected bool _isLoaded;
protected Dictionary<string, T> _effects = new Dictionary<string, T>();
public bool IsLoaded => this._isLoaded;
public T this[string key]
{
get
{
T obj;
return this._effects.TryGetValue(key, out obj) ? obj : default (T);
}
set => this.Bind(key, value);
}
public void Bind(string name, T effect)
{
this._effects[name] = effect;
if (!this._isLoaded)
return;
effect.Load();
}
public void Load()
{
if (this._isLoaded)
return;
this._isLoaded = true;
foreach (T obj in this._effects.Values)
obj.Load();
}
public T Activate(string name, Vector2 position = default (Vector2), params object[] args)
{
T effect = this._effects.ContainsKey(name) ? this._effects[name] : throw new MissingEffectException("Unable to find effect named: " + name + ". Type: " + (object) typeof (T) + ".");
this.OnActivate(effect, position);
effect.Activate(position, args);
return effect;
}
public void Deactivate(string name, params object[] args)
{
T effect = this._effects.ContainsKey(name) ? this._effects[name] : throw new MissingEffectException("Unable to find effect named: " + name + ". Type: " + (object) typeof (T) + ".");
this.OnDeactivate(effect);
effect.Deactivate(args);
}
public virtual void OnActivate(T effect, Vector2 position)
{
}
public virtual void OnDeactivate(T effect)
{
}
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.EffectPriority
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.Graphics.Effects
{
public enum EffectPriority
{
VeryLow,
Low,
Medium,
High,
VeryHigh,
}
}

View file

@ -0,0 +1,49 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.Filter
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Terraria.Graphics.Shaders;
namespace Terraria.Graphics.Effects
{
public class Filter : GameEffect
{
public bool Active;
private ScreenShaderData _shader;
public bool IsHidden;
public Filter(ScreenShaderData shader, EffectPriority priority = EffectPriority.VeryLow)
{
this._shader = shader;
this._priority = priority;
}
public void Update(GameTime gameTime)
{
this._shader.UseGlobalOpacity(this.Opacity);
this._shader.Update(gameTime);
}
public void Apply() => this._shader.Apply();
public ScreenShaderData GetShader() => this._shader;
public override void Activate(Vector2 position, params object[] args)
{
this._shader.UseGlobalOpacity(this.Opacity);
this._shader.UseTargetPosition(position);
this.Active = true;
}
public override void Deactivate(params object[] args) => this.Active = false;
public bool IsInUse() => this.Active || (double) this.Opacity > 0.0;
public bool IsActive() => this.Active;
public override bool IsVisible() => (double) this.GetShader().CombinedOpacity > 0.0 && !this.IsHidden;
}
}

View file

@ -0,0 +1,197 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.FilterManager
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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;
using System.Collections.Generic;
using Terraria.IO;
namespace Terraria.Graphics.Effects
{
public class FilterManager : EffectManager<Filter>
{
private const float OPACITY_RATE = 1f;
private LinkedList<Filter> _activeFilters = new LinkedList<Filter>();
private int _filterLimit = 16;
private EffectPriority _priorityThreshold;
private int _activeFilterCount;
private bool _captureThisFrame;
public event Action OnPostDraw;
public FilterManager()
{
Main.Configuration.OnLoad += (Action<Preferences>) (preferences =>
{
this._filterLimit = preferences.Get<int>("FilterLimit", 16);
EffectPriority result;
if (!Enum.TryParse<EffectPriority>(preferences.Get<string>("FilterPriorityThreshold", "VeryLow"), out result))
return;
this._priorityThreshold = result;
});
Main.Configuration.OnSave += (Action<Preferences>) (preferences =>
{
preferences.Put("FilterLimit", (object) this._filterLimit);
preferences.Put("FilterPriorityThreshold", (object) Enum.GetName(typeof (EffectPriority), (object) this._priorityThreshold));
});
}
public override void OnActivate(Filter effect, Vector2 position)
{
if (this._activeFilters.Contains(effect))
{
if (effect.Active)
return;
if (effect.Priority >= this._priorityThreshold)
--this._activeFilterCount;
this._activeFilters.Remove(effect);
}
else
effect.Opacity = 0.0f;
if (effect.Priority >= this._priorityThreshold)
++this._activeFilterCount;
if (this._activeFilters.Count == 0)
{
this._activeFilters.AddLast(effect);
}
else
{
for (LinkedListNode<Filter> node = this._activeFilters.First; node != null; node = node.Next)
{
Filter filter = node.Value;
if (effect.Priority <= filter.Priority)
{
this._activeFilters.AddAfter(node, effect);
return;
}
}
this._activeFilters.AddLast(effect);
}
}
public void BeginCapture(RenderTarget2D screenTarget1, Color clearColor)
{
if (this._activeFilterCount == 0 && this.OnPostDraw == null)
{
this._captureThisFrame = false;
}
else
{
this._captureThisFrame = true;
Main.instance.GraphicsDevice.SetRenderTarget(screenTarget1);
Main.instance.GraphicsDevice.Clear(clearColor);
}
}
public void Update(GameTime gameTime)
{
LinkedListNode<Filter> node = this._activeFilters.First;
int count = this._activeFilters.Count;
int num = 0;
LinkedListNode<Filter> next;
for (; node != null; node = next)
{
Filter filter = node.Value;
next = node.Next;
bool flag = false;
if (filter.Priority >= this._priorityThreshold)
{
++num;
if (num > this._activeFilterCount - this._filterLimit)
{
filter.Update(gameTime);
flag = true;
}
}
if (filter.Active & flag)
filter.Opacity = Math.Min(filter.Opacity + (float) (gameTime.ElapsedGameTime.TotalSeconds * 1.0), 1f);
else
filter.Opacity = Math.Max(filter.Opacity - (float) (gameTime.ElapsedGameTime.TotalSeconds * 1.0), 0.0f);
if (!filter.Active && (double) filter.Opacity == 0.0)
{
if (filter.Priority >= this._priorityThreshold)
--this._activeFilterCount;
this._activeFilters.Remove(node);
}
}
}
public void EndCapture(
RenderTarget2D finalTexture,
RenderTarget2D screenTarget1,
RenderTarget2D screenTarget2,
Color clearColor)
{
if (!this._captureThisFrame)
return;
LinkedListNode<Filter> linkedListNode = this._activeFilters.First;
int count = this._activeFilters.Count;
Filter filter1 = (Filter) null;
RenderTarget2D renderTarget2D = screenTarget1;
GraphicsDevice graphicsDevice = Main.instance.GraphicsDevice;
int num = 0;
if ((double) Main.player[Main.myPlayer].gravDir == -1.0)
{
RenderTarget2D renderTarget = screenTarget2;
graphicsDevice.SetRenderTarget(renderTarget);
graphicsDevice.Clear(clearColor);
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, (Effect) null, Matrix.Invert(Main.GameViewMatrix.EffectMatrix));
Main.spriteBatch.Draw((Texture2D) renderTarget2D, Vector2.Zero, Color.White);
Main.spriteBatch.End();
renderTarget2D = screenTarget2;
}
LinkedListNode<Filter> next;
for (; linkedListNode != null; linkedListNode = next)
{
Filter filter2 = linkedListNode.Value;
next = linkedListNode.Next;
if (filter2.Priority >= this._priorityThreshold)
{
++num;
if (num > this._activeFilterCount - this._filterLimit && filter2.IsVisible())
{
if (filter1 != null)
{
RenderTarget2D renderTarget = renderTarget2D != screenTarget1 ? screenTarget1 : screenTarget2;
graphicsDevice.SetRenderTarget(renderTarget);
graphicsDevice.Clear(clearColor);
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
filter1.Apply();
Main.spriteBatch.Draw((Texture2D) renderTarget2D, Vector2.Zero, Main.ColorOfTheSkies);
Main.spriteBatch.End();
renderTarget2D = renderTarget2D != screenTarget1 ? screenTarget1 : screenTarget2;
}
filter1 = filter2;
}
}
}
graphicsDevice.SetRenderTarget(finalTexture);
graphicsDevice.Clear(clearColor);
if ((double) Main.player[Main.myPlayer].gravDir == -1.0)
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, (Effect) null, Main.GameViewMatrix.EffectMatrix);
else
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
if (filter1 != null)
{
filter1.Apply();
Main.spriteBatch.Draw((Texture2D) renderTarget2D, Vector2.Zero, Main.ColorOfTheSkies);
}
else
Main.spriteBatch.Draw((Texture2D) renderTarget2D, Vector2.Zero, Color.White);
Main.spriteBatch.End();
for (int index = 0; index < 8; ++index)
graphicsDevice.Textures[index] = (Texture) null;
if (this.OnPostDraw == null)
return;
this.OnPostDraw();
}
public bool HasActiveFilter() => (uint) this._activeFilters.Count > 0U;
public bool CanCapture() => this.HasActiveFilter() || this.OnPostDraw != null;
}
}

View file

@ -0,0 +1,13 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.Filters
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.Graphics.Effects
{
public static class Filters
{
public static FilterManager Scene = new FilterManager();
}
}

View file

@ -0,0 +1,39 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.GameEffect
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.Graphics.Effects
{
public abstract class GameEffect
{
public float Opacity;
protected bool _isLoaded;
protected EffectPriority _priority;
public bool IsLoaded => this._isLoaded;
public EffectPriority Priority => this._priority;
public void Load()
{
if (this._isLoaded)
return;
this._isLoaded = true;
this.OnLoad();
}
public virtual void OnLoad()
{
}
public abstract bool IsVisible();
public abstract void Activate(Vector2 position, params object[] args);
public abstract void Deactivate(params object[] args);
}
}

View file

@ -0,0 +1,18 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.MissingEffectException
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System;
namespace Terraria.Graphics.Effects
{
public class MissingEffectException : Exception
{
public MissingEffectException(string text)
: base(text)
{
}
}
}

View file

@ -0,0 +1,29 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.Overlay
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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.Graphics.Effects
{
public abstract class Overlay : GameEffect
{
public OverlayMode Mode = OverlayMode.Inactive;
private RenderLayers _layer = RenderLayers.All;
public RenderLayers Layer => this._layer;
public Overlay(EffectPriority priority, RenderLayers layer)
{
this._priority = priority;
this._layer = layer;
}
public abstract void Draw(SpriteBatch spriteBatch);
public abstract void Update(GameTime gameTime);
}
}

View file

@ -0,0 +1,113 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.OverlayManager
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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;
using System.Collections.Generic;
namespace Terraria.Graphics.Effects
{
public class OverlayManager : EffectManager<Overlay>
{
private const float OPACITY_RATE = 1f;
private LinkedList<Overlay>[] _activeOverlays = new LinkedList<Overlay>[Enum.GetNames(typeof (EffectPriority)).Length];
private int _overlayCount;
public OverlayManager()
{
for (int index = 0; index < this._activeOverlays.Length; ++index)
this._activeOverlays[index] = new LinkedList<Overlay>();
}
public override void OnActivate(Overlay overlay, Vector2 position)
{
LinkedList<Overlay> activeOverlay = this._activeOverlays[(int) overlay.Priority];
if (overlay.Mode == OverlayMode.FadeIn || overlay.Mode == OverlayMode.Active)
return;
if (overlay.Mode == OverlayMode.FadeOut)
{
activeOverlay.Remove(overlay);
--this._overlayCount;
}
else
overlay.Opacity = 0.0f;
if (activeOverlay.Count != 0)
{
foreach (Overlay overlay1 in activeOverlay)
overlay1.Mode = OverlayMode.FadeOut;
}
activeOverlay.AddLast(overlay);
++this._overlayCount;
}
public void Update(GameTime gameTime)
{
LinkedListNode<Overlay> next;
for (int index = 0; index < this._activeOverlays.Length; ++index)
{
for (LinkedListNode<Overlay> node = this._activeOverlays[index].First; node != null; node = next)
{
Overlay overlay = node.Value;
next = node.Next;
overlay.Update(gameTime);
switch (overlay.Mode)
{
case OverlayMode.FadeIn:
overlay.Opacity += (float) (gameTime.ElapsedGameTime.TotalSeconds * 1.0);
if ((double) overlay.Opacity >= 1.0)
{
overlay.Opacity = 1f;
overlay.Mode = OverlayMode.Active;
break;
}
break;
case OverlayMode.Active:
overlay.Opacity = Math.Min(1f, overlay.Opacity + (float) (gameTime.ElapsedGameTime.TotalSeconds * 1.0));
break;
case OverlayMode.FadeOut:
overlay.Opacity -= (float) (gameTime.ElapsedGameTime.TotalSeconds * 1.0);
if ((double) overlay.Opacity <= 0.0)
{
overlay.Opacity = 0.0f;
overlay.Mode = OverlayMode.Inactive;
this._activeOverlays[index].Remove(node);
--this._overlayCount;
break;
}
break;
}
}
}
}
public void Draw(SpriteBatch spriteBatch, RenderLayers layer)
{
if (this._overlayCount == 0)
return;
bool flag = false;
for (int index = 0; index < this._activeOverlays.Length; ++index)
{
for (LinkedListNode<Overlay> linkedListNode = this._activeOverlays[index].First; linkedListNode != null; linkedListNode = linkedListNode.Next)
{
Overlay overlay = linkedListNode.Value;
if (overlay.Layer == layer && overlay.IsVisible())
{
if (!flag)
{
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, (Effect) null, Main.Transform);
flag = true;
}
overlay.Draw(spriteBatch);
}
}
}
if (!flag)
return;
spriteBatch.End();
}
}
}

View file

@ -0,0 +1,16 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.OverlayMode
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.Graphics.Effects
{
public enum OverlayMode
{
FadeIn,
Active,
FadeOut,
Inactive,
}
}

View file

@ -0,0 +1,14 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.Overlays
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.Graphics.Effects
{
public static class Overlays
{
public static OverlayManager Scene = new OverlayManager();
public static OverlayManager FilterFallback = new OverlayManager();
}
}

View file

@ -0,0 +1,22 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.RenderLayers
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.Graphics.Effects
{
public enum RenderLayers
{
Sky,
Landscape,
Background,
InWorldUI,
BackgroundWater,
Walls,
TilesAndNPCs,
Entities,
ForegroundWater,
All,
}
}

View file

@ -0,0 +1,64 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.SimpleOverlay
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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 ReLogic.Content;
using Terraria.Graphics.Shaders;
namespace Terraria.Graphics.Effects
{
public class SimpleOverlay : Overlay
{
private Asset<Texture2D> _texture;
private ScreenShaderData _shader;
public Vector2 TargetPosition = Vector2.Zero;
public SimpleOverlay(
string textureName,
ScreenShaderData shader,
EffectPriority priority = EffectPriority.VeryLow,
RenderLayers layer = RenderLayers.All)
: base(priority, layer)
{
this._texture = Main.Assets.Request<Texture2D>(textureName == null ? "" : textureName, (AssetRequestMode) 1);
this._shader = shader;
}
public SimpleOverlay(
string textureName,
string shaderName = "Default",
EffectPriority priority = EffectPriority.VeryLow,
RenderLayers layer = RenderLayers.All)
: base(priority, layer)
{
this._texture = Main.Assets.Request<Texture2D>(textureName == null ? "" : textureName, (AssetRequestMode) 1);
this._shader = new ScreenShaderData(Main.ScreenShaderRef, shaderName);
}
public ScreenShaderData GetShader() => this._shader;
public override void Draw(SpriteBatch spriteBatch)
{
this._shader.UseGlobalOpacity(this.Opacity);
this._shader.UseTargetPosition(this.TargetPosition);
this._shader.Apply();
spriteBatch.Draw(this._texture.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Main.ColorOfTheSkies);
}
public override void Update(GameTime gameTime) => this._shader.Update(gameTime);
public override void Activate(Vector2 position, params object[] args)
{
this.TargetPosition = position;
this.Mode = OverlayMode.FadeIn;
}
public override void Deactivate(params object[] args) => this.Mode = OverlayMode.FadeOut;
public override bool IsVisible() => (double) this._shader.CombinedOpacity > 0.0;
}
}

View file

@ -0,0 +1,89 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Effects.SkyManager
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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.Graphics.Effects
{
public class SkyManager : EffectManager<CustomSky>
{
public static SkyManager Instance = new SkyManager();
private float _lastDepth;
private LinkedList<CustomSky> _activeSkies = new LinkedList<CustomSky>();
public void Reset()
{
foreach (CustomSky customSky in this._effects.Values)
customSky.Reset();
this._activeSkies.Clear();
}
public void Update(GameTime gameTime)
{
LinkedListNode<CustomSky> next;
for (int index = 0; index < Main.dayRate; ++index)
{
for (LinkedListNode<CustomSky> node = this._activeSkies.First; node != null; node = next)
{
CustomSky customSky = node.Value;
next = node.Next;
customSky.Update(gameTime);
if (!customSky.IsActive())
this._activeSkies.Remove(node);
}
}
}
public void Draw(SpriteBatch spriteBatch) => this.DrawDepthRange(spriteBatch, float.MinValue, float.MaxValue);
public void DrawToDepth(SpriteBatch spriteBatch, float minDepth)
{
if ((double) this._lastDepth <= (double) minDepth)
return;
this.DrawDepthRange(spriteBatch, minDepth, this._lastDepth);
this._lastDepth = minDepth;
}
public void DrawDepthRange(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
foreach (CustomSky activeSky in this._activeSkies)
activeSky.Draw(spriteBatch, minDepth, maxDepth);
}
public void DrawRemainingDepth(SpriteBatch spriteBatch)
{
this.DrawDepthRange(spriteBatch, float.MinValue, this._lastDepth);
this._lastDepth = float.MinValue;
}
public void ResetDepthTracker() => this._lastDepth = float.MaxValue;
public void SetStartingDepth(float depth) => this._lastDepth = depth;
public override void OnActivate(CustomSky effect, Vector2 position)
{
this._activeSkies.Remove(effect);
this._activeSkies.AddLast(effect);
}
public Color ProcessTileColor(Color color)
{
foreach (CustomSky activeSky in this._activeSkies)
color = activeSky.OnTileColor(color);
return color;
}
public float ProcessCloudAlpha()
{
float num = 1f;
foreach (CustomSky activeSky in this._activeSkies)
num *= activeSky.GetCloudAlpha();
return MathHelper.Clamp(num, 0.0f, 1f);
}
}
}

View file

@ -0,0 +1,41 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.EmpressBladeDrawer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
namespace Terraria.Graphics
{
public struct EmpressBladeDrawer
{
public const int TotalIllusions = 1;
public const int FramesPerImportantTrail = 60;
private static VertexStrip _vertexStrip = new VertexStrip();
public Color ColorStart;
public Color ColorEnd;
public void Draw(Projectile proj)
{
double num = (double) proj.ai[1];
MiscShaderData miscShaderData = GameShaders.Misc["EmpressBlade"];
miscShaderData.UseShaderSpecificData(new Vector4(1f, 0.0f, 0.0f, 0.6f));
miscShaderData.Apply(new DrawData?());
EmpressBladeDrawer._vertexStrip.PrepareStrip(proj.oldPos, proj.oldRot, new VertexStrip.StripColorFunction(this.StripColors), new VertexStrip.StripHalfWidthFunction(this.StripWidth), -Main.screenPosition + proj.Size / 2f, new int?(proj.oldPos.Length), true);
EmpressBladeDrawer._vertexStrip.DrawTrail();
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
}
private Color StripColors(float progressOnStrip)
{
Color color = Color.Lerp(this.ColorStart, this.ColorEnd, Utils.GetLerpValue(0.0f, 0.7f, progressOnStrip, true)) * (1f - Utils.GetLerpValue(0.0f, 0.98f, progressOnStrip, true));
color.A /= (byte) 2;
return color;
}
private float StripWidth(float progressOnStrip) => 36f;
}
}

View file

@ -0,0 +1,201 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.FinalFractalHelper
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
namespace Terraria.Graphics
{
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct FinalFractalHelper
{
public const int TotalIllusions = 4;
public const int FramesPerImportantTrail = 15;
private static VertexStrip _vertexStrip = new VertexStrip();
private static Dictionary<int, FinalFractalHelper.FinalFractalProfile> _fractalProfiles = new Dictionary<int, FinalFractalHelper.FinalFractalProfile>()
{
{
65,
new FinalFractalHelper.FinalFractalProfile(48f, new Color(236, 62, 192))
},
{
1123,
new FinalFractalHelper.FinalFractalProfile(48f, Main.OurFavoriteColor)
},
{
46,
new FinalFractalHelper.FinalFractalProfile(48f, new Color(122, 66, 191))
},
{
121,
new FinalFractalHelper.FinalFractalProfile(76f, new Color(254, 158, 35))
},
{
190,
new FinalFractalHelper.FinalFractalProfile(70f, new Color(107, 203, 0))
},
{
368,
new FinalFractalHelper.FinalFractalProfile(70f, new Color(236, 200, 19))
},
{
674,
new FinalFractalHelper.FinalFractalProfile(70f, new Color(236, 200, 19))
},
{
273,
new FinalFractalHelper.FinalFractalProfile(70f, new Color(179, 54, 201))
},
{
675,
new FinalFractalHelper.FinalFractalProfile(70f, new Color(179, 54, 201))
},
{
2880,
new FinalFractalHelper.FinalFractalProfile(70f, new Color(84, 234, 245))
},
{
989,
new FinalFractalHelper.FinalFractalProfile(48f, new Color(91, 158, 232))
},
{
1826,
new FinalFractalHelper.FinalFractalProfile(76f, new Color(252, 95, 4))
},
{
3063,
new FinalFractalHelper.FinalFractalProfile(76f, new Color(254, 194, 250))
},
{
3065,
new FinalFractalHelper.FinalFractalProfile(70f, new Color(237, 63, 133))
},
{
757,
new FinalFractalHelper.FinalFractalProfile(70f, new Color(80, 222, 122))
},
{
155,
new FinalFractalHelper.FinalFractalProfile(70f, new Color(56, 78, 210))
},
{
795,
new FinalFractalHelper.FinalFractalProfile(70f, new Color(237, 28, 36))
},
{
3018,
new FinalFractalHelper.FinalFractalProfile(80f, new Color(143, 215, 29))
},
{
4144,
new FinalFractalHelper.FinalFractalProfile(45f, new Color(178, (int) byte.MaxValue, 180))
},
{
3507,
new FinalFractalHelper.FinalFractalProfile(45f, new Color(235, 166, 135))
},
{
4956,
new FinalFractalHelper.FinalFractalProfile(86f, new Color(178, (int) byte.MaxValue, 180))
}
};
private static FinalFractalHelper.FinalFractalProfile _defaultProfile = new FinalFractalHelper.FinalFractalProfile(50f, Color.White);
public static int GetRandomProfileIndex()
{
List<int> list = FinalFractalHelper._fractalProfiles.Keys.ToList<int>();
int index = Main.rand.Next(list.Count);
if (list[index] == 4956)
{
list.RemoveAt(index);
index = Main.rand.Next(list.Count);
}
return list[index];
}
public void Draw(Projectile proj)
{
FinalFractalHelper.FinalFractalProfile finalFractalProfile = FinalFractalHelper.GetFinalFractalProfile((int) proj.ai[1]);
MiscShaderData miscShaderData = GameShaders.Misc["FinalFractal"];
miscShaderData.UseShaderSpecificData(new Vector4(4f, 0.0f, 0.0f, 4f));
miscShaderData.UseImage0("Images/Extra_" + (object) (short) 201);
miscShaderData.UseImage1("Images/Extra_" + (object) (short) 193);
miscShaderData.Apply(new DrawData?());
FinalFractalHelper._vertexStrip.PrepareStrip(proj.oldPos, proj.oldRot, finalFractalProfile.colorMethod, finalFractalProfile.widthMethod, -Main.screenPosition + proj.Size / 2f, new int?(proj.oldPos.Length), true);
FinalFractalHelper._vertexStrip.DrawTrail();
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
}
public static FinalFractalHelper.FinalFractalProfile GetFinalFractalProfile(
int usedSwordId)
{
FinalFractalHelper.FinalFractalProfile defaultProfile;
if (!FinalFractalHelper._fractalProfiles.TryGetValue(usedSwordId, out defaultProfile))
defaultProfile = FinalFractalHelper._defaultProfile;
return defaultProfile;
}
private Color StripColors(float progressOnStrip)
{
Color color = Color.Lerp(Color.White, Color.Violet, Utils.GetLerpValue(0.0f, 0.7f, progressOnStrip, true)) * (1f - Utils.GetLerpValue(0.0f, 0.98f, progressOnStrip, false));
color.A /= (byte) 2;
return color;
}
private float StripWidth(float progressOnStrip) => 50f;
public delegate void SpawnDustMethod(Vector2 centerPosition, float rotation, Vector2 velocity);
public struct FinalFractalProfile
{
public float trailWidth;
public Color trailColor;
public FinalFractalHelper.SpawnDustMethod dustMethod;
public VertexStrip.StripColorFunction colorMethod;
public VertexStrip.StripHalfWidthFunction widthMethod;
public FinalFractalProfile(float fullBladeLength, Color color)
{
this.trailWidth = fullBladeLength / 2f;
this.trailColor = color;
this.widthMethod = (VertexStrip.StripHalfWidthFunction) null;
this.colorMethod = (VertexStrip.StripColorFunction) null;
this.dustMethod = (FinalFractalHelper.SpawnDustMethod) null;
this.widthMethod = new VertexStrip.StripHalfWidthFunction(this.StripWidth);
this.colorMethod = new VertexStrip.StripColorFunction(this.StripColors);
this.dustMethod = new FinalFractalHelper.SpawnDustMethod(this.StripDust);
}
private void StripDust(Vector2 centerPosition, float rotation, Vector2 velocity)
{
if (Main.rand.Next(9) != 0)
return;
int num = Main.rand.Next(1, 4);
for (int index = 0; index < num; ++index)
{
Dust dust = Dust.NewDustPerfect(centerPosition, 278, Alpha: 100, newColor: Color.Lerp(this.trailColor, Color.White, Main.rand.NextFloat() * 0.3f));
dust.scale = 0.4f;
dust.fadeIn = (float) (0.400000005960464 + (double) Main.rand.NextFloat() * 0.300000011920929);
dust.noGravity = true;
dust.velocity += rotation.ToRotationVector2() * (float) (3.0 + (double) Main.rand.NextFloat() * 4.0);
}
}
private Color StripColors(float progressOnStrip)
{
Color color = this.trailColor * (1f - Utils.GetLerpValue(0.0f, 0.98f, progressOnStrip, false));
color.A /= (byte) 2;
return color;
}
private float StripWidth(float progressOnStrip) => this.trailWidth;
}
}
}

View file

@ -0,0 +1,45 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.FlameLashDrawer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
namespace Terraria.Graphics
{
public struct FlameLashDrawer
{
private static VertexStrip _vertexStrip = new VertexStrip();
private float transitToDark;
public void Draw(Projectile proj)
{
this.transitToDark = Utils.GetLerpValue(0.0f, 6f, proj.localAI[0], true);
MiscShaderData miscShaderData = GameShaders.Misc["FlameLash"];
miscShaderData.UseSaturation(-2f);
miscShaderData.UseOpacity(MathHelper.Lerp(4f, 8f, this.transitToDark));
miscShaderData.Apply(new DrawData?());
FlameLashDrawer._vertexStrip.PrepareStripWithProceduralPadding(proj.oldPos, proj.oldRot, new VertexStrip.StripColorFunction(this.StripColors), new VertexStrip.StripHalfWidthFunction(this.StripWidth), -Main.screenPosition + proj.Size / 2f);
FlameLashDrawer._vertexStrip.DrawTrail();
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
}
private Color StripColors(float progressOnStrip)
{
float lerpValue = Utils.GetLerpValue((float) (0.0 - 0.100000001490116 * (double) this.transitToDark), (float) (0.699999988079071 - 0.200000002980232 * (double) this.transitToDark), progressOnStrip, true);
Color color = Color.Lerp(Color.Lerp(Color.White, Color.Orange, this.transitToDark * 0.5f), Color.Red, lerpValue) * (1f - Utils.GetLerpValue(0.0f, 0.98f, progressOnStrip, false));
color.A /= (byte) 8;
return color;
}
private float StripWidth(float progressOnStrip)
{
float lerpValue = Utils.GetLerpValue(0.0f, (float) (0.0599999986588955 + (double) this.transitToDark * 0.00999999977648258), progressOnStrip, true);
float num = (float) (1.0 - (1.0 - (double) lerpValue) * (1.0 - (double) lerpValue));
return MathHelper.Lerp((float) (24.0 + (double) this.transitToDark * 16.0), 8f, Utils.GetLerpValue(0.0f, 1f, progressOnStrip, true)) * num;
}
}
}

View file

@ -0,0 +1,23 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Light.ILightingEngine
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.Graphics.Light
{
public interface ILightingEngine
{
void Rebuild();
void AddLight(int x, int y, Vector3 color);
void ProcessArea(Rectangle area);
Vector3 GetColor(int x, int y);
void Clear();
}
}

File diff suppressed because it is too large Load diff

198
Graphics/Light/LightMap.cs Normal file
View file

@ -0,0 +1,198 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Light.LightMap
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using ReLogic.Threading;
using Terraria.Utilities;
namespace Terraria.Graphics.Light
{
public class LightMap
{
private Vector3[] _colors;
private LightMaskMode[] _mask;
private FastRandom _random = FastRandom.CreateWithRandomSeed();
private const int DEFAULT_WIDTH = 203;
private const int DEFAULT_HEIGHT = 203;
public int NonVisiblePadding { get; set; }
public int Width { get; private set; }
public int Height { get; private set; }
public float LightDecayThroughAir { get; set; }
public float LightDecayThroughSolid { get; set; }
public Vector3 LightDecayThroughWater { get; set; }
public Vector3 LightDecayThroughHoney { get; set; }
public Vector3 this[int x, int y]
{
get => this._colors[this.IndexOf(x, y)];
set => this._colors[this.IndexOf(x, y)] = value;
}
public LightMap()
{
this.LightDecayThroughAir = 0.91f;
this.LightDecayThroughSolid = 0.56f;
this.LightDecayThroughWater = new Vector3(0.88f, 0.96f, 1.015f) * 0.91f;
this.LightDecayThroughHoney = new Vector3(0.75f, 0.7f, 0.6f) * 0.91f;
this.Width = 203;
this.Height = 203;
this._colors = new Vector3[41209];
this._mask = new LightMaskMode[41209];
}
public void GetLight(int x, int y, out Vector3 color) => color = this._colors[this.IndexOf(x, y)];
public LightMaskMode GetMask(int x, int y) => this._mask[this.IndexOf(x, y)];
public void Clear()
{
for (int index = 0; index < this._colors.Length; ++index)
{
this._colors[index].X = 0.0f;
this._colors[index].Y = 0.0f;
this._colors[index].Z = 0.0f;
this._mask[index] = LightMaskMode.None;
}
}
public void SetMaskAt(int x, int y, LightMaskMode mode) => this._mask[this.IndexOf(x, y)] = mode;
public void Blur()
{
this.BlurPass();
this.BlurPass();
this._random.NextSeed();
}
private void BlurPass()
{
// ISSUE: method pointer
FastParallel.For(0, this.Width, new ParallelForAction((object) this, __methodptr(\u003CBlurPass\u003Eb__42_0)), (object) null);
// ISSUE: method pointer
FastParallel.For(0, this.Height, new ParallelForAction((object) this, __methodptr(\u003CBlurPass\u003Eb__42_1)), (object) null);
}
private void BlurLine(int startIndex, int endIndex, int stride)
{
Vector3 zero = Vector3.Zero;
bool flag1 = false;
bool flag2 = false;
bool flag3 = false;
for (int index = startIndex; index != endIndex + stride; index += stride)
{
if ((double) zero.X < (double) this._colors[index].X)
{
zero.X = this._colors[index].X;
flag1 = false;
}
else if (!flag1)
{
if ((double) zero.X < 0.0185000002384186)
flag1 = true;
else
this._colors[index].X = zero.X;
}
if ((double) zero.Y < (double) this._colors[index].Y)
{
zero.Y = this._colors[index].Y;
flag2 = false;
}
else if (!flag2)
{
if ((double) zero.Y < 0.0185000002384186)
flag2 = true;
else
this._colors[index].Y = zero.Y;
}
if ((double) zero.Z < (double) this._colors[index].Z)
{
zero.Z = this._colors[index].Z;
flag3 = false;
}
else if (!flag3)
{
if ((double) zero.Z < 0.0185000002384186)
flag3 = true;
else
this._colors[index].Z = zero.Z;
}
if (!(flag1 & flag3 & flag2))
{
switch (this._mask[index])
{
case LightMaskMode.None:
if (!flag1)
zero.X *= this.LightDecayThroughAir;
if (!flag2)
zero.Y *= this.LightDecayThroughAir;
if (!flag3)
{
zero.Z *= this.LightDecayThroughAir;
continue;
}
continue;
case LightMaskMode.Solid:
if (!flag1)
zero.X *= this.LightDecayThroughSolid;
if (!flag2)
zero.Y *= this.LightDecayThroughSolid;
if (!flag3)
{
zero.Z *= this.LightDecayThroughSolid;
continue;
}
continue;
case LightMaskMode.Water:
float num = (float) this._random.WithModifier((ulong) index).Next(98, 100) / 100f;
if (!flag1)
zero.X *= this.LightDecayThroughWater.X * num;
if (!flag2)
zero.Y *= this.LightDecayThroughWater.Y * num;
if (!flag3)
{
zero.Z *= this.LightDecayThroughWater.Z * num;
continue;
}
continue;
case LightMaskMode.Honey:
if (!flag1)
zero.X *= this.LightDecayThroughHoney.X;
if (!flag2)
zero.Y *= this.LightDecayThroughHoney.Y;
if (!flag3)
{
zero.Z *= this.LightDecayThroughHoney.Z;
continue;
}
continue;
default:
continue;
}
}
}
}
private int IndexOf(int x, int y) => x * this.Height + y;
public void SetSize(int width, int height)
{
if (width * height > this._colors.Length)
{
this._colors = new Vector3[width * height];
this._mask = new LightMaskMode[width * height];
}
this.Width = width;
this.Height = height;
}
}
}

View file

@ -0,0 +1,16 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Light.LightMaskMode
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.Graphics.Light
{
public enum LightMaskMode : byte
{
None,
Solid,
Water,
Honey,
}
}

View file

@ -0,0 +1,16 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Light.LightMode
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.Graphics.Light
{
public enum LightMode
{
White,
Retro,
Trippy,
Color,
}
}

View file

@ -0,0 +1,249 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Light.LightingEngine
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using ReLogic.Threading;
using System.Collections.Generic;
using System.Diagnostics;
namespace Terraria.Graphics.Light
{
public class LightingEngine : ILightingEngine
{
private const int AREA_PADDING = 28;
private const int NON_VISIBLE_PADDING = 18;
private readonly List<LightingEngine.PerFrameLight> _perFrameLights = new List<LightingEngine.PerFrameLight>();
private TileLightScanner _tileScanner;
private LightMap _activeLightMap = new LightMap();
private Rectangle _activeProcessedArea;
private LightMap _workingLightMap = new LightMap();
private Rectangle _workingProcessedArea;
private readonly Stopwatch _timer = new Stopwatch();
private LightingEngine.EngineState _state;
public LightingEngine(World world) => this.SetWorld(world);
public void AddLight(int x, int y, Vector3 color) => this._perFrameLights.Add(new LightingEngine.PerFrameLight(new Point(x, y), color));
public void Clear()
{
this._activeLightMap.Clear();
this._workingLightMap.Clear();
this._perFrameLights.Clear();
}
public Vector3 GetColor(int x, int y)
{
if (!this._activeProcessedArea.Contains(x, y))
return Vector3.Zero;
x -= this._activeProcessedArea.X;
y -= this._activeProcessedArea.Y;
return this._activeLightMap[x, y];
}
public void ProcessArea(Rectangle area)
{
Main.renderCount = (Main.renderCount + 1) % 4;
this._timer.Start();
TimeLogger.LightingTime(0, 0.0);
switch (this._state)
{
case LightingEngine.EngineState.MinimapUpdate:
if (Main.mapDelay > 0)
--Main.mapDelay;
else
this.ExportToMiniMap();
TimeLogger.LightingTime(1, this._timer.Elapsed.TotalMilliseconds);
break;
case LightingEngine.EngineState.ExportMetrics:
area.Inflate(28, 28);
Main.SceneMetrics.ScanAndExportToMain(new SceneMetricsScanSettings()
{
VisualScanArea = new Rectangle?(area),
BiomeScanCenterPositionInWorld = new Vector2?(Main.LocalPlayer.Center),
ScanOreFinderData = Main.LocalPlayer.accOreFinder
});
TimeLogger.LightingTime(2, this._timer.Elapsed.TotalMilliseconds);
break;
case LightingEngine.EngineState.Scan:
this.ProcessScan(area);
TimeLogger.LightingTime(3, this._timer.Elapsed.TotalMilliseconds);
break;
case LightingEngine.EngineState.Blur:
this.ProcessBlur();
this.Present();
TimeLogger.LightingTime(4, this._timer.Elapsed.TotalMilliseconds);
break;
}
this.IncrementState();
this._timer.Reset();
}
private void IncrementState() => this._state = (LightingEngine.EngineState) ((int) (this._state + 1) % 4);
private void ProcessScan(Rectangle area)
{
area.Inflate(28, 28);
this._workingProcessedArea = area;
this._workingLightMap.SetSize(area.Width, area.Height);
this._workingLightMap.NonVisiblePadding = 18;
this._tileScanner.Update();
this._tileScanner.ExportTo(area, this._workingLightMap);
}
private void ProcessBlur()
{
this.UpdateLightDecay();
this.ApplyPerFrameLights();
this._workingLightMap.Blur();
}
private void Present()
{
Utils.Swap<LightMap>(ref this._activeLightMap, ref this._workingLightMap);
Utils.Swap<Rectangle>(ref this._activeProcessedArea, ref this._workingProcessedArea);
}
private void UpdateLightDecay()
{
LightMap workingLightMap = this._workingLightMap;
workingLightMap.LightDecayThroughAir = 0.91f;
workingLightMap.LightDecayThroughSolid = 0.56f;
workingLightMap.LightDecayThroughHoney = new Vector3(0.75f, 0.7f, 0.6f) * 0.91f;
switch (Main.waterStyle)
{
case 0:
case 1:
case 7:
case 8:
workingLightMap.LightDecayThroughWater = new Vector3(0.88f, 0.96f, 1.015f) * 0.91f;
break;
case 2:
workingLightMap.LightDecayThroughWater = new Vector3(0.94f, 0.85f, 1.01f) * 0.91f;
break;
case 3:
workingLightMap.LightDecayThroughWater = new Vector3(0.84f, 0.95f, 1.015f) * 0.91f;
break;
case 4:
workingLightMap.LightDecayThroughWater = new Vector3(0.9f, 0.86f, 1.01f) * 0.91f;
break;
case 5:
workingLightMap.LightDecayThroughWater = new Vector3(0.84f, 0.99f, 1.01f) * 0.91f;
break;
case 6:
workingLightMap.LightDecayThroughWater = new Vector3(0.83f, 0.93f, 0.98f) * 0.91f;
break;
case 9:
workingLightMap.LightDecayThroughWater = new Vector3(1f, 0.88f, 0.84f) * 0.91f;
break;
case 10:
workingLightMap.LightDecayThroughWater = new Vector3(0.83f, 1f, 1f) * 0.91f;
break;
case 12:
workingLightMap.LightDecayThroughWater = new Vector3(0.95f, 0.98f, 0.85f) * 0.91f;
break;
}
if (Main.player[Main.myPlayer].nightVision)
{
workingLightMap.LightDecayThroughAir *= 1.03f;
workingLightMap.LightDecayThroughSolid *= 1.03f;
}
if (Main.player[Main.myPlayer].blind)
{
workingLightMap.LightDecayThroughAir *= 0.95f;
workingLightMap.LightDecayThroughSolid *= 0.95f;
}
if (Main.player[Main.myPlayer].blackout)
{
workingLightMap.LightDecayThroughAir *= 0.85f;
workingLightMap.LightDecayThroughSolid *= 0.85f;
}
if (!Main.player[Main.myPlayer].headcovered)
return;
workingLightMap.LightDecayThroughAir *= 0.85f;
workingLightMap.LightDecayThroughSolid *= 0.85f;
}
private void ApplyPerFrameLights()
{
for (int index = 0; index < this._perFrameLights.Count; ++index)
{
Point position = this._perFrameLights[index].Position;
if (this._workingProcessedArea.Contains(position))
{
Vector3 result = this._perFrameLights[index].Color;
Vector3 workingLight = this._workingLightMap[position.X - this._workingProcessedArea.X, position.Y - this._workingProcessedArea.Y];
Vector3.Max(ref workingLight, ref result, out result);
this._workingLightMap[position.X - this._workingProcessedArea.X, position.Y - this._workingProcessedArea.Y] = result;
}
}
this._perFrameLights.Clear();
}
public void Rebuild()
{
this._activeProcessedArea = Rectangle.Empty;
this._workingProcessedArea = Rectangle.Empty;
this._state = LightingEngine.EngineState.MinimapUpdate;
this._activeLightMap = new LightMap();
this._workingLightMap = new LightMap();
}
private void SetWorld(World world) => this._tileScanner = new TileLightScanner(world);
private void ExportToMiniMap()
{
// ISSUE: object of a compiler-generated type is created
// ISSUE: variable of a compiler-generated type
LightingEngine.\u003C\u003Ec__DisplayClass24_0 cDisplayClass240 = new LightingEngine.\u003C\u003Ec__DisplayClass24_0();
// ISSUE: reference to a compiler-generated field
cDisplayClass240.\u003C\u003E4__this = this;
if (!Main.mapEnabled || this._activeProcessedArea.Width <= 0 || this._activeProcessedArea.Height <= 0)
return;
// ISSUE: reference to a compiler-generated field
cDisplayClass240.area = new Rectangle(this._activeProcessedArea.X + 28, this._activeProcessedArea.Y + 28, this._activeProcessedArea.Width - 56, this._activeProcessedArea.Height - 56);
Rectangle rectangle = new Rectangle(0, 0, Main.maxTilesX, Main.maxTilesY);
rectangle.Inflate(-Main.Map.BlackEdgeWidth, -Main.Map.BlackEdgeWidth);
// ISSUE: reference to a compiler-generated field
// ISSUE: reference to a compiler-generated field
cDisplayClass240.area = Rectangle.Intersect(cDisplayClass240.area, rectangle);
// ISSUE: reference to a compiler-generated field
Main.mapMinX = cDisplayClass240.area.Left;
// ISSUE: reference to a compiler-generated field
Main.mapMinY = cDisplayClass240.area.Top;
// ISSUE: reference to a compiler-generated field
Main.mapMaxX = cDisplayClass240.area.Right;
// ISSUE: reference to a compiler-generated field
Main.mapMaxY = cDisplayClass240.area.Bottom;
// ISSUE: reference to a compiler-generated field
// ISSUE: reference to a compiler-generated field
// ISSUE: method pointer
FastParallel.For(cDisplayClass240.area.Left, cDisplayClass240.area.Right, new ParallelForAction((object) cDisplayClass240, __methodptr(\u003CExportToMiniMap\u003Eb__0)), (object) null);
Main.updateMap = true;
}
private enum EngineState
{
MinimapUpdate,
ExportMetrics,
Scan,
Blur,
Max,
}
private struct PerFrameLight
{
public readonly Point Position;
public readonly Vector3 Color;
public PerFrameLight(Point position, Vector3 color)
{
this.Position = position;
this.Color = color;
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,39 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.MagicMissileDrawer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System.Runtime.InteropServices;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
namespace Terraria.Graphics
{
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct MagicMissileDrawer
{
private static VertexStrip _vertexStrip = new VertexStrip();
public void Draw(Projectile proj)
{
MiscShaderData miscShaderData = GameShaders.Misc["MagicMissile"];
miscShaderData.UseSaturation(-2.8f);
miscShaderData.UseOpacity(2f);
miscShaderData.Apply(new DrawData?());
MagicMissileDrawer._vertexStrip.PrepareStripWithProceduralPadding(proj.oldPos, proj.oldRot, new VertexStrip.StripColorFunction(this.StripColors), new VertexStrip.StripHalfWidthFunction(this.StripWidth), -Main.screenPosition + proj.Size / 2f);
MagicMissileDrawer._vertexStrip.DrawTrail();
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
}
private Color StripColors(float progressOnStrip)
{
Color color = Color.Lerp(Color.White, Color.Violet, Utils.GetLerpValue(0.0f, 0.7f, progressOnStrip, true)) * (1f - Utils.GetLerpValue(0.0f, 0.98f, progressOnStrip, false));
color.A /= (byte) 2;
return color;
}
private float StripWidth(float progressOnStrip) => MathHelper.Lerp(26f, 32f, Utils.GetLerpValue(0.0f, 0.2f, progressOnStrip, true)) * Utils.GetLerpValue(0.0f, 0.07f, progressOnStrip, true);
}
}

View file

@ -0,0 +1,44 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.RainbowRodDrawer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System.Runtime.InteropServices;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
namespace Terraria.Graphics
{
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct RainbowRodDrawer
{
private static VertexStrip _vertexStrip = new VertexStrip();
public void Draw(Projectile proj)
{
MiscShaderData miscShaderData = GameShaders.Misc["RainbowRod"];
miscShaderData.UseSaturation(-2.8f);
miscShaderData.UseOpacity(4f);
miscShaderData.Apply(new DrawData?());
RainbowRodDrawer._vertexStrip.PrepareStripWithProceduralPadding(proj.oldPos, proj.oldRot, new VertexStrip.StripColorFunction(this.StripColors), new VertexStrip.StripHalfWidthFunction(this.StripWidth), -Main.screenPosition + proj.Size / 2f);
RainbowRodDrawer._vertexStrip.DrawTrail();
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
}
private Color StripColors(float progressOnStrip)
{
Color color = Color.Lerp(Color.White, Main.hslToRgb((float) (((double) progressOnStrip * 1.60000002384186 - (double) Main.GlobalTimeWrappedHourly) % 1.0), 1f, 0.5f), Utils.GetLerpValue(-0.2f, 0.5f, progressOnStrip, true)) * (1f - Utils.GetLerpValue(0.0f, 0.98f, progressOnStrip, false));
color.A = (byte) 0;
return color;
}
private float StripWidth(float progressOnStrip)
{
float num = 1f;
float lerpValue = Utils.GetLerpValue(0.0f, 0.2f, progressOnStrip, true);
return MathHelper.Lerp(0.0f, 32f, num * (float) (1.0 - (1.0 - (double) lerpValue) * (1.0 - (double) lerpValue)));
}
}
}

View file

@ -0,0 +1,88 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.ABasicParticle
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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 ReLogic.Content;
namespace Terraria.Graphics.Renderers
{
public abstract class ABasicParticle : IPooledParticle, IParticle
{
public Vector2 AccelerationPerFrame;
public Vector2 Velocity;
public Vector2 LocalPosition;
protected Asset<Texture2D> _texture;
protected Rectangle _frame;
protected Vector2 _origin;
public float Rotation;
public float RotationVelocity;
public float RotationAcceleration;
public Vector2 Scale;
public Vector2 ScaleVelocity;
public Vector2 ScaleAcceleration;
public bool ShouldBeRemovedFromRenderer { get; protected set; }
public ABasicParticle()
{
this._texture = (Asset<Texture2D>) null;
this._frame = Rectangle.Empty;
this._origin = Vector2.Zero;
this.Velocity = Vector2.Zero;
this.LocalPosition = Vector2.Zero;
this.ShouldBeRemovedFromRenderer = false;
}
public virtual void SetBasicInfo(
Asset<Texture2D> textureAsset,
Rectangle? frame,
Vector2 initialVelocity,
Vector2 initialLocalPosition)
{
this._texture = textureAsset;
this._frame = frame.HasValue ? frame.Value : this._texture.Frame();
this._origin = this._frame.Size() / 2f;
this.Velocity = initialVelocity;
this.LocalPosition = initialLocalPosition;
this.ShouldBeRemovedFromRenderer = false;
}
public virtual void Update(ref ParticleRendererSettings settings)
{
this.Velocity += this.AccelerationPerFrame;
this.LocalPosition += this.Velocity;
this.RotationVelocity += this.RotationAcceleration;
this.Rotation += this.RotationVelocity;
this.ScaleVelocity += this.ScaleAcceleration;
this.Scale += this.ScaleVelocity;
}
public abstract void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch);
public bool IsRestingInPool { get; private set; }
public void RestInPool() => this.IsRestingInPool = true;
public virtual void FetchFromPool()
{
this.IsRestingInPool = false;
this.ShouldBeRemovedFromRenderer = false;
this.AccelerationPerFrame = Vector2.Zero;
this.Velocity = Vector2.Zero;
this.LocalPosition = Vector2.Zero;
this._texture = (Asset<Texture2D>) null;
this._frame = Rectangle.Empty;
this._origin = Vector2.Zero;
this.Rotation = 0.0f;
this.RotationVelocity = 0.0f;
this.RotationAcceleration = 0.0f;
this.Scale = Vector2.Zero;
this.ScaleVelocity = Vector2.Zero;
this.ScaleAcceleration = Vector2.Zero;
}
}
}

View file

@ -0,0 +1,59 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.CreativeSacrificeParticle
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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 ReLogic.Content;
namespace Terraria.Graphics.Renderers
{
public class CreativeSacrificeParticle : IParticle
{
public Vector2 AccelerationPerFrame;
public Vector2 Velocity;
public Vector2 LocalPosition;
public float ScaleOffsetPerFrame;
public float StopWhenBelowXScale;
private Asset<Texture2D> _texture;
private Rectangle _frame;
private Vector2 _origin;
private float _scale;
public bool ShouldBeRemovedFromRenderer { get; private set; }
public CreativeSacrificeParticle(
Asset<Texture2D> textureAsset,
Rectangle? frame,
Vector2 initialVelocity,
Vector2 initialLocalPosition)
{
this._texture = textureAsset;
this._frame = frame.HasValue ? frame.Value : this._texture.Frame();
this._origin = this._frame.Size() / 2f;
this.Velocity = initialVelocity;
this.LocalPosition = initialLocalPosition;
this.StopWhenBelowXScale = 0.0f;
this.ShouldBeRemovedFromRenderer = false;
this._scale = 0.6f;
}
public void Update(ref ParticleRendererSettings settings)
{
this.Velocity += this.AccelerationPerFrame;
this.LocalPosition += this.Velocity;
this._scale += this.ScaleOffsetPerFrame;
if ((double) this._scale > (double) this.StopWhenBelowXScale)
return;
this.ShouldBeRemovedFromRenderer = true;
}
public void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch)
{
Color color = Color.Lerp(Color.White, new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue, 0), Utils.GetLerpValue(0.1f, 0.5f, this._scale, false));
spritebatch.Draw(this._texture.Value, settings.AnchorPosition + this.LocalPosition, new Rectangle?(this._frame), color, 0.0f, this._origin, this._scale, SpriteEffects.None, 0.0f);
}
}
}

View file

@ -0,0 +1,47 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.FadingParticle
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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.Graphics.Renderers
{
public class FadingParticle : ABasicParticle
{
public float FadeInNormalizedTime;
public float FadeOutNormalizedTime = 1f;
public Color ColorTint = Color.White;
private float _timeTolive;
private float _timeSinceSpawn;
public override void FetchFromPool()
{
base.FetchFromPool();
this.FadeInNormalizedTime = 0.0f;
this.FadeOutNormalizedTime = 1f;
this.ColorTint = Color.White;
this._timeTolive = 0.0f;
this._timeSinceSpawn = 0.0f;
}
public void SetTypeInfo(float timeToLive) => this._timeTolive = timeToLive;
public override void Update(ref ParticleRendererSettings settings)
{
base.Update(ref settings);
++this._timeSinceSpawn;
if ((double) this._timeSinceSpawn < (double) this._timeTolive)
return;
this.ShouldBeRemovedFromRenderer = true;
}
public override void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch)
{
Color color = this.ColorTint * Utils.GetLerpValue(0.0f, this.FadeInNormalizedTime, this._timeSinceSpawn / this._timeTolive, true) * Utils.GetLerpValue(1f, this.FadeOutNormalizedTime, this._timeSinceSpawn / this._timeTolive, true);
spritebatch.Draw(this._texture.Value, settings.AnchorPosition + this.LocalPosition, new Rectangle?(this._frame), color, this.Rotation, this._origin, this.Scale, SpriteEffects.None, 0.0f);
}
}
}

View file

@ -0,0 +1,77 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.FlameParticle
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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 ReLogic.Content;
using Terraria.DataStructures;
namespace Terraria.Graphics.Renderers
{
public class FlameParticle : ABasicParticle
{
public float FadeOutNormalizedTime = 1f;
private float _timeTolive;
private float _timeSinceSpawn;
private int _indexOfPlayerWhoSpawnedThis;
private int _packedShaderIndex;
public override void FetchFromPool()
{
base.FetchFromPool();
this.FadeOutNormalizedTime = 1f;
this._timeTolive = 0.0f;
this._timeSinceSpawn = 0.0f;
this._indexOfPlayerWhoSpawnedThis = 0;
this._packedShaderIndex = 0;
}
public override void SetBasicInfo(
Asset<Texture2D> textureAsset,
Rectangle? frame,
Vector2 initialVelocity,
Vector2 initialLocalPosition)
{
base.SetBasicInfo(textureAsset, frame, initialVelocity, initialLocalPosition);
this._origin = new Vector2((float) (this._frame.Width / 2), (float) (this._frame.Height - 2));
}
public void SetTypeInfo(float timeToLive, int indexOfPlayerWhoSpawnedIt, int packedShaderIndex)
{
this._timeTolive = timeToLive;
this._indexOfPlayerWhoSpawnedThis = indexOfPlayerWhoSpawnedIt;
this._packedShaderIndex = packedShaderIndex;
}
public override void Update(ref ParticleRendererSettings settings)
{
base.Update(ref settings);
++this._timeSinceSpawn;
if ((double) this._timeSinceSpawn < (double) this._timeTolive)
return;
this.ShouldBeRemovedFromRenderer = true;
}
public override void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch)
{
Color color = new Color(120, 120, 120, 60) * Utils.GetLerpValue(1f, this.FadeOutNormalizedTime, this._timeSinceSpawn / this._timeTolive, true);
Vector2 vector2_1 = settings.AnchorPosition + this.LocalPosition;
ulong seed = Main.TileFrameSeed ^ ((ulong) this.LocalPosition.X << 32 | (ulong) (uint) this.LocalPosition.Y);
Player player = Main.player[this._indexOfPlayerWhoSpawnedThis];
for (int index = 0; index < 4; ++index)
{
Vector2 vector2_2 = new Vector2((float) Utils.RandomInt(ref seed, -2, 3), (float) Utils.RandomInt(ref seed, -2, 3));
DrawData cdd = new DrawData(this._texture.Value, vector2_1 + vector2_2 * this.Scale, new Rectangle?(this._frame), color, this.Rotation, this._origin, this.Scale, SpriteEffects.None, 0)
{
shader = this._packedShaderIndex
};
PlayerDrawHelper.SetShaderForData(player, 0, ref cdd);
cdd.Draw(spritebatch);
}
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
}
}
}

View file

@ -0,0 +1,19 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.IParticle
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework.Graphics;
namespace Terraria.Graphics.Renderers
{
public interface IParticle
{
bool ShouldBeRemovedFromRenderer { get; }
void Update(ref ParticleRendererSettings settings);
void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch);
}
}

View file

@ -0,0 +1,33 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.IPlayerRenderer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System.Collections.Generic;
namespace Terraria.Graphics.Renderers
{
public interface IPlayerRenderer
{
void DrawPlayers(Camera camera, IEnumerable<Player> players);
void DrawPlayerHead(
Camera camera,
Player drawPlayer,
Vector2 position,
float alpha = 1f,
float scale = 1f,
Color borderColor = default (Color));
void DrawPlayer(
Camera camera,
Player drawPlayer,
Vector2 position,
float rotation,
Vector2 rotationOrigin,
float shadow = 0.0f,
float scale = 1f);
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.IPooledParticle
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.Graphics.Renderers
{
public interface IPooledParticle : IParticle
{
bool IsRestingInPool { get; }
void RestInPool();
void FetchFromPool();
}
}

View file

@ -0,0 +1,453 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.LegacyPlayerRenderer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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;
using System.Collections.Generic;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.ID;
namespace Terraria.Graphics.Renderers
{
public class LegacyPlayerRenderer : IPlayerRenderer
{
private readonly List<DrawData> _drawData = new List<DrawData>();
private readonly List<int> _dust = new List<int>();
private readonly List<int> _gore = new List<int>();
public static SamplerState MountedSamplerState => !Main.drawToScreen ? SamplerState.AnisotropicClamp : SamplerState.LinearClamp;
public void DrawPlayers(Camera camera, IEnumerable<Player> players)
{
foreach (Player player in players)
this.DrawPlayerFull(camera, player);
}
public void DrawPlayerHead(
Camera camera,
Player drawPlayer,
Vector2 position,
float alpha = 1f,
float scale = 1f,
Color borderColor = default (Color))
{
this._drawData.Clear();
this._dust.Clear();
this._gore.Clear();
PlayerDrawHeadSet drawinfo = new PlayerDrawHeadSet();
drawinfo.BoringSetup(drawPlayer, this._drawData, this._dust, this._gore, position.X, position.Y, alpha, scale);
PlayerDrawHeadLayers.DrawPlayer_00_BackHelmet(ref drawinfo);
PlayerDrawHeadLayers.DrawPlayer_01_FaceSkin(ref drawinfo);
PlayerDrawHeadLayers.DrawPlayer_02_DrawArmorWithFullHair(ref drawinfo);
PlayerDrawHeadLayers.DrawPlayer_03_HelmetHair(ref drawinfo);
PlayerDrawHeadLayers.DrawPlayer_04_JungleRose(ref drawinfo);
PlayerDrawHeadLayers.DrawPlayer_05_TallHats(ref drawinfo);
PlayerDrawHeadLayers.DrawPlayer_06_NormalHats(ref drawinfo);
PlayerDrawHeadLayers.DrawPlayer_07_JustHair(ref drawinfo);
PlayerDrawHeadLayers.DrawPlayer_08_FaceAcc(ref drawinfo);
this.CreateOutlines(alpha, scale, borderColor);
PlayerDrawHeadLayers.DrawPlayer_RenderAllLayers(ref drawinfo);
}
private void CreateOutlines(float alpha, float scale, Color borderColor)
{
if (!(borderColor != Color.Transparent))
return;
List<DrawData> drawDataList1 = new List<DrawData>((IEnumerable<DrawData>) this._drawData);
List<DrawData> drawDataList2 = new List<DrawData>((IEnumerable<DrawData>) this._drawData);
float num1 = 2f * scale;
Color color1 = borderColor * (alpha * alpha);
Color color2 = Color.Black * (alpha * alpha);
int colorOnlyShaderIndex = ContentSamples.CommonlyUsedContentSamples.ColorOnlyShaderIndex;
for (int index = 0; index < drawDataList2.Count; ++index)
{
DrawData drawData = drawDataList2[index];
drawData.shader = colorOnlyShaderIndex;
drawData.color = color2;
drawDataList2[index] = drawData;
}
int num2 = 2;
for (int index1 = -num2; index1 <= num2; ++index1)
{
for (int index2 = -num2; index2 <= num2; ++index2)
{
if (Math.Abs(index1) + Math.Abs(index2) == num2)
{
Vector2 vector2 = new Vector2((float) index1 * num1, (float) index2 * num1);
for (int index3 = 0; index3 < drawDataList2.Count; ++index3)
{
DrawData drawData = drawDataList2[index3];
drawData.position += vector2;
this._drawData.Add(drawData);
}
}
}
}
for (int index = 0; index < drawDataList2.Count; ++index)
{
DrawData drawData = drawDataList2[index];
drawData.shader = colorOnlyShaderIndex;
drawData.color = color1;
drawDataList2[index] = drawData;
}
Vector2 vector2_1 = Vector2.Zero;
int num3 = 1;
for (int index4 = -num3; index4 <= num3; ++index4)
{
for (int index5 = -num3; index5 <= num3; ++index5)
{
if (Math.Abs(index4) + Math.Abs(index5) == num3)
{
vector2_1 = new Vector2((float) index4 * num1, (float) index5 * num1);
for (int index6 = 0; index6 < drawDataList2.Count; ++index6)
{
DrawData drawData = drawDataList2[index6];
drawData.position += vector2_1;
this._drawData.Add(drawData);
}
}
}
}
this._drawData.AddRange((IEnumerable<DrawData>) drawDataList1);
}
public void DrawPlayer(
Camera camera,
Player drawPlayer,
Vector2 position,
float rotation,
Vector2 rotationOrigin,
float shadow = 0.0f,
float scale = 1f)
{
if (drawPlayer.ShouldNotDraw)
return;
PlayerDrawSet drawinfo = new PlayerDrawSet();
this._drawData.Clear();
this._dust.Clear();
this._gore.Clear();
drawinfo.BoringSetup(drawPlayer, this._drawData, this._dust, this._gore, position, shadow, rotation, rotationOrigin);
PlayerDrawLayers.DrawPlayer_extra_TorsoPlus(ref drawinfo);
PlayerDrawLayers.DrawPlayer_01_BackHair(ref drawinfo);
PlayerDrawLayers.DrawPlayer_01_2_JimsCloak(ref drawinfo);
PlayerDrawLayers.DrawPlayer_01_3_BackHead(ref drawinfo);
PlayerDrawLayers.DrawPlayer_extra_TorsoMinus(ref drawinfo);
PlayerDrawLayers.DrawPlayer_02_MountBehindPlayer(ref drawinfo);
PlayerDrawLayers.DrawPlayer_03_Carpet(ref drawinfo);
PlayerDrawLayers.DrawPlayer_03_PortableStool(ref drawinfo);
PlayerDrawLayers.DrawPlayer_extra_TorsoPlus(ref drawinfo);
PlayerDrawLayers.DrawPlayer_04_ElectrifiedDebuffBack(ref drawinfo);
PlayerDrawLayers.DrawPlayer_05_ForbiddenSetRing(ref drawinfo);
PlayerDrawLayers.DrawPlayer_05_2_SafemanSun(ref drawinfo);
PlayerDrawLayers.DrawPlayer_06_WebbedDebuffBack(ref drawinfo);
PlayerDrawLayers.DrawPlayer_07_LeinforsHairShampoo(ref drawinfo);
PlayerDrawLayers.DrawPlayer_extra_TorsoMinus(ref drawinfo);
PlayerDrawLayers.DrawPlayer_08_Backpacks(ref drawinfo);
PlayerDrawLayers.DrawPlayer_09_BackAc(ref drawinfo);
PlayerDrawLayers.DrawPlayer_10_Wings(ref drawinfo);
PlayerDrawLayers.DrawPlayer_11_Balloons(ref drawinfo);
if (drawinfo.weaponDrawOrder == WeaponDrawOrder.BehindBackArm)
PlayerDrawLayers.DrawPlayer_27_HeldItem(ref drawinfo);
PlayerDrawLayers.DrawPlayer_12_Skin(ref drawinfo);
if (drawinfo.drawPlayer.wearsRobe && drawinfo.drawPlayer.body != 166)
{
PlayerDrawLayers.DrawPlayer_14_Shoes(ref drawinfo);
PlayerDrawLayers.DrawPlayer_13_Leggings(ref drawinfo);
}
else
{
PlayerDrawLayers.DrawPlayer_13_Leggings(ref drawinfo);
PlayerDrawLayers.DrawPlayer_14_Shoes(ref drawinfo);
}
PlayerDrawLayers.DrawPlayer_extra_TorsoPlus(ref drawinfo);
PlayerDrawLayers.DrawPlayer_15_SkinLongCoat(ref drawinfo);
PlayerDrawLayers.DrawPlayer_16_ArmorLongCoat(ref drawinfo);
PlayerDrawLayers.DrawPlayer_17_Torso(ref drawinfo);
PlayerDrawLayers.DrawPlayer_18_OffhandAcc(ref drawinfo);
PlayerDrawLayers.DrawPlayer_19_WaistAcc(ref drawinfo);
PlayerDrawLayers.DrawPlayer_20_NeckAcc(ref drawinfo);
PlayerDrawLayers.DrawPlayer_21_Head(ref drawinfo);
PlayerDrawLayers.DrawPlayer_22_FaceAcc(ref drawinfo);
if (drawinfo.drawFrontAccInNeckAccLayer)
{
PlayerDrawLayers.DrawPlayer_extra_TorsoMinus(ref drawinfo);
PlayerDrawLayers.DrawPlayer_32_FrontAcc(ref drawinfo);
PlayerDrawLayers.DrawPlayer_extra_TorsoPlus(ref drawinfo);
}
PlayerDrawLayers.DrawPlayer_23_MountFront(ref drawinfo);
PlayerDrawLayers.DrawPlayer_24_Pulley(ref drawinfo);
PlayerDrawLayers.DrawPlayer_25_Shield(ref drawinfo);
PlayerDrawLayers.DrawPlayer_extra_MountPlus(ref drawinfo);
PlayerDrawLayers.DrawPlayer_26_SolarShield(ref drawinfo);
PlayerDrawLayers.DrawPlayer_extra_MountMinus(ref drawinfo);
if (drawinfo.weaponDrawOrder == WeaponDrawOrder.BehindFrontArm)
PlayerDrawLayers.DrawPlayer_27_HeldItem(ref drawinfo);
PlayerDrawLayers.DrawPlayer_28_ArmOverItem(ref drawinfo);
PlayerDrawLayers.DrawPlayer_29_OnhandAcc(ref drawinfo);
PlayerDrawLayers.DrawPlayer_30_BladedGlove(ref drawinfo);
PlayerDrawLayers.DrawPlayer_extra_TorsoMinus(ref drawinfo);
if (!drawinfo.drawFrontAccInNeckAccLayer)
PlayerDrawLayers.DrawPlayer_32_FrontAcc(ref drawinfo);
if (drawinfo.weaponDrawOrder == WeaponDrawOrder.OverFrontArm)
PlayerDrawLayers.DrawPlayer_27_HeldItem(ref drawinfo);
PlayerDrawLayers.DrawPlayer_31_ProjectileOverArm(ref drawinfo);
PlayerDrawLayers.DrawPlayer_33_FrozenOrWebbedDebuff(ref drawinfo);
PlayerDrawLayers.DrawPlayer_34_ElectrifiedDebuffFront(ref drawinfo);
PlayerDrawLayers.DrawPlayer_35_IceBarrier(ref drawinfo);
PlayerDrawLayers.DrawPlayer_36_CTG(ref drawinfo);
PlayerDrawLayers.DrawPlayer_37_BeetleBuff(ref drawinfo);
PlayerDrawLayers.DrawPlayer_MakeIntoFirstFractalAfterImage(ref drawinfo);
PlayerDrawLayers.DrawPlayer_TransformDrawData(ref drawinfo);
if ((double) scale != 1.0)
PlayerDrawLayers.DrawPlayer_ScaleDrawData(ref drawinfo, scale);
PlayerDrawLayers.DrawPlayer_RenderAllLayers(ref drawinfo);
if (!drawinfo.drawPlayer.mount.Active || drawinfo.drawPlayer.mount.Type != 11)
return;
for (int i = 0; i < 1000; ++i)
{
if (Main.projectile[i].active && Main.projectile[i].owner == drawinfo.drawPlayer.whoAmI && Main.projectile[i].type == 591)
Main.instance.DrawProj(i);
}
}
private void DrawPlayerFull(Camera camera, Player drawPlayer)
{
SpriteBatch spriteBatch = camera.SpriteBatch;
SamplerState samplerState = camera.Sampler;
if (drawPlayer.mount.Active && (double) drawPlayer.fullRotation != 0.0)
samplerState = LegacyPlayerRenderer.MountedSamplerState;
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, samplerState, DepthStencilState.None, camera.Rasterizer, (Effect) null, camera.GameViewMatrix.TransformationMatrix);
if (Main.gamePaused)
drawPlayer.PlayerFrame();
if (drawPlayer.ghost)
{
for (int index = 0; index < 3; ++index)
{
Vector2 shadowPo = drawPlayer.shadowPos[index];
Vector2 position = drawPlayer.position - drawPlayer.velocity * (float) (2 + index * 2);
this.DrawGhost(camera, drawPlayer, position, (float) (0.5 + 0.200000002980232 * (double) index));
}
this.DrawGhost(camera, drawPlayer, drawPlayer.position);
}
else
{
if (drawPlayer.inventory[drawPlayer.selectedItem].flame || drawPlayer.head == 137 || drawPlayer.wings == 22)
{
--drawPlayer.itemFlameCount;
if (drawPlayer.itemFlameCount <= 0)
{
drawPlayer.itemFlameCount = 5;
for (int index = 0; index < 7; ++index)
{
drawPlayer.itemFlamePos[index].X = (float) Main.rand.Next(-10, 11) * 0.15f;
drawPlayer.itemFlamePos[index].Y = (float) Main.rand.Next(-10, 1) * 0.35f;
}
}
}
if (drawPlayer.armorEffectDrawShadowEOCShield)
{
int num = drawPlayer.eocDash / 4;
if (num > 3)
num = 3;
for (int index = 0; index < num; ++index)
this.DrawPlayer(camera, drawPlayer, drawPlayer.shadowPos[index], drawPlayer.shadowRotation[index], drawPlayer.shadowOrigin[index], (float) (0.5 + 0.200000002980232 * (double) index), 1f);
}
Vector2 position1;
if (drawPlayer.invis)
{
drawPlayer.armorEffectDrawOutlines = false;
drawPlayer.armorEffectDrawShadow = false;
drawPlayer.armorEffectDrawShadowSubtle = false;
position1 = drawPlayer.position;
if (drawPlayer.aggro <= -750)
{
this.DrawPlayer(camera, drawPlayer, position1, drawPlayer.fullRotation, drawPlayer.fullRotationOrigin, 1f, 1f);
}
else
{
drawPlayer.invis = false;
this.DrawPlayer(camera, drawPlayer, position1, drawPlayer.fullRotation, drawPlayer.fullRotationOrigin, 0.0f, 1f);
drawPlayer.invis = true;
}
}
if (drawPlayer.armorEffectDrawOutlines)
{
Vector2 position2 = drawPlayer.position;
if (!Main.gamePaused)
drawPlayer.ghostFade += drawPlayer.ghostDir * 0.075f;
if ((double) drawPlayer.ghostFade < 0.1)
{
drawPlayer.ghostDir = 1f;
drawPlayer.ghostFade = 0.1f;
}
else if ((double) drawPlayer.ghostFade > 0.9)
{
drawPlayer.ghostDir = -1f;
drawPlayer.ghostFade = 0.9f;
}
float num1 = drawPlayer.ghostFade * 5f;
for (int index = 0; index < 4; ++index)
{
float num2;
float num3;
switch (index)
{
case 1:
num2 = -num1;
num3 = 0.0f;
break;
case 2:
num2 = 0.0f;
num3 = num1;
break;
case 3:
num2 = 0.0f;
num3 = -num1;
break;
default:
num2 = num1;
num3 = 0.0f;
break;
}
position1 = new Vector2(drawPlayer.position.X + num2, drawPlayer.position.Y + drawPlayer.gfxOffY + num3);
this.DrawPlayer(camera, drawPlayer, position1, drawPlayer.fullRotation, drawPlayer.fullRotationOrigin, drawPlayer.ghostFade, 1f);
}
}
if (drawPlayer.armorEffectDrawOutlinesForbidden)
{
Vector2 position3 = drawPlayer.position;
if (!Main.gamePaused)
drawPlayer.ghostFade += drawPlayer.ghostDir * 0.025f;
if ((double) drawPlayer.ghostFade < 0.1)
{
drawPlayer.ghostDir = 1f;
drawPlayer.ghostFade = 0.1f;
}
else if ((double) drawPlayer.ghostFade > 0.9)
{
drawPlayer.ghostDir = -1f;
drawPlayer.ghostFade = 0.9f;
}
float num4 = drawPlayer.ghostFade * 5f;
for (int index = 0; index < 4; ++index)
{
float num5;
float num6;
switch (index)
{
case 1:
num5 = -num4;
num6 = 0.0f;
break;
case 2:
num5 = 0.0f;
num6 = num4;
break;
case 3:
num5 = 0.0f;
num6 = -num4;
break;
default:
num5 = num4;
num6 = 0.0f;
break;
}
position1 = new Vector2(drawPlayer.position.X + num5, drawPlayer.position.Y + drawPlayer.gfxOffY + num6);
this.DrawPlayer(camera, drawPlayer, position1, drawPlayer.fullRotation, drawPlayer.fullRotationOrigin, drawPlayer.ghostFade, 1f);
}
}
if (drawPlayer.armorEffectDrawShadowBasilisk)
{
int num = (int) ((double) drawPlayer.basiliskCharge * 3.0);
for (int index = 0; index < num; ++index)
this.DrawPlayer(camera, drawPlayer, drawPlayer.shadowPos[index], drawPlayer.shadowRotation[index], drawPlayer.shadowOrigin[index], (float) (0.5 + 0.200000002980232 * (double) index), 1f);
}
else if (drawPlayer.armorEffectDrawShadow)
{
for (int index = 0; index < 3; ++index)
this.DrawPlayer(camera, drawPlayer, drawPlayer.shadowPos[index], drawPlayer.shadowRotation[index], drawPlayer.shadowOrigin[index], (float) (0.5 + 0.200000002980232 * (double) index), 1f);
}
if (drawPlayer.armorEffectDrawShadowLokis)
{
for (int index = 0; index < 3; ++index)
this.DrawPlayer(camera, drawPlayer, Vector2.Lerp(drawPlayer.shadowPos[index], drawPlayer.position + new Vector2(0.0f, drawPlayer.gfxOffY), 0.5f), drawPlayer.shadowRotation[index], drawPlayer.shadowOrigin[index], MathHelper.Lerp(1f, (float) (0.5 + 0.200000002980232 * (double) index), 0.5f), 1f);
}
if (drawPlayer.armorEffectDrawShadowSubtle)
{
for (int index = 0; index < 4; ++index)
{
position1.X = drawPlayer.position.X + (float) Main.rand.Next(-20, 21) * 0.1f;
position1.Y = drawPlayer.position.Y + (float) Main.rand.Next(-20, 21) * 0.1f + drawPlayer.gfxOffY;
this.DrawPlayer(camera, drawPlayer, position1, drawPlayer.fullRotation, drawPlayer.fullRotationOrigin, 0.9f, 1f);
}
}
if (drawPlayer.shadowDodge)
{
++drawPlayer.shadowDodgeCount;
if ((double) drawPlayer.shadowDodgeCount > 30.0)
drawPlayer.shadowDodgeCount = 30f;
}
else
{
--drawPlayer.shadowDodgeCount;
if ((double) drawPlayer.shadowDodgeCount < 0.0)
drawPlayer.shadowDodgeCount = 0.0f;
}
if ((double) drawPlayer.shadowDodgeCount > 0.0)
{
Vector2 position4 = drawPlayer.position;
position1.X = drawPlayer.position.X + drawPlayer.shadowDodgeCount;
position1.Y = drawPlayer.position.Y + drawPlayer.gfxOffY;
this.DrawPlayer(camera, drawPlayer, position1, drawPlayer.fullRotation, drawPlayer.fullRotationOrigin, (float) (0.5 + (double) Main.rand.Next(-10, 11) * 0.00499999988824129), 1f);
position1.X = drawPlayer.position.X - drawPlayer.shadowDodgeCount;
this.DrawPlayer(camera, drawPlayer, position1, drawPlayer.fullRotation, drawPlayer.fullRotationOrigin, (float) (0.5 + (double) Main.rand.Next(-10, 11) * 0.00499999988824129), 1f);
}
if (drawPlayer.brainOfConfusionDodgeAnimationCounter > 0)
{
Vector2 vector2 = drawPlayer.position + new Vector2(0.0f, drawPlayer.gfxOffY);
float lerpValue = Utils.GetLerpValue(300f, 270f, (float) drawPlayer.brainOfConfusionDodgeAnimationCounter, false);
float y = MathHelper.Lerp(2f, 120f, lerpValue);
if ((double) lerpValue >= 0.0 && (double) lerpValue <= 1.0)
{
for (float num = 0.0f; (double) num < 6.28318548202515; num += 1.047198f)
{
position1 = vector2 + new Vector2(0.0f, y).RotatedBy(6.28318548202515 * (double) lerpValue * 0.5 + (double) num);
this.DrawPlayer(camera, drawPlayer, position1, drawPlayer.fullRotation, drawPlayer.fullRotationOrigin, lerpValue, 1f);
}
}
}
position1 = drawPlayer.position;
position1.Y += drawPlayer.gfxOffY;
if (drawPlayer.stoned)
this.DrawPlayerStoned(camera, drawPlayer, position1);
else if (!drawPlayer.invis)
this.DrawPlayer(camera, drawPlayer, position1, drawPlayer.fullRotation, drawPlayer.fullRotationOrigin, 0.0f, 1f);
}
spriteBatch.End();
}
private void DrawPlayerStoned(Camera camera, Player drawPlayer, Vector2 position)
{
if (drawPlayer.dead)
return;
SpriteEffects effects = drawPlayer.direction != 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
camera.SpriteBatch.Draw(TextureAssets.Extra[37].Value, new Vector2((float) (int) ((double) position.X - (double) camera.UnscaledPosition.X - (double) (drawPlayer.bodyFrame.Width / 2) + (double) (drawPlayer.width / 2)), (float) (int) ((double) position.Y - (double) camera.UnscaledPosition.Y + (double) drawPlayer.height - (double) drawPlayer.bodyFrame.Height + 8.0)) + drawPlayer.bodyPosition + new Vector2((float) (drawPlayer.bodyFrame.Width / 2), (float) (drawPlayer.bodyFrame.Height / 2)), new Rectangle?(), Lighting.GetColor((int) ((double) position.X + (double) drawPlayer.width * 0.5) / 16, (int) ((double) position.Y + (double) drawPlayer.height * 0.5) / 16, Color.White), 0.0f, new Vector2((float) (TextureAssets.Extra[37].Width() / 2), (float) (TextureAssets.Extra[37].Height() / 2)), 1f, effects, 0.0f);
}
private void DrawGhost(Camera camera, Player drawPlayer, Vector2 position, float shadow = 0.0f)
{
byte mouseTextColor = Main.mouseTextColor;
SpriteEffects effects = drawPlayer.direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
Color immuneAlpha = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int) ((double) drawPlayer.position.X + (double) drawPlayer.width * 0.5) / 16, (int) ((double) drawPlayer.position.Y + (double) drawPlayer.height * 0.5) / 16, new Color((int) mouseTextColor / 2 + 100, (int) mouseTextColor / 2 + 100, (int) mouseTextColor / 2 + 100, (int) mouseTextColor / 2 + 100)), shadow);
immuneAlpha.A = (byte) ((double) immuneAlpha.A * (1.0 - (double) Math.Max(0.5f, shadow - 0.5f)));
Rectangle rectangle = new Rectangle(0, TextureAssets.Ghost.Height() / 4 * drawPlayer.ghostFrame, TextureAssets.Ghost.Width(), TextureAssets.Ghost.Height() / 4);
Vector2 origin = new Vector2((float) rectangle.Width * 0.5f, (float) rectangle.Height * 0.5f);
camera.SpriteBatch.Draw(TextureAssets.Ghost.Value, new Vector2((float) (int) ((double) position.X - (double) camera.UnscaledPosition.X + (double) (rectangle.Width / 2)), (float) (int) ((double) position.Y - (double) camera.UnscaledPosition.Y + (double) (rectangle.Height / 2))), new Rectangle?(rectangle), immuneAlpha, 0.0f, origin, 1f, effects, 0.0f);
}
}
}

View file

@ -0,0 +1,141 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.MapHeadRenderer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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;
using System.Collections.Generic;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.ID;
namespace Terraria.Graphics.Renderers
{
public class MapHeadRenderer : INeedRenderTargetContent
{
private bool _anyDirty;
private PlayerHeadDrawRenderTargetContent[] _playerRenders = new PlayerHeadDrawRenderTargetContent[(int) byte.MaxValue];
private readonly List<DrawData> _drawData = new List<DrawData>();
public MapHeadRenderer()
{
for (int index = 0; index < this._playerRenders.Length; ++index)
this._playerRenders[index] = new PlayerHeadDrawRenderTargetContent();
}
public void DrawPlayerHead(
Camera camera,
Player drawPlayer,
Vector2 position,
float alpha = 1f,
float scale = 1f,
Color borderColor = default (Color))
{
PlayerHeadDrawRenderTargetContent playerRender = this._playerRenders[drawPlayer.whoAmI];
playerRender.UsePlayer(drawPlayer);
playerRender.UseColor(borderColor);
playerRender.Request();
this._anyDirty = true;
this._drawData.Clear();
if (!playerRender.IsReady)
return;
RenderTarget2D target = playerRender.GetTarget();
this._drawData.Add(new DrawData((Texture2D) target, position, new Rectangle?(), Color.White, 0.0f, target.Size() / 2f, scale, SpriteEffects.None, 0));
this.RenderDrawData(drawPlayer);
}
private void RenderDrawData(Player drawPlayer)
{
Effect pixelShader = Main.pixelShader;
Projectile[] projectile = Main.projectile;
SpriteBatch spriteBatch = Main.spriteBatch;
for (int index = 0; index < this._drawData.Count; ++index)
{
DrawData cdd = this._drawData[index];
if (!cdd.sourceRect.HasValue)
cdd.sourceRect = new Rectangle?(cdd.texture.Frame());
PlayerDrawHelper.SetShaderForData(drawPlayer, drawPlayer.cHead, ref cdd);
if (cdd.texture != null)
cdd.Draw(spriteBatch);
}
pixelShader.CurrentTechnique.Passes[0].Apply();
}
public bool IsReady => !this._anyDirty;
public void PrepareRenderTarget(GraphicsDevice device, SpriteBatch spriteBatch)
{
if (!this._anyDirty)
return;
for (int index = 0; index < this._playerRenders.Length; ++index)
this._playerRenders[index].PrepareRenderTarget(device, spriteBatch);
this._anyDirty = false;
}
private void CreateOutlines(float alpha, float scale, Color borderColor)
{
if (!(borderColor != Color.Transparent))
return;
List<DrawData> drawDataList1 = new List<DrawData>((IEnumerable<DrawData>) this._drawData);
List<DrawData> drawDataList2 = new List<DrawData>((IEnumerable<DrawData>) this._drawData);
this._drawData.Clear();
float num1 = 2f * scale;
Color color1 = borderColor * (alpha * alpha);
Color color2 = Color.Black * (alpha * alpha);
int colorOnlyShaderIndex = ContentSamples.CommonlyUsedContentSamples.ColorOnlyShaderIndex;
for (int index = 0; index < drawDataList2.Count; ++index)
{
DrawData drawData = drawDataList2[index];
drawData.shader = colorOnlyShaderIndex;
drawData.color = color2;
drawDataList2[index] = drawData;
}
int num2 = 2;
for (int index1 = -num2; index1 <= num2; ++index1)
{
for (int index2 = -num2; index2 <= num2; ++index2)
{
if (Math.Abs(index1) + Math.Abs(index2) == num2)
{
Vector2 vector2 = new Vector2((float) index1 * num1, (float) index2 * num1);
for (int index3 = 0; index3 < drawDataList2.Count; ++index3)
{
DrawData drawData = drawDataList2[index3];
drawData.position += vector2;
this._drawData.Add(drawData);
}
}
}
}
for (int index = 0; index < drawDataList2.Count; ++index)
{
DrawData drawData = drawDataList2[index];
drawData.shader = colorOnlyShaderIndex;
drawData.color = color1;
drawDataList2[index] = drawData;
}
Vector2 vector2_1 = Vector2.Zero;
int num3 = 1;
for (int index4 = -num3; index4 <= num3; ++index4)
{
for (int index5 = -num3; index5 <= num3; ++index5)
{
if (Math.Abs(index4) + Math.Abs(index5) == num3)
{
vector2_1 = new Vector2((float) index4 * num1, (float) index5 * num1);
for (int index6 = 0; index6 < drawDataList2.Count; ++index6)
{
DrawData drawData = drawDataList2[index6];
drawData.position += vector2_1;
this._drawData.Add(drawData);
}
}
}
}
this._drawData.AddRange((IEnumerable<DrawData>) drawDataList1);
}
}
}

View file

@ -0,0 +1,60 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.NPCHeadRenderer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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 ReLogic.Content;
using Terraria.GameContent;
namespace Terraria.Graphics.Renderers
{
public class NPCHeadRenderer : INeedRenderTargetContent
{
private NPCHeadDrawRenderTargetContent[] _contents;
private Asset<Texture2D>[] _matchingArray;
public NPCHeadRenderer(Asset<Texture2D>[] matchingArray)
{
this._matchingArray = matchingArray;
this._contents = new NPCHeadDrawRenderTargetContent[matchingArray.Length];
}
public void DrawWithOutlines(
Entity entity,
int headId,
Vector2 position,
Color color,
float rotation,
float scale,
SpriteEffects effects)
{
if (this._contents[headId] == null)
{
this._contents[headId] = new NPCHeadDrawRenderTargetContent();
this._contents[headId].SetTexture(this._matchingArray[headId].Value);
}
NPCHeadDrawRenderTargetContent content = this._contents[headId];
if (content.IsReady)
{
RenderTarget2D target = content.GetTarget();
Main.spriteBatch.Draw((Texture2D) target, position, new Rectangle?(), color, rotation, target.Size() / 2f, scale, effects, 0.0f);
}
else
content.Request();
}
public bool IsReady => false;
public void PrepareRenderTarget(GraphicsDevice device, SpriteBatch spriteBatch)
{
for (int index = 0; index < this._contents.Length; ++index)
{
if (this._contents[index] != null && !this._contents[index].IsReady)
this._contents[index].PrepareRenderTarget(device, spriteBatch);
}
}
}
}

View file

@ -0,0 +1,43 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.ParticlePool`1
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.Graphics.Renderers
{
public class ParticlePool<T> where T : IPooledParticle
{
private ParticlePool<T>.ParticleInstantiator _instantiator;
private List<T> _particles;
public ParticlePool(int initialPoolSize, ParticlePool<T>.ParticleInstantiator instantiator)
{
this._particles = new List<T>(initialPoolSize);
this._instantiator = instantiator;
}
public T RequestParticle()
{
int count = this._particles.Count;
for (int index = 0; index < count; ++index)
{
T particle = this._particles[index];
if (particle.IsRestingInPool)
{
particle = this._particles[index];
particle.FetchFromPool();
return this._particles[index];
}
}
T obj = this._instantiator();
this._particles.Add(obj);
obj.FetchFromPool();
return obj;
}
public delegate T ParticleInstantiator() where T : IPooledParticle;
}
}

View file

@ -0,0 +1,46 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.ParticleRenderer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
namespace Terraria.Graphics.Renderers
{
public class ParticleRenderer
{
public ParticleRendererSettings Settings;
public List<IParticle> Particles = new List<IParticle>();
public ParticleRenderer() => this.Settings = new ParticleRendererSettings();
public void Add(IParticle particle) => this.Particles.Add(particle);
public void Update()
{
for (int index = 0; index < this.Particles.Count; ++index)
{
if (this.Particles[index].ShouldBeRemovedFromRenderer)
{
if (this.Particles[index] is IPooledParticle particle3)
particle3.RestInPool();
this.Particles.RemoveAt(index);
--index;
}
else
this.Particles[index].Update(ref this.Settings);
}
}
public void Draw(SpriteBatch spriteBatch)
{
for (int index = 0; index < this.Particles.Count; ++index)
{
if (!this.Particles[index].ShouldBeRemovedFromRenderer)
this.Particles[index].Draw(ref this.Settings, spriteBatch);
}
}
}
}

View file

@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.ParticleRendererSettings
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.Graphics.Renderers
{
public struct ParticleRendererSettings
{
public Vector2 AnchorPosition;
}
}

View file

@ -0,0 +1,59 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.PrettySparkleParticle
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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 Terraria.GameContent;
namespace Terraria.Graphics.Renderers
{
public class PrettySparkleParticle : ABasicParticle
{
public Color ColorTint;
public float Opacity;
private float _timeSinceSpawn;
public override void FetchFromPool()
{
base.FetchFromPool();
this.ColorTint = Color.Transparent;
this._timeSinceSpawn = 0.0f;
this.Opacity = 0.0f;
}
public override void Update(ref ParticleRendererSettings settings)
{
base.Update(ref settings);
++this._timeSinceSpawn;
this.Opacity = Utils.GetLerpValue(0.0f, 0.05f, this._timeSinceSpawn / 60f, true) * Utils.GetLerpValue(1f, 0.9f, this._timeSinceSpawn / 60f, true);
if ((double) this._timeSinceSpawn < 60.0)
return;
this.ShouldBeRemovedFromRenderer = true;
}
public override void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch)
{
Color color1 = Color.White * this.Opacity * 0.9f;
color1.A /= (byte) 2;
Texture2D texture2D = TextureAssets.Extra[98].Value;
Color color2 = this.ColorTint * this.Opacity * 0.5f;
color2.A = (byte) 0;
Vector2 origin = texture2D.Size() / 2f;
Color color3 = color1 * 0.5f;
float num = Utils.GetLerpValue(0.0f, 20f, this._timeSinceSpawn, true) * Utils.GetLerpValue(45f, 30f, this._timeSinceSpawn, true);
Vector2 scale1 = new Vector2(0.3f, 2f) * num * this.Scale;
Vector2 scale2 = new Vector2(0.3f, 1f) * num * this.Scale;
Color color4 = color2 * num;
Color color5 = color3 * num;
Vector2 position = settings.AnchorPosition + this.LocalPosition;
SpriteEffects effects = SpriteEffects.None;
spritebatch.Draw(texture2D, position, new Rectangle?(), color4, 1.570796f + this.Rotation, origin, scale1, effects, 0.0f);
spritebatch.Draw(texture2D, position, new Rectangle?(), color4, 0.0f + this.Rotation, origin, scale2, effects, 0.0f);
spritebatch.Draw(texture2D, position, new Rectangle?(), color5, 1.570796f + this.Rotation, origin, scale1 * 0.6f, effects, 0.0f);
spritebatch.Draw(texture2D, position, new Rectangle?(), color5, 0.0f + this.Rotation, origin, scale2 * 0.6f, effects, 0.0f);
}
}
}

View file

@ -0,0 +1,71 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.RandomizedFrameParticle
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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.Graphics.Renderers
{
public class RandomizedFrameParticle : ABasicParticle
{
public float FadeInNormalizedTime;
public float FadeOutNormalizedTime = 1f;
public Color ColorTint = Color.White;
public int AnimationFramesAmount;
public int GameFramesPerAnimationFrame;
private float _timeTolive;
private float _timeSinceSpawn;
private int _gameFramesCounted;
public override void FetchFromPool()
{
base.FetchFromPool();
this.FadeInNormalizedTime = 0.0f;
this.FadeOutNormalizedTime = 1f;
this.ColorTint = Color.White;
this.AnimationFramesAmount = 0;
this.GameFramesPerAnimationFrame = 0;
this._timeTolive = 0.0f;
this._timeSinceSpawn = 0.0f;
this._gameFramesCounted = 0;
}
public void SetTypeInfo(
int animationFramesAmount,
int gameFramesPerAnimationFrame,
float timeToLive)
{
this._timeTolive = timeToLive;
this.GameFramesPerAnimationFrame = gameFramesPerAnimationFrame;
this.AnimationFramesAmount = animationFramesAmount;
this.RandomizeFrame();
}
private void RandomizeFrame()
{
this._frame = this._texture.Frame(verticalFrames: this.AnimationFramesAmount, frameY: Main.rand.Next(this.AnimationFramesAmount));
this._origin = this._frame.Size() / 2f;
}
public override void Update(ref ParticleRendererSettings settings)
{
base.Update(ref settings);
++this._timeSinceSpawn;
if ((double) this._timeSinceSpawn >= (double) this._timeTolive)
this.ShouldBeRemovedFromRenderer = true;
if (++this._gameFramesCounted < this.GameFramesPerAnimationFrame)
return;
this._gameFramesCounted = 0;
this.RandomizeFrame();
}
public override void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch)
{
Color color = this.ColorTint * Utils.GetLerpValue(0.0f, this.FadeInNormalizedTime, this._timeSinceSpawn / this._timeTolive, true) * Utils.GetLerpValue(1f, this.FadeOutNormalizedTime, this._timeSinceSpawn / this._timeTolive, true);
spritebatch.Draw(this._texture.Value, settings.AnchorPosition + this.LocalPosition, new Rectangle?(this._frame), color, this.Rotation, this._origin, this.Scale, SpriteEffects.None, 0.0f);
}
}
}

View file

@ -0,0 +1,87 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Renderers.ReturnGatePlayerRenderer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.GameContent.ObjectInteractions;
namespace Terraria.Graphics.Renderers
{
internal class ReturnGatePlayerRenderer : IPlayerRenderer
{
private List<DrawData> _voidLensData = new List<DrawData>();
private PotionOfReturnGateInteractionChecker _interactionChecker = new PotionOfReturnGateInteractionChecker();
public void DrawPlayers(Camera camera, IEnumerable<Player> players)
{
foreach (Player player in players)
this.DrawReturnGateInWorld(camera, player);
}
public void DrawPlayerHead(
Camera camera,
Player drawPlayer,
Vector2 position,
float alpha = 1f,
float scale = 1f,
Color borderColor = default (Color))
{
this.DrawReturnGateInMap(camera, drawPlayer);
}
public void DrawPlayer(
Camera camera,
Player drawPlayer,
Vector2 position,
float rotation,
Vector2 rotationOrigin,
float shadow = 0.0f,
float scale = 1f)
{
this.DrawReturnGateInWorld(camera, drawPlayer);
}
private void DrawReturnGateInMap(Camera camera, Player player)
{
}
private void DrawReturnGateInWorld(Camera camera, Player player)
{
Rectangle homeHitbox = Rectangle.Empty;
if (!PotionOfReturnHelper.TryGetGateHitbox(player, out homeHitbox))
return;
if (player == Main.LocalPlayer)
{
int num = (int) this._interactionChecker.AttemptInteraction(player, homeHitbox);
}
int selectionMode = 0;
if (!player.PotionOfReturnOriginalUsePosition.HasValue)
return;
SpriteBatch spriteBatch = camera.SpriteBatch;
SamplerState sampler = camera.Sampler;
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, sampler, DepthStencilState.None, camera.Rasterizer, (Effect) null, camera.GameViewMatrix.TransformationMatrix);
float opacity = player.whoAmI == Main.myPlayer ? 1f : 0.1f;
Vector2 worldPosition = player.PotionOfReturnOriginalUsePosition.Value + new Vector2(0.0f, (float) (-player.height / 2));
Vector2 vector2 = homeHitbox.Center.ToVector2();
PotionOfReturnGateHelper returnGateHelper1 = new PotionOfReturnGateHelper(PotionOfReturnGateHelper.GateType.ExitPoint, worldPosition, opacity);
PotionOfReturnGateHelper returnGateHelper2 = new PotionOfReturnGateHelper(PotionOfReturnGateHelper.GateType.EntryPoint, vector2, opacity);
if (!Main.gamePaused)
{
returnGateHelper1.Update();
returnGateHelper2.Update();
}
this._voidLensData.Clear();
returnGateHelper1.DrawToDrawData(this._voidLensData, 0);
returnGateHelper2.DrawToDrawData(this._voidLensData, selectionMode);
foreach (DrawData drawData in this._voidLensData)
drawData.Draw(spriteBatch);
spriteBatch.End();
}
}
}

View file

@ -0,0 +1,118 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Shaders.ArmorShaderData
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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 ReLogic.Content;
using System;
using Terraria.DataStructures;
namespace Terraria.Graphics.Shaders
{
public class ArmorShaderData : ShaderData
{
private Vector3 _uColor = Vector3.One;
private Vector3 _uSecondaryColor = Vector3.One;
private float _uSaturation = 1f;
private float _uOpacity = 1f;
private Asset<Texture2D> _uImage;
private Vector2 _uTargetPosition = Vector2.One;
public ArmorShaderData(Ref<Effect> shader, string passName)
: base(shader, passName)
{
}
public virtual void Apply(Entity entity, DrawData? drawData = null)
{
this.Shader.Parameters["uColor"].SetValue(this._uColor);
this.Shader.Parameters["uSaturation"].SetValue(this._uSaturation);
this.Shader.Parameters["uSecondaryColor"].SetValue(this._uSecondaryColor);
this.Shader.Parameters["uTime"].SetValue(Main.GlobalTimeWrappedHourly);
this.Shader.Parameters["uOpacity"].SetValue(this._uOpacity);
this.Shader.Parameters["uTargetPosition"].SetValue(this._uTargetPosition);
if (drawData.HasValue)
{
DrawData drawData1 = drawData.Value;
Vector4 vector4 = !drawData1.sourceRect.HasValue ? new Vector4(0.0f, 0.0f, (float) drawData1.texture.Width, (float) drawData1.texture.Height) : new Vector4((float) drawData1.sourceRect.Value.X, (float) drawData1.sourceRect.Value.Y, (float) drawData1.sourceRect.Value.Width, (float) drawData1.sourceRect.Value.Height);
this.Shader.Parameters["uSourceRect"].SetValue(vector4);
this.Shader.Parameters["uLegacyArmorSourceRect"].SetValue(vector4);
this.Shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition + drawData1.position);
this.Shader.Parameters["uImageSize0"].SetValue(new Vector2((float) drawData1.texture.Width, (float) drawData1.texture.Height));
this.Shader.Parameters["uLegacyArmorSheetSize"].SetValue(new Vector2((float) drawData1.texture.Width, (float) drawData1.texture.Height));
this.Shader.Parameters["uRotation"].SetValue(drawData1.rotation * (drawData1.effect.HasFlag((Enum) SpriteEffects.FlipHorizontally) ? -1f : 1f));
this.Shader.Parameters["uDirection"].SetValue(drawData1.effect.HasFlag((Enum) SpriteEffects.FlipHorizontally) ? -1 : 1);
}
else
{
Vector4 vector4 = new Vector4(0.0f, 0.0f, 4f, 4f);
this.Shader.Parameters["uSourceRect"].SetValue(vector4);
this.Shader.Parameters["uLegacyArmorSourceRect"].SetValue(vector4);
this.Shader.Parameters["uRotation"].SetValue(0.0f);
}
if (this._uImage != null)
{
Main.graphics.GraphicsDevice.Textures[1] = (Texture) this._uImage.Value;
this.Shader.Parameters["uImageSize1"].SetValue(new Vector2((float) this._uImage.Width(), (float) this._uImage.Height()));
}
if (entity != null)
this.Shader.Parameters["uDirection"].SetValue((float) entity.direction);
if (entity is Player player)
{
Rectangle bodyFrame = player.bodyFrame;
this.Shader.Parameters["uLegacyArmorSourceRect"].SetValue(new Vector4((float) bodyFrame.X, (float) bodyFrame.Y, (float) bodyFrame.Width, (float) bodyFrame.Height));
this.Shader.Parameters["uLegacyArmorSheetSize"].SetValue(new Vector2(40f, 1120f));
}
this.Apply();
}
public ArmorShaderData UseColor(float r, float g, float b) => this.UseColor(new Vector3(r, g, b));
public ArmorShaderData UseColor(Color color) => this.UseColor(color.ToVector3());
public ArmorShaderData UseColor(Vector3 color)
{
this._uColor = color;
return this;
}
public ArmorShaderData UseImage(string path)
{
this._uImage = Main.Assets.Request<Texture2D>(path, (AssetRequestMode) 1);
return this;
}
public ArmorShaderData UseOpacity(float alpha)
{
this._uOpacity = alpha;
return this;
}
public ArmorShaderData UseTargetPosition(Vector2 position)
{
this._uTargetPosition = position;
return this;
}
public ArmorShaderData UseSecondaryColor(float r, float g, float b) => this.UseSecondaryColor(new Vector3(r, g, b));
public ArmorShaderData UseSecondaryColor(Color color) => this.UseSecondaryColor(color.ToVector3());
public ArmorShaderData UseSecondaryColor(Vector3 color)
{
this._uSecondaryColor = color;
return this;
}
public ArmorShaderData UseSaturation(float saturation)
{
this._uSaturation = saturation;
return this;
}
public virtual ArmorShaderData GetSecondaryShader(Entity entity) => this;
}
}

View file

@ -0,0 +1,47 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Shaders.ArmorShaderDataSet
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
using Terraria.DataStructures;
namespace Terraria.Graphics.Shaders
{
public class ArmorShaderDataSet
{
protected List<ArmorShaderData> _shaderData = new List<ArmorShaderData>();
protected Dictionary<int, int> _shaderLookupDictionary = new Dictionary<int, int>();
protected int _shaderDataCount;
public T BindShader<T>(int itemId, T shaderData) where T : ArmorShaderData
{
this._shaderLookupDictionary[itemId] = ++this._shaderDataCount;
this._shaderData.Add((ArmorShaderData) shaderData);
return shaderData;
}
public void Apply(int shaderId, Entity entity, DrawData? drawData = null)
{
if (shaderId >= 1 && shaderId <= this._shaderDataCount)
this._shaderData[shaderId - 1].Apply(entity, drawData);
else
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
}
public void ApplySecondary(int shaderId, Entity entity, DrawData? drawData = null)
{
if (shaderId >= 1 && shaderId <= this._shaderDataCount)
this._shaderData[shaderId - 1].GetSecondaryShader(entity).Apply(entity, drawData);
else
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
}
public ArmorShaderData GetShaderFromItemId(int type) => this._shaderLookupDictionary.ContainsKey(type) ? this._shaderData[this._shaderLookupDictionary[type] - 1] : (ArmorShaderData) null;
public int GetShaderIdFromItemId(int type) => this._shaderLookupDictionary.ContainsKey(type) ? this._shaderLookupDictionary[type] : 0;
public ArmorShaderData GetSecondaryShader(int id, Player player) => id != 0 && id <= this._shaderDataCount && this._shaderData[id - 1] != null ? this._shaderData[id - 1].GetSecondaryShader((Entity) player) : (ArmorShaderData) null;
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Shaders.GameShaders
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.Graphics.Shaders
{
public class GameShaders
{
public static ArmorShaderDataSet Armor = new ArmorShaderDataSet();
public static HairShaderDataSet Hair = new HairShaderDataSet();
public static Dictionary<string, MiscShaderData> Misc = new Dictionary<string, MiscShaderData>();
}
}

View file

@ -0,0 +1,106 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Shaders.HairShaderData
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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 ReLogic.Content;
using Terraria.DataStructures;
namespace Terraria.Graphics.Shaders
{
public class HairShaderData : ShaderData
{
protected Vector3 _uColor = Vector3.One;
protected Vector3 _uSecondaryColor = Vector3.One;
protected float _uSaturation = 1f;
protected float _uOpacity = 1f;
protected Asset<Texture2D> _uImage;
protected bool _shaderDisabled;
private Vector2 _uTargetPosition = Vector2.One;
public bool ShaderDisabled => this._shaderDisabled;
public HairShaderData(Ref<Effect> shader, string passName)
: base(shader, passName)
{
}
public virtual void Apply(Player player, DrawData? drawData = null)
{
if (this._shaderDisabled)
return;
this.Shader.Parameters["uColor"].SetValue(this._uColor);
this.Shader.Parameters["uSaturation"].SetValue(this._uSaturation);
this.Shader.Parameters["uSecondaryColor"].SetValue(this._uSecondaryColor);
this.Shader.Parameters["uTime"].SetValue(Main.GlobalTimeWrappedHourly);
this.Shader.Parameters["uOpacity"].SetValue(this._uOpacity);
this.Shader.Parameters["uTargetPosition"].SetValue(this._uTargetPosition);
if (drawData.HasValue)
{
DrawData drawData1 = drawData.Value;
this.Shader.Parameters["uSourceRect"].SetValue(new Vector4((float) drawData1.sourceRect.Value.X, (float) drawData1.sourceRect.Value.Y, (float) drawData1.sourceRect.Value.Width, (float) drawData1.sourceRect.Value.Height));
this.Shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition + drawData1.position);
this.Shader.Parameters["uImageSize0"].SetValue(new Vector2((float) drawData1.texture.Width, (float) drawData1.texture.Height));
}
else
this.Shader.Parameters["uSourceRect"].SetValue(new Vector4(0.0f, 0.0f, 4f, 4f));
if (this._uImage != null)
{
Main.graphics.GraphicsDevice.Textures[1] = (Texture) this._uImage.Value;
this.Shader.Parameters["uImageSize1"].SetValue(new Vector2((float) this._uImage.Width(), (float) this._uImage.Height()));
}
if (player != null)
this.Shader.Parameters["uDirection"].SetValue((float) player.direction);
this.Apply();
}
public virtual Color GetColor(Player player, Color lightColor) => new Color(lightColor.ToVector4() * player.hairColor.ToVector4());
public HairShaderData UseColor(float r, float g, float b) => this.UseColor(new Vector3(r, g, b));
public HairShaderData UseColor(Color color) => this.UseColor(color.ToVector3());
public HairShaderData UseColor(Vector3 color)
{
this._uColor = color;
return this;
}
public HairShaderData UseImage(string path)
{
this._uImage = Main.Assets.Request<Texture2D>(path, (AssetRequestMode) 1);
return this;
}
public HairShaderData UseOpacity(float alpha)
{
this._uOpacity = alpha;
return this;
}
public HairShaderData UseSecondaryColor(float r, float g, float b) => this.UseSecondaryColor(new Vector3(r, g, b));
public HairShaderData UseSecondaryColor(Color color) => this.UseSecondaryColor(color.ToVector3());
public HairShaderData UseSecondaryColor(Vector3 color)
{
this._uSecondaryColor = color;
return this;
}
public HairShaderData UseSaturation(float saturation)
{
this._uSaturation = saturation;
return this;
}
public HairShaderData UseTargetPosition(Vector2 position)
{
this._uTargetPosition = position;
return this;
}
}
}

View file

@ -0,0 +1,43 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Shaders.HairShaderDataSet
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria.DataStructures;
namespace Terraria.Graphics.Shaders
{
public class HairShaderDataSet
{
protected List<HairShaderData> _shaderData = new List<HairShaderData>();
protected Dictionary<int, short> _shaderLookupDictionary = new Dictionary<int, short>();
protected byte _shaderDataCount;
public T BindShader<T>(int itemId, T shaderData) where T : HairShaderData
{
if (this._shaderDataCount == byte.MaxValue)
throw new Exception("Too many shaders bound.");
this._shaderLookupDictionary[itemId] = (short) ++this._shaderDataCount;
this._shaderData.Add((HairShaderData) shaderData);
return shaderData;
}
public void Apply(short shaderId, Player player, DrawData? drawData = null)
{
if (shaderId != (short) 0 && (int) shaderId <= (int) this._shaderDataCount)
this._shaderData[(int) shaderId - 1].Apply(player, drawData);
else
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
}
public Color GetColor(short shaderId, Player player, Color lightColor) => shaderId != (short) 0 && (int) shaderId <= (int) this._shaderDataCount ? this._shaderData[(int) shaderId - 1].GetColor(player, lightColor) : new Color(lightColor.ToVector4() * player.hairColor.ToVector4());
public HairShaderData GetShaderFromItemId(int type) => this._shaderLookupDictionary.ContainsKey(type) ? this._shaderData[(int) this._shaderLookupDictionary[type] - 1] : (HairShaderData) null;
public short GetShaderIdFromItemId(int type) => this._shaderLookupDictionary.ContainsKey(type) ? this._shaderLookupDictionary[type] : (short) -1;
}
}

View file

@ -0,0 +1,138 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Shaders.MiscShaderData
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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 ReLogic.Content;
using Terraria.DataStructures;
namespace Terraria.Graphics.Shaders
{
public class MiscShaderData : ShaderData
{
private Vector3 _uColor = Vector3.One;
private Vector3 _uSecondaryColor = Vector3.One;
private float _uSaturation = 1f;
private float _uOpacity = 1f;
private Asset<Texture2D> _uImage0;
private Asset<Texture2D> _uImage1;
private Asset<Texture2D> _uImage2;
private bool _useProjectionMatrix;
private Vector4 _shaderSpecificData = Vector4.Zero;
public MiscShaderData(Ref<Effect> shader, string passName)
: base(shader, passName)
{
}
public virtual void Apply(DrawData? drawData = null)
{
this.Shader.Parameters["uColor"].SetValue(this._uColor);
this.Shader.Parameters["uSaturation"].SetValue(this._uSaturation);
this.Shader.Parameters["uSecondaryColor"].SetValue(this._uSecondaryColor);
this.Shader.Parameters["uTime"].SetValue(Main.GlobalTimeWrappedHourly);
this.Shader.Parameters["uOpacity"].SetValue(this._uOpacity);
this.Shader.Parameters["uShaderSpecificData"].SetValue(this._shaderSpecificData);
if (drawData.HasValue)
{
DrawData drawData1 = drawData.Value;
Vector4 vector4 = Vector4.Zero;
if (drawData.Value.sourceRect.HasValue)
vector4 = new Vector4((float) drawData1.sourceRect.Value.X, (float) drawData1.sourceRect.Value.Y, (float) drawData1.sourceRect.Value.Width, (float) drawData1.sourceRect.Value.Height);
this.Shader.Parameters["uSourceRect"].SetValue(vector4);
this.Shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition + drawData1.position);
this.Shader.Parameters["uImageSize0"].SetValue(new Vector2((float) drawData1.texture.Width, (float) drawData1.texture.Height));
}
else
this.Shader.Parameters["uSourceRect"].SetValue(new Vector4(0.0f, 0.0f, 4f, 4f));
if (this._uImage0 != null)
{
Main.graphics.GraphicsDevice.Textures[0] = (Texture) this._uImage0.Value;
Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
this.Shader.Parameters["uImageSize0"].SetValue(new Vector2((float) this._uImage0.Width(), (float) this._uImage0.Height()));
}
if (this._uImage1 != null)
{
Main.graphics.GraphicsDevice.Textures[1] = (Texture) this._uImage1.Value;
Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap;
this.Shader.Parameters["uImageSize1"].SetValue(new Vector2((float) this._uImage1.Width(), (float) this._uImage1.Height()));
}
if (this._uImage2 != null)
{
Main.graphics.GraphicsDevice.Textures[2] = (Texture) this._uImage2.Value;
Main.graphics.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap;
this.Shader.Parameters["uImageSize2"].SetValue(new Vector2((float) this._uImage2.Width(), (float) this._uImage2.Height()));
}
if (this._useProjectionMatrix)
this.Shader.Parameters["uMatrixTransform0"].SetValue(Main.GameViewMatrix.NormalizedTransformationmatrix);
this.Apply();
}
public MiscShaderData UseColor(float r, float g, float b) => this.UseColor(new Vector3(r, g, b));
public MiscShaderData UseColor(Color color) => this.UseColor(color.ToVector3());
public MiscShaderData UseColor(Vector3 color)
{
this._uColor = color;
return this;
}
public MiscShaderData UseImage0(string path)
{
this._uImage0 = Main.Assets.Request<Texture2D>(path, (AssetRequestMode) 1);
return this;
}
public MiscShaderData UseImage1(string path)
{
this._uImage1 = Main.Assets.Request<Texture2D>(path, (AssetRequestMode) 1);
return this;
}
public MiscShaderData UseImage2(string path)
{
this._uImage2 = Main.Assets.Request<Texture2D>(path, (AssetRequestMode) 1);
return this;
}
public MiscShaderData UseOpacity(float alpha)
{
this._uOpacity = alpha;
return this;
}
public MiscShaderData UseSecondaryColor(float r, float g, float b) => this.UseSecondaryColor(new Vector3(r, g, b));
public MiscShaderData UseSecondaryColor(Color color) => this.UseSecondaryColor(color.ToVector3());
public MiscShaderData UseSecondaryColor(Vector3 color)
{
this._uSecondaryColor = color;
return this;
}
public MiscShaderData UseProjectionMatrix(bool doUse)
{
this._useProjectionMatrix = doUse;
return this;
}
public MiscShaderData UseSaturation(float saturation)
{
this._uSaturation = saturation;
return this;
}
public virtual MiscShaderData GetSecondaryShader(Entity entity) => this;
public MiscShaderData UseShaderSpecificData(Vector4 specificData)
{
this._shaderSpecificData = specificData;
return this;
}
}
}

View file

@ -0,0 +1,179 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Shaders.ScreenShaderData
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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 ReLogic.Content;
namespace Terraria.Graphics.Shaders
{
public class ScreenShaderData : ShaderData
{
private Vector3 _uColor = Vector3.One;
private Vector3 _uSecondaryColor = Vector3.One;
private float _uOpacity = 1f;
private float _globalOpacity = 1f;
private float _uIntensity = 1f;
private Vector2 _uTargetPosition = Vector2.One;
private Vector2 _uDirection = new Vector2(0.0f, 1f);
private float _uProgress;
private Vector2 _uImageOffset = Vector2.Zero;
private Asset<Texture2D>[] _uAssetImages = new Asset<Texture2D>[3];
private Texture2D[] _uCustomImages = new Texture2D[3];
private SamplerState[] _samplerStates = new SamplerState[3];
private Vector2[] _imageScales = new Vector2[3]
{
Vector2.One,
Vector2.One,
Vector2.One
};
public float Intensity => this._uIntensity;
public float CombinedOpacity => this._uOpacity * this._globalOpacity;
public ScreenShaderData(string passName)
: base(Main.ScreenShaderRef, passName)
{
}
public ScreenShaderData(Ref<Effect> shader, string passName)
: base(shader, passName)
{
}
public virtual void Update(GameTime gameTime)
{
}
public override void Apply()
{
Vector2 vector2_1 = new Vector2((float) Main.offScreenRange, (float) Main.offScreenRange);
Vector2 vector2_2 = new Vector2((float) Main.screenWidth, (float) Main.screenHeight) / Main.GameViewMatrix.Zoom;
Vector2 vector2_3 = new Vector2((float) Main.screenWidth, (float) Main.screenHeight) * 0.5f;
Vector2 vector2_4 = Main.screenPosition + vector2_3 * (Vector2.One - Vector2.One / Main.GameViewMatrix.Zoom);
this.Shader.Parameters["uColor"].SetValue(this._uColor);
this.Shader.Parameters["uOpacity"].SetValue(this.CombinedOpacity);
this.Shader.Parameters["uSecondaryColor"].SetValue(this._uSecondaryColor);
this.Shader.Parameters["uTime"].SetValue(Main.GlobalTimeWrappedHourly);
this.Shader.Parameters["uScreenResolution"].SetValue(vector2_2);
this.Shader.Parameters["uScreenPosition"].SetValue(vector2_4 - vector2_1);
this.Shader.Parameters["uTargetPosition"].SetValue(this._uTargetPosition - vector2_1);
this.Shader.Parameters["uImageOffset"].SetValue(this._uImageOffset);
this.Shader.Parameters["uIntensity"].SetValue(this._uIntensity);
this.Shader.Parameters["uProgress"].SetValue(this._uProgress);
this.Shader.Parameters["uDirection"].SetValue(this._uDirection);
this.Shader.Parameters["uZoom"].SetValue(Main.GameViewMatrix.Zoom);
for (int index = 0; index < this._uAssetImages.Length; ++index)
{
Texture2D uCustomImage = this._uCustomImages[index];
if (this._uAssetImages[index] != null && this._uAssetImages[index].IsLoaded)
uCustomImage = this._uAssetImages[index].Value;
if (uCustomImage != null)
{
Main.graphics.GraphicsDevice.Textures[index + 1] = (Texture) uCustomImage;
int width = uCustomImage.Width;
int height = uCustomImage.Height;
Main.graphics.GraphicsDevice.SamplerStates[index + 1] = this._samplerStates[index] == null ? (!Utils.IsPowerOfTwo(width) || !Utils.IsPowerOfTwo(height) ? SamplerState.AnisotropicClamp : SamplerState.LinearWrap) : this._samplerStates[index];
this.Shader.Parameters["uImageSize" + (object) (index + 1)].SetValue(new Vector2((float) width, (float) height) * this._imageScales[index]);
}
}
base.Apply();
}
public ScreenShaderData UseImageOffset(Vector2 offset)
{
this._uImageOffset = offset;
return this;
}
public ScreenShaderData UseIntensity(float intensity)
{
this._uIntensity = intensity;
return this;
}
public ScreenShaderData UseColor(float r, float g, float b) => this.UseColor(new Vector3(r, g, b));
public ScreenShaderData UseProgress(float progress)
{
this._uProgress = progress;
return this;
}
public ScreenShaderData UseImage(
Texture2D image,
int index = 0,
SamplerState samplerState = null)
{
this._samplerStates[index] = samplerState;
this._uAssetImages[index] = (Asset<Texture2D>) null;
this._uCustomImages[index] = image;
return this;
}
public ScreenShaderData UseImage(
string path,
int index = 0,
SamplerState samplerState = null)
{
this._uAssetImages[index] = Main.Assets.Request<Texture2D>(path, (AssetRequestMode) 1);
this._uCustomImages[index] = (Texture2D) null;
this._samplerStates[index] = samplerState;
return this;
}
public ScreenShaderData UseColor(Color color) => this.UseColor(color.ToVector3());
public ScreenShaderData UseColor(Vector3 color)
{
this._uColor = color;
return this;
}
public ScreenShaderData UseDirection(Vector2 direction)
{
this._uDirection = direction;
return this;
}
public ScreenShaderData UseGlobalOpacity(float opacity)
{
this._globalOpacity = opacity;
return this;
}
public ScreenShaderData UseTargetPosition(Vector2 position)
{
this._uTargetPosition = position;
return this;
}
public ScreenShaderData UseSecondaryColor(float r, float g, float b) => this.UseSecondaryColor(new Vector3(r, g, b));
public ScreenShaderData UseSecondaryColor(Color color) => this.UseSecondaryColor(color.ToVector3());
public ScreenShaderData UseSecondaryColor(Vector3 color)
{
this._uSecondaryColor = color;
return this;
}
public ScreenShaderData UseOpacity(float opacity)
{
this._uOpacity = opacity;
return this;
}
public ScreenShaderData UseImageScale(Vector2 scale, int index = 0)
{
this._imageScales[index] = scale;
return this;
}
public virtual ScreenShaderData GetSecondaryShader(Player player) => this;
}
}

View file

@ -0,0 +1,40 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.Shaders.ShaderData
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework.Graphics;
namespace Terraria.Graphics.Shaders
{
public class ShaderData
{
private readonly Ref<Effect> _shader;
private string _passName;
private EffectPass _effectPass;
public Effect Shader => this._shader != null ? this._shader.Value : (Effect) null;
public ShaderData(Ref<Effect> shader, string passName)
{
this._passName = passName;
this._shader = shader;
}
public void SwapProgram(string passName)
{
this._passName = passName;
if (passName == null)
return;
this._effectPass = this.Shader.CurrentTechnique.Passes[passName];
}
public virtual void Apply()
{
if (this._shader != null && this.Shader != null && this._passName != null)
this._effectPass = this.Shader.CurrentTechnique.Passes[this._passName];
this._effectPass.Apply();
}
}
}

View file

@ -0,0 +1,79 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.SpriteRenderTargetHelper
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Terraria.DataStructures;
namespace Terraria.Graphics
{
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct SpriteRenderTargetHelper
{
public static void GetDrawBoundary(
List<DrawData> playerDrawData,
out Vector2 lowest,
out Vector2 highest)
{
lowest = Vector2.Zero;
highest = Vector2.Zero;
for (int index = 0; index <= playerDrawData.Count; ++index)
{
if (index != playerDrawData.Count)
{
DrawData cdd = playerDrawData[index];
if (index == 0)
{
lowest = cdd.position;
highest = cdd.position;
}
SpriteRenderTargetHelper.GetHighsAndLowsOf(ref lowest, ref highest, ref cdd);
}
}
}
public static void GetHighsAndLowsOf(ref Vector2 lowest, ref Vector2 highest, ref DrawData cdd)
{
Vector2 origin = cdd.origin;
Rectangle rectangle = cdd.destinationRectangle;
if (cdd.sourceRect.HasValue)
rectangle = cdd.sourceRect.Value;
if (!cdd.sourceRect.HasValue)
rectangle = cdd.texture.Frame();
rectangle.X = 0;
rectangle.Y = 0;
Vector2 position = cdd.position;
SpriteRenderTargetHelper.GetHighsAndLowsOf(ref lowest, ref highest, ref cdd, ref position, ref origin, new Vector2(0.0f, 0.0f));
SpriteRenderTargetHelper.GetHighsAndLowsOf(ref lowest, ref highest, ref cdd, ref position, ref origin, new Vector2((float) rectangle.Width, 0.0f));
SpriteRenderTargetHelper.GetHighsAndLowsOf(ref lowest, ref highest, ref cdd, ref position, ref origin, new Vector2(0.0f, (float) rectangle.Height));
SpriteRenderTargetHelper.GetHighsAndLowsOf(ref lowest, ref highest, ref cdd, ref position, ref origin, new Vector2((float) rectangle.Width, (float) rectangle.Height));
}
public static void GetHighsAndLowsOf(
ref Vector2 lowest,
ref Vector2 highest,
ref DrawData cdd,
ref Vector2 pos,
ref Vector2 origin,
Vector2 corner)
{
Vector2 corner1 = SpriteRenderTargetHelper.GetCorner(ref cdd, ref pos, ref origin, corner);
lowest = Vector2.Min(lowest, corner1);
highest = Vector2.Max(highest, corner1);
}
public static Vector2 GetCorner(
ref DrawData cdd,
ref Vector2 pos,
ref Vector2 origin,
Vector2 corner)
{
Vector2 spinningpoint = corner - origin;
return pos + spinningpoint.RotatedBy((double) cdd.rotation) * cdd.scale;
}
}
}

View file

@ -0,0 +1,141 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.SpriteViewMatrix
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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;
namespace Terraria.Graphics
{
public class SpriteViewMatrix
{
private Vector2 _zoom = Vector2.One;
private Vector2 _translation = Vector2.Zero;
private Matrix _zoomMatrix = Matrix.Identity;
private Matrix _transformationMatrix = Matrix.Identity;
private Matrix _normalizedTransformationMatrix = Matrix.Identity;
private SpriteEffects _effects;
private Matrix _effectMatrix;
private GraphicsDevice _graphicsDevice;
private Viewport _viewport;
private bool _overrideSystemViewport;
private bool _needsRebuild = true;
public Vector2 Zoom
{
get => this._zoom;
set
{
if (!(this._zoom != value))
return;
this._zoom = value;
this._needsRebuild = true;
}
}
public Vector2 Translation
{
get
{
if (this.ShouldRebuild())
this.Rebuild();
return this._translation;
}
}
public Matrix ZoomMatrix
{
get
{
if (this.ShouldRebuild())
this.Rebuild();
return this._zoomMatrix;
}
}
public Matrix TransformationMatrix
{
get
{
if (this.ShouldRebuild())
this.Rebuild();
return this._transformationMatrix;
}
}
public Matrix NormalizedTransformationmatrix
{
get
{
if (this.ShouldRebuild())
this.Rebuild();
return this._normalizedTransformationMatrix;
}
}
public SpriteEffects Effects
{
get => this._effects;
set
{
if (this._effects == value)
return;
this._effects = value;
this._needsRebuild = true;
}
}
public Matrix EffectMatrix
{
get
{
if (this.ShouldRebuild())
this.Rebuild();
return this._effectMatrix;
}
}
public SpriteViewMatrix(GraphicsDevice graphicsDevice) => this._graphicsDevice = graphicsDevice;
private void Rebuild()
{
if (!this._overrideSystemViewport)
this._viewport = this._graphicsDevice.Viewport;
Vector2 vector2_1 = new Vector2((float) this._viewport.Width, (float) this._viewport.Height);
Matrix identity = Matrix.Identity;
if (this._effects.HasFlag((Enum) SpriteEffects.FlipHorizontally))
identity *= Matrix.CreateScale(-1f, 1f, 1f) * Matrix.CreateTranslation(vector2_1.X, 0.0f, 0.0f);
if (this._effects.HasFlag((Enum) SpriteEffects.FlipVertically))
identity *= Matrix.CreateScale(1f, -1f, 1f) * Matrix.CreateTranslation(0.0f, vector2_1.Y, 0.0f);
Vector2 vector2_2 = vector2_1 * 0.5f;
Vector2 vector2_3 = vector2_2 - vector2_2 / this._zoom;
Matrix orthographicOffCenter = Matrix.CreateOrthographicOffCenter(0.0f, vector2_1.X, vector2_1.Y, 0.0f, 0.0f, 1f);
this._translation = vector2_3;
this._zoomMatrix = Matrix.CreateTranslation(-vector2_3.X, -vector2_3.Y, 0.0f) * Matrix.CreateScale(this._zoom.X, this._zoom.Y, 1f);
this._effectMatrix = identity;
this._transformationMatrix = identity * this._zoomMatrix;
this._normalizedTransformationMatrix = Matrix.Invert(identity) * this._zoomMatrix * orthographicOffCenter;
this._needsRebuild = false;
}
public void SetViewportOverride(Viewport viewport)
{
this._viewport = viewport;
this._overrideSystemViewport = true;
}
public void ClearViewportOverride() => this._overrideSystemViewport = false;
private bool ShouldRebuild()
{
if (this._needsRebuild)
return true;
if (this._overrideSystemViewport)
return false;
return this._graphicsDevice.Viewport.Width != this._viewport.Width || this._graphicsDevice.Viewport.Height != this._viewport.Height;
}
}
}

368
Graphics/TileBatch.cs Normal file
View file

@ -0,0 +1,368 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.TileBatch
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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;
namespace Terraria.Graphics
{
public class TileBatch
{
private static readonly float[] CORNER_OFFSET_X = new float[4]
{
0.0f,
1f,
1f,
0.0f
};
private static readonly float[] CORNER_OFFSET_Y = new float[4]
{
0.0f,
0.0f,
1f,
1f
};
private GraphicsDevice _graphicsDevice;
private TileBatch.SpriteData[] _spriteDataQueue = new TileBatch.SpriteData[2048];
private Texture2D[] _spriteTextures;
private int _queuedSpriteCount;
private SpriteBatch _spriteBatch;
private static Vector2 _vector2Zero;
private static Rectangle? _nullRectangle;
private DynamicVertexBuffer _vertexBuffer;
private DynamicIndexBuffer _indexBuffer;
private short[] _fallbackIndexData;
private VertexPositionColorTexture[] _vertices = new VertexPositionColorTexture[8192];
private int _vertexBufferPosition;
public TileBatch(GraphicsDevice graphicsDevice)
{
this._graphicsDevice = graphicsDevice;
this._spriteBatch = new SpriteBatch(graphicsDevice);
this.Allocate();
}
private void Allocate()
{
if (this._vertexBuffer == null || this._vertexBuffer.IsDisposed)
{
this._vertexBuffer = new DynamicVertexBuffer(this._graphicsDevice, typeof (VertexPositionColorTexture), 8192, BufferUsage.WriteOnly);
this._vertexBufferPosition = 0;
this._vertexBuffer.ContentLost += (EventHandler<EventArgs>) ((_param1, _param2) => this._vertexBufferPosition = 0);
}
if (this._indexBuffer != null && !this._indexBuffer.IsDisposed)
return;
if (this._fallbackIndexData == null)
{
this._fallbackIndexData = new short[12288];
for (int index = 0; index < 2048; ++index)
{
this._fallbackIndexData[index * 6] = (short) (index * 4);
this._fallbackIndexData[index * 6 + 1] = (short) (index * 4 + 1);
this._fallbackIndexData[index * 6 + 2] = (short) (index * 4 + 2);
this._fallbackIndexData[index * 6 + 3] = (short) (index * 4);
this._fallbackIndexData[index * 6 + 4] = (short) (index * 4 + 2);
this._fallbackIndexData[index * 6 + 5] = (short) (index * 4 + 3);
}
}
this._indexBuffer = new DynamicIndexBuffer(this._graphicsDevice, typeof (short), 12288, BufferUsage.WriteOnly);
this._indexBuffer.SetData<short>(this._fallbackIndexData);
this._indexBuffer.ContentLost += (EventHandler<EventArgs>) ((_param1, _param2) => this._indexBuffer.SetData<short>(this._fallbackIndexData));
}
private void FlushRenderState()
{
this.Allocate();
this._graphicsDevice.SetVertexBuffer((VertexBuffer) this._vertexBuffer);
this._graphicsDevice.Indices = (IndexBuffer) this._indexBuffer;
this._graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
}
public void Dispose()
{
if (this._vertexBuffer != null)
this._vertexBuffer.Dispose();
if (this._indexBuffer == null)
return;
this._indexBuffer.Dispose();
}
public void Begin(Matrix transformation)
{
this._spriteBatch.Begin(SpriteSortMode.Deferred, (BlendState) null, (SamplerState) null, (DepthStencilState) null, (RasterizerState) null, (Effect) null, transformation);
this._spriteBatch.End();
}
public void Begin()
{
this._spriteBatch.Begin();
this._spriteBatch.End();
}
public void Draw(Texture2D texture, Vector2 position, VertexColors colors) => this.InternalDraw(texture, ref new Vector4()
{
X = position.X,
Y = position.Y,
Z = 1f,
W = 1f
}, true, ref TileBatch._nullRectangle, ref colors, ref TileBatch._vector2Zero, SpriteEffects.None, 0.0f);
public void Draw(
Texture2D texture,
Vector2 position,
Rectangle? sourceRectangle,
VertexColors colors,
Vector2 origin,
float scale,
SpriteEffects effects)
{
this.InternalDraw(texture, ref new Vector4()
{
X = position.X,
Y = position.Y,
Z = scale,
W = scale
}, true, ref sourceRectangle, ref colors, ref origin, effects, 0.0f);
}
public void Draw(Texture2D texture, Vector4 destination, VertexColors colors) => this.InternalDraw(texture, ref destination, false, ref TileBatch._nullRectangle, ref colors, ref TileBatch._vector2Zero, SpriteEffects.None, 0.0f);
public void Draw(Texture2D texture, Vector2 position, VertexColors colors, Vector2 scale) => this.InternalDraw(texture, ref new Vector4()
{
X = position.X,
Y = position.Y,
Z = scale.X,
W = scale.Y
}, true, ref TileBatch._nullRectangle, ref colors, ref TileBatch._vector2Zero, SpriteEffects.None, 0.0f);
public void Draw(
Texture2D texture,
Vector4 destination,
Rectangle? sourceRectangle,
VertexColors colors)
{
this.InternalDraw(texture, ref destination, false, ref sourceRectangle, ref colors, ref TileBatch._vector2Zero, SpriteEffects.None, 0.0f);
}
public void Draw(
Texture2D texture,
Vector4 destination,
Rectangle? sourceRectangle,
VertexColors colors,
Vector2 origin,
SpriteEffects effects,
float rotation)
{
this.InternalDraw(texture, ref destination, false, ref sourceRectangle, ref colors, ref origin, effects, rotation);
}
public void Draw(
Texture2D texture,
Rectangle destinationRectangle,
Rectangle? sourceRectangle,
VertexColors colors)
{
this.InternalDraw(texture, ref new Vector4()
{
X = (float) destinationRectangle.X,
Y = (float) destinationRectangle.Y,
Z = (float) destinationRectangle.Width,
W = (float) destinationRectangle.Height
}, false, ref sourceRectangle, ref colors, ref TileBatch._vector2Zero, SpriteEffects.None, 0.0f);
}
private static short[] CreateIndexData()
{
short[] numArray = new short[12288];
for (int index = 0; index < 2048; ++index)
{
numArray[index * 6] = (short) (index * 4);
numArray[index * 6 + 1] = (short) (index * 4 + 1);
numArray[index * 6 + 2] = (short) (index * 4 + 2);
numArray[index * 6 + 3] = (short) (index * 4);
numArray[index * 6 + 4] = (short) (index * 4 + 2);
numArray[index * 6 + 5] = (short) (index * 4 + 3);
}
return numArray;
}
private unsafe void InternalDraw(
Texture2D texture,
ref Vector4 destination,
bool scaleDestination,
ref Rectangle? sourceRectangle,
ref VertexColors colors,
ref Vector2 origin,
SpriteEffects effects,
float rotation)
{
if (this._queuedSpriteCount >= this._spriteDataQueue.Length)
Array.Resize<TileBatch.SpriteData>(ref this._spriteDataQueue, this._spriteDataQueue.Length << 1);
fixed (TileBatch.SpriteData* spriteDataPtr = &this._spriteDataQueue[this._queuedSpriteCount])
{
float z = destination.Z;
float w = destination.W;
if (sourceRectangle.HasValue)
{
Rectangle rectangle = sourceRectangle.Value;
spriteDataPtr->Source.X = (float) rectangle.X;
spriteDataPtr->Source.Y = (float) rectangle.Y;
spriteDataPtr->Source.Z = (float) rectangle.Width;
spriteDataPtr->Source.W = (float) rectangle.Height;
if (scaleDestination)
{
z *= (float) rectangle.Width;
w *= (float) rectangle.Height;
}
}
else
{
float width = (float) texture.Width;
float height = (float) texture.Height;
spriteDataPtr->Source.X = 0.0f;
spriteDataPtr->Source.Y = 0.0f;
spriteDataPtr->Source.Z = width;
spriteDataPtr->Source.W = height;
if (scaleDestination)
{
z *= width;
w *= height;
}
}
spriteDataPtr->Destination.X = destination.X;
spriteDataPtr->Destination.Y = destination.Y;
spriteDataPtr->Destination.Z = z;
spriteDataPtr->Destination.W = w;
spriteDataPtr->Origin.X = origin.X;
spriteDataPtr->Origin.Y = origin.Y;
spriteDataPtr->Effects = effects;
spriteDataPtr->Colors = colors;
spriteDataPtr->Rotation = rotation;
}
if (this._spriteTextures == null || this._spriteTextures.Length != this._spriteDataQueue.Length)
Array.Resize<Texture2D>(ref this._spriteTextures, this._spriteDataQueue.Length);
this._spriteTextures[this._queuedSpriteCount++] = texture;
}
public void End()
{
if (this._queuedSpriteCount == 0)
return;
this.FlushRenderState();
this.Flush();
}
private void Flush()
{
Texture2D texture = (Texture2D) null;
int offset = 0;
for (int index = 0; index < this._queuedSpriteCount; ++index)
{
if (this._spriteTextures[index] != texture)
{
if (index > offset)
this.RenderBatch(texture, this._spriteDataQueue, offset, index - offset);
offset = index;
texture = this._spriteTextures[index];
}
}
this.RenderBatch(texture, this._spriteDataQueue, offset, this._queuedSpriteCount - offset);
Array.Clear((Array) this._spriteTextures, 0, this._queuedSpriteCount);
this._queuedSpriteCount = 0;
}
private unsafe void RenderBatch(
Texture2D texture,
TileBatch.SpriteData[] sprites,
int offset,
int count)
{
this._graphicsDevice.Textures[0] = (Texture) texture;
float num1 = 1f / (float) texture.Width;
float num2 = 1f / (float) texture.Height;
int num3;
for (; count > 0; count -= num3)
{
SetDataOptions options = SetDataOptions.NoOverwrite;
num3 = count;
if (num3 > 2048 - this._vertexBufferPosition)
{
num3 = 2048 - this._vertexBufferPosition;
if (num3 < 256)
{
this._vertexBufferPosition = 0;
options = SetDataOptions.Discard;
num3 = count;
if (num3 > 2048)
num3 = 2048;
}
}
fixed (TileBatch.SpriteData* spriteDataPtr1 = &sprites[offset])
fixed (VertexPositionColorTexture* positionColorTexturePtr1 = &this._vertices[0])
{
TileBatch.SpriteData* spriteDataPtr2 = spriteDataPtr1;
VertexPositionColorTexture* positionColorTexturePtr2 = positionColorTexturePtr1;
for (int index1 = 0; index1 < num3; ++index1)
{
float num4;
float num5;
if ((double) spriteDataPtr2->Rotation != 0.0)
{
num4 = (float) Math.Cos((double) spriteDataPtr2->Rotation);
num5 = (float) Math.Sin((double) spriteDataPtr2->Rotation);
}
else
{
num4 = 1f;
num5 = 0.0f;
}
float num6 = spriteDataPtr2->Origin.X / spriteDataPtr2->Source.Z;
float num7 = spriteDataPtr2->Origin.Y / spriteDataPtr2->Source.W;
positionColorTexturePtr2->Color = spriteDataPtr2->Colors.TopLeftColor;
positionColorTexturePtr2[1].Color = spriteDataPtr2->Colors.TopRightColor;
positionColorTexturePtr2[2].Color = spriteDataPtr2->Colors.BottomRightColor;
positionColorTexturePtr2[3].Color = spriteDataPtr2->Colors.BottomLeftColor;
for (int index2 = 0; index2 < 4; ++index2)
{
float num8 = TileBatch.CORNER_OFFSET_X[index2];
float num9 = TileBatch.CORNER_OFFSET_Y[index2];
float num10 = (num8 - num6) * spriteDataPtr2->Destination.Z;
float num11 = (num9 - num7) * spriteDataPtr2->Destination.W;
float num12 = (float) ((double) spriteDataPtr2->Destination.X + (double) num10 * (double) num4 - (double) num11 * (double) num5);
float num13 = (float) ((double) spriteDataPtr2->Destination.Y + (double) num10 * (double) num5 + (double) num11 * (double) num4);
if ((spriteDataPtr2->Effects & SpriteEffects.FlipVertically) != SpriteEffects.None)
num8 = 1f - num8;
if ((spriteDataPtr2->Effects & SpriteEffects.FlipHorizontally) != SpriteEffects.None)
num9 = 1f - num9;
positionColorTexturePtr2->Position.X = num12;
positionColorTexturePtr2->Position.Y = num13;
positionColorTexturePtr2->Position.Z = 0.0f;
positionColorTexturePtr2->TextureCoordinate.X = (spriteDataPtr2->Source.X + num8 * spriteDataPtr2->Source.Z) * num1;
positionColorTexturePtr2->TextureCoordinate.Y = (spriteDataPtr2->Source.Y + num9 * spriteDataPtr2->Source.W) * num2;
++positionColorTexturePtr2;
}
++spriteDataPtr2;
}
}
this._vertexBuffer.SetData<VertexPositionColorTexture>(this._vertexBufferPosition * sizeof (VertexPositionColorTexture) * 4, this._vertices, 0, num3 * 4, sizeof (VertexPositionColorTexture), options);
this._graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, this._vertexBufferPosition * 4, num3 * 4, this._vertexBufferPosition * 6, num3 * 2);
this._vertexBufferPosition += num3;
offset += num3;
}
}
private struct SpriteData
{
public Vector4 Source;
public Vector4 Destination;
public Vector2 Origin;
public SpriteEffects Effects;
public VertexColors Colors;
public float Rotation;
}
}
}

34
Graphics/VertexColors.cs Normal file
View file

@ -0,0 +1,34 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.VertexColors
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.Graphics
{
public struct VertexColors
{
public Color TopLeftColor;
public Color TopRightColor;
public Color BottomLeftColor;
public Color BottomRightColor;
public VertexColors(Color color)
{
this.TopLeftColor = color;
this.TopRightColor = color;
this.BottomRightColor = color;
this.BottomLeftColor = color;
}
public VertexColors(Color topLeft, Color topRight, Color bottomRight, Color bottomLeft)
{
this.TopLeftColor = topLeft;
this.TopRightColor = topRight;
this.BottomLeftColor = bottomLeft;
this.BottomRightColor = bottomRight;
}
}
}

194
Graphics/VertexStrip.cs Normal file
View file

@ -0,0 +1,194 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.VertexStrip
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// 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;
using System.Collections.Generic;
namespace Terraria.Graphics
{
public class VertexStrip
{
private VertexStrip.CustomVertexInfo[] _vertices = new VertexStrip.CustomVertexInfo[1];
private int _vertexAmountCurrentlyMaintained;
private short[] _indices = new short[1];
private int _indicesAmountCurrentlyMaintained;
private List<Vector2> _temporaryPositionsCache = new List<Vector2>();
private List<float> _temporaryRotationsCache = new List<float>();
public void PrepareStrip(
Vector2[] positions,
float[] rotations,
VertexStrip.StripColorFunction colorFunction,
VertexStrip.StripHalfWidthFunction widthFunction,
Vector2 offsetForAllPositions = default (Vector2),
int? expectedVertexPairsAmount = null,
bool includeBacksides = false)
{
int vertexPaidsAdded = positions.Length;
int newSize = vertexPaidsAdded * 2;
this._vertexAmountCurrentlyMaintained = newSize;
if (this._vertices.Length < newSize)
Array.Resize<VertexStrip.CustomVertexInfo>(ref this._vertices, newSize);
int num = vertexPaidsAdded;
if (expectedVertexPairsAmount.HasValue)
num = expectedVertexPairsAmount.Value;
for (int index = 0; index < vertexPaidsAdded; ++index)
{
if (positions[index] == Vector2.Zero)
{
vertexPaidsAdded = index - 1;
this._vertexAmountCurrentlyMaintained = vertexPaidsAdded * 2;
break;
}
Vector2 pos = positions[index] + offsetForAllPositions;
float rot = MathHelper.WrapAngle(rotations[index]);
int indexOnVertexArray = index * 2;
float progressOnStrip = (float) index / (float) (num - 1);
this.AddVertex(colorFunction, widthFunction, pos, rot, indexOnVertexArray, progressOnStrip);
}
this.PrepareIndices(vertexPaidsAdded, includeBacksides);
}
public void PrepareStripWithProceduralPadding(
Vector2[] positions,
float[] rotations,
VertexStrip.StripColorFunction colorFunction,
VertexStrip.StripHalfWidthFunction widthFunction,
Vector2 offsetForAllPositions = default (Vector2),
bool includeBacksides = false)
{
int length = positions.Length;
this._temporaryPositionsCache.Clear();
this._temporaryRotationsCache.Clear();
for (int index = 0; index < length && !(positions[index] == Vector2.Zero); ++index)
{
Vector2 position1 = positions[index];
float f1 = MathHelper.WrapAngle(rotations[index]);
this._temporaryPositionsCache.Add(position1);
this._temporaryRotationsCache.Add(f1);
if (index + 1 < length && positions[index + 1] != Vector2.Zero)
{
Vector2 position2 = positions[index + 1];
float f2 = MathHelper.WrapAngle(rotations[index + 1]);
int num1 = (int) ((double) Math.Abs(MathHelper.WrapAngle(f2 - f1)) / 0.261799395084381);
if (num1 != 0)
{
float num2 = position1.Distance(position2);
Vector2 vector2_1 = position1 + f1.ToRotationVector2() * num2;
Vector2 vector2_2 = position2 + f2.ToRotationVector2() * -num2;
float num3 = 1f / (float) (num1 + 2);
Vector2 Target = position1;
for (float amount = num3; (double) amount < 1.0; amount += num3)
{
Vector2 Origin = Vector2.CatmullRom(vector2_1, position1, position2, vector2_2, amount);
float num4 = MathHelper.WrapAngle(Origin.DirectionTo(Target).ToRotation());
this._temporaryPositionsCache.Add(Origin);
this._temporaryRotationsCache.Add(num4);
Target = Origin;
}
}
}
}
int count = this._temporaryPositionsCache.Count;
for (int index = 0; index < count; ++index)
{
Vector2 pos = this._temporaryPositionsCache[index] + offsetForAllPositions;
float rot = this._temporaryRotationsCache[index];
int indexOnVertexArray = index * 2;
float progressOnStrip = (float) index / (float) (count - 1);
this.AddVertex(colorFunction, widthFunction, pos, rot, indexOnVertexArray, progressOnStrip);
}
this._vertexAmountCurrentlyMaintained = count * 2;
this.PrepareIndices(count, includeBacksides);
}
private void PrepareIndices(int vertexPaidsAdded, bool includeBacksides)
{
int num1 = vertexPaidsAdded - 1;
int num2 = 6 + includeBacksides.ToInt() * 6;
int newSize = num1 * num2;
this._indicesAmountCurrentlyMaintained = newSize;
if (this._indices.Length < newSize)
Array.Resize<short>(ref this._indices, newSize);
for (short index = 0; (int) index < num1; ++index)
{
short num3 = (short) ((int) index * num2);
int num4 = (int) index * 2;
this._indices[(int) num3] = (short) num4;
this._indices[(int) num3 + 1] = (short) (num4 + 1);
this._indices[(int) num3 + 2] = (short) (num4 + 2);
this._indices[(int) num3 + 3] = (short) (num4 + 2);
this._indices[(int) num3 + 4] = (short) (num4 + 1);
this._indices[(int) num3 + 5] = (short) (num4 + 3);
if (includeBacksides)
{
this._indices[(int) num3 + 6] = (short) (num4 + 2);
this._indices[(int) num3 + 7] = (short) (num4 + 1);
this._indices[(int) num3 + 8] = (short) num4;
this._indices[(int) num3 + 9] = (short) (num4 + 2);
this._indices[(int) num3 + 10] = (short) (num4 + 3);
this._indices[(int) num3 + 11] = (short) (num4 + 1);
}
}
}
private void AddVertex(
VertexStrip.StripColorFunction colorFunction,
VertexStrip.StripHalfWidthFunction widthFunction,
Vector2 pos,
float rot,
int indexOnVertexArray,
float progressOnStrip)
{
while (indexOnVertexArray + 1 >= this._vertices.Length)
Array.Resize<VertexStrip.CustomVertexInfo>(ref this._vertices, this._vertices.Length * 2);
Color color = colorFunction(progressOnStrip);
float num = widthFunction(progressOnStrip);
Vector2 vector2 = MathHelper.WrapAngle(rot - 1.570796f).ToRotationVector2() * num;
this._vertices[indexOnVertexArray].Position = pos + vector2;
this._vertices[indexOnVertexArray + 1].Position = pos - vector2;
this._vertices[indexOnVertexArray].TexCoord = new Vector3(progressOnStrip, num, num);
this._vertices[indexOnVertexArray + 1].TexCoord = new Vector3(progressOnStrip, 0.0f, num);
this._vertices[indexOnVertexArray].Color = color;
this._vertices[indexOnVertexArray + 1].Color = color;
}
public void DrawTrail()
{
if (this._vertexAmountCurrentlyMaintained < 3)
return;
Main.instance.GraphicsDevice.DrawUserIndexedPrimitives<VertexStrip.CustomVertexInfo>(PrimitiveType.TriangleList, this._vertices, 0, this._vertexAmountCurrentlyMaintained, this._indices, 0, this._indicesAmountCurrentlyMaintained / 3);
}
public delegate Color StripColorFunction(float progressOnStrip);
public delegate float StripHalfWidthFunction(float progressOnStrip);
private struct CustomVertexInfo : IVertexType
{
public Vector2 Position;
public Color Color;
public Vector3 TexCoord;
private static VertexDeclaration _vertexDeclaration = new VertexDeclaration(new VertexElement[3]
{
new VertexElement(0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0),
new VertexElement(8, VertexElementFormat.Color, VertexElementUsage.Color, 0),
new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.TextureCoordinate, 0)
});
public CustomVertexInfo(Vector2 position, Color color, Vector3 texCoord)
{
this.Position = position;
this.Color = color;
this.TexCoord = texCoord;
}
public VertexDeclaration VertexDeclaration => VertexStrip.CustomVertexInfo._vertexDeclaration;
}
}
}

23
Graphics/VirtualCamera.cs Normal file
View file

@ -0,0 +1,23 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.VirtualCamera
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.Graphics
{
public struct VirtualCamera
{
public readonly Player Player;
public VirtualCamera(Player player) => this.Player = player;
public Vector2 Position => this.Center - this.Size * 0.5f;
public Vector2 Size => new Vector2((float) Main.maxScreenW, (float) Main.maxScreenH);
public Vector2 Center => this.Player.Center;
}
}

View file

@ -0,0 +1,55 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Graphics.WindowStateController
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Drawing;
using System.Windows.Forms;
namespace Terraria.Graphics
{
public class WindowStateController
{
public bool CanMoveWindowAcrossScreens => true;
public string ScreenDeviceName => Main.instance.Window.ScreenDeviceName;
public void TryMovingToScreen(string screenDeviceName)
{
Rectangle bounds;
if (!this.CanMoveWindowAcrossScreens || !this.TryGetBounds(screenDeviceName, out bounds) || !this.IsVisibleOnAnyScreen(bounds))
return;
Form form = (Form) Control.FromHandle(Main.instance.Window.Handle);
if (!this.WouldViewFitInScreen(form.Bounds, bounds))
return;
form.Location = new Point(bounds.Width / 2 - form.Width / 2 + bounds.X, bounds.Height / 2 - form.Height / 2 + bounds.Y);
}
private bool TryGetBounds(string screenDeviceName, out Rectangle bounds)
{
bounds = new Rectangle();
foreach (Screen allScreen in Screen.AllScreens)
{
if (allScreen.DeviceName == screenDeviceName)
{
bounds = allScreen.Bounds;
return true;
}
}
return false;
}
private bool WouldViewFitInScreen(Rectangle view, Rectangle screen) => view.Width <= screen.Width && view.Height <= screen.Height;
private bool IsVisibleOnAnyScreen(Rectangle rect)
{
foreach (Screen allScreen in Screen.AllScreens)
{
if (allScreen.WorkingArea.IntersectsWith(rect))
return true;
}
return false;
}
}
}