#Help with some ECS problem solving.

1 messages · Page 1 of 1 (latest)

idle wing
#

One thing I'm having a bit of a hard time grasping is say I'm making a card game with lots of unique logic for different cards. How would I implement this? Say I have a card that does x when it enters the battlefield (etb). What I have rn is I have a component called HasETBTrigger. And then when the card is played, I can have a system that checks for HasETBTriggers and add a tag ETBTrigger, that system can then also remove that trigger the next frame. Or for example a component called HasStartTurnTrigger, which a system can iterate over and add a StartTurnTrigger when a turn changes. What I'm not understanding is how to then link these triggers to different effects or chains of effects, etc. Basically how do you tackle a situation like this in an DOTS non OOP way of thinking?

rotund saddle
#

You would need to tell a bit more how the game is supposed to work. Is it a deterministic stack based game?

undone pasture
#

you can implement generic logic of passing some component enabled state like IsActive, which relies on IsDone to get disabled and to trigger next entity's IsActive in chain

#

and then have as many entities in chain as you want

#

and then you just compose logic

#

while all logic needs is to rely on IsActive enabled state

idle wing
#

hmm that makes a lot of sense... I never really thought of using entities to model effects

undone pasture
#

I had very great results using this pattern, which reuses tons of logic

#

so codebase turned out very little

idle wing
#

I was stuck in thinking of ways to do this just using components and tags because of OOP brain

#

but it would be much easier with entities representing effects in stack

#

it seems so obvious now that u point it out haha

#

thanks so much yall really helped

#

one last question is how would I compose these behaviours with the authoring workflow, normally I would just write a script in lua or otherwise use some oop concept like inheritance and a class with a bunch of triggers to be called by a scripting engine but without that. What do I do? The linking part still eludes me. IDK how I would compose such behaviours using the authoring workflow

undone pasture
#

if chains are meant to be more complicated than just one by one

#

then you can maybe make a graph tool

#

essentially it is just graph out of entities

idle wing
#

hmm okay lemme play around with an idea

#

this is my first data orientated project and I have to say I love this way more than OOP even though I'm still in the process of relearning a lot of skills

bronze glen
#

I'm not entirely sure ECS is the best way to do a card game? You could also consider looking into data oriented ways of using burst that doesn't use ECS

undone pasture
bronze glen
# undone pasture I wouldn't say card games need burst at all

it can be useful if you want to do some brute forcing in an AI, but other than that not really useful yeah. Though burst can be a nice way to constrain your programming in a way that can lead to better code style, but might not be worth it just for that

undone pasture
idle wing
#

I assumed an rts is the perfect use case for ecs

bronze glen
idle wing
#

as well as all the rts stuff

bronze glen
#

So all the effects of cards happen in realtime?

bronze glen
# idle wing as well as all the rts stuff

You could create a system group for all the different triggers, and only run them when the "trigger" happens. If there's effects that are shared across different triggers you could create structs for the data they use and share the methods that work on those structs.
Kind of depends on what kind of effects and stuff you plan on having