1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 00:13:36 +08:00

UXAssist v1.0.14 & bugfix

This commit is contained in:
2024-03-04 03:19:37 +08:00
parent 3ddd20845a
commit 86818197d8
5 changed files with 58 additions and 8 deletions

View File

@@ -547,7 +547,17 @@ public static class FactoryPatch
_patch = null;
}
private static void CalculateGridOffset(PlanetData planet, Vector3 pos, out float x, out float y)
private static bool _initialized;
[HarmonyPostfix, HarmonyPatch(typeof(UIRoot), "_OnOpen")]
public static void UIRoot__OnOpen_Postfix()
{
if (_initialized) return;
UIGeneralTips.instance.buildCursorTextComp.supportRichText = true;
UIGeneralTips.instance.entityBriefInfo.entityNameText.supportRichText = true;
_initialized = true;
}
private static void CalculateGridOffset(PlanetData planet, Vector3 pos, out float x, out float y, out float z)
{
var npos = pos.normalized;
var segment = planet.aux.activeGrid?.segment ?? 200;
@@ -558,8 +568,19 @@ public static class FactoryPatch
var longitudeRad = BlueprintUtils.GetLongitudeRad(npos);
x = longitudeRad / longitudeRadPerGrid;
y = latitudeRad / latitudeRadPerGrid;
z = (pos.magnitude - planet.realRadius - 0.2f) / 1.3333333f;
}
private static string FixedPoint(float f)
{
var s = Mathf.RoundToInt(f * 10000);
return $"{s / 10000}.{Math.Abs(s % 10000)}".TrimEnd('0').TrimEnd('.');
}
private static PlanetData _lastPlanet;
private static Vector3 _lastPos;
private static string _lastOffsetText;
[HarmonyPostfix]
[HarmonyPriority(Priority.Last), HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
private static void BuildTool_Click_CheckBuildConditions_Postfix(BuildTool_Click __instance)
@@ -567,8 +588,15 @@ public static class FactoryPatch
if (__instance.buildPreviews.Count != 1) return;
var preview = __instance.buildPreviews[0];
if (preview.desc.isInserter) return;
CalculateGridOffset(__instance.planet, preview.lpos, out var x, out var y);
__instance.actionBuild.model.cursorText = $"({x},{y})\n" + __instance.actionBuild.model.cursorText;
var planet = __instance.planet;
if (_lastPlanet != planet || _lastPos != preview.lpos)
{
CalculateGridOffset(__instance.planet, preview.lpos, out var x, out var y, out var z);
_lastPlanet = planet;
_lastPos = preview.lpos;
_lastOffsetText = $"<color=#ffbfbfff>{FixedPoint(x)}</color>,<color=#bfffbfff>{FixedPoint(y)}</color>,<color=#bfbfffff>{FixedPoint(z)}</color>";
}
__instance.actionBuild.model.cursorText = $"({_lastOffsetText})\n" + __instance.actionBuild.model.cursorText;
}
[HarmonyTranspiler]
@@ -587,8 +615,15 @@ public static class FactoryPatch
{
var entity = entityBriefInfo.factory.entityPool[entityBriefInfo.entityId];
if (entity.inserterId > 0) return;
CalculateGridOffset(entityBriefInfo.factory.planet, entity.pos, out var x, out var y);
entityBriefInfo.entityNameText.text += $" ({x},{y})";
var planet = entityBriefInfo.factory.planet;
if (_lastPlanet != planet || _lastPos != entity.pos)
{
CalculateGridOffset(planet, entity.pos, out var x, out var y, out var z);
_lastPlanet = planet;
_lastPos = entity.pos;
_lastOffsetText = $"<color=#ffbfbfff>{FixedPoint(x)}</color>,<color=#bfffbfff>{FixedPoint(y)}</color>,<color=#bfbfffff>{FixedPoint(z)}</color>";
}
entityBriefInfo.entityNameText.text += $" ({_lastOffsetText})";
}
)
);

View File

@@ -51,6 +51,13 @@ public static class PlanetFunctions
var planet = GameMain.localPlanet;
var factory = planet?.factory;
if (factory == null) return;
var uiGame = UIRoot.instance.uiGame;
if (uiGame)
{
uiGame.ShutAllFunctionWindow();
uiGame.ShutAllFullScreens();
}
GameMain.data.mainPlayer?.controller.actionBuild.Close();
//planet.data = new PlanetRawData(planet.precision);
//planet.data.CalcVerts();
for (var id = factory.entityCursor - 1; id > 0; id--)
@@ -152,6 +159,8 @@ public static class PlanetFunctions
factory.enemyRecycleCursor = 0;
factory.enemyCapacity = 0;
factory.SetEnemyCapacity(isCombatMode ? 1024 : 32);
factory.hashSystemDynamic = new HashSystem();
factory.hashSystemStatic = new HashSystem();
factory.cargoContainer = new CargoContainer();
factory.cargoTraffic = new CargoTraffic(planet);
factory.blockContainer = new MiniBlockContainer();

View File

@@ -4,8 +4,11 @@
#### 一些提升用户体验的功能和补丁
## Changlog
* 1.0.14
+ Fix crash in `Re-initialize planet` again
+ `Off-grid building and stepped rotation`: Add Z coordinate to display, and adjust the precision to 4 decimal after point
* 1.0.13
+ `Off-grid building and stepped rotation`: show building coorinates(relative to grids) on building preview and building info panel now
+ `Off-grid building and stepped rotation`: show building coordinates(relative to grids) on building preview and building info panel now
+ Increase maximum count of Metadata Instantiations to 20000 (from 2000)
+ Increase capacity of player order queue to 128 (from 16)
+ Fix issue caused by game updates
@@ -101,6 +104,9 @@
* [OffGridConstruction](https://github.com/Velociraptor115-DSPModding/OffGridConstruction): Off-grid building & stepped rotation implementations
## 更新日志
* 1.0.14
+ 再次尝试修复`初始化本行星`导致的崩溃问题
+ `脱离网格建造和小角度旋转`现在显示建筑Z坐标并将精度调整为小数点后4位
* 1.0.13
+ `脱离网格建造和小角度旋转`:现在在建造预览和建筑信息面板上显示建筑坐标(相对于网格)
+ 将元数据提取的最大数量增加到20000(原来为2000)

View File

@@ -4,7 +4,7 @@
<TargetFramework>net472</TargetFramework>
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
<Description>DSP MOD - UXAssist</Description>
<Version>1.0.13</Version>
<Version>1.0.14</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<PackageId>UXAssist</PackageId>

View File

@@ -1,6 +1,6 @@
{
"name": "UXAssist",
"version_number": "1.0.13",
"version_number": "1.0.14",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist",
"description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁",
"dependencies": [