#Removing components

1 messages · Page 1 of 1 (latest)

rose swallow
#

Is there a way to specify which component to remove without applying custom components like TextA TextB to them? this is a big deal when I'd have to make more than a hundred of these custom components because I want only the specific one to be removed

timid jackal
#

What do you want to be the condition for removing the component?

rose swallow
#

event like keypress or mousepress or message from server or just certain amount of passed time

timid jackal
#

I was more interested in what the condition would be for a specific Text Component, How to differentiate the "hundreds of custom components"

Is it if text is "mytext" then Remove?

rose swallow
#

for example game item stats where each stat is different text component and i want them to appear/disappear in quick succession (like an animation)

timid jackal
#

Ah, do you want to spawn/despawn children of an entity?
is it structured something like this?

game_item_stats_card
-- title
-- stats_list
  - stat1 (has a TextComponent)
  - stat2 (has a TextComponent)
  - stat3 (has a TextComponent)
#

If that is the case I would have a

#[derive(Component)]
struct StatsList(Vec<Entity>);

on the game_item_stats_card entity

then you can have a system that takes an event or something and a reference to the stats_list and then despawn them in the way that you want to.

But I'm sure that there are many ways to achieve this.