mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-01 02:14:32 +07:00
Moved alternate listener to separate CharData.AlternateListener class
This change removed need for EquipAdapter
This commit is contained in:
parent
997c57ad5e
commit
6cbea53c19
@ -71,6 +71,8 @@ public class CharData {
|
||||
|
||||
private byte[] data; // TODO: replace this reference with D2S.serialize(CharData)
|
||||
|
||||
final Array<AlternateListener> alternateListeners = new Array<>(false, 16);
|
||||
|
||||
final IntIntMap skills = new IntIntMap();
|
||||
final Array<Stat> chargedSkills = new Array<>(false, 16);
|
||||
final Array<SkillListener> skillListeners = new Array<>(false, 16);
|
||||
@ -156,6 +158,8 @@ public class CharData {
|
||||
mercData.itemData.clear();
|
||||
golemItemData = null;
|
||||
|
||||
alternateListeners.clear();
|
||||
|
||||
skills.clear();
|
||||
chargedSkills.clear();
|
||||
skillListeners.clear();
|
||||
@ -467,7 +471,7 @@ public class CharData {
|
||||
Item LH = getEquipped(BodyLoc.LARM);
|
||||
Item RH = getEquipped(BodyLoc.RARM);
|
||||
updateStats();
|
||||
itemData.notifyEquipmentAlternated(alternate, LH, RH);
|
||||
notifyAlternated(alternate, LH, RH);
|
||||
}
|
||||
}
|
||||
|
||||
@ -494,6 +498,7 @@ public class CharData {
|
||||
public void clearListeners() {
|
||||
itemData.equipListeners.clear();
|
||||
mercData.itemData.equipListeners.clear();
|
||||
alternateListeners.clear();
|
||||
skillListeners.clear();
|
||||
}
|
||||
|
||||
@ -509,4 +514,17 @@ public class CharData {
|
||||
public interface SkillListener {
|
||||
void onChanged(CharData client, IntIntMap skills, Array<Stat> chargedSkills);
|
||||
}
|
||||
|
||||
public boolean addAlternateListener(AlternateListener l) {
|
||||
alternateListeners.add(l);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void notifyAlternated(int alternate, Item LH, Item RH) {
|
||||
for (AlternateListener l : alternateListeners) l.onAlternated(this, alternate, LH, RH);
|
||||
}
|
||||
|
||||
public interface AlternateListener {
|
||||
void onAlternated(CharData charData, int alternate, Item LH, Item RH);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
package com.riiablo.save;
|
||||
|
||||
import com.riiablo.item.BodyLoc;
|
||||
import com.riiablo.item.Item;
|
||||
|
||||
public class EquipAdapter implements ItemData.EquipListener {
|
||||
@Override public void onChanged(ItemData items, BodyLoc bodyLoc, Item oldItem, Item item) {}
|
||||
@Override public void onAlternated(ItemData items, int alternate, Item LH, Item RH) {}
|
||||
}
|
@ -146,16 +146,11 @@ public class ItemData {
|
||||
return true;
|
||||
}
|
||||
|
||||
void notifyEquipmentChanged(BodyLoc bodyLoc, Item oldItem, Item item) {
|
||||
private void notifyEquipmentChanged(BodyLoc bodyLoc, Item oldItem, Item item) {
|
||||
for (EquipListener l : equipListeners) l.onChanged(this, bodyLoc, oldItem, item);
|
||||
}
|
||||
|
||||
void notifyEquipmentAlternated(int alternate, Item LH, Item RH) {
|
||||
for (EquipListener l : equipListeners) l.onAlternated(this, alternate, LH, RH);
|
||||
}
|
||||
|
||||
public interface EquipListener {
|
||||
void onChanged(ItemData items, BodyLoc bodyLoc, Item oldItem, Item item);
|
||||
void onAlternated(ItemData items, int alternate, Item LH, Item RH);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user