use of main.game.logic.event.Event 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 main.game.logic.event.Event in project Eidolons by IDemiurge.
the class UnconsciousRule method fallUnconscious.
public static void fallUnconscious(Unit unit) {
if (unit.getAI().isOutsideCombat()) {
unit.getAI().isOutsideCombat();
}
unit.getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_FALLEN_UNCONSCIOUS, unit.getRef()));
DC_SoundMaster.playEffectSound(SOUNDS.DEATH, unit);
DC_SoundMaster.playEffectSound(SOUNDS.FALL, unit);
getUnconsciousEffect(unit).apply();
unit.getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_FALLS_UNCONSCIOUS, unit.getRef()));
unit.getGame().getLogManager().newLogEntryNode(ENTRY_TYPE.UNCONSCIOUS, unit);
// double regen? what's with focus, stamina, essence, morale? ... some
// may be reset, others reduced, others regen
}
use of main.game.logic.event.Event in project Eidolons by IDemiurge.
the class UnconsciousRule method unitRecovers.
private static void unitRecovers(Unit unit) {
// unit.removeBuff(BUFF_NAME);
unit.getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_RECOVERED_FROM_UNCONSCIOUSNESS, unit.getRef()));
// remove buff pretty much
getWakeUpEffect(unit).apply();
unit.getGame().getLogManager().newLogEntryNode(ENTRY_TYPE.CONSCIOUS, unit);
// event
}
use of main.game.logic.event.Event in project Eidolons by IDemiurge.
the class AtbController method processTimeElapsed.
private void processTimeElapsed(Float time) {
addTime(time);
getManager().getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.TIME_ELAPSED, new Ref(Math.round(time * TIME_LOGIC_MODIFIER))));
GuiEventManager.trigger(GuiEventType.TIME_PASSED, time);
GuiEventManager.trigger(GuiEventType.NEW_ATB_TIME, this.time);
if (this.time >= TIME_IN_ROUND) {
addTime(-TIME_IN_ROUND);
manager.getGame().getStateManager().newRound();
newRound();
}
if (!isPrecalc())
manager.getGame().getLogManager().log(getTimeString(time) + " passed, " + getTimeString(TIME_IN_ROUND - this.time) + " until end of round");
for (AtbUnit unit : this.unitsInAtb) {
unit.setAtbReadiness(unit.getAtbReadiness() + time * unit.getInitiative());
}
if (!isPrecalc())
manager.getGame().getManager().atbTimeElapsed(time);
}
use of main.game.logic.event.Event in project Eidolons by IDemiurge.
the class DC_StateManager method endTurn.
public void endTurn() {
try {
if (game.isStarted()) {
applyEndOfTurnRules();
applyEndOfTurnDamage();
}
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
try {
new Event(STANDARD_EVENT_TYPE.ROUND_ENDS, new Ref(getGame())).fire();
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
Aggregations