Search in sources :

Example 11 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class WindowGenesis method refreshTemplate.

private void refreshTemplate(@Nullable IChromosomeType selection) {
    List<Gene> genes = new ArrayList<>();
    IChromosomeType[] chromosomeTypes = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(new IChromosomeType[0]);
    for (IChromosomeType type : chromosomeTypes) {
        IAllele allele = this.template[type.ordinal()];
        if (allele == null) {
            throw new NullPointerException("Allele missing for Chromosome " + type.getName());
        }
        genes.add(new Gene(allele, type, this.root));
    }
    geneList.setOptions(genes);
    if (selection != null) {
        this.geneList.setValue(new Gene(this.template[selection.ordinal()], selection, this.root));
    } else {
        this.geneOptions.setOptions(new ArrayList<>());
    }
    this.refreshPickup();
}
Also used : IAllele(forestry.api.genetics.IAllele) Gene(binnie.core.genetics.Gene) ArrayList(java.util.ArrayList) IChromosomeType(forestry.api.genetics.IChromosomeType)

Example 12 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class IsolatorLogic method onFinishTask.

@Override
protected void onFinishTask() {
    super.onFinishTask();
    final Random rand = this.getMachine().getWorld().rand;
    MachineUtil util = this.getUtil();
    final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(util.getStack(Isolator.SLOT_TARGET));
    if (root == null) {
        return;
    }
    final IIndividual individual = root.getMember(util.getStack(Isolator.SLOT_TARGET));
    if (individual == null) {
        return;
    }
    IChromosomeType[] karyotype = root.getKaryotype();
    IChromosomeType chromosome = karyotype[rand.nextInt(karyotype.length)];
    IGenome genome = individual.getGenome();
    IAllele allele = rand.nextBoolean() ? genome.getActiveAllele(chromosome) : genome.getInactiveAllele(chromosome);
    Gene gene = Gene.create(allele, chromosome, root);
    final ItemStack serum = ItemSequence.create(gene);
    util.setStack(Isolator.SLOT_RESULUT, serum);
    util.decreaseStack(Isolator.SLOT_SEQUENCER_VIAL, 1);
    if (rand.nextFloat() < TARGET_LOSS_CHANCE) {
        util.decreaseStack(Isolator.SLOT_TARGET, 1);
    }
    util.drainTank(Isolator.TANK_ETHANOL, ETHANOL_PER_PROCESS);
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) IAllele(forestry.api.genetics.IAllele) IGenome(forestry.api.genetics.IGenome) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) Random(java.util.Random) IIndividual(forestry.api.genetics.IIndividual) Gene(binnie.core.genetics.Gene) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack)

Example 13 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class ToleranceSystem method alter.

public ItemStack alter(final ItemStack stack, final ItemStack acc) {
    final Random rand = new Random();
    final float effect = this.type.getEffect(acc);
    if (rand.nextFloat() > Math.abs(effect)) {
        return stack;
    }
    final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
    final IGenome genome = member.getGenome();
    final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeType);
    final Tolerance tol = Tolerance.get(tolAllele.getValue());
    final Tolerance newTol = Acclimatiser.alterTolerance(tol, effect);
    if (rand.nextFloat() > 1.0f / (-newTol.getBounds()[0] + newTol.getBounds()[1])) {
        return stack;
    }
    final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
    boolean setPrimary = rand.nextBoolean();
    boolean setSecondary = !setPrimary;
    Gene gene = new Gene(newTol.getAllele(), this.chromosomeType, root);
    Splicer.setGene(gene, stack, setPrimary, setSecondary);
    return stack;
}
Also used : IGenome(forestry.api.genetics.IGenome) IAlleleTolerance(forestry.api.genetics.IAlleleTolerance) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) Random(java.util.Random) IIndividual(forestry.api.genetics.IIndividual) Gene(binnie.core.genetics.Gene) Tolerance(binnie.core.genetics.Tolerance) IAlleleTolerance(forestry.api.genetics.IAlleleTolerance)

Example 14 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class InoculatorRecipeMaker method create.

public static List<InoculatorRecipeWrapper> create() {
    List<InoculatorRecipeWrapper> recipes = new ArrayList<>();
    for (IBreedingSystem system : Binnie.GENETICS.getActiveSystems()) {
        ISpeciesRoot root = system.getSpeciesRoot();
        IChromosomeType speciesChromosomeType = root.getSpeciesChromosomeType();
        IAllele[] defaultTemplate = root.getDefaultTemplate();
        IIndividual individual = root.templateAsIndividual(defaultTemplate);
        for (ISpeciesType speciesType : system.getActiveTypes()) {
            if (system.isDNAManipulable(speciesType)) {
                ItemStack memberStack = root.getMemberStack(individual, speciesType);
                memberStack.setItemDamage(OreDictionary.WILDCARD_VALUE);
                IAllele species = defaultTemplate[speciesChromosomeType.ordinal()];
                ItemStack serum = ItemSerum.create(new Gene(species, speciesChromosomeType, root));
                // set fully charged
                serum.setItemDamage(0);
                recipes.add(new InoculatorRecipeWrapper(serum, memberStack));
                recipes.add(new SplicerRecipeWrapper(serum, memberStack));
                ItemStack serumArray = ItemSerumArray.create(new Gene(species, speciesChromosomeType, root));
                // set fully charged
                serumArray.setItemDamage(0);
                for (IChromosomeType chromosomeType : root.getKaryotype()) {
                    if (chromosomeType != speciesChromosomeType) {
                        IAllele allele = defaultTemplate[chromosomeType.ordinal()];
                        Engineering.addGene(serumArray, new Gene(allele, chromosomeType, root));
                    }
                }
                recipes.add(new InoculatorRecipeWrapper(serumArray, memberStack));
                recipes.add(new SplicerRecipeWrapper(serumArray, memberStack));
            }
        }
    }
    return recipes;
}
Also used : IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType) ArrayList(java.util.ArrayList) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) Gene(binnie.core.genetics.Gene) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack)

Example 15 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class IsolatorRecipeMaker method create.

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;
}
Also used : IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType) ArrayList(java.util.ArrayList) IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) Gene(binnie.core.genetics.Gene) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Gene (binnie.core.genetics.Gene)18 IAllele (forestry.api.genetics.IAllele)11 IChromosomeType (forestry.api.genetics.IChromosomeType)11 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)10 ItemStack (net.minecraft.item.ItemStack)8 IGene (binnie.core.api.genetics.IGene)7 IIndividual (forestry.api.genetics.IIndividual)6 ArrayList (java.util.ArrayList)6 List (java.util.List)4 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)3 Map (java.util.Map)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 BreedingSystem (binnie.core.genetics.BreedingSystem)2 ControlText (binnie.core.gui.controls.ControlText)2 Point (binnie.core.gui.geometry.Point)2 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)2 Panel (binnie.core.gui.window.Panel)2 GeneTracker (binnie.genetics.genetics.GeneTracker)2 IGeneItem (binnie.genetics.genetics.IGeneItem)2 IGenome (forestry.api.genetics.IGenome)2