Refactored out duplicate power collection.

This commit is contained in:
2023-08-31 13:42:15 -04:00
parent 11c154e564
commit 55c6e3cf93
5 changed files with 53 additions and 42 deletions
+19 -1
View File
@@ -53,7 +53,7 @@ public enum PowersManager {
public static HashMap<Integer, AbstractPowerAction> powerActionsByID = new HashMap<>();
public static HashMap<String, Integer> ActionTokenByIDString = new HashMap<>();
public static HashMap<String, Integer> AnimationOverrides = new HashMap<>();
public static HashMap<Integer, ArrayList<MobPowerEntry>> AllMobPowers;
public static HashMap<Integer, ArrayList<MobPowerEntry>> _allMobPowers;
private static JobScheduler js;
private PowersManager() {
@@ -103,6 +103,24 @@ public enum PowersManager {
}
}
public static ArrayList<MobPowerEntry> getPowersForMobile(Mob mobile) {
ArrayList<MobPowerEntry> mobPowers = new ArrayList<>();
ArrayList<MobPowerEntry> powerEntries;
powerEntries = PowersManager._allMobPowers.get(mobile.loadID);
if (powerEntries != null)
mobPowers.addAll(powerEntries);
powerEntries = PowersManager._allMobPowers.get(mobile.contractUUID);
if (powerEntries != null)
mobPowers.addAll(powerEntries);
return mobPowers;
}
// This pre-loads all powers and effects
public static void InitializePowers() {