From ffd248cfd45558597b62918e153064f5f58d0089 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 27 Feb 2024 14:36:27 -0500 Subject: [PATCH] Parse animation data --- src/engine/objects/ItemTemplate.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index eee1753a..d38cf34c 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -14,6 +14,7 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.pmw.tinylog.Logger; +import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; @@ -58,6 +59,8 @@ public class ItemTemplate { public float item_weapon_projectile_speed; public int item_weapon_combat_idle_anim; public HashMap item_weapon_damage = new HashMap<>(); + public ArrayList weapon_attack_anim_right = new ArrayList(); + public ArrayList weapon_attack_anim_left = new ArrayList(); public Enum.AttributeType item_primary_attr = Enum.AttributeType.None; public Enum.AttributeType item_secondary_attr = Enum.AttributeType.None; public EnumSet item_flags = EnumSet.noneOf(Enum.ItemFlags.class); @@ -206,6 +209,26 @@ public class ItemTemplate { item_weapon_damage.put(sourceType, minMax); } + JSONArray attack_anim_right = (JSONArray) jsonObject.get("weapon_attack_anim_right"); + + if (attack_anim_right.isEmpty() == false) + for (Object o : weapon_damage) { + JSONArray animationEntry = (JSONArray) o; + int animation = (int) animationEntry.get(0); + int duration = (int) animationEntry.get(1); + weapon_attack_anim_right.add(new int[]{animation, duration}); + } + + JSONArray attack_anim_left = (JSONArray) jsonObject.get("attack_anim_left"); + + if (attack_anim_left.isEmpty() == false) + for (Object o : weapon_damage) { + JSONArray animationEntry = (JSONArray) o; + int animation = (int) animationEntry.get(0); + int duration = (int) animationEntry.get(1); + weapon_attack_anim_left.add(new int[]{animation, duration}); + } + item_primary_attr = Enum.AttributeType.valueOf((String) jsonObject.get("item_primary_attr")); item_secondary_attr = Enum.AttributeType.valueOf((String) jsonObject.get("item_secondary_attr")); }