Giter Site home page Giter Site logo

Add/Remove system improvement about ashley HOT 2 OPEN

fabiitch avatar fabiitch commented on June 2, 2024
Add/Remove system improvement

from ashley.

Comments (2)

dsaltares avatar dsaltares commented on June 2, 2024

Thanks for opening the issue.
Can you share some more info on your use case and what you're trying to achieve?

from ashley.

fabiitch avatar fabiitch commented on June 2, 2024

Hi !
Its for my Gdx game, it use only ashley in render(dt).

I want sometimes to do some code at specific moment in the engine (but just one time !)

My solution was to create an EngineTaskSystem extends EntitySystem with priority 0 (first in my system list)

EngineTaskSystem contains an Array of EngineTask
Engine Task is like

public interface EngineTask {
    void doTask();
    int priority();
}

So i use EngineTaskSystem to insert new EntitySystem(task.priority()) and override update(dt) to call task.doTask()
and an EngineTaskSystemRemove at last to remove all system created

And when i test i see the problem to modify systems during iteration
Actually my solution was to call my engineTaskSystem.insertTaskInEngine() manually before ashley update for add all my systems in ashley.
and call engineTaskSystem.removeEngineTaskDone() after engine.update().
(EngineTaskSystemRemove is not a system anyway and he is out of ashley)

it work no problem but i like to keep only engine.update in my render()

Anyway i think we need to do a little fix for fix the case of add/remove system during iteration. (why not throw exception)
because actually it do a random behavior because it modified systems array during his iteration.

or this solution :D, perform operation at end of system update loop

Thanks for reading

from ashley.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.