use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.
the class DC_BattleFieldGrid method resetComponents.
@Deprecated
private void resetComponents() {
int offsetX = getOffsetX();
int offsetY = getOffsetY();
LogMaster.log(0, "resetting grid comps with offsetX = " + offsetX + ";offsetY =" + offsetY);
for (int i = 0; i < getDisplayedCellsX(); i++) {
for (int j = 0; j < getDisplayedCellsY(); j++) {
int x = i + getOffsetX();
int y = j + getOffsetY();
Coordinates c = new Coordinates(x, y);
List<BattleFieldObject> objects = game.getObjectsOnCoordinate(getZ(), c, false, true, false);
List<Unit> overlayingObjects = new ArrayList<>(new DequeImpl(game.getObjectsOnCoordinate(getZ(), c, true, true, false)).getRemoveAll(objects));
// visibility preCheck!
CellComp comp = gridComp.getCells()[x][y];
List<BattleFieldObject> list = new ArrayList<>();
for (BattleFieldObject obj : objects) {
if (VisionManager.checkVisible(obj)) {
list.add(obj);
}
}
comp.setSizeFactor(gridComp.getZoom());
comp.setOverlayingObjects(overlayingObjects);
if (list.size() != 0) {
// comp.setObjects(list);
}
comp.refresh();
}
}
comp.refresh();
}
use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.
the class ShapeEffect method initTargeting.
@Override
public void initTargeting() {
// init unit group
Coordinates baseCoordinate = getBaseCoordinate();
int base_width = radius.getInt(ref);
int distance = this.distance.getInt(ref);
coordinates = DC_PositionMaster.getShapedCoordinates(baseCoordinate, getFacing(), base_width, distance, getShape());
DequeImpl<Obj> objects = new DequeImpl<>();
objects.addAllCast(getGame().getMaster().getUnitsForCoordinates(coordinates));
Filter.filter(objects, targetType);
if (allyOrEnemyOnly != null) {
if (allyOrEnemyOnly) {
FilterMaster.applyFilter(objects, FILTERS.ALLY, ref, false);
} else {
FilterMaster.applyFilter(objects, FILTERS.ENEMY, ref, false);
}
}
if (notSelf) {
FilterMaster.applyFilter(objects, FILTERS.NOT_SELF, ref, false);
}
if (targetType.equals(DC_TYPE.TERRAIN)) {
// C_TYPE equals if contains() !
objects.addAll(game.getCellsForCoordinates(coordinates));
}
targeting = new AutoTargeting(new GroupImpl(objects));
setFilteringConditions(new Conditions());
targeting.setConditions(getFilteringConditions());
}
use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.
the class StackingRule method canBeMovedOnto.
private boolean canBeMovedOnto(Integer maxSpaceTakenPercentage, Entity unit, Coordinates c, Integer z, List<? extends Entity> otherUnits) {
HashMap<Coordinates, Boolean> bools = cache.get(unit);
boolean result = false;
if (maxSpaceTakenPercentage == 100) {
if (bools != null) {
if (bools.containsKey(c)) {
return bools.get(c);
}
} else {
bools = new HashMap<>();
cache.put(unit, bools);
}
}
// get all units on the cell
DequeImpl<? extends Entity> units = new DequeImpl<>(otherUnits);
for (BattleFieldObject u : game.getObjectsOnCoordinate(z, c, false, false, false)) {
if (!units.contains(u)) {
if (!u.isAnnihilated())
// continue; TODO why was Type necessary?
units.addCast(!u.isDead() ? u.getType() : u);
if (u.isWall())
if (!u.isDead())
return false;
}
}
// check if '1 unit per cell' is on
if (maxSpaceTakenPercentage <= 0) {
if (!units.isEmpty()) {
return false;
}
}
if (unit == null) {
unit = DataManager.getType(HeroCreator.BASE_HERO, DC_TYPE.CHARS);
}
Obj cell;
if (!game.isSimulation()) {
cell = game.getCellByCoordinate(c);
} else {
cell = new DC_Cell(c, game);
}
if (cell == null) {
return false;
}
if (z == null) {
if (unit instanceof Unit) {
Unit heroObj = (Unit) unit;
z = heroObj.getZ();
}
}
// TODO ???
if (game.isSimulation()) {
if (units.size() > 1) {
return false;
}
}
// no passable/overlaying!
int space = StringMaster.getInteger(PARAMS.SPACE.getDefaultValue());
if (c != null) {
if (!game.isSimulation()) {
space = cell.getIntParam(PARAMS.SPACE);
}
}
int girth = 0;
for (Entity u : units) {
if (u == unit) {
continue;
}
// }
if (UnitAnalyzer.isWall(u)) {
// if (!UnitAnalyzer.isFlying(unit)) {
return false;
// }
}
if (u.isDead())
girth += u.getIntParam(PARAMS.GIRTH) / 3;
else
girth += u.getIntParam(PARAMS.GIRTH);
// TODO if (DoorMaster.isDoor((BattleFieldObject) u)) {
//
// }
// main.system.auxiliary.LogMaster.log(1, "****************** " +
// u.getName()
// + "'s Girth " + u.getIntParam(PARAMS.GIRTH));
}
// [QUICK FIX]
if (unit.getIntParam(PARAMS.GIRTH) == 0) {
girth += StringMaster.getInteger(PARAMS.GIRTH.getDefaultValue());
} else {
girth += unit.getIntParam(PARAMS.GIRTH);
}
// main.system.auxiliary.LogMaster.log(1, "****************** " + space
// + " Space vs " + girth
// + " Girth on " + c + " for " + unit);
space = space * maxSpaceTakenPercentage / 100;
if (space >= girth) {
result = true;
} else {
if (unit.getIntParam(PARAMS.GIRTH) > space) {
if (units.isEmpty()) {
result = true;
}
}
}
if (// only cache for default cases!
maxSpaceTakenPercentage == 100) {
bools.put(c, result);
}
return result;
}
use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.
the class GridPanel method init.
public GridPanel init(DequeImpl<BattleFieldObject> units) {
this.viewMap = new HashMap<>();
emptyImage = TextureCache.getOrCreateR(getCellImagePath());
cornerRegion = TextureCache.getOrCreateR(gridCornerElementPath);
cells = new GridCellContainer[cols][rows];
int rows1 = rows - 1;
for (int x = 0; x < cols; x++) {
for (int y = 0; y < rows; y++) {
cells[x][y] = new GridCellContainer(emptyImage, x, rows1 - y);
cells[x][y].setX(x * GridMaster.CELL_W);
cells[x][y].setY(y * GridMaster.CELL_H);
addActor(cells[x][y].init());
checkAddBorder(x, y);
}
}
if (OptionsMaster.getGraphicsOptions().getBooleanValue(GRAPHIC_OPTION.SPRITE_CACHE_ON))
TextureManager.addCellsToCache(cols, rows);
addActor(new CellBorderManager());
bindEvents();
createUnitsViews(units);
setHeight(cells[0][0].getHeight() * rows);
setWidth(cells[0][0].getWidth() * cols);
addListener(new BattleClickListener() {
@Override
public boolean mouseMoved(InputEvent event, float x, float y) {
GridPanel.this.getStage().setScrollFocus(GridPanel.this);
return false;
}
@Override
public boolean touchDown(InputEvent e, float x, float y, int pointer, int button) {
// return PhaseAnimator.getInstance().checkAnimClicked(x, y, pointer, button);
return false;
}
});
addActor(overlayManager = new OverlaysManager(this));
addActor(animMaster = AnimMaster.getInstance());
animMaster.bindEvents();
if (AnimationConstructor.isPreconstructAllOnGameInit())
units.forEach(unit -> {
if (unit instanceof Unit)
animMaster.getConstructor().preconstructAll((Unit) unit);
});
if (fpsDebug) {
fpsLabel = new Label("0", StyleHolder.getDefaultLabelStyle());
addActor(fpsLabel);
fpsLabel.setAlignment(Align.topLeft);
}
return this;
}
use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.
the class DC_ActionManager method checkSetFeatRef.
private void checkSetFeatRef(DC_UnitAction action) {
DequeImpl<DC_FeatObj> skills = new DequeImpl<>(action.getOwnerObj().getSkills());
skills.addAll(action.getOwnerObj().getClasses());
for (DC_FeatObj s : skills) {
if (StringMaster.contains(s.getProperty(G_PROPS.ACTIVES), action.getName())) {
action.getRef().setID(KEYS.SKILL, s.getId());
return;
}
}
}
Aggregations