refactor(CheatEnabler): split DysonSphereFunctions into focused helpers

This commit is contained in:
2026-06-23 04:10:09 +08:00
parent eae4ba0376
commit 2dce3a7b93
6 changed files with 1664 additions and 1680 deletions
@@ -0,0 +1,52 @@
using System;
using UnityEngine;
using UXAssist.Common;
using UXAssist.Common.ModFeatures;
namespace CheatEnabler.Functions.DysonSphere;
[ModFeature("DysonSphereResolver")]
public static class DysonSphereResolver
{
public static (global::DysonSphere sphere, StarData star)? ResolveCurrent()
{
var star = GameMain.localStar;
if (star == null) return null;
var sphere = GameMain.data.dysonSpheres[star.index];
if (sphere == null) return null;
return (sphere, star);
}
public static StarData ResolveEditorOrLocalStar()
{
var dysonEditor = UIRoot.instance?.uiGame?.dysonEditor;
if (dysonEditor != null && dysonEditor.gameObject.activeSelf)
{
return dysonEditor.selection.viewStar;
}
var star = GameMain.localStar;
if (star == null)
{
UIMessageBox.Show("CheatEnabler".Translate(), "You are not in any system.".Translate(), "确定".Translate(), UIMessageBox.ERROR, null);
}
return star;
}
public static (global::DysonSphere sphere, StarData star)? ResolveEditorOrLocalSphere(bool requireLayer = true)
{
var star = ResolveEditorOrLocalStar();
if (star == null) return null;
var sphere = GameMain.data?.dysonSpheres[star.index];
if (sphere == null)
{
UIMessageBox.Show("CheatEnabler".Translate(), string.Format("There is no Dyson Sphere data on \"{0}\".".Translate(), star.displayName), "确定".Translate(), UIMessageBox.ERROR, null);
return null;
}
if (requireLayer && sphere.layerCount == 0)
{
UIMessageBox.Show("CheatEnabler".Translate(), string.Format("There is no Dyson Sphere shell on \"{0}\".".Translate(), star.displayName), "确定".Translate(), UIMessageBox.ERROR, null);
return null;
}
return (sphere, star);
}
}