Skip to content

Conversation

gotmachine
Copy link
Contributor

@gotmachine gotmachine commented Oct 23, 2024

This was extracted and refactored from the larger #118 PR.

The purpose of this patch if to allow BaseField and associated features (PAW controls, persistence, etc) to work when a custom BaseField is added to a BaseFieldList (ie, a Part or PartModule) with a host instance other than the BaseFieldList owner. This allow to dynamically add fields defined in another class to a Part or PartModule and to benefit from all the associated KSP sugar :

  • PAW UI controls
  • Value and symmetry events
  • Automatic persistence on the Part or PartModule hosting the BaseFieldList

Potential use cases for this are either :

  • Having a part or module-level PAW item associated to and sharing the state of a common field, for example a field in a KSPAddon.
  • Extending external (typically stock) modules with additional PAW UI controls and/or persisted fields.

Sample code demonstrating those use cases is provided in the source file, after the patch.

@gotmachine gotmachine changed the base branch from master to dev October 23, 2024 17:29
@gotmachine gotmachine added the kspModding Modding fix or API extension label Oct 23, 2024
@gotmachine gotmachine merged commit 15c2c0e into dev Mar 8, 2025
1 check passed
@gotmachine gotmachine deleted the BaseFieldListUseFieldHost branch March 9, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kspModding Modding fix or API extension
Development

Successfully merging this pull request may close these issues.

1 participant