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);
}
}
Aggregations