Skip to content

Commit

Permalink
Increase the max number of stars -- Experimental past 64 !
Browse files Browse the repository at this point in the history
  • Loading branch information
Touhma committed Feb 2, 2021
1 parent 2e17232 commit 30a4f25
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions DSP_Plugin/MoreStars.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Reflection;
using BepInEx;
using HarmonyLib;
using UnityEngine.UI;
Expand All @@ -11,29 +11,52 @@ namespace DSP_Plugin {
public class DSP_MoreStars : BaseUnityPlugin {
internal void Awake() {
var harmony = new Harmony("org.bepinex.plugins.moreStars");
Harmony.CreateAndPatchAll(typeof(Patch));
Harmony.CreateAndPatchAll(typeof(Patch));
Harmony.CreateAndPatchAll(typeof(PatchOnUniverseGen));
Harmony.CreateAndPatchAll(typeof(PatchOnStarGen));
}

[HarmonyPatch(typeof(UIGalaxySelect))]
private class Patch {
[HarmonyPostfix]
[HarmonyPatch("_OnInit")]
public static void Postfix(UIGalaxySelect __instance, ref Slider ___starCountSlider) {
___starCountSlider.maxValue = 255;
___starCountSlider.maxValue = 1024;
}

[HarmonyPrefix]
[HarmonyPatch("OnStarCountSliderValueChange")]
public static bool OnStarCountSliderValueChange(UIGalaxySelect __instance, ref Slider ___starCountSlider , ref GameDesc ___gameDesc, float val)
{
public static bool OnStarCountSliderValueChange(UIGalaxySelect __instance, ref Slider ___starCountSlider,
ref GameDesc ___gameDesc, float val) {
int num = (int) (___starCountSlider.value + 0.100000001490116);
if (num == ___gameDesc.starCount) {
return false;
}

___gameDesc.starCount = num;
__instance.SetStarmapGalaxy();
return false;
}
}

[HarmonyPatch(typeof(UniverseGen))]
private class PatchOnUniverseGen {
[HarmonyPrefix]
[HarmonyPatch("CreateGalaxy")]
public static bool CreateGalaxy(GalaxyData __instance, GameDesc gameDesc) {
return true;
}
}

[HarmonyPatch(typeof(StarGen))]
private class PatchOnStarGen {
[HarmonyPrefix]
[HarmonyPatch("CreateBirthStar")]
public static bool CreateBirthStar(GalaxyData galaxy, int seed) {
int gSize = galaxy.starCount > 64 ? galaxy.starCount * 4 * 100 : 25600;
galaxy.astroPoses = new AstroPose[gSize];
return true;
}
}
}
}

0 comments on commit 30a4f25

Please sign in to comment.