use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.
the class CellCondition method getCoordinates.
@Override
protected Coordinates getCoordinates(Ref ref) {
if (obj_ref == null) {
obj_ref = KEYS.MATCH.toString();
}
if (direction == null) {
return super.getCoordinates(ref);
}
Obj obj = ref.getObj(obj_ref);
FACING_DIRECTION f = null;
if (obj instanceof DC_UnitModel) {
f = ((DC_UnitModel) obj).getFacing();
}
if (f == null) {
return null;
}
return super.getCoordinates(ref).getAdjacentCoordinate(DirectionMaster.getDirectionByFacing(f, direction));
}
use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.
the class LocationBuilder method placeCulDeSacs.
// public static ObjType getDungeonTypeFromLevelData(String data) {
// return null;
// }
private void placeCulDeSacs() {
int n = helper.getParams().CUL_DE_SACS;
n = MathMaster.applyMod(n, getDungeon().getPlan().getWidthMod());
n = RandomWizard.getRandomIntBetween(n / 2, n * 2);
Loop.startLoop(10000);
while (!Loop.loopEnded()) {
MapBlock block = new RandomWizard<MapBlock>().getRandomListItem(plan.getBlocks());
FACING_DIRECTION direction = FacingMaster.getRandomFacing();
Coordinates baseCoordinate = helper.getRandomWallCoordinate(direction, block);
if (helper.tryPlaceCorridor(block, baseCoordinate, direction, true)) {
n--;
}
if (n < 0) {
break;
}
}
}
use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.
the class ArenaPositioner method getCoordinatesForUnitGroup.
public List<ObjAtCoordinate> getCoordinatesForUnitGroup(List<ObjType> presetGroupTypes, Wave wave, int unitLevel) {
Map<Coordinates, ObjType> map = new LinkedHashMap<>();
boolean custom = false;
Coordinates presetCenterCoordinate = wave.getCoordinates();
if (wave.isPresetCoordinate()) {
if (presetCenterCoordinate != null) {
custom = isAutoOptimalFacing();
}
}
if (wave.getBlock() != null) {
// TODO return
// getCoordinatesForUnitGroupInMapBlock(presetGroupTypes, wave,
// wave.getBlock());
}
if (forcedSide != null) {
side = forcedSide;
// forcedSide = null;
} else {
side = new EnumMaster<FACING_DIRECTION>().retrieveEnumConst(FACING_DIRECTION.class, wave.getProperty(PROPS.SPAWNING_SIDE));
if (side == null) {
nextSide();
}
}
unitGroups.put(side, map);
int maxUnitsPerRow = getMaxUnitsPerRow(side);
List<Coordinates> list = getCoordinatesForUnits(presetGroupTypes, custom, presetCenterCoordinate, maxUnitsPerRow);
List<ObjAtCoordinate> group = new ArrayList<>();
int i = 0;
for (Coordinates c : list) {
ObjType type = new ObjType(presetGroupTypes.get(i));
type.getGame().initType(type);
i++;
if (unitLevel > 0) {
type = new UnitLevelManager().getLeveledType(type, unitLevel, false);
}
ObjAtCoordinate objAtCoordinate = new ObjAtCoordinate(type, c);
group.add(objAtCoordinate);
}
return group;
}
use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.
the class ArenaPositioner method getPartyCoordinates.
@Unimplemented
public List<Coordinates> getPartyCoordinates(Coordinates origin, Boolean me, List<String> partyTypes) {
List<Coordinates> list = new ArrayList<>();
// TODO
if (CoreEngine.isArcaneVault() || CoreEngine.isLevelEditor()) {
origin = new Coordinates(PositionMaster.getMiddleIndex(false), PositionMaster.getMiddleIndex(true));
} else {
FACING_DIRECTION side = ArenaPositioner.DEFAULT_PLAYER_SIDE;
// if ( getSpawningSide() != null) {
// side = getSpawningSide();
// }
unitGroups.put(side, new LinkedHashMap<>());
}
return list;
}
use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.
the class ArenaSpawner method spawnWave.
private void spawnWave(List<ObjAtCoordinate> unitMap, Wave wave, boolean prespawnMode) {
game.getLogManager().log("New encounter: " + wave.getName());
if (unitMap == null) {
getPositioner().setMaxSpacePercentageTaken(MAX_SPACE_PERC_CREEPS);
wave.initUnitMap();
unitMap = wave.getUnitMap();
}
try {
getBattleMaster().getWaveAssembler().resetPositions(wave);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
for (ObjAtCoordinate oac : unitMap) {
Coordinates c = oac.getCoordinates();
FACING_DIRECTION facing = getFacingAdjuster().getFacingForEnemy(c);
boolean invalid = false;
if (c == null) {
invalid = true;
} else if (c.isInvalid()) {
invalid = true;
} else if (game.getBattleField().getGrid().isCoordinateObstructed(c)) {
invalid = true;
}
if (invalid) {
c = Positioner.adjustCoordinate(c, facing);
}
ObjType type = oac.getType();
Unit unit = (Unit) game.createUnit(type, c, wave.getOwner());
UnitTrainingMaster.train(unit);
unit.setFacing(facing);
wave.addUnit(unit);
game.fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_CHANGED_FACING, Ref.getSelfTargetingRefCopy(unit)));
}
if (!PartyHelper.checkMergeParty(wave)) {
try {
PartyHelper.addCreepParty(wave);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
}
Aggregations