@Override public int getComplexity() { if (complexityOverride != null) { return complexityOverride; } return GeneticsUtil.getResearchComplexity(this, getRoot().getSpeciesChromosomeType()); }
@ModuleContainerObjectMethod.Inject( module = IntegrationForestry.analyzerMod, worldThread = false, modId = Constants.MOD_ID, doc = "function(root:string):table -- Get a list of all species in the given species root" ) public static Object[] getSpeciesList(IContext<IModuleContainer> context, Object[] args) throws LuaException { String uid = ArgumentHelper.getString(args, 0); ISpeciesRoot root = getSpeciesRoot(uid); // please don't hurt me squid LuaList<Object> species = alleleRegistry.getRegisteredAlleles(root.getSpeciesChromosomeType()).stream() .map(IAlleleSpecies.class::cast) .filter(s -> !s.isSecret()) .map(MetaGenome::getAlleleMeta) .collect(LuaList.toLuaList()); return new Object[]{species.asMap()}; }
public static List<SequencerRecipeWrapper> create() { List<SequencerRecipeWrapper> recipes = new ArrayList<>(); Collection<ISpeciesRoot> roots = AlleleManager.alleleRegistry.getSpeciesRoot().values(); for (ISpeciesRoot root : roots) { IChromosomeType speciesChromosomeType = root.getSpeciesChromosomeType(); IAllele[] defaultTemplate = root.getDefaultTemplate(); IAllele species = defaultTemplate[speciesChromosomeType.ordinal()]; ItemStack filledSequence = ItemSequence.create(new Gene(species, speciesChromosomeType, root), false); recipes.add(new SequencerRecipeWrapper(filledSequence)); filledSequence = filledSequence.copy(); filledSequence.setItemDamage(0); recipes.add(new SequencerRecipeWrapper(filledSequence)); } return recipes; } }
public static List<IsolatorRecipeWrapper> create() { List<IsolatorRecipeWrapper> recipes = new ArrayList<>(); Collection<ISpeciesRoot> roots = AlleleManager.alleleRegistry.getSpeciesRoot().values(); for (ISpeciesRoot root : roots) { ISpeciesType[] speciesTypes = root.getIconType().getClass().getEnumConstants(); IChromosomeType speciesChromosomeType = root.getSpeciesChromosomeType(); IAllele[] defaultTemplate = root.getDefaultTemplate(); IIndividual individual = root.templateAsIndividual(defaultTemplate); for (ISpeciesType speciesType : speciesTypes) { ItemStack memberStack = root.getMemberStack(individual, speciesType); memberStack.setItemDamage(OreDictionary.WILDCARD_VALUE); IAllele species = defaultTemplate[speciesChromosomeType.ordinal()]; ItemStack filledSequence = ItemSequence.create(new Gene(species, speciesChromosomeType, root), false); IsolatorRecipeWrapper recipeWrapper = new IsolatorRecipeWrapper(memberStack, filledSequence); recipes.add(recipeWrapper); } } return recipes; } }
public boolean initialize(ItemStack specimen) { IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen); if (individual == null) { return false; } IGenome genome = individual.getGenome(); ISpeciesRoot root = genome.getPrimary().getRoot(); tokenCount = getTokenCount(genome); for (int i = 0; i < tokenCount / 2; i++) { IAllele[] randomTemplate = root.getRandomTemplate(rand); String speciesUid = randomTemplate[root.getSpeciesChromosomeType().ordinal()].getUID(); gameTokens.add(new EscritoireGameToken(speciesUid)); gameTokens.add(new EscritoireGameToken(speciesUid)); } Collections.shuffle(gameTokens); return true; }
String mutationChanceKey = EnumMutateChance.rateChance(encoded.getBaseChance()).toString().toLowerCase(Locale.ENGLISH); String mutationChance = Translator.translateToLocal("for.researchNote.chance." + mutationChanceKey); String speciesResult = encoded.getTemplate()[root.getSpeciesChromosomeType().ordinal()].getAlleleName();
/** * Quickly gets the species without loading the whole genome. * We need this because the client uses the species for rendering. */ @Nullable public static IAlleleSpecies getSpeciesDirectly(ISpeciesRoot speciesRoot, ItemStack itemStack) { NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); if (nbtTagCompound == null) { return null; } NBTTagCompound genomeNBT = nbtTagCompound.getCompoundTag("Genome"); if (genomeNBT.isEmpty()) { return null; } NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10); if (chromosomesNBT.isEmpty()) { return null; } NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(0); Chromosome chromosome = Chromosome.create(null, null, speciesRoot.getSpeciesChromosomeType(), chromosomeNBT); IAllele activeAllele = chromosome.getActiveAllele(); if (!(activeAllele instanceof IAlleleSpecies)) { return null; } return (IAlleleSpecies) activeAllele; }
@Nullable public IElementGroup createMutation(int x, int y, int width, int height, IMutation mutation, IAllele species, IBreedingTracker breedingTracker) { if (breedingTracker.isDiscovered(mutation)) { PaneLayout element = new PaneLayout(x, y, width, height); ISpeciesRoot speciesRoot = mutation.getRoot(); int speciesIndex = speciesRoot.getSpeciesChromosomeType().ordinal(); IDatabasePlugin plugin = mutation.getRoot().getSpeciesPlugin(); Map<String, ItemStack> iconStacks = plugin.getIndividualStacks(); ItemStack partner = iconStacks.get(mutation.getPartner(species).getUID()); IAllele resultAllele = mutation.getTemplate()[speciesIndex]; ItemStack result = iconStacks.get(resultAllele.getUID()); element.add(new ItemElement(0, 0, partner), new ItemElement(33, 0, result)); createProbabilityArrow(element, mutation, 18, 4, breedingTracker); return element; } // Do not display secret undiscovered mutations. if (mutation.isSecret()) { return null; } return createUnknownMutationGroup(x, y, width, height, mutation, breedingTracker); }
IChromosomeType speciesChromosomeType = root.getSpeciesChromosomeType(); IAllele[] defaultTemplate = root.getDefaultTemplate(); IIndividual individual = root.templateAsIndividual(defaultTemplate);
private static IChromosome[] getChromosomes(NBTTagCompound genomeNBT, ISpeciesRoot speciesRoot) { NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10); IChromosome[] chromosomes = new IChromosome[speciesRoot.getDefaultTemplate().length]; String primarySpeciesUid = null; String secondarySpeciesUid = null; for (int i = 0; i < chromosomesNBT.tagCount(); i++) { NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(i); byte chromosomeOrdinal = chromosomeNBT.getByte(SLOT_TAG); if (chromosomeOrdinal >= 0 && chromosomeOrdinal < chromosomes.length) { IChromosomeType chromosomeType = speciesRoot.getKaryotype()[chromosomeOrdinal]; Chromosome chromosome = Chromosome.create(primarySpeciesUid, secondarySpeciesUid, chromosomeType, chromosomeNBT); chromosomes[chromosomeOrdinal] = chromosome; if (chromosomeOrdinal == speciesRoot.getSpeciesChromosomeType().ordinal()) { primarySpeciesUid = chromosome.getPrimaryAllele().getUID(); secondarySpeciesUid = chromosome.getSecondaryAllele().getUID(); } } } return chromosomes; }
ISpeciesRoot speciesRoot = gene.getSpeciesRoot(); IAllele allele = gene.getAllele(); if (chromosomeType == speciesRoot.getSpeciesChromosomeType()) { template = speciesRoot.getTemplate(allele.getUID()); } else {
IAlleleSpecies speciesResult = (IAlleleSpecies) encoded.getTemplate()[root.getSpeciesChromosomeType().ordinal()];
ISpeciesRoot speciesRoot = individual.getGenome().getSpeciesRoot(); IAlleleSpecies species = individual.getGenome().getPrimary(); ItemStack serum = ItemSerum.create(new Gene(species, speciesRoot.getSpeciesChromosomeType(), speciesRoot)); serum.setItemDamage(0); // set fully charged