/// <summary> /// If I could I would paste the corresponding IL code here, but that would be illegal. /// Look it up @ UIGalaxySelect -> OnStarCountSliderValueChange /// IL0013 to IL002D is the if/else block. /// /// According to the HarmonyLib Documentation it should be generally fine to nuke the if/else block /// but since this crashes DSP I just replace the whole block with NOP which ain't pretty but it works /// </summary> public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { Harmony.DEBUG = true; var beginningFound = false; var endingFound = false; var beginning = -1; var ending = -1; var codes = new List <CodeInstruction>(instructions); for (var i = 0; i < codes.Count; i++) { DysonsGalaxy.Log($"{codes[i]}"); if (codes[i].opcode.Equals(OpCodes.Stloc_0) && codes[i + 1].opcode.Equals(OpCodes.Ldloc_0) && !beginningFound) { beginning = i + 1; beginningFound = true; DysonsGalaxy.Log($"BEGINNING AT => {i}"); } else if ( (codes[i].opcode.Equals(OpCodes.Ldc_I4_S) && codes[i].operand.Equals((sbyte)80)) && codes[i + 1].opcode.Equals(OpCodes.Stloc_0) && beginningFound) { ending = i + 1; endingFound = true; DysonsGalaxy.Log($"ENDING AT => {i}"); } if (beginningFound && endingFound) { break; } } if (beginning > -1 && ending > -1) { DysonsGalaxy.Log($"NOPed: {beginning} to {ending} from {codes.Count}"); for (var i = beginning; i <= ending; i++) { codes[i] = new CodeInstruction(OpCodes.Nop); DysonsGalaxy.Log($"{codes[i]}"); } DysonsGalaxy.Log($"NOPed!"); } else { DysonsGalaxy.Log($"Beginning => {beginning}"); DysonsGalaxy.Log($"Ending => {ending}"); } Harmony.DEBUG = false; return(codes.AsEnumerable()); }
/// <summary> /// Here I just attach the Postfix to the _OnOpen method in UIGalaxySelect to overwrite the limits on the star count slider. /// Sadly the sliders are not named so we have to select the correct slider based on the maximum value it can hold. /// </summary> /// <param name="instance"></param> public static void Postfix(ref UIGalaxySelect __instance) { foreach (var child in __instance.transform.GetComponentsInChildren <Slider>()) { DysonsGalaxy.Log($"Setting min star count to {DysonsGalaxyConfig.MinStarCount}"); DysonsGalaxy.Log($"Setting max star count to {DysonsGalaxyConfig.MaxStarCount}"); if (Math.Abs(child.maxValue - 64f) < 1f) { child.minValue = DysonsGalaxyConfig.MinStarCount; child.maxValue = DysonsGalaxyConfig.MaxStarCount; } else if (Math.Abs(child.maxValue - DysonsGalaxyConfig.MaxStarCount) < 1f) { child.minValue = DysonsGalaxyConfig.MinStarCount; child.maxValue = DysonsGalaxyConfig.MaxStarCount; } } }
/// <summary> /// This interestingly was the easiest part. /// I grab the minDist value before the GenerateTempPoses method can access it and overwrite it /// with the desired value. /// </summary> public static void Prefix(ref double minDist) { DysonsGalaxy.Log($"Setting the minimum distance between stars to {DysonsGalaxyConfig.MinStarDistance}"); minDist = DysonsGalaxyConfig.MinStarDistance; }