Search in sources :

Example 16 with BuffObj

use of main.entity.obj.BuffObj in project Eidolons by IDemiurge.

the class HeroManager method update.

public void update(Unit hero, boolean refresh) {
    // hero.setItemsInitialized(false);
    if (hero == null) {
        return;
    }
    for (DC_HeroSlotItem item : hero.getSlotItems()) {
        if (item != null) {
            if (item.getAttachments() != null) {
                item.getAttachments().clear();
                for (BuffObj buff : item.getBuffs()) {
                    buff.kill();
                }
            }
        }
    }
    hero.toBase();
    if (game.isSimulation()) {
        List<Attachment> attachments = hero.getAttachments();
        List<Effect> secondLayerEffects = new ArrayList<>();
        if (attachments != null) {
            for (Attachment a : attachments) {
                try {
                    for (Effect e : a.getEffects()) {
                        if (e.getLayer() != Effect.SECOND_LAYER) {
                            e.apply(Ref.getSelfTargetingRefCopy(hero));
                        } else {
                            secondLayerEffects.add(e);
                        }
                    }
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            }
        }
        for (Effect e : secondLayerEffects) {
            e.apply(Ref.getSelfTargetingRefCopy(hero));
        }
        EffectFinder.applyAttachmentEffects(hero.getMainWeapon(), null);
        EffectFinder.applyAttachmentEffects(hero.getOffhandWeapon(), null);
        EffectFinder.applyAttachmentEffects(hero.getArmor(), null);
    }
    hero.afterEffects();
    hero.setDirty(true);
    if (!hero.getGame().isSimulation()) {
        try {
            hero.resetObjects();
            hero.resetQuickSlotsNumber();
            refreshInvWindow();
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
        return;
    }
    if (refresh) {
        refresh(hero);
    }
}
Also used : Attachment(main.entity.obj.Attachment) Effect(main.ability.effects.Effect) BuffObj(main.entity.obj.BuffObj) DC_HeroSlotItem(eidolons.entity.item.DC_HeroSlotItem)

Aggregations

BuffObj (main.entity.obj.BuffObj)16 Obj (main.entity.obj.Obj)5 DC_BuffObj (eidolons.entity.obj.attach.DC_BuffObj)4 Effect (main.ability.effects.Effect)4 Attachment (main.entity.obj.Attachment)4 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)3 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)3 ArrayList (java.util.ArrayList)3 Ref (main.entity.Ref)3 RemoveBuffEffect (eidolons.ability.effects.oneshot.buff.RemoveBuffEffect)2 DC_Obj (eidolons.entity.obj.DC_Obj)2 SpectrumEffect (eidolons.ability.effects.common.SpectrumEffect)1 BehaviorModeEffect (eidolons.ability.effects.continuous.BehaviorModeEffect)1 WatchActionEffect (eidolons.ability.effects.oneshot.rule.WatchActionEffect)1 ImmobilizeEffect (eidolons.ability.effects.oneshot.status.ImmobilizeEffect)1 DC_SpellObj (eidolons.entity.active.DC_SpellObj)1 DC_HeroSlotItem (eidolons.entity.item.DC_HeroSlotItem)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_HeroAttachedObj (eidolons.entity.obj.attach.DC_HeroAttachedObj)1 Unit (eidolons.entity.obj.unit.Unit)1