Skip to content

Commit

Permalink
Fix #439: make mk2expansion patches resilient against mk2rebalance mod
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyOThan committed Sep 13, 2024
1 parent c747342 commit 36caeff
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 34 deletions.
6 changes: 6 additions & 0 deletions GameData/FreeIva/Mk2Expansion/M2X_Passthrough.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
FreeIva_AutoPassThrough_VolumeScalar = -0.25
}

// Mk2Rebalance changes the names of the bottom nodes on this part
@PART[M2X_625tricoupler]:HAS[~FreeIva_AutoPassThrough&#node_stack_bottom03]:FOR[FreeIva]
{
FreeIva_AutoPassThrough_NodeB = bottom03
}

@PART[M2X_625tricoupler|M2X_UST|M2X_InverterFuselage|M2X_SlantAdapterS]:HAS[~FreeIva_AutoPassThrough]:FOR[FreeIva]
{
FreeIva_AutoPassThrough = true
Expand Down
33 changes: 7 additions & 26 deletions GameData/FreeIva/Mk2Expansion/M2X_linearTricoupler.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
@PART[M2X_linearTricoupler]:HAS[!MODULE[ModuleFreeIva]]:FOR[FreeIva]
// NOTE: Mk2Rebalance also changes the names of these nodes, but to something different. So only change them if they haven't already been changed
// Even with auto-detection we still need to rename these because otherwise the lookup by name fails when there are multiple "bottom" nodes
@PART[M2X_linearTricoupler]:HAS[!MODULE[ModuleFreeIva]&#node_stack_bottom_01]:FOR[FreeIva]
{
// when KSP loads the part, it splits these keys by underscore and only takes the 3rd token.
// So, the part ends up with 3 attachnodes named "bottom" and we can't tell hatches which one they belong to
node_stack_bottom01 = #$node_stack_bottom_01$
node_stack_bottom02 = #$node_stack_bottom_02$
-node_stack_bottom_01 = delete
-node_stack_bottom_02 = delete
}

@PART[M2X_linearTricoupler]:HAS[!MODULE[ModuleFreeIva]]:FOR[FreeIva]
{
FreeIva_AutoPassThrough_InternalName = FreeIva_M2X_linearTricoupler_IVA
}

Expand All @@ -30,51 +35,27 @@ INTERNAL
name = Hatch_Plane
position = 0, 0, -0.76
rotation = -3.09086197e-08, -0.707106709, -0.707106829, -3.09086197e-08
MODULE
{
name = HatchConfig
attachNodeId = top
}
}

PROP
{
name = Hatch_Plane
position = 0, 0, 0.875
rotation = 0.707106888, 6.18172535e-08, 0, -0.70710665
MODULE
{
name = HatchConfig
attachNodeId = bottom
}
}

PROP
{
name = FreeIva_Hatch_Round_Size0
position = -1.223489, 0, 0.876697361
rotation = 0.707106829, 0, 0, -0.707106709
MODULE
{
name = HatchConfig
attachNodeId = bottom01
}
}

PROP
{
name = FreeIva_Hatch_Round_Size0
position = 1.223489, 0, 0.876697361
rotation = 0.707106829, 0, 0, -0.707106709
MODULE
{
name = HatchConfig
attachNodeId = bottom02
}
}

}
Expand Down
21 changes: 14 additions & 7 deletions GameData/FreeIva/Patches/AutoPassThrough.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,22 @@ B9_TANK_TYPE
}
}
// step 3.1: if the part doesn't have resources, just set it up directly for passthrough
// step 3.1: determine the node names to use when applying passthrough
@PART:HAS[#FreeIva_AutoPassThrough[true]&~FreeIva_AutoPassThrough_InternalName]:FOR[zzz_FreeIva]
{
&FreeIva_AutoPassThrough_NodeA = top
&FreeIva_AutoPassThrough_NodeB = bottom
}
// step 3.2: if the part doesn't have resources, just set it up directly to be traversible
// with passthrough...
@PART:HAS[#FreeIva_AutoPassThrough[true]&~FreeIva_AutoPassThrough_FuelSwitchID&!RESOURCE&~FreeIva_AutoPassThrough_InternalName]:FOR[zzz_FreeIva]
{
MODULE
{
name = ModuleFreeIva
passThroughNodeA = top
passThroughNodeB = bottom
passThroughNodeA = #$/FreeIva_AutoPassThrough_NodeA$
passThroughNodeB = #$/FreeIva_AutoPassThrough_NodeB$
}
}
// ...or with a named internal
Expand Down Expand Up @@ -356,8 +363,8 @@ B9_TANK_TYPE
}
DATA
{
passThroughNodeA = top
passThroughNodeB = bottom
passThroughNodeA = #$/FreeIva_AutoPassThrough_NodeA$
passThroughNodeB = #$/FreeIva_AutoPassThrough_NodeB$
}
}
}
Expand Down Expand Up @@ -412,8 +419,8 @@ B9_TANK_TYPE
}
DATA
{
passThroughNodeA = top
passThroughNodeB = bottom
passThroughNodeA = #$/FreeIva_AutoPassThrough_NodeA$
passThroughNodeB = #$/FreeIva_AutoPassThrough_NodeB$
}
}
}
Expand Down

0 comments on commit 36caeff

Please sign in to comment.