use of main.entity.obj.BfObj in project Eidolons by IDemiurge.
the class VisibilityCondition method check.
@Override
public boolean check(Ref ref) {
if (!(ref.getObj(KEYS.MATCH) instanceof BfObj)) {
return false;
}
DC_Obj match = (DC_Obj) ref.getObj(KEYS.MATCH);
boolean result = false;
if (this.match == null && this.source == null) {
if (p_vision != null) {
PLAYER_VISION playerVision = match.getActivePlayerVisionStatus();
if (game.getManager().getActiveObj().isMine() != ref.getSourceObj().isMine()) {
if (ref.getSourceObj().isMine()) {
playerVision = match.getPlayerVisionStatus(false);
} else {
// TODO for enemy unit on player's unit...
}
}
if (playerVision == p_vision) {
return true;
}
}
UNIT_VISION visionStatus = match.getUnitVisionStatus();
if (!ref.getSourceObj().isActiveSelected()) {
visionStatus = match.getGame().getVisionMaster().getSightMaster().getUnitVisibilityStatus(match, (Unit) ref.getSourceObj());
}
return visionStatus.isSufficient(u_vision);
}
if (p_vision != null) {
Unit unit = (Unit) ref.getObj(source);
result = unit.getActivePlayerVisionStatus() == p_vision;
} else if (u_vision != null) {
match = (DC_Obj) ref.getObj(this.match);
// if (((DC_Game) game).getManager().isAI_Turn()) { what's the idea?
Unit activeObj = (Unit) ref.getObj(source);
result = ((DC_Game) game).getVisionMaster().getUnitVisibilityStatus(match, activeObj).isSufficient(u_vision);
// }
}
return result;
}
use of main.entity.obj.BfObj in project Eidolons by IDemiurge.
the class ChangeFacingEffect method applyThis.
@Override
public boolean applyThis() {
if (!(ref.getTargetObj() instanceof Unit)) {
return false;
}
Unit obj = (Unit) ref.getTargetObj();
FACING_DIRECTION oldDirection = obj.getFacing();
FACING_DIRECTION newDirection = null;
if (isClockwise() == null) {
for (FACING_DIRECTION f : FACING_DIRECTION.values()) {
Obj active = ref.getObj(KEYS.ACTIVE);
if (active == null) {
return false;
}
if (FacingMaster.getSingleFacing(f, obj, (BfObj) active.getRef().getTargetObj()) == UnitEnums.FACING_SINGLE.IN_FRONT) {
newDirection = f;
break;
}
}
} else {
newDirection = FacingMaster.rotate(oldDirection, isClockwise());
}
obj.setFacing(newDirection);
game.fireEvent(new Event(getEventTypeDone(), ref));
return true;
}
use of main.entity.obj.BfObj in project Eidolons by IDemiurge.
the class FacingCondition method check.
@Override
public boolean check(Ref ref) {
if (!(ref.getSourceObj() instanceof DC_UnitModel)) {
return false;
}
BattleFieldObject obj1 = (BattleFieldObject) ref.getSourceObj();
DC_Obj obj2;
if (!(ref.getObj(KEYS.MATCH) instanceof BfObj)) {
if (!(ref.getObj(KEYS.MATCH) instanceof DC_HeroSlotItem)) {
return false;
}
obj2 = ((DC_HeroAttachedObj) ref.getObj(KEYS.MATCH)).getOwnerObj();
} else {
obj2 = (DC_Obj) ref.getObj(KEYS.MATCH);
}
boolean result = false;
if (getTemplate() != null) {
Coordinates c = obj2.getCoordinates();
if (obj2.isOverlaying())
if (obj2 instanceof BattleFieldObject) {
DIRECTION d = ((BattleFieldObject) obj2).getDirection();
if (d != null) {
c = c.getAdjacentCoordinate(d.rotate180(), 2);
}
// the coordinate to which unit must be facing in order to face the overlaying obj on the other side
}
if (obj1 == null)
return false;
if (c == null)
return false;
FACING_SINGLE facing = FacingMaster.getSingleFacing(obj1.getFacing(), obj1.getCoordinates(), c);
result = Arrays.asList(templates).contains(facing);
if (facing == UnitEnums.FACING_SINGLE.TO_THE_SIDE) {
if (result) {
if (left_right == null) {
left_right = obj1.checkBool(GenericEnums.STD_BOOLS.LEFT_RIGHT_REACH);
}
if (left_right) {
int degrees = obj1.getFacing().getDirection().getDegrees();
int degrees2 = DirectionMaster.getRelativeDirection(obj1, obj2).getDegrees();
boolean left = degrees > degrees2;
if (left) {
return left_right;
}
return !left_right;
}
}
}
}
return result;
}
Aggregations