use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DeathMaster method unitDies.
public void unitDies(DC_ActiveObj activeObj, Obj _killed, Obj _killer, boolean leaveCorpse, boolean quietly) {
if (_killed.isDead())
return;
String message = null;
if (_killed == _killer) {
// + _killed.getInfoString();
message = _killed + " dies ";
} else
message = _killed + " killed by " + _killer + " with " + activeObj;
SpecialLogger.getInstance().appendSpecialLog(SPECIAL_LOG.MAIN, message);
_killed.setDead(true);
BattleFieldObject killed = (BattleFieldObject) _killed;
BattleFieldObject killer = (BattleFieldObject) _killer;
Ref ref = Ref.getCopy(killed.getRef());
ref.setSource(killer.getId());
ref.setTarget(killed.getId());
for (AbilityObj abil : killed.getPassives()) {
abil.kill();
}
if (killed.getBuffs() != null) {
for (Attachment attach : killed.getBuffs()) {
if (!attach.isRetainAfterDeath()) {
getState().getAttachmentsMap().get(killed).remove(attach);
attach.remove();
}
}
}
if (!leaveCorpse) {
// leave a *ghost*?
// destroy items?
} else {
if (killed instanceof Unit) {
try {
getGame().getDroppedItemManager().dropDead((Unit) killed);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
try {
getGame().getGraveyardManager().unitDies(killed);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
// getGame().getBattleField().remove(killed); // TODO GRAVEYARD
if (!quietly) {
Ref REF = Ref.getCopy(killer.getRef());
REF.setTarget(killed.getId());
REF.setSource(killer.getId());
if (activeObj != null)
REF.setObj(KEYS.ACTIVE, activeObj);
if (killed instanceof Unit) {
getGame().getRules().getMoraleKillingRule().unitDied((Unit) killed, killer.getRef().getAnimationActive());
}
LogEntryNode node = game.getLogManager().newLogEntryNode(ENTRY_TYPE.DEATH, killed);
if (killer.getRef().getAnimationActive() != null) {
ANIM animation = killer.getRef().getAnimationActive().getAnimation();
if (animation != null) {
animation.addPhase(new AnimPhase(PHASE_TYPE.DEATH, killer, killed));
node.setLinkedAnimation(animation);
}
}
DC_SoundMaster.playEffectSound(SOUNDS.DEATH, killed);
game.getLogManager().logDeath(killed, killer);
getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_KILLED, REF));
game.getLogManager().doneLogEntryNode();
} else {
GuiEventManager.trigger(GuiEventType.DESTROY_UNIT_MODEL, killed);
}
// refreshAll();
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class ObjCreator method createUnit.
public MicroObj createUnit(ObjType type, int x, int y, Player owner, Ref ref) {
if (!CoreEngine.isArcaneVault()) {
if (!CoreEngine.isLevelEditor()) {
if (!type.isGenerated()) {
type = new ObjType(type);
game.initType(type);
}
}
}
if (!CoreEngine.isLevelEditor())
if (!CoreEngine.isArcaneVault())
type = checkTypeSubstitution(type, ref);
BattleFieldObject obj = null;
if (type.checkProperty(G_PROPS.BF_OBJECT_GROUP, BfObjEnums.BF_OBJECT_GROUP.ENTRANCE.toString())) {
// TODO obj = new Entrance(x, y, type, getGame().getDungeon(), null);
return null;
} else if (type.getOBJ_TYPE_ENUM() == DC_TYPE.BF_OBJ) {
obj = newStructure(type, x, y, owner, ref);
} else {
obj = new Unit(type, x, y, owner, getGame(), ref);
}
if (CoreEngine.isLevelEditor()) {
return obj;
}
// if (WaitMaster.getCompleteOperations().contains(WAIT_OPERATIONS.DUNGEON_SCREEN_READY))
GuiEventManager.trigger(GuiEventType.UNIT_CREATED, obj);
game.getState().addObject(obj);
if (obj instanceof Unit)
game.getState().getManager().reset((Unit) obj);
else {
obj.toBase();
obj.resetObjects();
obj.afterEffects();
}
return obj;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_Game method createUnit.
@Override
public MicroObj createUnit(ObjType type, int x, int y, Player owner, Ref ref) {
BattleFieldObject unit = ((BattleFieldObject) super.createUnit(type, x, y, owner, ref.getCopy()));
game.getState().addObject(unit);
unit.toBase();
unit.resetObjects();
unit.afterEffects();
return unit;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_GameManager method resetValues.
// a single-method spell, Warp Time: take another turn...
public void resetValues(Player owner) {
for (Obj obj : getGame().getBfObjects()) {
BattleFieldObject unit = null;
if (obj instanceof BattleFieldObject) {
unit = (BattleFieldObject) obj;
if (owner == null || unit.getOwner() == owner) {
unit.newRound();
}
}
unit.regen();
}
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_GameMaster method getObjectsOnCoordinate.
public List<BattleFieldObject> getObjectsOnCoordinate(Integer z, Coordinates c, Boolean overlayingIncluded, boolean passableIncluded, boolean cellsIncluded) {
// TODO auto adding cells won't work!
if (c == null) {
return null;
}
if (z == null) {
z = getGame().getDungeon().getZ();
}
List<BattleFieldObject> list = null;
if (// TODO support multi-z?
z == 0)
if (getCache(overlayingIncluded) != null)
list = getCache(overlayingIncluded).get(c);
if (list != null) {
return list;
}
list = new XList<>();
for (BattleFieldObject object : getGame().getBfObjects()) {
if (overlayingIncluded != null) {
if (overlayingIncluded) {
if (!object.isOverlaying()) {
continue;
}
} else {
if (object.isOverlaying()) {
continue;
}
}
}
if (object.getZ() != z) {
continue;
}
if (object.getCoordinates().equals(c)) {
list.add(object);
}
}
// if (overlayingIncluded == null)
if (z == 0)
if (getCache(overlayingIncluded) != null) {
getCache(overlayingIncluded).put(c, list);
}
return list;
}
Aggregations