@Override public boolean canExecute(Unit unit, Action action) { UnitType unitType = unit.getType(); return unitType.isCanMove(); }
/** Loads type data from BWAPI. */ public void loadTypeData() { // race types int[] raceTypeData = getRaceTypes(); for (int index = 0; index < raceTypeData.length; index += RaceType.numAttributes) { RaceType type = new RaceType(raceTypeData, index); type.setName(getRaceTypeName(type.getID())); raceTypes.put(type.getID(), type); } // unit types int[] unitTypeData = getUnitTypes(); for (int index = 0; index < unitTypeData.length; index += UnitType.numAttributes) { UnitType type = new UnitType(unitTypeData, index); type.setName(getUnitTypeName(type.getID())); unitTypes.put(type.getID(), type); } // tech types int[] techTypeData = getTechTypes(); for (int index = 0; index < techTypeData.length; index += TechType.numAttributes) { TechType type = new TechType(techTypeData, index); type.setName(getTechTypeName(type.getID())); techTypes.put(type.getID(), type); } // upgrade types int[] upgradeTypeData = getUpgradeTypes(); for (int index = 0; index < upgradeTypeData.length; index += UpgradeType.numAttributes) { UpgradeType type = new UpgradeType(upgradeTypeData, index); type.setName(getUpgradeTypeName(type.getID())); upgradeTypes.put(type.getID(), type); } // weapon types int[] weaponTypeData = getWeaponTypes(); for (int index = 0; index < weaponTypeData.length; index += WeaponType.numAttributes) { WeaponType type = new WeaponType(weaponTypeData, index); type.setName(getWeaponTypeName(type.getID())); weaponTypes.put(type.getID(), type); } // unit size types int[] unitSizeTypeData = getUnitSizeTypes(); for (int index = 0; index < unitSizeTypeData.length; index += UnitSizeType.numAttributes) { UnitSizeType type = new UnitSizeType(unitSizeTypeData, index); type.setName(getUnitSizeTypeName(type.getID())); unitSizeTypes.put(type.getID(), type); } // bullet types int[] bulletTypeData = getBulletTypes(); for (int index = 0; index < bulletTypeData.length; index += BulletType.numAttributes) { BulletType type = new BulletType(bulletTypeData, index); type.setName(getBulletTypeName(type.getID())); bulletTypes.put(type.getID(), type); } // damage types int[] damageTypeData = getDamageTypes(); for (int index = 0; index < damageTypeData.length; index += DamageType.numAttributes) { DamageType type = new DamageType(damageTypeData, index); type.setName(getDamageTypeName(type.getID())); damageTypes.put(type.getID(), type); } // explosion types int[] explosionTypeData = getExplosionTypes(); for (int index = 0; index < explosionTypeData.length; index += ExplosionType.numAttributes) { ExplosionType type = new ExplosionType(explosionTypeData, index); type.setName(getExplosionTypeName(type.getID())); explosionTypes.put(type.getID(), type); } // unitCommand types int[] unitCommandTypeData = getUnitCommandTypes(); for (int index = 0; index < unitCommandTypeData.length; index += UnitCommandType.numAttributes) { UnitCommandType type = new UnitCommandType(unitCommandTypeData, index); type.setName(getUnitCommandTypeName(type.getID())); unitCommandTypes.put(type.getID(), type); } // order types int[] orderTypeData = getOrderTypes(); for (int index = 0; index < orderTypeData.length; index += OrderType.numAttributes) { OrderType type = new OrderType(orderTypeData, index); type.setName(getOrderTypeName(type.getID())); orderTypes.put(type.getID(), type); } }