space-wizards / RobustToolbox

Robust multiplayer game engine, used by Space Station 14
https://spacestation14.io
Other
542 stars 399 forks source link

need way to copy and remove components from source to target #4484

Open deltanedas opened 1 year ago

deltanedas commented 1 year ago

Description

some api to add all of a component registry's components

would be useful for ninja and blob chemicals

add a component registry abilities to ninja gloves component:

- type: entity
  id: NinjaGloves
  components:
  ...
  - type: NinjaGloves
    abilities:
    - type: StunProvider
    - type: EmagProvider
    - type: BatteryDrainer
    ...
// in enable gloves
comp.Abilities.CopyComponents(ninja);

// in disable gloves
comp.Abilities.RemoveComponents(ninja);

cool api would EnsureComp each component then copy data to it using serializationmanager removing just remcomp

bonus points if its able to track if the target already had some of the components and to leave them alone, say if wearing emag socks as a ninja then turning gloves off it wouldnt remove emagprovider

EmoGarbage404 commented 1 year ago

Artifacts already do this with compregistry.

Nonetheless, i feel like in 99% of cases, it's more logical to just use events or a custom boolean to enable/disable the logic of a component.

With archetypes being added soon, it would be a good performance thing. Furthermore, it prevents values from being obscured in yaml and allows more control when adjusting datafields.

deltanedas commented 1 year ago

with blob chemicals it would be adding and removing something that handles e.g. doing burn damage when emp'd so having 50 components with a few of them enabled would be bad

Furthermore, it prevents values from being obscured in yaml and allows more control when adjusting datafields.

how is this the case? for ninja the components arent even specified in yaml so the fields cant even be adjusted outside of VV