use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class WanderAi method changeGroupMoveDirection.
public static void changeGroupMoveDirection(GroupAI group, GOAL_TYPE type) {
DIRECTION wanderDirection = group.getWanderDirection();
if (type == AiEnums.GOAL_TYPE.PATROL) {
// one-way-turn
if (// GUARD?
group.isBackAndForth()) {
wanderDirection = DirectionMaster.rotate90(DirectionMaster.rotate90(wanderDirection, true), true);
} else {
wanderDirection = DirectionMaster.rotate90(wanderDirection, group.isClockwisePatrol());
}
} else if (type == AiEnums.GOAL_TYPE.WANDER) {
if (PositionMaster.getDistance(group.getOriginCoordinates(), group.getLeader().getCoordinates()) >= getMaxWanderTotalDistance(group, type)) {
wanderDirection = DirectionMaster.getRelativeDirection(group.getLeader().getCoordinates(), group.getOriginCoordinates());
}
}
if (wanderDirection == group.getWanderDirection()) {
if (RandomWizard.random() || RandomWizard.random()) {
wanderDirection = DirectionMaster.rotate45(wanderDirection, RandomWizard.random());
} else {
wanderDirection = DirectionMaster.rotate90(wanderDirection, RandomWizard.random());
}
}
// if () //TODO change of opposite!
// DirectionMaster.getDirectionByDegree(degrees);
// getOrCreate direction by Leader's facing at the time, and make him
// turn and turn while waiting!
group.setWanderDirection(wanderDirection);
}
use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class WanderAi method getWanderTargetCoordinatesCell.
public static Coordinates getWanderTargetCoordinatesCell(UnitAI ai, GOAL_TYPE type) {
// List<? extends DC_Obj> cells = getWanderCells(ai);
// ai.getStandingOrders(); TODO set target???
// // from original coordinate? Or 'last'?
// ai.getGroup().getWanderDistance();
boolean follow = ai.getGroup().isFollowLeader() || isFollowLeader(type);
if (follow) {
if (isAheadOfLeader(ai)) {
return null;
}
}
DIRECTION direction = ai.getGroup().getWanderDirection();
// DirectionMaster.getRelativeDirection(source, target);
if (direction == null) {
return null;
}
Coordinates c = ai.getUnit().getCoordinates().getAdjacentCoordinate(direction);
return c;
// auto-turn if facing ain't right? take relative *position*
}
use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class DC_BattleFieldManager method resetWalls.
public void resetWalls() {
doorMap.clear();
Map<Coordinates, BattleFieldObject> wallObjects = new HashMap<>();
for (Obj obj : game.getObjects(DC_TYPE.BF_OBJ)) {
BattleFieldObject bfObj = (BattleFieldObject) obj;
if (bfObj.getZ() == game.getDungeon().getZ()) {
if (bfObj.isWall()) {
wallObjects.put(obj.getCoordinates(), bfObj);
}
if (bfObj instanceof Door) {
doorMap.put(obj.getCoordinates(), ((Door) bfObj).getState());
}
}
}
if (wallMap == null) {
wallMap = new HashMap<>();
}
wallMap.clear();
ArrayList<Coordinates> coordinates = new ArrayList<>(wallObjects.keySet());
for (Coordinates coordinate : coordinates) {
BattleFieldObject wall = wallObjects.get(coordinate);
if (wall.isDead()) {
continue;
}
List<DIRECTION> list = new ArrayList<>();
for (Coordinates c : coordinate.getAdjacent(false)) {
BattleFieldObject adjWall = wallObjects.get(c);
if (adjWall != null) {
if (adjWall.isWall() && !adjWall.isDead()) {
DIRECTION side = DirectionMaster.getRelativeDirection(coordinate, c);
list.add(side);
}
}
}
adjacent: for (Coordinates c : coordinate.getAdjacent(true)) {
BattleFieldObject adjWall = wallObjects.get(c);
if (adjWall != null) {
if (adjWall.isWall() && !adjWall.isDead()) {
DIRECTION side = DirectionMaster.getRelativeDirection(coordinate, c);
if (!side.isDiagonal()) {
continue;
}
for (DIRECTION s : list) {
if (s.isDiagonal()) {
continue;
}
if (side.getXDirection() == s) {
continue adjacent;
}
if (side.getYDirection() == s) {
continue adjacent;
}
}
list.add(side);
}
}
}
if (!list.isEmpty()) {
if (coordinate == null)
continue;
wallMap.put(coordinate, list);
}
}
if (diagonalJoints == null) {
diagonalJoints = new HashMap<>();
}
diagonalJoints.clear();
loop: for (Coordinates c : wallMap.keySet()) {
for (DIRECTION s : wallMap.get(c)) {
if (s.isDiagonal()) {
// for (Coordinates c :
// o.getCoordinates().getAdjacentCoordinates(null)) {
// if (wallObjects.get(c) != null) {
// if (containsAdjacentDiagonal in X direction
// }
// }
List<DIRECTION> list = diagonalJoints.get(c);
if (list == null) {
list = new ArrayList<>();
}
diagonalJoints.put(c, list);
if (list.size() == 1) {
DIRECTION d = list.get(0);
if (s.growX)
if (!d.growX)
continue;
else if (d.growX)
continue;
if (s.growY)
if (!d.growY)
continue;
else if (d.growY)
continue;
}
list.add(s);
continue loop;
}
}
}
wallResetRequired = false;
}
use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class SightMaster method addSides.
private void addSides(DequeImpl<Coordinates> list, Coordinates orig, DIRECTION facing, int range, boolean remove) {
DIRECTION side = DirectionMaster.rotate90(facing, true);
addLine(orig.getAdjacentCoordinate(side), range, list, side, false, remove);
side = DirectionMaster.rotate90(facing, false);
addLine(orig.getAdjacentCoordinate(side), range, list, side, false, remove);
}
use of main.game.bf.Coordinates.DIRECTION 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;
}
Aggregations