Search in sources :

Example 6 with Attachment

use of main.entity.obj.Attachment 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

Attachment (main.entity.obj.Attachment)6 BuffObj (main.entity.obj.BuffObj)4 DC_BuffObj (eidolons.entity.obj.attach.DC_BuffObj)3 Effect (main.ability.effects.Effect)2 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 DC_SpellObj (eidolons.entity.active.DC_SpellObj)1 DC_ArmorObj (eidolons.entity.item.DC_ArmorObj)1 DC_HeroSlotItem (eidolons.entity.item.DC_HeroSlotItem)1 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)1 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_FeatObj (eidolons.entity.obj.attach.DC_FeatObj)1 Unit (eidolons.entity.obj.unit.Unit)1 AbilityObj (main.ability.AbilityObj)1 PassiveAbilityObj (main.ability.PassiveAbilityObj)1 Ref (main.entity.Ref)1 Obj (main.entity.obj.Obj)1 Event (main.game.logic.event.Event)1 ANIM (main.system.graphics.ANIM)1 AnimPhase (main.system.graphics.AnimPhase)1