mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-08 20:13:29 +08:00
UXAssist: Drag build Power Towers fix
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
|
||||
## Changlog
|
||||
|
||||
* 1.4.3
|
||||
* `Build Tesla Tower and Wireless Power Tower alternately`:
|
||||
* Fix wrong implementation for latest game patch.
|
||||
* Cannot use Tesla Tower as start Power Tower now, due to new matrix build mechanism.
|
||||
* 1.4.2
|
||||
* Fixed a crash issue.
|
||||
* 1.4.1
|
||||
@@ -340,6 +344,10 @@
|
||||
|
||||
## 更新日志
|
||||
|
||||
* 1.4.3
|
||||
* `交替建造电力感应塔和无线输电塔`:
|
||||
* 修复了在最新游戏补丁中的错误实现
|
||||
* 由于新的矩阵建造机制,现在无法使用电力感应塔作为起始电塔
|
||||
* 1.4.2
|
||||
* 修复了一个崩溃问题
|
||||
* 1.4.1
|
||||
|
||||
@@ -1401,7 +1401,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
{
|
||||
private static readonly List<bool> OldDragBuild = [];
|
||||
private static readonly List<Vector2> OldDragBuildDist = [];
|
||||
private static readonly int[] PowerPoleIds = [2201, 2202, 2212];
|
||||
private static readonly int[] PowerPoleIds = [2202, 2212];
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
@@ -1435,13 +1435,13 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
OldDragBuildDist.Clear();
|
||||
foreach (var id in PowerPoleIds)
|
||||
{
|
||||
var powerPole = LDB.items.Select(id);
|
||||
if (powerPole?.prefabDesc == null) return;
|
||||
OldDragBuild.Add(powerPole.prefabDesc.dragBuild);
|
||||
OldDragBuildDist.Add(powerPole.prefabDesc.dragBuildDist);
|
||||
powerPole.prefabDesc.dragBuild = true;
|
||||
var distance = (id == 2201 && DragBuildPowerPolesAlternatelyEnabled.Value ? LDB.items.Select(2202) : powerPole).prefabDesc.powerConnectDistance - 0.72f;
|
||||
powerPole.prefabDesc.dragBuildDist = new Vector2(distance, distance);
|
||||
var prefabDesc = LDB.items.Select(id)?.prefabDesc;
|
||||
if (prefabDesc == null) return;
|
||||
OldDragBuild.Add(prefabDesc.dragBuild);
|
||||
OldDragBuildDist.Add(prefabDesc.dragBuildDist);
|
||||
prefabDesc.dragBuild = true;
|
||||
var distance = prefabDesc.powerConnectDistance - 0.72f;
|
||||
prefabDesc.dragBuildDist = new Vector2(distance, distance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1560,17 +1560,28 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(BuildTool_Click), nameof(BuildTool_Click.handPrefabDesc))),
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(BuildPreview), nameof(BuildPreview.desc)))
|
||||
).Advance(2).InsertAndAdvance(new CodeInstruction(OpCodes.Ldloc_S, 6)).SetInstructionAndAdvance(Transpilers.EmitDelegate((BuildTool_Click click, int i) =>
|
||||
);
|
||||
var pos = matcher.Pos;
|
||||
matcher.MatchBack(false,
|
||||
new CodeMatch(ci => ci.IsLdloc()),
|
||||
new CodeMatch(ci => ci.IsLdloc()),
|
||||
new CodeMatch(OpCodes.Mul),
|
||||
new CodeMatch(ci => ci.IsLdloc()),
|
||||
new CodeMatch(OpCodes.Add)
|
||||
);
|
||||
var operand = matcher.Operand;
|
||||
matcher.Start().Advance(pos);
|
||||
matcher.Advance(2).InsertAndAdvance(new CodeInstruction(OpCodes.Ldloc_S, operand)).SetInstructionAndAdvance(Transpilers.EmitDelegate((BuildTool_Click click, int i) =>
|
||||
{
|
||||
if (!DragBuildPowerPolesAlternatelyEnabled.Value || (i & 1) == 0) return click.handItem;
|
||||
var id = click.handItem.ID;
|
||||
if (id != 2201 && id != 2202) return click.handItem;
|
||||
if (id != 2202) return click.handItem;
|
||||
return LDB.items.Select(id ^ 3);
|
||||
})).Advance(3).InsertAndAdvance(new CodeInstruction(OpCodes.Ldloc_S, 6)).SetInstructionAndAdvance(Transpilers.EmitDelegate((BuildTool_Click click, int i) =>
|
||||
})).Advance(3).InsertAndAdvance(new CodeInstruction(OpCodes.Ldloc_S, operand)).SetInstructionAndAdvance(Transpilers.EmitDelegate((BuildTool_Click click, int i) =>
|
||||
{
|
||||
if (!DragBuildPowerPolesAlternatelyEnabled.Value || (i & 1) == 0) return click.handPrefabDesc;
|
||||
var id = click.handItem.ID;
|
||||
if (id != 2201 && id != 2202) return click.handPrefabDesc;
|
||||
if (id != 2202) return click.handPrefabDesc;
|
||||
return LDB.items.Select(id ^ 3).prefabDesc;
|
||||
}));
|
||||
return matcher.InstructionEnumeration();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
|
||||
<Description>DSP MOD - UXAssist</Description>
|
||||
<Version>1.4.2</Version>
|
||||
<Version>1.4.3</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageId>UXAssist</PackageId>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "UXAssist",
|
||||
"version_number": "1.4.2",
|
||||
"version_number": "1.4.3",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist",
|
||||
"description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁",
|
||||
"dependencies": [
|
||||
|
||||
Reference in New Issue
Block a user