Refactored weapon recipes (broken)

This commit is contained in:
Anuken
2018-01-05 23:53:43 -05:00
parent a4cc149aab
commit e5ae5ae122
2 changed files with 32 additions and 4 deletions

View File

@@ -0,0 +1,31 @@
package io.anuke.mindustry.resource;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectMap.Entries;
import io.anuke.ucore.util.Mathf;
public class UpgradeRecipes {
private static final ObjectMap<Upgrade, ItemStack[]> recipes = Mathf.map(
Weapon.triblaster, list(stack(Item.iron, 40)),
Weapon.multigun, list(stack(Item.iron, 60), stack(Item.steel, 20)),
Weapon.flamer, list(stack(Item.steel, 60), stack(Item.iron, 120)),
Weapon.railgun, list(stack(Item.iron, 60), stack(Item.steel, 60)),
Weapon.mortar, list(stack(Item.titanium, 40), stack(Item.steel, 60))
);
public ItemStack[] get(Upgrade upgrade){
return recipes.get(upgrade);
}
public static Entries<Upgrade, ItemStack[]> getAllRecipes(){
return recipes.entries();
}
private static ItemStack[] list(ItemStack... stacks){
return stacks;
}
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);
}
}

View File

@@ -52,6 +52,7 @@ public class Weapon extends Upgrade{
shake = 2f;
}
};
float reload;
BulletType type;
String shootsound = "shoot";
@@ -92,8 +93,4 @@ public class Weapon extends Upgrade{
Angles.translation(angle, 3f);
new Bullet(type, owner, x + Angles.x(), y + Angles.y(), angle).add();
}
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);
}
}