package game.entity.npc; import game.init.SpeciesRegistry; import game.item.ItemStack; import game.item.RngLoot; import game.rng.Random; import game.rng.WeightedList; public class CharacterInfo { public final boolean spawner; public final SpeciesInfo species; public final ClassInfo spclass; public final String name; public final String skin; public final String cape; public final int color1; public final int color2; private final WeightedList[] items; public CharacterInfo(SpeciesInfo species, ClassInfo spclass, String name, String skin, String cape, int color1, int color2, boolean spawner) { this.spawner = spawner; // ? SpeciesRegistry.CHARACTERS.size() : -1; this.species = species; this.spclass = spclass; this.name = name; this.skin = skin; this.cape = cape; this.color1 = color1; this.color2 = color2; this.items = new WeightedList[6]; for(int z = 0; z < this.items.length; z++) { this.items[z] = new WeightedList(); } SpeciesRegistry.SKINS.put(skin, species.renderer); if(!cape.isEmpty()) { SpeciesRegistry.CAPES.add(cape); } if(spclass != null) spclass.chars.add(this); // if(spawner) // SpeciesRegistry.CHARACTERS.add(this); } public WeightedList[] getItems() { return this.items; } public ItemStack pickItem(int slot, Random rand) { WeightedList list = this.items[slot]; if(list.isEmpty()) { if(this.spclass != null) { list = this.spclass.getItems()[slot]; } if(this.spclass == null || list.isEmpty()) { list = this.species.getItems()[slot]; if(list.isEmpty()) { return null; } } } return list.pick(rand).getItem(rand); } }