v0.3.0: reworked acting order, now uses a proper priority system with owned properties
This commit is contained in:
@@ -40,6 +40,10 @@ public abstract class Actor implements Bundlable {
|
||||
|
||||
private int id = 0;
|
||||
|
||||
//used to determine what order actors act in.
|
||||
//hero should always act on 0, therefore negative is before hero, positive is after hero
|
||||
protected int actPriority = Integer.MAX_VALUE;
|
||||
|
||||
protected abstract boolean act();
|
||||
|
||||
protected void spend( float time ) {
|
||||
@@ -186,12 +190,10 @@ public abstract class Actor implements Bundlable {
|
||||
Arrays.fill( chars, null );
|
||||
|
||||
for (Actor actor : all) {
|
||||
//Order of actions when time is equal:
|
||||
//1. Hero
|
||||
//2. Other Chars
|
||||
//3. Other Actors (e.g. blobs)
|
||||
if (actor.time < now || (actor instanceof Hero && actor.time == now)
|
||||
|| (actor instanceof Char && actor.time == now && !(current instanceof Hero))) {
|
||||
|
||||
//some actors will always go before others if time is equal.
|
||||
if (actor.time < now ||
|
||||
actor.time == now && actor.actPriority < current.actPriority) {
|
||||
now = actor.time;
|
||||
current = actor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user