Search in sources :

Example 1 with WatchActionEffect

use of eidolons.ability.effects.oneshot.rule.WatchActionEffect in project Eidolons by IDemiurge.

the class WatchRule method updateWatchStatus.

public void updateWatchStatus(Unit watcher) {
    List<DC_Obj> list = getWatchersMap().get(watcher);
    boolean invalid = false;
    if (list != null) {
        if (!checkValidWatcher(watcher)) {
            invalid = true;
            removeWatcher(watcher);
        } else {
            for (DC_Obj watched : list) {
                if (!checkValidWatchTarget(watched)) {
                    breakWatch(watcher, watched);
                    break;
                } else if (!checkValidWatchPairTarget(watcher, watched)) {
                    breakWatch(watcher, watched);
                    break;
                }
            }
        }
    }
    BuffObj buff = watcher.getBuff("Watching", false);
    if (buff != null) {
        watcher.getGame().getManager().buffRemoved(buff);
    }
    if (!invalid) {
        if (watcher.getMode().equals(STD_MODES.ALERT)) {
            Ref ref = watcher.getRef().getCopy();
            try {
                SpectrumEffect spectrumEffect = new SpectrumEffect(new OwnershipCondition(true, "match", "source"), new WatchActionEffect(true));
                spectrumEffect.setRangeFormula(StringMaster.getValueRef(KEYS.SOURCE, PARAMS.SIGHT_RANGE));
                // for now...
                spectrumEffect.setApplyThrough(false);
                spectrumEffect.apply(ref);
                watcher.getBuff(STD_MODES.ALERT.getBuffName(), false).setOnDispelEffects(new RemoveBuffEffect("Watching ", false));
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
    }
    list = getWatchersMap().get(watcher);
    if (ListMaster.isNotEmpty(list)) // TODO alert???
    {
        getWatchBuffEffect(watcher, list).apply(Ref.getSelfTargetingRefCopy(watcher));
    }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Ref(main.entity.Ref) OwnershipCondition(main.elements.conditions.standard.OwnershipCondition) RemoveBuffEffect(eidolons.ability.effects.oneshot.buff.RemoveBuffEffect) BuffObj(main.entity.obj.BuffObj) SpectrumEffect(eidolons.ability.effects.common.SpectrumEffect) WatchActionEffect(eidolons.ability.effects.oneshot.rule.WatchActionEffect)

Aggregations

SpectrumEffect (eidolons.ability.effects.common.SpectrumEffect)1 RemoveBuffEffect (eidolons.ability.effects.oneshot.buff.RemoveBuffEffect)1 WatchActionEffect (eidolons.ability.effects.oneshot.rule.WatchActionEffect)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 OwnershipCondition (main.elements.conditions.standard.OwnershipCondition)1 Ref (main.entity.Ref)1 BuffObj (main.entity.obj.BuffObj)1