use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class DroppedItemManager method pickUp.
public boolean pickUp(Unit hero, Entity type) {
Obj cell = game.getCellByCoordinate(hero.getCoordinates());
DC_HeroItemObj item = (DC_HeroItemObj) ObjUtilities.findObjByType(type, getDroppedItems(cell));
if (item == null) {
return false;
}
pickUp(cell, item);
return true;
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class FacingMaster method getOptimalFacingTowardsUnits.
public static FACING_DIRECTION getOptimalFacingTowardsUnits(Coordinates c, Collection<? extends Obj> units, Function<Entity, Integer> function) {
HashMap<FACING_DIRECTION, Double> map = new LinkedHashMap<>();
for (FACING_DIRECTION facing : FACING_DIRECTION.values()) for (Obj member : units) {
if (FacingMaster.getSingleFacing(facing, c, member.getCoordinates()) != FACING_SINGLE.IN_FRONT) {
continue;
}
double x = ((Unit) member).calculatePower() / PositionMaster.getExactDistance(member.getCoordinates(), c);
Double i = map.get(facing);
if (i == null) {
i = 0.0;
}
i += function.apply(member) * x;
map.put(facing, i);
}
FACING_DIRECTION pick = null;
Double max = 0.0;
for (FACING_DIRECTION fac : map.keySet()) {
if (map.get(fac) > max) {
max = map.get(fac);
pick = fac;
}
}
return pick;
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class TargetingMaster method selectTargetForAction.
public static Integer selectTargetForAction(DC_ActiveObj a) {
/*
* getOrCreate possible targets init goal type prioritize
*/
GOAL_TYPE type = GoalManager.getGoalFromAction(a);
Obj target = null;
int max_priority = Integer.MIN_VALUE;
Set<Obj> objects = null;
a.getTargeting().getFilter().setRef(a.getRef());
try {
objects = a.getTargeting().getFilter().getObjects();
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
for (Obj obj : objects) {
ActionSequence sequence = new ActionSequence(type, new Action(a, obj));
sequence.setAi(a.getOwnerObj().getUnitAI());
sequence.setType(type);
int priority = DC_PriorityManager.getPriority(sequence);
if (priority > max_priority) {
target = obj;
max_priority = priority;
}
}
if (target == null) {
return null;
}
return target.getId();
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class ArenaBattleConstructor method pickSpawnCoordinateForWave.
private Coordinates pickSpawnCoordinateForWave(ENCOUNTER_TYPE type, Integer round, ObjType waveType, boolean recursion) {
if (sideSpawnTestMode) {
return null;
}
int minDistance = Integer.MAX_VALUE;
int maxDistance = 0;
Map<Coordinates, Point> map = new HashMap<>();
for (String substring : StringMaster.open(getDungeon().getProperty(PROPS.ENCOUNTER_SPAWN_POINTS))) {
Coordinates coordinates = new Coordinates(substring);
if (usedSpawnCoordinates.contains(coordinates)) {
continue;
}
for (Obj member : game.getPlayer(true).getControlledUnits()) {
// summoned?
int distance = PositionMaster.getDistance(member.getCoordinates(), coordinates);
if (distance > maxDistance) {
maxDistance = distance;
}
if (distance < minDistance) {
minDistance = distance;
}
}
map.put(coordinates, new Point(minDistance, maxDistance));
}
if (map.isEmpty()) {
if (recursion) {
return getDefaultSpawnCoordinate(type, round, waveType);
}
usedSpawnCoordinates.clear();
return pickSpawnCoordinateForWave(type, round, waveType, true);
}
Coordinates pick = null;
int minDistanceToOptimal = Integer.MAX_VALUE;
for (Coordinates coordinates : map.keySet()) {
minDistance = map.get(coordinates).x;
maxDistance = map.get(coordinates).y;
int distanceToOptimal = Math.max(0, getOptimalMinDistance() - minDistance);
distanceToOptimal += Math.max(0, maxDistance - getOptimalMaxDistance());
if (distanceToOptimal < minDistanceToOptimal) {
minDistanceToOptimal = distanceToOptimal;
pick = coordinates;
}
}
usedSpawnCoordinates.add(pick);
return pick;
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class GammaMaster method getAlphaForShadowMapCell.
public float getAlphaForShadowMapCell(int x, int y, SHADE_LIGHT type) {
if (type == SHADE_LIGHT.BLACKOUT) {
return getBlackoutAlpha(x, y);
}
if (type == SHADE_LIGHT.HIGLIGHT) {
return getHiglightAlpha(x, y);
}
Unit unit = Eidolons.game.getManager().getMainHero();
if (unit == null) {
unit = Eidolons.game.getManager().getActiveObj();
}
if (unit == null) {
switch(type) {
case GAMMA_SHADOW:
return 1;
}
return 0;
}
float alpha = 0;
float gamma = getGammaForCell(x, y);
switch(type) {
case GAMMA_SHADOW:
if (VisionManager.isVisionHacked()) {
return 0;
}
if (gamma >= 1)
return 0;
if (gamma < 0)
alpha = 1;
else
alpha = 1 - gamma;
if (unit.getX() == x && unit.getY() == y) {
alpha = alpha / 2;
}
break;
case GAMMA_LIGHT:
if (gamma < 0)
return 0;
alpha = (float) Math.min(Math.sqrt(gamma * 2), gamma / 3);
alpha = Math.min(alpha, 0.5f);
break;
case LIGHT_EMITTER:
for (Obj sub : DC_Game.game.getRules().getIlluminationRule().getEffectCache().keySet()) {
if (sub instanceof Unit)
// TODO illuminate some other way for units...
continue;
if (sub.getCoordinates().x == x)
if (sub.getCoordinates().y == y)
if (((DC_Obj) sub).getPlayerVisionStatus(false) == PLAYER_VISION.DETECTED) {
alpha += LIGHT_EMITTER_ALPHA_FACTOR * master.getGame().getRules().getIlluminationRule().getLightEmission((DC_Obj) sub);
}
}
if (alpha > 0) {
break;
}
break;
case CONCEALMENT:
alpha = // PARAMS.CONCEALMENT)*CONCEALMENT_ALPHA_FACTOR;
master.getIlluminationMaster().getConcealment(unit, Eidolons.game.getCellByCoordinate(new Coordinates(x, y))) * CONCEALMENT_ALPHA_FACTOR;
if (alpha > 0)
alpha += getAlphaForShadowMapCell(x, y, SHADE_LIGHT.LIGHT_EMITTER) / 3;
break;
}
return MathMaster.minMax(alpha, 0, 1);
}
Aggregations