Skip to content

Chatlog Re: Components Affecting Each Other

Matt O'Tousa edited this page Jul 13, 2019 · 3 revisions

[ 4:55 PM ] Tattomoosa : what's the best way to go about making a component that can affect another component of the same type? this isn't even in amethyst yet, just in specs. i figured out how to grab components off entities and store entities in components, but the borrow checker gets mad if i try and grab another component of the same kind while i'm iterating in a system. [ 4:55 PM ] Dispersia : you shouldn't be storing entities in components [ 4:55 PM ] Dispersia : to take a step back, what are you trying to do exactly? [ 4:56 PM ] Tattomoosa : so i'm just doing some example stuff - i'm trying to make it so one entity can track another entity and affect it on a simulation step [ 4:57 PM ] Tattomoosa : just trying to get a feel for how to accomplish things in specs [ 4:59 PM ] Tattomoosa : so i guess maybe "what is the correct way to relate an entity to another so that they can affect each other?" is my question? [ 5:00 PM ] Dispersia : it's hard to tell without a specific scenario. Say for instance you want to track who dealt damage to who, your player component could have an id, when the interaction occurs that would "deal damage" that leaves a burn or something, you could then apply a component to the opponent with the player id that dealt it. [ 5:01 PM ] Dispersia : if you're talking about something like collision or particles however, in general they would have their own components that define their specific properties, and they could (normally) care less who is touching who, just that they are and the system would act accordingly [ 5:03 PM ] Dispersia : but an entity is just an id for a group of components, it has no logic, no properties, no components, etc. They are owned by the world for the sole purpose of grouping components and having them have a unique id [ 5:08 PM ] Tattomoosa : Ok Yeah, so I am currently trying to make an “Actor” have a “actor.rival” that it damages every turn. But it’s kind of a stand-in for now, just trying to wrap my head around specs [ 5:09 PM ] kel (they/them pronouns) : you can target an entity with a component or resource [ 5:09 PM ] Dispersia : if you're having a damage over time system, i would have a component that just contains an array of all the current affects on the player, and who dealt them [ 5:09 PM ] kel (they/them pronouns) : https://slide-rs.github.io/specs/11_advanced_component.html#entity-targeting Advanced component strategies - The Specs Book Introduction to ECS and the Specs API. [ 5:10 PM ] Dispersia : that would make it really easy to iterate on each turn, and you would be able to do specific things (maybe one spell needs to hit before the other, etc) [ 5:14 PM ] Tattomoosa : Hmm so I’ve seen that page but maybe am missing something? @Dispersia ok so I am not doing damage over time, just “one actor takes damage from another” and I have the first actor being able to track the entity of the second, and I can grab components from that entity, but not the same component my system is currently iterating through [ 5:15 PM ] Tattomoosa : So are you saying my mistake is not making health a separate component? Because then I think I could target it [ 5:16 PM ] Dispersia : i usually have health as its own component, yes [ 5:16 PM ] Dispersia : containing both the current and max health

Clone this wiki locally