Skip to content

Commit 2f4eaa0

Browse files
authored
Merge pull request #5 from KSP2Community/dev
Hot fix
2 parents 3401923 + 7dfb66a commit 2f4eaa0

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

plugin_template/swinfo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "V-SwiFT",
66
"description": "Variant Switching & Feature Tweaking, a part switch mod for KSP2",
77
"source": "https://github.com/KSP2Community/V-SwiFT",
8-
"version": "0.4.0",
8+
"version": "0.4.1",
99
"version_check": "https://raw.githubusercontent.com/KSP2Community/V-SwiFT/main/plugin_template/swinfo.json",
1010
"ksp2_version": {
1111
"min": "0.2.0",

src/VSwift.Modules/Behaviours/Module_PartSwitch.cs

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using UnityEngine;
1313
using VSwift.Modules.Components;
1414
using VSwift.Modules.Data;
15+
using VSwift.Modules.Extensions;
1516
using VSwift.Modules.Logging;
1617
using VSwift.Modules.Reverters;
1718
using VSwift.Modules.Transformers;
@@ -53,20 +54,27 @@ public override void OnInitialize()
5354
private void HandleInOabInitialization()
5455
{
5556
_dataPartSwitch!.VariantSets.Aggregate(0, HandleVariantSetInOab);
56-
ApplyInOab(true);
5757
foreach (var predefinedNode in _dataPartSwitch.PredefinedDynamicNodes.Where(predefinedNode => OABPart.FindNodeWithTag(predefinedNode.nodeID) == null))
5858
{
59-
OABPart.AddDynamicNode(OABPart, new ObjectAssemblyAvailablePartNode(
60-
predefinedNode.size,
61-
predefinedNode.position,
62-
Quaternion.LookRotation(predefinedNode.orientation,Vector3.up),
63-
predefinedNode.nodeID,
64-
null,
65-
predefinedNode.size,
66-
AttachNodeType.Stack,
67-
true
68-
));
59+
if (OABPart.FindNodeWithTag(predefinedNode.nodeID) is { } node)
60+
{
61+
OABPart.FixedSetNodeLocalPosition(node, predefinedNode.position);
62+
}
63+
else
64+
{
65+
OABPart.AddDynamicNode(OABPart, new ObjectAssemblyAvailablePartNode(
66+
predefinedNode.size,
67+
predefinedNode.position,
68+
Quaternion.LookRotation(predefinedNode.orientation, Vector3.up),
69+
predefinedNode.nodeID,
70+
null,
71+
predefinedNode.size,
72+
AttachNodeType.Stack,
73+
true
74+
));
75+
}
6976
}
77+
ApplyInOab(true);
7078
}
7179

7280
private int HandleVariantSetInOab(int j, VariantSet variantSet)
@@ -240,12 +248,21 @@ public void QueueUpdateColors()
240248

241249
private IEnumerator UpdateColors()
242250
{
243-
yield return new WaitForEndOfFrame();
244-
yield return new WaitForEndOfFrame();
245-
yield return new WaitForEndOfFrame();
246-
if (OABPart.TryGetModule(out Module_Color moduleColor))
251+
yield return new WaitForSeconds(0.5f);
252+
if (PartBackingMode == PartBackingModes.OAB)
247253
{
248-
moduleColor.RefreshColors();
254+
255+
if (OABPart.TryGetModule(out Module_Color moduleColor))
256+
{
257+
moduleColor.RefreshColors();
258+
}
259+
}
260+
else
261+
{
262+
if (part.GetModule<Module_Color>() is { } moduleColor)
263+
{
264+
moduleColor.RefreshColors();
265+
}
249266
}
250267
}
251268

0 commit comments

Comments
 (0)