Browse Source

Refactor of animations

combat-2
MagicBot 8 months ago
parent
commit
ef38e93c11
  1. 28
      src/engine/db/handlers/dbItemBaseHandler.java
  2. 36
      src/engine/gameManager/CombatManager.java
  3. 25
      src/engine/objects/ItemBase.java

28
src/engine/db/handlers/dbItemBaseHandler.java

@ -26,34 +26,6 @@ public class dbItemBaseHandler extends dbHandlerBase { @@ -26,34 +26,6 @@ public class dbItemBaseHandler extends dbHandlerBase {
}
public void LOAD_ANIMATIONS(ItemBase itemBase) {
ArrayList<Integer> tempList = new ArrayList<>();
ArrayList<Integer> tempListOff = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_itembase_animations` WHERE `itemBaseUUID` = ?")) {
preparedStatement.setInt(1, itemBase.getUUID());
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
int animation = rs.getInt("animation");
boolean rightHand = rs.getBoolean("rightHand");
if (rightHand)
tempList.add(animation);
else
tempListOff.add(animation);
}
} catch (SQLException e) {
Logger.error(e);
}
itemBase.setAnimations(tempList);
itemBase.setOffHandAnimations(tempListOff);
}
public void LOAD_ALL_ITEMBASES() {
ItemBase itemBase;

36
src/engine/gameManager/CombatManager.java

@ -982,66 +982,66 @@ public enum CombatManager { @@ -982,66 +982,66 @@ public enum CombatManager {
if (wb == null)
return 75;
ItemTemplate template = ItemTemplate.itemTemplates.get(wb.getUUID());
if (mainHand) {
if (wb.getAnimations().size() > 0) {
if (template.weapon_attack_anim_right.size() > 0) {
int animation;
int random = ThreadLocalRandom.current().nextInt(wb.getAnimations().size());
int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_right.size());
try {
animation = wb.getAnimations().get(random);
animation = template.weapon_attack_anim_right.get(random)[0];
return animation;
} catch (Exception e) {
Logger.error(e.getMessage());
return wb.getAnimations().get(0);
return template.weapon_attack_anim_right.get(0)[0];
}
} else if (wb.getOffHandAnimations().size() > 0) {
} else if (template.weapon_attack_anim_left.size() > 0) {
int animation;
int random = ThreadLocalRandom.current().nextInt(wb.getOffHandAnimations().size());
int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size());
try {
animation = wb.getOffHandAnimations().get(random);
animation = template.weapon_attack_anim_left.get(random)[0];
return animation;
} catch (Exception e) {
Logger.error(e.getMessage());
return wb.getOffHandAnimations().get(0);
return template.weapon_attack_anim_right.get(0)[0];
}
}
} else {
if (wb.getOffHandAnimations().size() > 0) {
if (template.weapon_attack_anim_left.size() > 0) {
int animation;
int random = ThreadLocalRandom.current().nextInt(wb.getOffHandAnimations().size());
int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size());
try {
animation = wb.getOffHandAnimations().get(random);
animation = template.weapon_attack_anim_left.get(random)[0];
return animation;
} catch (Exception e) {
Logger.error(e.getMessage());
return wb.getOffHandAnimations().get(0);
return template.weapon_attack_anim_right.get(0)[0];
}
} else if (wb.getAnimations().size() > 0) {
} else if (template.weapon_attack_anim_left.size() > 0) {
int animation;
int random = ThreadLocalRandom.current().nextInt(wb.getAnimations().size());
int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size());
try {
animation = wb.getAnimations().get(random);
animation = template.weapon_attack_anim_left.get(random)[0];
return animation;
} catch (Exception e) {
Logger.error(e.getMessage());
return wb.getAnimations().get(0);
return template.weapon_attack_anim_right.get(0)[0];
}
}
}
ItemTemplate template = ItemTemplate.itemTemplates.get(wb.getUUID());
String required = template.item_skill_used;
String mastery = wb.getMastery();

25
src/engine/objects/ItemBase.java

@ -42,8 +42,6 @@ public class ItemBase { @@ -42,8 +42,6 @@ public class ItemBase {
private final engine.Enum.SourceType damageType;
private boolean isConsumable;
private final boolean isStrBased;
private ArrayList<Integer> animations = new ArrayList<>();
private ArrayList<Integer> offHandAnimations = new ArrayList<>();
public ItemBase(ResultSet rs) throws SQLException {
@ -84,12 +82,6 @@ public class ItemBase { @@ -84,12 +82,6 @@ public class ItemBase {
this.isConsumable = true;
break;
}
try {
DbManager.ItemBaseQueries.LOAD_ANIMATIONS(this);
} catch (Exception e) {
Logger.error(e.getMessage());
}
initializeHashes();
}
@ -204,7 +196,6 @@ public class ItemBase { @@ -204,7 +196,6 @@ public class ItemBase {
public short getMinDamage() {
return minDamage;
}
public Enum.SourceType getDamageType() {
return damageType;
}
@ -213,20 +204,4 @@ public class ItemBase { @@ -213,20 +204,4 @@ public class ItemBase {
return percentRequired;
}
public ArrayList<Integer> getAnimations() {
return animations;
}
public void setAnimations(ArrayList<Integer> animations) {
this.animations = animations;
}
public ArrayList<Integer> getOffHandAnimations() {
return offHandAnimations;
}
public void setOffHandAnimations(ArrayList<Integer> offHandAnimations) {
this.offHandAnimations = offHandAnimations;
}
}

Loading…
Cancel
Save