Files
CalamityModPublic/ILEditing/ILChanges.cs
T
DominicKarma42 55e89c9b98 Replaced (hopefully) every magic number with a constant
Note: Does not include item rarities, and appears to shown nonexistant using directive movement in the commit. This does not really affect anything, however.
2020-05-30 17:56:36 -04:00

36 lines
1.1 KiB
C#

using MonoMod.Cil;
using System;
using Terraria;
namespace CalamityMod.ILEditing
{
public class ILChanges
{
/// <summary>
/// Loads all IL Editing changes in the mod.
/// </summary>
public static void Initialize()
{
IL.Terraria.WorldGen.MakeDungeon += (il) =>
{
var cursor = new ILCursor(il);
if (!cursor.TryGotoNext(i => i.MatchStsfld("Terraria.WorldGen", "dMaxY")))
{
CalamityMod.instance.Logger.Warn("Dungeon movement editing code failed.");
return;
}
cursor.Index++;
cursor.EmitDelegate<Action>(() =>
{
WorldGen.dungeonX += (WorldGen.dungeonX < Main.maxTilesX / 2).ToDirectionInt() * 450;
if (WorldGen.dungeonX < 200)
WorldGen.dungeonX = 200;
if (WorldGen.dungeonX > Main.maxTilesX - 200)
WorldGen.dungeonX = Main.maxTilesX - 200;
});
};
}
}
}