use of eidolons.game.battlecraft.logic.dungeon.universal.Spawner.SPAWN_MODE in project Eidolons by IDemiurge.
the class CombatScriptExecutor method doSpawn.
private boolean doSpawn(Ref ref, String[] args) {
int i = 0;
DC_Player player = getPlayerManager().getPlayer(args[i]);
if (player == null)
player = getPlayerManager().getPlayer(false);
else
i++;
List<String> units = new ArrayList<>();
// if (args[i].contains(ScriptSyntax.SPAWN_ARG_UNITS_WAVE))
String unitString = args[i];
int level = StringMaster.getInteger(VariableManager.getVars(unitString));
unitString = VariableManager.removeVarPart(unitString);
ObjType wave = DataManager.getType(unitString, DC_TYPE.ENCOUNTERS);
if (wave != null) {
for (String sub : StringMaster.open(wave.getProperty(PROPS.PRESET_GROUP))) {
if (level > 0)
units.add(UnitLevelManager.getLeveledTypeName(level, sub));
else
units.add(sub);
}
}
// TODO adjust wave? difficulty => level
boolean group = false;
if (units.isEmpty()) {
units.addAll(StringMaster.openContainer(UnitGroupMaster.getUnitGroupData(unitString, level)));
}
if (units.isEmpty()) {
// DataManager.gettypes
units.addAll(StringMaster.openContainer(unitString));
} else
group = true;
if (units.isEmpty())
return false;
i++;
// CoordinatesFactory.createCoordinates(unitString);
// if (origin==null )
// origin = ref.getObj(unitString).getCoordinates();
List<Coordinates> coordinates = null;
if (group) {
for (String sub : units) {
coordinates.add(DC_ObjInitializer.getCoordinatesFromObjString(sub));
}
} else
coordinates = getCoordinatesListForUnits(unitString, player, units, ref);
String data = "";
data += DataUnitFactory.getKeyValueString(UnitData.FORMAT, PARTY_VALUE.COORDINATES, StringMaster.joinList(coordinates, DataUnitFactory.getContainerSeparator(UnitData.FORMAT)));
data += DataUnitFactory.getKeyValueString(UnitData.FORMAT, PARTY_VALUE.MEMBERS, StringMaster.joinStringList(units, DataUnitFactory.getContainerSeparator(UnitData.FORMAT)));
UnitData unitData = new UnitData(data);
SPAWN_MODE mode = SPAWN_MODE.SCRIPT;
List<Unit> unitsList = getSpawner().spawn(unitData, player, mode);
getSpawner().getFacingAdjuster().adjustFacing(unitsList);
return true;
}
Aggregations