Created constants for invalid component and mode

These values will never be set internally and are used as return checks
This commit is contained in:
Collin Smith 2020-08-22 16:55:01 -07:00
parent 6a904f7131
commit f93b44fb9c
3 changed files with 9 additions and 3 deletions

View File

@ -51,6 +51,9 @@ public class Engine {
return KEYFRAME_NAME[keyframe];
}
public static final int INVALID_COMPONENT = -1;
public static final int INVALID_MODE = -1;
public static final class Object {
public static final int SUBCLASS_SHRINE = 1 << 0; // displays "<shrine_type> Shrine"
public static final int SUBCLASS_OBELISH = 1 << 1; // does nothing

View File

@ -37,7 +37,7 @@ public class Actioneer extends PassiveSystem {
final Class.Type type = mClass.get(entityId).type;
byte mode = (byte) type.getMode(skill.anim);
log.trace("mode: {}", mode);
if (mode == -1) { // TODO: replace -1 with some const INVALID_SKILL
if (mode == Engine.INVALID_MODE) {
mode = (byte) type.getMode("SC");
log.trace("mode changed to {} because it was invalid", mode);
}

View File

@ -2,9 +2,12 @@ package com.riiablo.engine.server.component;
import com.artemis.Component;
import com.artemis.annotations.PooledWeaver;
import com.badlogic.gdx.utils.ObjectIntMap;
import com.riiablo.Riiablo;
import com.riiablo.codec.COFD2;
import com.riiablo.engine.Engine;
@PooledWeaver
public class Class extends Component {
@ -86,7 +89,7 @@ public class Class extends Component {
}
public int getMode(String mode) {
return MODES.get(mode.toLowerCase(), -1);
return MODES.get(mode.toLowerCase(), Engine.INVALID_MODE);
}
public String getMode(byte mode) {
@ -94,7 +97,7 @@ public class Class extends Component {
}
public int getComponent(String comp) {
return COMPS.get(comp.toLowerCase(), -1);
return COMPS.get(comp.toLowerCase(), Engine.INVALID_COMPONENT);
}
public static Type valueOf(int i) {