Search Unity

Assignees and unique assignments

Discussion in 'Entity Component System' started by PatrikL, May 20, 2019.

  1. PatrikL

    PatrikL

    Joined:
    May 11, 2014
    Posts:
    6
    I've just started to dabble in ECS, and for the most part it seems pretty straight forward, but I've come across a design issue that I can't seem to wrap my head around.

    Picture the following (very much simplified)
    1. There are several entitites with a component called "Assignment"
    2. There are several entities with a component called "Assignee"
    3. A system will then try to determin what assignment is best suited for what assignee (Think something in the line of Utility AI)
    4. This system will then assign these assignees to their assignments (perhaps using an "Assigned"-tag)
    My question is:
    • How can I make sure that each assignee is assigned to a unique assignment, and that this assignment is not overwritten later on during the same job.
    What I struggle with is looping though this using a job system. I either loop though the assigments or the assignees, and use a EntityBuffer to add this "Assigned"-tag. But when doing so, there is nothing stopping me from assigning the same assignment twice, since the "Assigned"-tag will not be created until the next time the job runs. Meaning I can't check if an assignment is already assigned.

    Sorry in advance for any exploded heads due too the use of the word assigned ;)