v0.3.0: reworked acting order, now uses a proper priority system with owned properties

This commit is contained in:
Evan Debenham
2015-05-14 19:47:25 -04:00
parent e60424bf15
commit e8a2004345
8 changed files with 38 additions and 7 deletions
@@ -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;
}