use of main.system.EventCallback in project Eidolons by IDemiurge.
the class GridPanel method onIngameEvent.
private EventCallback onIngameEvent() {
return param -> {
Event event = (Event) param.get();
Ref ref = event.getRef();
boolean caught = false;
if (event.getType() == STANDARD_EVENT_TYPE.EFFECT_HAS_BEEN_APPLIED) {
GuiEventManager.trigger(GuiEventType.EFFECT_APPLIED, event.getRef());
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_CHANGED_FACING || event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_TURNED_CLOCKWISE || event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_TURNED_ANTICLOCKWISE) {
BattleFieldObject hero = (BattleFieldObject) ref.getObj(KEYS.TARGET);
// if (hero.isMainHero()) TODO this is an experiment (insane) feature...
// if (hero.isMine()) {
// turnField(event.getType());
// }
BaseView view = viewMap.get(hero);
if (view != null && view instanceof GridUnitView) {
GridUnitView unitView = ((GridUnitView) view);
unitView.updateRotation(hero.getFacing().getDirection().getDegrees());
// SoundController.getCustomEventSound(SOUND_EVENT.UNIT_TURNS, );
if (hero instanceof Unit)
DC_SoundMaster.playTurnSound((Unit) hero);
}
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_FALLEN_UNCONSCIOUS) {
GuiEventManager.trigger(UNIT_GREYED_OUT_ON, ref.getSourceObj());
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_RECOVERED_FROM_UNCONSCIOUSNESS) {
GuiEventManager.trigger(UNIT_GREYED_OUT_OFF, ref.getSourceObj());
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_KILLED) {
GuiEventManager.trigger(UNIT_GREYED_OUT_OFF, ref.getSourceObj());
if (!DeathAnim.isOn() || ref.isDebug()) {
GuiEventManager.trigger(DESTROY_UNIT_MODEL, ref.getTargetObj());
}
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_BEING_MOVED) {
if (// || AnimMaster.isAnimationOffFor(ref.getSourceObj(), viewMap.get(ref.getSourceObj())))
!MoveAnimation.isOn())
removeUnitView((BattleFieldObject) ref.getSourceObj());
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_FINISHED_MOVING) {
if (!MoveAnimation.isOn() || AnimMaster.isAnimationOffFor(ref.getSourceObj(), viewMap.get(ref.getSourceObj())))
moveUnitView((BattleFieldObject) ref.getSourceObj());
caught = true;
} else if (event.getType().name().startsWith("PARAM_BEING_MODIFIED")) {
caught = true;
} else if (event.getType().name().startsWith("PROP_")) {
caught = true;
} else if (event.getType().name().startsWith("ABILITY_")) {
caught = true;
} else if (event.getType().name().startsWith("EFFECT_")) {
caught = true;
} else if (event.getType().name().startsWith("PARAM_MODIFIED")) {
if (GuiEventManager.isParamEventAlwaysFired(event.getType().getArg())) {
UnitView view = (UnitView) getViewMap().get(event.getRef().getSourceObj());
if (view != null)
if (view.isVisible())
if (view.getHpBar() != null)
// if (view.getHpBar( ).getDataSource().canHpBarBeVisible())
view.resetHpBar(new ResourceSourceImpl((BattleFieldObject) event.getRef().getSourceObj()));
}
caught = true;
}
if (!caught) {
/* System.out.println("catch ingame event: " + event.getType() + " in " + event.getRef());
*/
}
};
}
Aggregations