use of eidolons.entity.obj.DC_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);
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class Analyzer method getWanderCells.
public static List<? extends DC_Obj> getWanderCells(UnitAI ai) {
DIRECTION d = ai.getGroup().getWanderDirection();
// permittedCells = ai.getGroup().getWanderBlocks();
List<DC_Obj> list = new ArrayList<>();
for (DC_Cell cell : getCells(ai, false, false, true)) {
if (d != null) {
if (DirectionMaster.getRelativeDirection(cell, ai.getUnit()) != d) {
continue;
}
}
if (PositionMaster.getDistance(cell, ai.getUnit()) <= ai.getMaxWanderDistance()) {
list.add(cell);
}
}
if (list.isEmpty()) {
// change direction?
}
return list;
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class DC_GameManager method select.
@Override
public Integer select(Set<Obj> selectingSet, Ref ref) {
Pair<Set<Obj>, TargetRunnable> p = new ImmutablePair<>(selectingSet, (t) -> {
if (ref.getActive() instanceof DC_ActiveObj) {
// TODO CLICK ON ANY OTHER OBJ MUST RESULT IN SELECTION STOP!
// ((DC_ActiveObj) ref.getActive()).activateOn(t);
// WaitMaster.receiveInput(WAIT_OPERATIONS.SELECT_BF_OBJ, t.getId());
t.invokeClicked();
}
});
GuiEventManager.trigger(SELECT_MULTI_OBJECTS, p);
for (Obj obj : new ArrayList<>(selectingSet)) {
if (obj instanceof DC_Obj) {
DC_Obj unit = (DC_Obj) obj;
if (getActiveObj() != null) {
if (getActiveObj().getZ() != unit.getZ()) {
selectingSet.remove(unit);
}
}
}
}
this.selectingSet = selectingSet;
if (selectingSet.isEmpty()) {
// getGame().getToolTipMaster().addTooltip(SCREEN_POSITION.ACTIVE_UNIT_BOTTOM,
// "No targets available!");
DC_SoundMaster.playStandardSound(STD_SOUNDS.ACTION_CANCELLED);
return null;
}
setSelecting(true);
for (Obj obj : selectingSet) {
DrawMasterStatic.getObjImageCache().remove(obj);
}
Integer id = selectAwait();
if (id == null) {
if (ref.getTarget() != null) {
return ref.getTarget();
}
}
return id;
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class Level method getFacingMapData.
private String getFacingMapData() {
String facingMapData = "";
Map<Coordinates, List<Unit>> multiMap = new HashMap<>();
for (Coordinates c : getDirectionMap().keySet()) {
Map<BattleFieldObject, DIRECTION> map = getDirectionMap().get(c);
for (DC_Obj obj : map.keySet()) {
if (obj instanceof Unit) {
Unit u = (Unit) obj;
DIRECTION facing = map.get(u);
if (facing != null) {
u.setCoordinates(c);
String string = DC_ObjInitializer.getObjString(u);
List<Unit> list = multiMap.get(c);
if (list == null) {
list = new ArrayList<>();
multiMap.put(c, list);
}
list.add(u);
if (list.size() > 1) {
string += list.size() + 1;
}
facingMapData += RandomWizard.getWeightStringItem(string, facing.toString());
}
}
}
}
return facingMapData;
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class WatchActionEffect method applyThis.
@Override
public boolean applyThis() {
Obj sourceObj = ref.getSourceObj();
List<DC_Obj> list = WatchRule.getWatchersMap().get(sourceObj);
if (list == null) {
list = new ArrayList<>();
WatchRule.getWatchersMap().put((Unit) sourceObj, list);
} else if (!alert) {
if (list.contains(ref.getTargetObj())) {
list.remove(ref.getTargetObj());
if (RandomWizard.random()) {
DC_SoundMaster.playStandardSound(STD_SOUNDS.BACK);
} else {
DC_SoundMaster.playStandardSound(STD_SOUNDS.CLOSE);
}
LogMaster.log(1, sourceObj.getName() + " no longer watching " + ref.getTargetObj().getNameIfKnown());
return true;
} else if (!list.isEmpty()) {
if (RandomWizard.random()) {
DC_SoundMaster.playStandardSound(STD_SOUNDS.DIS__BLOCKED);
} else {
DC_SoundMaster.playStandardSound(STD_SOUNDS.CLICK_ERROR);
}
// if (maxUnitsWatched<=1)
return false;
}
}
list.add((DC_Obj) ref.getTargetObj());
if (!alert) {
if (// (sourceObj.isMine())
RandomWizard.random()) {
DC_SoundMaster.playStandardSound(STD_SOUNDS.DIS__KNIFE);
} else {
DC_SoundMaster.playStandardSound(STD_SOUNDS.NOTE);
}
}
return true;
}
Aggregations