use of main.entity.Entity 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.entity.Entity in project Eidolons by IDemiurge.
the class DC_RequirementsManager method getRequirements.
@Override
public Requirements getRequirements(Entity type, int mode) {
Map<Entity, Requirements> map = getReqMap(mode);
if (map != null) {
if (// TODO
map.get(type) != null) {
return map.get(type);
}
}
Requirements req = null;
OBJ_TYPE TYPE = type.getOBJ_TYPE_ENUM();
if (TYPE instanceof DC_TYPE) {
switch((DC_TYPE) TYPE) {
case ARMOR:
req = generateItemRequirements(type, mode);
break;
case ITEMS:
req = generateItemRequirements(type, mode);
break;
case CLASSES:
req = generateClassRequirements(type, mode);
break;
case SKILLS:
req = generateSkillRequirements(type, mode);
break;
case SPELLS:
req = generateSpellRequirements(type, mode);
break;
case WEAPONS:
req = generateItemRequirements(type, mode);
break;
case UNITS:
break;
case ACTIONS:
break;
default:
break;
}
}
if (req == null) {
return null;
}
String additionalRequirements = type.getProperty(PROPS.REQUIREMENTS);
if (!StringMaster.isEmpty(additionalRequirements)) {
try {
req.addAll(toRequirements(additionalRequirements));
} catch (Exception e) {
LogMaster.log(1, type + "'s req failed! - " + additionalRequirements);
// main.system.ExceptionMaster.printStackTrace(e);
}
}
if (type.isUpgrade() && TYPE != null) {
Requirement baseTypeRequirement = getBaseTypeRequirement(type, TYPE);
if (baseTypeRequirement != null) {
req.add(baseTypeRequirement);
}
}
if (map != null) {
map.put(type, req);
}
return req;
}
use of main.entity.Entity in project Eidolons by IDemiurge.
the class T3InfoPanel method init.
public void init() {
Entity skill = null;
try {
skill = CharacterCreator.getHero().getSkills().get(flipped ? 1 : 0);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
infoPanel = new DC_PagedInfoPanel(skill);
ImageIcon icon = ImageManager.getEmptyItemIcon(flipped);
if (skill != null) {
icon = skill.getIcon();
}
label = new JLabel(icon);
controlPanel = new G_Panel();
controlPanel.setPanelSize(new Dimension(122, getPanelSize().height));
costPool = new PoolComp(skill, PARAMS.XP_COST, "Experience cost", false);
xpPool = new PoolComp(CharacterCreator.getHero(), PARAMS.XP, "Experience points", true) {
};
addComps();
}
use of main.entity.Entity in project Eidolons by IDemiurge.
the class HeroItemSlots method getType.
private Entity getType(ITEM_SLOT slot, DC_TYPE TYPE) {
if (hero.getItem(slot) != null) {
return hero.getItem(slot);
}
String string = hero.getProperty(slot.getProp());
Entity type = DataManager.getType(string, C_OBJ_TYPE.SLOT_ITEMS);
if (type == null) {
if (StringMaster.isInteger(string)) {
Obj obj = hero.getGame().getObjectById(StringMaster.getInteger(string));
if (obj != null) {
type = obj.getType();
} else {
type = hero.getGame().getTypeById(StringMaster.getInteger(string));
}
}
}
return type;
}
use of main.entity.Entity in project Eidolons by IDemiurge.
the class HeroItemSlots method addComps.
private void addComps() {
Boolean posSwitch = null;
for (ITEM_SLOT slot : ItemEnums.ITEM_SLOT.values()) {
ListItem<Entity> item = itemMap.get(slot);
String pos;
if (posSwitch == null) {
pos = "@pos 32 0";
posSwitch = true;
} else if (posSwitch) {
pos = "@pos " + MigMaster.getCenteredPosition(getSlotPanelWidth(), 64) + " 0";
posSwitch = false;
} else {
pos = "@pos " + (getSlotPanelWidth() - 96) + " 0";
}
if (item == null) {
if (slot != ItemEnums.ITEM_SLOT.ARMOR) {
boolean offhand = slot == ItemEnums.ITEM_SLOT.OFF_HAND;
if (hero.getNaturalWeapon(offhand) != null) {
item = initItem(slot, hero.getNaturalWeapon(offhand).getType());
}
}
}
if (item != null) {
add(item, pos);
}
}
}
Aggregations