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

really need a way to add/remove items from component fields #5141

Open
deltanedas opened this issue May 15, 2024 · 2 comments
Open

really need a way to add/remove items from component fields #5141

deltanedas opened this issue May 15, 2024 · 2 comments
Labels

Comments

@deltanedas
Copy link
Contributor

something like

- type: entity
  id: Base
  components:
  - type: Tag
    tags:
    - A
    - B

- type: Entity
  parent: Base
  id: Extended
  components:
  - type: Tag
    tags: !Add
    - C # A B C

- type: entity
  parent: Base
  id: Removed
  components:
  - type: Tag
    tags: !Remove
    - A # just B

then "just" handle the Add Remove markers by looking up the parent prototype and adding or removing

presumably this would only be possible on fields of the component, and not fields of those fields

  1. this would make maintaining tags specifically a hell of a lot easier, no random thing overwriting it which has happened countless times
  2. this would make a lot of fork work easier since you can shrimply add a tag and done dont have to copy paste it into every single descendant
@K-Dynamic
Copy link

Was literally just thinking about this

@PJB3005 PJB3005 added Issue: Feature This issue is a feature request Area: Serialization Area: ECS labels May 16, 2024
@deltanedas
Copy link
Contributor Author

deltanedas commented Jun 14, 2024

another example usecase

# pai that can play music
- type: entity
  id: PAIMusic
  - type: UserInterface
    interfaces:
      enum.MusicUiKey.Key:
        type: MusicBoundUserInterface

# pai that has map AND music
- type: entity
  parent: PAIMusic
  id: PAIMap
  components:
  - type: UserInterface
    interfaces: !Add
      enum.MapUiKey.Key:
        type: MapBoundUserInterface

# an expansion card that adds a userinterface regardless of what the pai already had
# so ComponentRegistry has to support this syntax too
# right now this has a shitty boilerplate AddUserInterface component that does this by hand
- type: entity
  id: CoolCard
  components:
  - type: PAIExpansionCard
    components:
    - type: UserInterface
      interfaces: !Add
        enum.CoolUiKey.Key:
          type: CoolUserInterface

# combining add and remove in the entity prototype and a registry
# a card that removes midi player if you are a bad person, and also has the cool ui
- type: entity
  parent: CoolCard
  id: EvilCard
  components:
  - type: PAIExpansionCard
    components: !Add # keep the CoolUi with this module
    - type: UserInterface
      interfaces: !Remove # uses just key instead of key: value
      - enum.MusicUiKey.Key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants