use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class Executor method activate.
public boolean activate() {
reset();
syncActionRefWithSource();
getTargeter().initTarget();
if ((isCancelled()) != null) {
cancelled();
return false;
}
if (isInterrupted()) {
return interrupted();
}
Obj target = getAction().getTargetObj();
AnimContext animContext = new AnimContext(getAction());
animContext.setTarget(target);
boolean gameLog = getAction().getLogger().isActivationLogged();
String targets = " ";
if (getAction().getLogger().isTargetLogged())
if (target != null) {
if (game.isDebugMode())
targets = getAction().getTargetObj().getNameAndCoordinate();
else
targets = getAction().getTargetObj().getNameIfKnown();
} else if (getAction().getTargetGroup() != null) {
targets = getAction().getTargetGroup().toString();
}
log(getAction().getOwnerObj().getNameAndCoordinate() + " activates " + getAction().getName() + " " + targets, false);
if (gameLog)
log(getAction().getOwnerObj().getNameIfKnown() + " activates " + getAction().getNameIfKnown() + " " + targets, true);
beingActivated();
if (isInterrupted()) {
return interrupted();
}
initActivation();
if (isInterrupted()) {
return interrupted();
}
resolve();
if (!BooleanMaster.isTrue(cancelled)) {
payCosts();
}
if (AnimMaster.isOn())
if (!AnimMaster.getInstance().getConstructor().isReconstruct())
AnimMaster.getInstance().getConstructor().preconstruct(getAction());
GuiEventManager.trigger(GuiEventType.ACTION_RESOLVES, new ActionInput(getAction(), animContext));
actionComplete();
return isResult();
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class DefaultActionHandler method leftClickCell.
public static boolean leftClickCell(boolean turn, boolean moveTo, int gridX, int gridY) {
Unit source = null;
try {
source = Eidolons.getGame().getManager().getActiveObj();
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
if (source == null)
return false;
if (source.isAiControlled())
return false;
Coordinates c = new Coordinates(gridX, gridY);
if (turn) {
return turnToMotion(source, c);
}
if (moveTo) {
return moveToMotion(source, c);
}
if (source.getGame().isDebugMode()) {
return doDebugStuffCell(source, c);
}
if (c.x - source.getX() > 1) {
return false;
}
if (c.y - source.getY() > 1) {
return false;
}
DC_UnitAction action = getMoveToCellAction(source, c);
if (action == null) {
return false;
}
Obj target = action.getTargeting() instanceof SelectiveTargeting ? Eidolons.getGame().getCellByCoordinate(c) : null;
Context context = new Context(source, target);
return activate(context, action);
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class MiniObjComp method clicked.
public void clicked(Point point) {
if (getObjects().size() < 2) {
obj.getGame().getManager().objClicked(obj);
return;
}
if (point.x < getWidth() / 3) {
if (point.y < getHeight() / 3) {
// CYCLE THRU OBJs
Obj choice = DialogMaster.objChoice("Which object?", getObjects().toArray(new Obj[getObjects().size()]));
if (choice != null) {
obj = (DC_Obj) choice;
obj.getGame().getManager().objClicked(obj);
}
return;
}
}
obj.getGame().getManager().objClicked(obj);
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class PatrolMaster method getBlockingUnit.
private static Unit getBlockingUnit(Patrol patrol, UnitAI ai) {
Unit unit = ai.getUnit();
DIRECTION direction = DirectionMaster.getRelativeDirection(unit.getCoordinates(), patrol.getDestination());
// paths.getOrCreate(unit);
Coordinates coordinates = unit.getCoordinates().getAdjacentCoordinate(direction);
// TODO more than 1 coordinate?
// unit.getGame().getUnitByCoordinate(coordinates);
Unit unitByCoordinate = null;
// preCheck leader?
Collection<Unit> units = unit.getGame().getUnitsForCoordinates(coordinates);
for (Obj u : units) {
// sort?
Unit blocker = (Unit) u;
// if (u == leader)
if (!blocker.isOwnedBy(ai.getUnit().getOwner())) {
continue;
}
if (!blocker.canMove()) {
continue;
}
unitByCoordinate = blocker;
}
return unitByCoordinate;
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class OwnershipChangeEffect method applyThis.
@Override
public boolean applyThis() {
if (!new Event(STANDARD_EVENT_TYPE.UNIT_OWNERSHIP_CHANGED, ref).fire()) {
return false;
}
// + trigger rule flip image when ownership changes ;)
Obj obj = ref.getTargetObj();
Player newOwner = obj.getOriginalOwner();
if (!neutral) {
newOwner = // ref.getSourceObj().getOwner();
((MicroGame) ref.getGame()).getPlayer(!obj.getOwner().isMe());
}
obj.setOwner(newOwner);
if (permanent) {
obj.setOriginalOwner(newOwner);
// obj.addProperty(G_PROPS.STATUS, STATUS.CHARMED.name());
}
if (berserker) {
}
LogMaster.log(LogMaster.CORE_DEBUG_1, ref.getTargetObj().getName() + "'s new owner: " + obj.getOwner());
return true;
}
Aggregations