-
Notifications
You must be signed in to change notification settings - Fork 0
Update ModuleCoPFollowTransform #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Updated ModuleCoPFollowTransform to make better use of part prefabs while still supporting B9PS OnLoad calls.
Hey @JonnyOThan, |
if (followTransform == null || followTransform.name != transformName) | ||
{ | ||
if (transformName != null) followTransform = part.FindModelTransform(transformName); | ||
if (followTransform == null) Debug.LogError($"[{MODULENAME}] transformName was empty or does not exist."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be a good idea to include the transform name that was searched for in the error message.
Oh, right, I can just do that.
if (followTransform == null) | ||
{ | ||
// this may be important if someone is swapping out versions of this module with B9PS | ||
part.CoPOffset = Vector3.zero; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense but I feel like we might not want to set it to zero but to whatever it was in the part config itself, assuming there's a good way to get this at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually isn’t a KSPField so can’t be configured in the cfg. But maybe grabbing the value from the prefab is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh i swear i’ve seen it configured in the partconfig before, but the prefab should be exactly that i guess.
edit: yeah there’s like a bajillion parts on github here that define a CoPOffset in the part cfg. I assume that works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything in Assembly-CSharp that would set it from the cfg. Maybe it's in FirstPass? Maybe it's done by reflection somehow.
Oooh yeah it is reflection. Didn't realize parts did that. Any top-level key in the PART cfg will bind to a public field on the Part class even if it doesn't have [KSPField] or [Persistent]
Given stock code, this should always be 0 for everything except parts with ModuleProceduralFairing. But if some mod poked a different value into the prefab, this should be more correct. And if a mod poked a different module into the part instance, then we're kinda screwed anyway.
Resolves #2