Skip to content
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

New modding patch : BaseFieldListUseFieldHost #278

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

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
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