use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class IlluminationRule method getLightEmissionEffect.
public LightEmittingEffect getLightEmissionEffect(DC_Obj source) {
LightEmittingEffect effect = effectCache.get(source);
if (effect == null) {
int value = getLightEmission(source);
if (value <= 0) {
return null;
}
Boolean circular = true;
if (source instanceof Unit)
circular = false;
else if (source.checkBool(GenericEnums.STD_BOOLS.SPECTRUM_LIGHT)) {
circular = false;
} else if (EntityCheckMaster.isOverlaying(source)) {
BattleFieldObject dc_Obj = (BattleFieldObject) source;
if (dc_Obj.getDirection() != null) {
circular = false;
}
}
effect = new LightEmittingEffect(("" + value), circular);
effect.setRef(new Ref(source));
effectCache.put(source, effect);
} else
effect.getEffects().setFormula(new Formula("" + getLightEmission(source)));
return effect;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class ClearShotCondition method check.
@Override
public boolean check(Ref ref) {
Obj obj = game.getObjectById(ref.getId(str2));
if (!(obj instanceof DC_Obj)) {
return false;
}
DC_Obj target = (DC_Obj) game.getObjectById(ref.getId(str2));
if (target == null) {
return false;
}
Coordinates c2 = target.getCoordinates();
if (c2 == null)
return false;
BattleFieldObject source = (BattleFieldObject) game.getObjectById(ref.getId(str1));
if (source == null)
return false;
if (c2.equals(source.getCoordinates()))
return true;
if (target.isOverlaying()) {
if (target instanceof BattleFieldObject) {
DIRECTION d = ((BattleFieldObject) target).getDirection();
DIRECTION d1 = DirectionMaster.getRelativeDirection(target, source);
if (d != null) {
if (d1 != d) {
if (Math.abs(d.getDegrees() - d1.getDegrees()) > 90)
return false;
}
}
}
}
wallObstruction = false;
Coordinates c1 = source.getCoordinates();
boolean toCheck = true;
boolean result = true;
if (PositionMaster.inLine(c1, c2)) {
result = PositionMaster.noObstaclesInLine(source, target, game.getBattleField().getGrid());
toCheck = false;
if (!result)
return cacheResult(source, target, result);
} else {
// TODO TRANSPARENT FOR VISION!
if (PositionMaster.inLineDiagonally(c1, c2)) {
result = PositionMaster.noObstaclesInDiagonal(c1, c2, game.getBattleField().getGrid(), source);
if (!result)
return cacheResult(source, target, result);
List<Coordinates> list = new ArrayList<>();
if (!c2.isAdjacent(source.getCoordinates())) {
DIRECTION direction = DirectionMaster.getRelativeDirection(source, target);
list = (DC_PositionMaster.getLine(false, direction, source.getCoordinates(), // PositionMaster.getDistance(source,
Math.abs(source.getX() - target.getX())));
} else {
list.add(target.getCoordinates());
}
for (Coordinates c : list) {
if (checkWallObstruction(source, target, c))
return cacheResult(source, target, false);
}
return cacheResult(source, target, true);
}
}
if (!result)
return cacheResult(source, target, result);
if (!toCheck)
return cacheResult(source, target, result);
result = checkClearShot(source, target);
return cacheResult(source, target, result);
}
use of eidolons.entity.obj.BattleFieldObject 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;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DungeonBuilder method initDynamicObjData.
protected void initDynamicObjData(Location location, DungeonPlan plan) {
int z = location.getIntParam(G_PARAMS.Z_LEVEL);
for (MapBlock b : plan.getBlocks()) {
ArrayList<Obj> objects = new ArrayList<>(b.getObjects());
for (Obj obj : objects) {
// TODO of course - the issue was that I added an object to
// block too! ... init?
BattleFieldObject unit = (BattleFieldObject) obj;
if (z != 0) {
unit.setZ(z);
}
}
}
for (MapZone zone : plan.getZones()) {
ObjType wallType = DataManager.getType(zone.getFillerType(), DC_TYPE.BF_OBJ);
if (wallType == null)
continue;
List<Coordinates> list = zone.getCoordinates();
for (MapBlock b : zone.getBlocks()) {
list.removeAll(b.getCoordinates());
}
for (Coordinates c : list) {
getGame().getManager().getObjCreator().createUnit(wallType, c.x, c.y, Player.NEUTRAL, new Ref(game));
}
}
for (Obj obj : plan.getWallObjects()) {
BattleFieldObject unit = (BattleFieldObject) obj;
if (z != 0) {
unit.setZ(z);
}
}
if (plan.getDirectionMap() != null) {
try {
DC_ObjInitializer.initDirectionMap(z, plan.getDirectionMap());
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
if (plan.getFlipMap() != null) {
try {
DC_ObjInitializer.initFlipMap(z, plan.getFlipMap());
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_StateManager method removeObject.
public void removeObject(Integer id) {
Obj obj = game.getObjectById(id);
if (obj == null) {
return;
}
if (obj instanceof BattleFieldObject) {
if (obj instanceof Structure) {
getGame().getStructures().remove(obj);
}
if (obj instanceof Unit) {
getGame().getUnits().remove(obj);
}
removeAttachedObjects((Unit) obj);
}
Map<Integer, Obj> map = state.getObjMaps().get(obj.getOBJ_TYPE_ENUM());
if (map != null) {
map.remove(id);
}
// super.removeObject(id);
}
Aggregations