junkdog / artemis-odb

A continuation of the popular Artemis ECS framework
BSD 2-Clause "Simplified" License
769 stars 109 forks source link

[FEATURE] Provide annotation-compatible constructors in IntervalSystem #652

Open cpbeto opened 2 years ago

cpbeto commented 2 years ago

I propose both IntervalSystem and IntervalIteratingSystem provide a constructor that takes only the parameter float interval.

For example:

public IntervalSystem(float interval) {
    super(null);
    this.interval = interval;
}

public IntervalIteratingSystem(float interval) {
    super(interval);
}

I think this would make it more idiomatic to write extended systems, which use annotations for entity subscriptions. For example:

@All({Component1.class, Component2.class})
@Exclude(Component3.class)
public class MyIntervalSystem extends IntervalIteratingSystem {

    public MyIntervalSystem(float interval) {
        super(interval);
        // etc.
    }

    @Override
    protected void process(int entityId) {
        // etc.
    }
}

... instead of calling super(null, interval).

Cheers :+1: