Replace Reflection call to direct call if possible
This commit is contained in:
1 parent
f7448755a0
commit
c0da0d5ce2
14 files changed
+69
-121
No files matched your search
@@ -1,19 +1,15 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using CalamityMod.Skies;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Backgrounds
|
||||
{
|
||||
public class AstralDesertSurfaceBGStyle : ModSurfaceBackgroundStyle
|
||||
{
|
||||
internal static readonly FieldInfo screenOffField = typeof(Main).GetField("screenOff", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
internal static readonly FieldInfo scAdjField = typeof(Main).GetField("scAdj", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
internal static readonly FieldInfo COSBMAplhaField = typeof(Main).GetField("ColorOfSurfaceBackgroundsModified", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
readonly int CloseBGYOffset = 475;
|
||||
readonly int MiddleBGYOffset = 475;
|
||||
|
||||
@@ -45,9 +41,9 @@ namespace CalamityMod.Backgrounds
|
||||
public override bool PreDrawCloseBackground(SpriteBatch spriteBatch)
|
||||
{
|
||||
//Please see AstralSurfaceBGStyle for comments, code is pretty much identical here
|
||||
float screenOff = (float)screenOffField.GetValue(Main.instance);
|
||||
float scAdj = (float)scAdjField.GetValue(Main.instance);
|
||||
Color COSBMAplha = (Color)COSBMAplhaField.GetValue(null);
|
||||
float screenOff = Main.instance.screenOff;
|
||||
float scAdj = Main.instance.scAdj;
|
||||
Color COSBMAplha = Main.ColorOfSurfaceBackgroundsModified;
|
||||
Color ColorOfSurfaceBackgroundsModified = new Color(63, 51, 90, COSBMAplha.A);
|
||||
bool canBGDraw = false;
|
||||
if ((!Main.remixWorld || (Main.gameMenu && !WorldGen.remixWorldGen)) && (!WorldGen.remixWorldGen || !WorldGen.drunkWorldGen))
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using CalamityMod.Skies;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Backgrounds
|
||||
{
|
||||
public class AstralSnowSurfaceBGStyle : ModSurfaceBackgroundStyle
|
||||
{
|
||||
internal static readonly FieldInfo screenOffField = typeof(Main).GetField("screenOff", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
internal static readonly FieldInfo scAdjField = typeof(Main).GetField("scAdj", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
internal static readonly FieldInfo COSBMAplhaField = typeof(Main).GetField("ColorOfSurfaceBackgroundsModified", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
readonly int FrontBGYOffset = 275;
|
||||
readonly int CloseBGYOffset = 175;
|
||||
readonly int MiddleBGYOffset = 475;
|
||||
@@ -46,9 +42,9 @@ namespace CalamityMod.Backgrounds
|
||||
public override bool PreDrawCloseBackground(SpriteBatch spriteBatch)
|
||||
{
|
||||
//Please see AstralSurfaceBGStyle for comments, code is pretty much identical here
|
||||
float screenOff = (float)screenOffField.GetValue(Main.instance);
|
||||
float scAdj = (float)scAdjField.GetValue(Main.instance);
|
||||
Color COSBMAplha = (Color)COSBMAplhaField.GetValue(null);
|
||||
float screenOff = Main.instance.screenOff;
|
||||
float scAdj = Main.instance.scAdj;
|
||||
Color COSBMAplha = Main.ColorOfSurfaceBackgroundsModified;
|
||||
Color ColorOfSurfaceBackgroundsModified = new Color(63, 51, 90, COSBMAplha.A);
|
||||
bool canBGDraw = false;
|
||||
if ((!Main.remixWorld || (Main.gameMenu && !WorldGen.remixWorldGen)) && (!WorldGen.remixWorldGen || !WorldGen.drunkWorldGen))
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using System;
|
||||
using CalamityMod.Skies;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Backgrounds
|
||||
{
|
||||
//this is just a blank background, so each custom background will draw over it
|
||||
public class AstralSurfaceBGStyle : ModSurfaceBackgroundStyle
|
||||
{
|
||||
internal static readonly FieldInfo screenOffField = typeof(Main).GetField("screenOff", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
internal static readonly FieldInfo scAdjField = typeof(Main).GetField("scAdj", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
internal static readonly FieldInfo COSBMAplhaField = typeof(Main).GetField("ColorOfSurfaceBackgroundsModified", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
readonly int FrontBGYOffset = 275; //Offsets for the height positioning. Make these 0 for backgrounds that want to be the same as treeline backgrounds (backgrounds that have the front 3 layers as trees)
|
||||
readonly int CloseBGYOffset = 175;
|
||||
readonly int MiddleBGYOffset = 475;
|
||||
@@ -50,9 +46,9 @@ namespace CalamityMod.Backgrounds
|
||||
|
||||
public override bool PreDrawCloseBackground(SpriteBatch spriteBatch) //Taken from vanilla to draw the front 3 layers, edited to fit tmod and astral background needs
|
||||
{
|
||||
float screenOff = (float)screenOffField.GetValue(Main.instance);
|
||||
float scAdj = (float)scAdjField.GetValue(Main.instance);
|
||||
Color COSBMAplha = (Color)COSBMAplhaField.GetValue(null);
|
||||
float screenOff = Main.instance.screenOff;
|
||||
float scAdj = Main.instance.scAdj;
|
||||
Color COSBMAplha = Main.ColorOfSurfaceBackgroundsModified;
|
||||
Color ColorOfSurfaceBackgroundsModified = new Color(63, 51, 90, COSBMAplha.A); //Astral Biome Coloration with the alpha as the background fade
|
||||
bool canBGDraw = false;
|
||||
if ((!Main.remixWorld || (Main.gameMenu && !WorldGen.remixWorldGen)) && (!WorldGen.remixWorldGen || !WorldGen.drunkWorldGen))
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using CalamityMod.Tiles.DraedonStructures;
|
||||
using CalamityMod.Tiles.DraedonStructures;
|
||||
using CalamityMod.Tiles.FurnitureExo;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
@@ -36,10 +34,6 @@ namespace CalamityMod.ILEditing
|
||||
/// </summary>
|
||||
private static void ApplyEdits(ManipulatorContext ctx)
|
||||
{
|
||||
// Wrap the vanilla town NPC spawning function in a delegate so that it can be tossed around and called at will.
|
||||
var updateTime = typeof(Main).GetMethod("UpdateTime_SpawnTownNPCs", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
VanillaSpawnTownNPCs = Delegate.CreateDelegate(typeof(Action), updateTime) as Action;
|
||||
|
||||
// Cache the six lab door tile types for efficiency.
|
||||
labDoorOpen = ModContent.TileType<LaboratoryDoorOpen>();
|
||||
labDoorClosed = ModContent.TileType<LaboratoryDoorClosed>();
|
||||
|
||||
@@ -350,13 +350,11 @@ namespace CalamityMod.ILEditing
|
||||
var cursor = new ILCursor(il);
|
||||
cursor.EmitDelegate<Action>(() =>
|
||||
{
|
||||
// A cached delegate is used here instead of direct reflection for performance reasons
|
||||
// since UpdateTime is called every frame.
|
||||
if (Main.dayTime || CalamityServerConfig.Instance.TownNPCsSpawnAtNight)
|
||||
VanillaSpawnTownNPCs();
|
||||
Main.UpdateTime_SpawnTownNPCs();
|
||||
});
|
||||
|
||||
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCallOrCallvirt<Main>("UpdateTime_SpawnTownNPCs")))
|
||||
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCallOrCallvirt<Main>(nameof(Main.UpdateTime_SpawnTownNPCs))))
|
||||
{
|
||||
CalamityMod.Log.Warn("Town NPC spawn editing code failed.");
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Systems;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -75,11 +74,11 @@ namespace CalamityMod.MainMenu
|
||||
public static List<SunkenFishBoid> Fishes { get; private set; } = [];
|
||||
|
||||
public static Asset<Texture2D> LogoWater => ModContent.Request<Texture2D>("CalamityMod/MainMenu/LogoSunken_Water");
|
||||
|
||||
|
||||
public static Asset<Texture2D> LogoWaterFill => ModContent.Request<Texture2D>("CalamityMod/MainMenu/LogoSunken_Water_Fill");
|
||||
|
||||
|
||||
public static Asset<Texture2D> Perlin => ModContent.Request<Texture2D>("CalamityMod/MainMenu/Perlin");
|
||||
|
||||
|
||||
public static Asset<Texture2D> WorleyInverted => ModContent.Request<Texture2D>("CalamityMod/MainMenu/WorleyInverted");
|
||||
|
||||
private static RenderTarget2D logoWaterFillTarget;
|
||||
@@ -88,7 +87,7 @@ namespace CalamityMod.MainMenu
|
||||
public int MaxBoids = 120;
|
||||
|
||||
public float remixLogoRotation = 0f;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The global save data key which dictates whether or not the player is opening the Sunken Sea Overhaul update for the first time.
|
||||
/// </summary>
|
||||
@@ -129,15 +128,13 @@ namespace CalamityMod.MainMenu
|
||||
if (GlobalSaveDataSystem.IsKeyAlreadySaved(FirstTimeOpeningSunkenSeaOverhaulKey))
|
||||
return;
|
||||
|
||||
FieldInfo menusInfo = typeof(MenuLoader).GetField("menus", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
List<ModMenu> modMenus = (List<ModMenu>)menusInfo.GetValue(null);
|
||||
List<ModMenu> modMenus = MenuLoader.menus;
|
||||
|
||||
var sunkenMenu = ModContent.GetInstance<CalamityMainMenu_Sunken>();
|
||||
if (modMenus.Contains(sunkenMenu))
|
||||
{
|
||||
FieldInfo lastSelectedMenuInfo = typeof(MenuLoader).GetField("LastSelectedModMenu", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
int sunkenSeaMenuIndex = modMenus.IndexOf(sunkenMenu);
|
||||
lastSelectedMenuInfo.SetValue(null, modMenus[sunkenSeaMenuIndex].FullName);
|
||||
MenuLoader.LastSelectedModMenu = modMenus[sunkenSeaMenuIndex].FullName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +147,7 @@ namespace CalamityMod.MainMenu
|
||||
public override bool PreDrawLogo(SpriteBatch spriteBatch, ref Vector2 logoDrawCenter, ref float logoRotation, ref float logoScale, ref Color drawColor)
|
||||
{
|
||||
DrawLogoWaterShader(spriteBatch);
|
||||
|
||||
|
||||
// Draw the main background for the menu.
|
||||
DrawMenuBackground(spriteBatch);
|
||||
|
||||
@@ -165,17 +162,17 @@ namespace CalamityMod.MainMenu
|
||||
|
||||
// Draw the logo.
|
||||
DrawLogo(spriteBatch, ref logoDrawCenter, ref logoRotation, ref logoScale, ref drawColor);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void DrawLogoWaterShader(SpriteBatch sb)
|
||||
{
|
||||
sb.End();
|
||||
|
||||
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(logoWaterFillTarget);
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
|
||||
|
||||
sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity);
|
||||
|
||||
var fillShader = CalamityShaders.SunkenSeaMenuLogoWater.Value;
|
||||
@@ -192,19 +189,19 @@ namespace CalamityMod.MainMenu
|
||||
fillShader.Parameters["uEdgeColor"]?.SetValue(new Color(16, 99, 112, 255 / 2).ToVector4() * 0.7f);
|
||||
fillShader.Parameters["uLineColor"]?.SetValue(new Color(179, 255, 255, 255 / 2).ToVector4() * 0.7f);
|
||||
fillShader.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
|
||||
sb.Draw(LogoWaterFill.Value, Vector2.Zero, Color.White);
|
||||
|
||||
|
||||
sb.End();
|
||||
|
||||
|
||||
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(logoTarget);
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity);
|
||||
|
||||
|
||||
sb.Draw(logoWaterFillTarget, new Vector2(406, 48), Color.White);
|
||||
|
||||
|
||||
sb.End();
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(null);
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.UIScaleMatrix);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using CalamityMod.Balancing;
|
||||
using CalamityMod.BiomeManagers;
|
||||
using CalamityMod.Buffs;
|
||||
@@ -1020,8 +1019,8 @@ namespace CalamityMod.NPCs
|
||||
blazingStarShredTimer--;
|
||||
}
|
||||
npc.lifeRegenCount -= dmg;
|
||||
if (damage < dmg/12) // 1/6th of the DPS dealt by Glaive Shred shows up as the indicator, unless another debuff does more per tick
|
||||
damage = dmg/12;
|
||||
if (damage < dmg / 12) // 1/6th of the DPS dealt by Glaive Shred shows up as the indicator, unless another debuff does more per tick
|
||||
damage = dmg / 12;
|
||||
|
||||
if (-120 * damage >= npc.lifeRegenCount)
|
||||
{
|
||||
@@ -2421,7 +2420,7 @@ namespace CalamityMod.NPCs
|
||||
VulnerableToSickness = true;
|
||||
VulnerableToWater = true;
|
||||
break;
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -4730,15 +4729,13 @@ namespace CalamityMod.NPCs
|
||||
#endregion
|
||||
|
||||
#region Edit Spawn Pool
|
||||
internal static readonly FieldInfo MaxSpawnsField = typeof(NPC).GetField("maxSpawns", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
|
||||
public static void AttemptToSpawnLabCritters(Player player)
|
||||
{
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
return;
|
||||
|
||||
int spawnRate = 400;
|
||||
int maxSpawnCount = (int)MaxSpawnsField.GetValue(null);
|
||||
int maxSpawnCount = NPC.maxSpawns;
|
||||
NPCLoader.EditSpawnRate(player, ref spawnRate, ref maxSpawnCount);
|
||||
|
||||
// Enforce a limit on the amount of enemies that can appear.
|
||||
@@ -4812,7 +4809,7 @@ namespace CalamityMod.NPCs
|
||||
return;
|
||||
|
||||
int spawnRate = 400;
|
||||
int maxSpawnCount = (int)MaxSpawnsField.GetValue(null);
|
||||
int maxSpawnCount = NPC.maxSpawns;
|
||||
NPCLoader.EditSpawnRate(player, ref spawnRate, ref maxSpawnCount);
|
||||
|
||||
// Enforce a limit on the amount of enemies that can appear.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using CalamityMod.Events;
|
||||
using CalamityMod.Skies;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -11,8 +10,6 @@ namespace CalamityMod.Systems
|
||||
{
|
||||
public class BossRushScene : ModSceneEffect
|
||||
{
|
||||
internal static readonly FieldInfo EffectsField = typeof(SkyManager).GetField("_effects", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public override int Music => BossRushEvent.MusicToPlay;
|
||||
public override SceneEffectPriority Priority => SceneEffectPriority.BossHigh;
|
||||
|
||||
@@ -23,7 +20,7 @@ namespace CalamityMod.Systems
|
||||
// Clear all other skies, including the vanilla ones.
|
||||
if (isActive)
|
||||
{
|
||||
Dictionary<string, CustomSky> skies = EffectsField.GetValue(SkyManager.Instance) as Dictionary<string, CustomSky>;
|
||||
Dictionary<string, CustomSky> skies = SkyManager.Instance._effects;
|
||||
bool updateRequired = false;
|
||||
foreach (string skyName in skies.Keys)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace CalamityMod.Systems.Graphic.LiquidSystem
|
||||
[Autoload(Side = ModSide.Client)]
|
||||
public sealed partial class ModLavaStyleSystem : ModSystem
|
||||
{
|
||||
private static readonly MethodInfo Tex2DAssetGetter = typeof(Asset<Texture2D>).GetProperty(nameof(Asset<Texture2D>.Value)).GetMethod;
|
||||
private static readonly MethodInfo Tex2DAssetGetter = typeof(Asset<Texture2D>).GetProperty(nameof(Asset<>.Value)).GetMethod;
|
||||
|
||||
private static void ApplyEdits(ManipulatorContext ctx)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace CalamityMod.Systems
|
||||
public static List<DifficultyMode[]> DifficultyTiers; //Difficulty modes grouped together by difficulty
|
||||
public static int MostAlternateDifficulties; //The most alternate difficulties at any tier that exists. Used to know the widest space to take in the ui
|
||||
|
||||
public static FieldInfo journeySliderCacheField; // The current value of the journey mode difficulty slider
|
||||
public static MethodInfo journeyDifficultyUpdateMethod; // The method which updates difficulty modes in journey mode
|
||||
|
||||
public override void OnModLoad()
|
||||
@@ -40,8 +39,6 @@ namespace CalamityMod.Systems
|
||||
ModContent.GetInstance<MasterDifficulty>(), ModContent.GetInstance<RevengeanceDifficulty>(),
|
||||
ModContent.GetInstance<DeathDifficulty>() };
|
||||
|
||||
// Reflect private journey difficulty slider info
|
||||
journeySliderCacheField = typeof(CreativePowers.DifficultySliderPower).GetField("_sliderCurrentValueCache", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
journeyDifficultyUpdateMethod = typeof(CreativePowers.DifficultySliderPower).GetMethod("UpdateInfoFromSliderValueCache", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
CalculateDifficultyData();
|
||||
@@ -95,7 +92,7 @@ namespace CalamityMod.Systems
|
||||
if (power.GetIsUnlocked())
|
||||
{
|
||||
int effectiveVanillaDifficulty;
|
||||
var sliderValue = (float)journeySliderCacheField.GetValue(power);
|
||||
var sliderValue = power._sliderCurrentValueCache;
|
||||
if (sliderValue == 1)
|
||||
{
|
||||
effectiveVanillaDifficulty = GameModeID.Master;
|
||||
@@ -181,10 +178,10 @@ namespace CalamityMod.Systems
|
||||
throw new ArgumentException("DifficultyModeSystemAlignJourneyDifficultySlider(): must be invoked in journey mode");
|
||||
}
|
||||
CreativePowers.DifficultySliderPower power = CreativePowerManager.Instance.GetPower<CreativePowers.DifficultySliderPower>();
|
||||
var oldValue = (float)journeySliderCacheField.GetValue(power);
|
||||
if (compatitableValueRanges.ContainsKey(_newGameModeID))
|
||||
var oldValue = power._sliderCurrentValueCache;
|
||||
if (compatitableValueRanges.TryGetValue(_newGameModeID, out var value))
|
||||
{
|
||||
var (low, high) = compatitableValueRanges[_newGameModeID];
|
||||
var (low, high) = value;
|
||||
float valueToSet;
|
||||
if (oldValue >= low && oldValue < high)
|
||||
{
|
||||
@@ -194,7 +191,7 @@ namespace CalamityMod.Systems
|
||||
{
|
||||
valueToSet = low;
|
||||
}
|
||||
journeySliderCacheField.SetValue(power, valueToSet);
|
||||
power._sliderCurrentValueCache = valueToSet;
|
||||
journeyDifficultyUpdateMethod.Invoke(power, null);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
@@ -51,8 +50,7 @@ namespace CalamityMod.Systems
|
||||
public static bool GetDeath(AWorldListItem item)
|
||||
{
|
||||
// Grab data from the listed world
|
||||
FieldInfo worldDataField = typeof(UIWorldListItem).GetField("_data", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
WorldFileData worldData = (WorldFileData)worldDataField.GetValue(item);
|
||||
WorldFileData worldData = item._data;
|
||||
|
||||
if (item.Data.TryGetHeaderData<WorldSelectionDifficultySystem>(out TagCompound tag))
|
||||
{
|
||||
@@ -71,8 +69,7 @@ namespace CalamityMod.Systems
|
||||
public static bool GetMalice(AWorldListItem item)
|
||||
{
|
||||
// Grab data from the listed world
|
||||
FieldInfo worldDataField = typeof(UIWorldListItem).GetField("_data", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
WorldFileData worldData = (WorldFileData)worldDataField.GetValue(item);
|
||||
WorldFileData worldData = item._data;
|
||||
|
||||
int trueGameMode = worldData.GameMode;
|
||||
if (worldData.ForTheWorthy)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -643,11 +642,6 @@ namespace CalamityMod
|
||||
return false;
|
||||
}
|
||||
|
||||
// Cached for efficiency purposes.
|
||||
internal static readonly FieldInfo UImageFieldMisc0 = typeof(MiscShaderData).GetField("_uImage0", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
internal static readonly FieldInfo UImageFieldMisc1 = typeof(MiscShaderData).GetField("_uImage1", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
internal static readonly FieldInfo UImageFieldArmor = typeof(ArmorShaderData).GetField("_uImage", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
/// <summary>
|
||||
/// Manually sets the texture of a <see cref="MiscShaderData"/> instance, since vanilla's implementation only supports strings that access vanilla textures.
|
||||
/// </summary>
|
||||
@@ -658,10 +652,9 @@ namespace CalamityMod
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
UImageFieldMisc0.SetValue(shader, texture);
|
||||
shader._uImage0 = texture;
|
||||
break;
|
||||
case 1:
|
||||
UImageFieldMisc1.SetValue(shader, texture);
|
||||
break;
|
||||
}
|
||||
return shader;
|
||||
@@ -674,7 +667,7 @@ namespace CalamityMod
|
||||
/// <param name="texture">The texture to bind.</param>
|
||||
public static ArmorShaderData SetShaderTextureArmor(this ArmorShaderData shader, Asset<Texture2D> texture)
|
||||
{
|
||||
UImageFieldArmor.SetValue(shader, texture);
|
||||
shader._uImage = texture;
|
||||
return shader;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using CalamityMod.Balancing;
|
||||
using CalamityMod.CalPlayer;
|
||||
using CalamityMod.Cooldowns;
|
||||
@@ -613,17 +612,13 @@ namespace CalamityMod
|
||||
player.hurtCooldowns[i] = 0;
|
||||
}
|
||||
|
||||
private static readonly FieldInfo hurtInfoDamageField = typeof(HurtInfo).GetField("_damage", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
/// <summary>
|
||||
/// Lifted from Fargo's. Sets the damage and knockback of an incoming hit to zero, making it not affect the player.
|
||||
/// </summary>
|
||||
/// <param name="hurtInfo">The HurtInfo instance to nullify.</param>
|
||||
public static void NullifyHit(ref this HurtInfo hurtInfo)
|
||||
{
|
||||
object unboxedHurtInfo = hurtInfo;
|
||||
hurtInfoDamageField.SetValue(unboxedHurtInfo, 0);
|
||||
hurtInfo = (Player.HurtInfo)unboxedHurtInfo;
|
||||
hurtInfo._damage = 0;
|
||||
hurtInfo.Knockback = 0;
|
||||
}
|
||||
#endregion
|
||||
@@ -645,7 +640,7 @@ namespace CalamityMod
|
||||
|
||||
// Limit the amount of heal to the player's max health
|
||||
amount = Math.Min(amount, player.statLifeMax2 - player.statLife);
|
||||
|
||||
|
||||
// As well as the physical cap to how much HP can be healed
|
||||
amount = Math.Min(amount, BalancingConstants.LifeStealCap);
|
||||
|
||||
@@ -697,7 +692,7 @@ namespace CalamityMod
|
||||
|
||||
// Limit the amount of heal to the target player's max health
|
||||
amount = Math.Min(amount, lowestHealthCheck);
|
||||
|
||||
|
||||
// As well as the physical cap to how much HP can be healed
|
||||
amount = Math.Min(amount, BalancingConstants.LifeStealCap);
|
||||
|
||||
@@ -997,7 +992,7 @@ namespace CalamityMod
|
||||
public static Vector2 ClampedMouseWorld(this Player player)
|
||||
{
|
||||
Vector2 mouseWorld = player.Calamity().mouseWorld;
|
||||
|
||||
|
||||
// Clamp each axis
|
||||
mouseWorld.X = mouseWorld.X >= player.MountedCenter.X ? MathF.Min(mouseWorld.X, player.MountedCenter.X + 960f) : MathF.Max(mouseWorld.X, player.MountedCenter.X - 960f);
|
||||
mouseWorld.Y = mouseWorld.Y >= player.MountedCenter.Y ? MathF.Min(mouseWorld.Y, player.MountedCenter.Y + 540f) : MathF.Max(mouseWorld.Y, player.MountedCenter.Y - 540f);
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using System.Reflection;
|
||||
using CalamityMod.Items.Tools.ClimateChange;
|
||||
using CalamityMod.Items.Tools.ClimateChange;
|
||||
using CalamityMod.NPCs.ExoMechs;
|
||||
using CalamityMod.NPCs.ExoMechs.Apollo;
|
||||
using CalamityMod.NPCs.ExoMechs.Ares;
|
||||
using CalamityMod.NPCs.ExoMechs.Artemis;
|
||||
using CalamityMod.NPCs.ExoMechs.Thanatos;
|
||||
using CalamityMod.Systems;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent.Creative;
|
||||
using Terraria.GameContent.Events;
|
||||
using Terraria.ID;
|
||||
@@ -61,13 +58,11 @@ namespace CalamityMod.World
|
||||
if (Main.GameModeInfo.IsJourneyMode)
|
||||
{
|
||||
CreativePowers.DifficultySliderPower power = CreativePowerManager.Instance.GetPower<CreativePowers.DifficultySliderPower>();
|
||||
float level = (float)DifficultyModeSystem.journeySliderCacheField.GetValue(power);
|
||||
float level = power._sliderCurrentValueCache;
|
||||
return level == 1f;
|
||||
}
|
||||
|
||||
FieldInfo findInfo = typeof(Main).GetField("_currentGameModeInfo", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
GameModeData data = (GameModeData)findInfo.GetValue(null);
|
||||
return data.IsMasterMode;
|
||||
return Main._currentGameModeInfo.IsMasterMode;
|
||||
}
|
||||
|
||||
// Sunken Sea
|
||||
|
||||
Reference in new issue
Block a user