use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class SightMaster method getSpectrumCoordinates.
public DequeImpl<Coordinates> getSpectrumCoordinates(Integer range, Integer side_penalty, Integer back_bonus, BattleFieldObject source, boolean vision, FACING_DIRECTION facing, boolean extended) {
DequeImpl<Coordinates> list = new DequeImpl<>();
BattleFieldObject unit = null;
Coordinates orig = source.getCoordinates();
if (source instanceof BattleFieldObject) {
unit = (BattleFieldObject) source;
}
if (facing == null) {
if (unit != null) {
facing = unit.getFacing();
}
}
DIRECTION direction;
if (facing == null) {
facing = FacingMaster.getRandomFacing();
}
direction = facing.getDirection();
if (range == null) {
range = source.getIntParam(PARAMS.SIGHT_RANGE);
if (extended) {
range = MathMaster.applyModIfNotZero(range, source.getIntParam(PARAMS.SIGHT_RANGE_EXPANSION));
}
}
if (side_penalty == null) {
side_penalty = source.getIntParam(PARAMS.SIDE_SIGHT_PENALTY);
if (extended) {
side_penalty = MathMaster.applyModIfNotZero(side_penalty, source.getIntParam(PARAMS.SIGHT_RANGE_EXPANSION_SIDES));
}
}
if (back_bonus == null) {
back_bonus = source.getIntParam(PARAMS.BEHIND_SIGHT_BONUS);
if (!extended)
back_bonus--;
// back_bonus = MathMaster.applyModIfNotZero(back_bonus, source
// .getIntParam(PARAMS.SIGHT_RANGE_EXPANSION_BACKWARD));
}
addLine(orig.getAdjacentCoordinate(direction), range, list, direction, true);
addSides(list, orig, direction, range - side_penalty, false);
DIRECTION backDirection = DirectionMaster.flip(direction);
Coordinates backCoordinate = orig.getAdjacentCoordinate(backDirection);
if (back_bonus > 0) {
if (backCoordinate != null) {
addLine(backCoordinate, back_bonus, list, backDirection, true);
// if (back_bonus > side_penalty)
// addSides(list, backCoordinate, backDirection, back_bonus -
// side_penalty, false);
}
}
Collection<Coordinates> blocked = getBlockedList(list, source, facing);
list.removeAll(blocked);
list.add(source.getCoordinates());
return list;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_GameMaster method getObjects.
public BattleFieldObject[] getObjects(int x_, int y_) {
BattleFieldObject[] array = getObjCells()[x_][y_];
if (array == null) {
List<BattleFieldObject> list = getObjectsOnCoordinate(new Coordinates(x_, y_), false);
if (list.isEmpty())
array = new BattleFieldObject[0];
else
array = list.toArray(new BattleFieldObject[list.size()]);
objCells[x_][y_] = array;
}
return array;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DcHelper method object.
public BattleFieldObject object(String name, int x, int y, DC_Player owner, DC_TYPE TYPE) {
ObjType type = DataManager.getType(name, TYPE);
assertTrue(type != null);
return (BattleFieldObject) game.getManager().getObjCreator().createUnit(type, x, y, owner, new Ref(game));
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class Level method getFacingMapData.
private String getFacingMapData() {
String facingMapData = "";
Map<Coordinates, List<Unit>> multiMap = new HashMap<>();
for (Coordinates c : getDirectionMap().keySet()) {
Map<BattleFieldObject, DIRECTION> map = getDirectionMap().get(c);
for (DC_Obj obj : map.keySet()) {
if (obj instanceof Unit) {
Unit u = (Unit) obj;
DIRECTION facing = map.get(u);
if (facing != null) {
u.setCoordinates(c);
String string = DC_ObjInitializer.getObjString(u);
List<Unit> list = multiMap.get(c);
if (list == null) {
list = new ArrayList<>();
multiMap.put(c, list);
}
list.add(u);
if (list.size() > 1) {
string += list.size() + 1;
}
facingMapData += RandomWizard.getWeightStringItem(string, facing.toString());
}
}
}
}
return facingMapData;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DeathMaster method killAllUnits.
public void killAllUnits(boolean removeBfObjects, boolean retainPlayerParty, boolean quiet) {
DequeImpl<BattleFieldObject> list = new DequeImpl();
List<BattleFieldObject> toRemove = new ArrayList<>();
list.addAll(getGame().getUnits());
if (removeBfObjects) {
list.addAll(getGame().getStructures());
}
for (BattleFieldObject unit : list) {
if (retainPlayerParty) {
if (PartyHelper.getParty() != null) {
if (PartyHelper.getParty().getMembers().contains(unit)) {
continue;
}
}
// if (unit.isMine())
// continue;
}
unit.kill(unit, false, quiet);
toRemove.add(unit);
}
// if (remove)
for (BattleFieldObject unit : toRemove) {
getGame().remove(unit);
}
// reset();
// refreshAll();
// WaitMaster.receiveInput(WAIT_OPERATIONS.ACTION_COMPLETE, true);
}
Aggregations