Created
January 11, 2020 12:22
-
-
Save NodusCursorius/43f9e294c2b7267f881bf5705c873a4d to your computer and use it in GitHub Desktop.
RemovePlanetSizeLimits.dll decompile - Space Engineers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Decompile of RemovePlanetSizeLimits.dll for Space Engineers, not intended for recompile | |
// MyInfiniteDensityFunction.cs | |
using System; | |
using Sandbox.Game.World.Generator; | |
using VRage.Library.Utils; | |
using VRage.Noise; | |
using VRageMath; | |
namespace RemovePlanetSizeLimits | |
{ | |
// Token: 0x02000005 RID: 5 | |
internal class MyInfiniteDensityFunction : IMyAsteroidFieldDensityFunction, IMyModule | |
{ | |
// Token: 0x06000008 RID: 8 RVA: 0x0000224F File Offset: 0x0000044F | |
public MyInfiniteDensityFunction(MyRandom random, double frequency) | |
{ | |
this.noise = new MySimplexFast(random.Next(), frequency); | |
} | |
// Token: 0x06000009 RID: 9 RVA: 0x00002269 File Offset: 0x00000469 | |
public bool ExistsInCell(ref BoundingBoxD bbox) | |
{ | |
return true; | |
} | |
// Token: 0x0600000A RID: 10 RVA: 0x0000226C File Offset: 0x0000046C | |
public double GetValue(double x) | |
{ | |
return this.noise.GetValue(x); | |
} | |
// Token: 0x0600000B RID: 11 RVA: 0x0000227A File Offset: 0x0000047A | |
public double GetValue(double x, double y) | |
{ | |
return this.noise.GetValue(x, y); | |
} | |
// Token: 0x0600000C RID: 12 RVA: 0x00002289 File Offset: 0x00000489 | |
public double GetValue(double x, double y, double z) | |
{ | |
return this.noise.GetValue(x, y, z); | |
} | |
// Token: 0x04000005 RID: 5 | |
private IMyModule noise; | |
} | |
} | |
// RemovePlanetSizeLimits.cs | |
using System; | |
using Harmony; | |
using Sandbox.Graphics.GUI; | |
namespace RemovePlanetSizeLimits | |
{ | |
// Token: 0x02000003 RID: 3 | |
public static class Patch_MyGuiScreenDebugSpawnMenu | |
{ | |
// Token: 0x06000006 RID: 6 RVA: 0x000020C0 File Offset: 0x000002C0 | |
public static void Postfix(object __instance) | |
{ | |
MyGuiControlSlider myGuiControlSlider = (MyGuiControlSlider)AccessTools.Field(__instance.GetType(), "m_planetSizeSlider").GetValue(__instance); | |
myGuiControlSlider.MaxValue = 1.6E+08f; | |
myGuiControlSlider.MinValue = 1000f; | |
} | |
} | |
} | |
// MyProceduralPlanetCellGenerator.cs | |
using System; | |
using Harmony; | |
using Sandbox.Game.World.Generator; | |
using VRage.Library.Utils; | |
namespace RemovePlanetSizeLimits | |
{ | |
// Token: 0x02000004 RID: 4 | |
[HarmonyPatch(typeof(MyProceduralPlanetCellGenerator), 3, new Type[] | |
{ | |
typeof(int), | |
typeof(double), | |
typeof(float), | |
typeof(float), | |
typeof(float), | |
typeof(float), | |
typeof(MyProceduralWorldModule) | |
})] | |
public static class Patch_MyProceduralPlanetCellGenerator | |
{ | |
// Token: 0x06000007 RID: 7 RVA: 0x000020F4 File Offset: 0x000002F4 | |
public static bool Prefix(object __instance, int seed, double density, float planetSizeMax, float planetSizeMin, float moonSizeMax, float moonSizeMin, MyProceduralWorldModule parent = null) | |
{ | |
RemovePlanetSizeLimits.log.Log("Patching planets prefix"); | |
MyProceduralPlanetCellGenerator obj = (MyProceduralPlanetCellGenerator)__instance; | |
if (planetSizeMax < planetSizeMin) | |
{ | |
float num = planetSizeMax; | |
planetSizeMax = planetSizeMin; | |
planetSizeMin = num; | |
} | |
AccessTools.Field(typeof(MyProceduralPlanetCellGenerator), "PLANET_SIZE_MAX").SetValue(obj, planetSizeMax); | |
AccessTools.Field(typeof(MyProceduralPlanetCellGenerator), "PLANET_SIZE_MIN").SetValue(obj, planetSizeMin); | |
if (moonSizeMax < moonSizeMin) | |
{ | |
float num2 = moonSizeMax; | |
moonSizeMax = moonSizeMin; | |
moonSizeMin = num2; | |
} | |
AccessTools.Field(typeof(MyProceduralPlanetCellGenerator), "MOON_SIZE_MAX").SetValue(obj, moonSizeMax); | |
AccessTools.Field(typeof(MyProceduralPlanetCellGenerator), "MOON_SIZE_MIN").SetValue(obj, moonSizeMin); | |
AccessTools.Field(typeof(MyProceduralPlanetCellGenerator), "OBJECT_SEED_RADIUS").SetValue(obj, (double)planetSizeMax / 2.0 * 1.1 + 2.0 * ((double)moonSizeMax / 2.0 * 1.1 + 64000.0)); | |
AccessTools.Method(typeof(MyProceduralWorldModule), "AddDensityFunctionFilled", null, null).Invoke(obj, new object[] | |
{ | |
new MyInfiniteDensityFunction(MyRandom.Instance, 0.001) | |
}); | |
return false; | |
} | |
} | |
} | |
// RemovePlanetSizeLimits.cs | |
using System; | |
using System.Reflection; | |
using Harmony; | |
using Sandbox.Game.Gui; | |
using SEHarmonyWrapper; | |
using VRage.Plugins; | |
namespace RemovePlanetSizeLimits | |
{ | |
// Token: 0x02000002 RID: 2 | |
public class RemovePlanetSizeLimits : ModBase, IPlugin, IDisposable | |
{ | |
// Token: 0x06000001 RID: 1 RVA: 0x00002048 File Offset: 0x00000248 | |
public void Main(HarmonyInstance harmony, Logger log) | |
{ | |
RemovePlanetSizeLimits.log = log; | |
MethodInfo methodInfo = AccessTools.Method(typeof(MyGuiScreenEditor).Assembly.GetType("Sandbox.Game.Gui.MyGuiScreenDebugSpawnMenu"), "CreatePlanetsSpawnMenu", null, null); | |
harmony.Patch(methodInfo, null, new HarmonyMethod(typeof(Patch_MyGuiScreenDebugSpawnMenu), "Postfix", null), null); | |
log.Log("Patched methods"); | |
} | |
// Token: 0x06000002 RID: 2 RVA: 0x000020AB File Offset: 0x000002AB | |
public void Init(object gameObject) | |
{ | |
this.initialized = true; | |
} | |
// Token: 0x06000003 RID: 3 RVA: 0x000020B4 File Offset: 0x000002B4 | |
public void Update() | |
{ | |
} | |
// Token: 0x06000004 RID: 4 RVA: 0x000020B6 File Offset: 0x000002B6 | |
public void Dispose() | |
{ | |
} | |
// Token: 0x04000001 RID: 1 | |
public bool initialized; | |
// Token: 0x04000002 RID: 2 | |
public bool renameScreenOpen; | |
// Token: 0x04000003 RID: 3 | |
public Type tMyTerminalControlPanel; | |
// Token: 0x04000004 RID: 4 | |
public static Logger log; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment