Fix hatch attachNodeId auto-detection polluting shared internal prefabs#532
Closed
kilfoil wants to merge 2 commits into
Closed
Fix hatch attachNodeId auto-detection polluting shared internal prefabs#532kilfoil wants to merge 2 commits into
kilfoil wants to merge 2 commits into
Conversation
When multiple parts share the same INTERNAL, OnLoad_Finalize() picked only the first one via GetPartPrefabForInternal() and ran attach-node auto-detection against its nodes, writing the result (e.g. 'airlock') directly onto the shared prop prefab. Every subsequent part that cloned that prefab inherited the wrong attachNodeId. Symptoms: parts that reuse a stock internal as a placeholder (e.g. USILS.Greenhouse.Inline using crewCabinInternals) log an ERR on every flight load because their attach nodes don't include the one that was auto-detected for the canonical part. Fix: remove the prefab-time auto-detection from OnLoad_Finalize() and move it into FreeIvaHatch.OnAwake(), which runs per flight instance against the actual part. Each part now detects its own nearest attach node independently, so shared internals work correctly for all parts that use them.
OnLoad_Finalize() called GetPartPrefabForInternal() to auto-detect which airlock transform to associate with each EVA hatch. That returns only the FIRST part registered for a given internal, so its airlockName was written into the shared prefab and inherited by every other part sharing the same internal (e.g. USILS.Greenhouse.Inline, sspx-observation-25-1, and Kosntruction.Workshop.250 all inherit crewCabinInternals' "Airlock" name even though those parts have no such transform). Move airlock auto-detection to Hatch.OnAwake(), where this.part is the actual flight instance, applying the same spatial matching logic as before but only for that specific hatch instance. Also remove explicit airlockName = Airlock from docking port HatchConfigs: those ports add FreeIva/Parts/Airlock to their model to provide an EVA exit, but FindAirlock can't locate the transform by name (likely because the instantiated model root gets "(Clone)" appended by Unity). The fallback to part.airlock correctly finds the tagged transform already, so the named lookup was just generating noise. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3943b22 to
ec2076b
Compare
Collaborator
|
Doing it at load time is far more efficient. This isn’t the right fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When multiple parts share the same
INTERNAL,OnLoad_Finalize()callsGetPartPrefabForInternal()which returns only the first part registered for that internal. Attach-node auto-detection runs against that part's nodes and writes the result directly onto the shared prop prefab (e.g.hatch.attachNodeId = "airlock").Every subsequent part that clones the same prefab inherits that
attachNodeId— even if the part has completely different (or no) attach nodes. This produces a logged error for every affected part on every flight load:GetPartPrefabForInternal()already logs a warning when multiple parts share an internal, but the auto-detection still proceeds with the wrong part and corrupts the prefab for all others.Root cause
The detection runs at prefab-load time in
InternalModuleFreeIva.OnLoad_Finalize(), where only one representative part is available. The result is written to a shared prop component, so all instances of that prop — regardless of which part they belong to — see the sameattachNodeId.Fix
Remove the attach-node auto-detection from
OnLoad_Finalize()and move it intoFreeIvaHatch.OnAwake(), which runs per flight instance withthis.partbeing the actual instantiated part. Each part now detects its own nearest attach node independently against its own nodes.InternalModuleFreeIva.x_partToInternalSpaceis madeinternalsoHatch.cscan access the shared coordinate-space constant without duplication.Test case
Place a vessel containing both a stock Mk1 Crew Cabin and a USI-LS Greenhouse Inline (both use
crewCabinInternals). The ERR log entry for the greenhouse should no longer appear, and the crew cabin's airlock hatch should continue to function normally.