Search in sources :

Example 6 with IAlleleInteger

use of forestry.api.genetics.IAlleleInteger in project ForestryMC by ForestryMC.

the class ButterflyDatabaseTab method createElements.

@Override
public void createElements(IGuiElementHelper elementHelper, IButterfly butterfly, ItemStack itemStack) {
    boolean active = tab == EnumDatabaseTab.ACTIVE_SPECIES;
    IAlleleButterflySpecies primarySpecies = butterfly.getGenome().getPrimary();
    elementHelper.addText(Translator.translateToLocal("for.gui.database.tab." + tab.name().toLowerCase() + ".name"), GuiElementAlignment.CENTER, 0xcfb53b);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.species"), butterfly, EnumButterflyChromosome.SPECIES, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.size"), butterfly, EnumButterflyChromosome.SIZE, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.lifespan"), butterfly, EnumButterflyChromosome.LIFESPAN, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.speed"), butterfly, EnumButterflyChromosome.SPEED, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.metabolism"), (IAlleleInteger a) -> GenericRatings.rateMetabolism(a.getValue()), butterfly, EnumButterflyChromosome.METABOLISM, active);
    IAlleleInteger fertility = (IAlleleInteger) (active ? butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.FERTILITY) : butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FERTILITY));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.fertility"), GuiElementAlignment.CENTER);
    elementHelper.addFertilityInfo(fertility, 0, 8);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.flowers"), butterfly, EnumButterflyChromosome.FLOWER_PROVIDER, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.effect"), butterfly, EnumButterflyChromosome.EFFECT, active);
    IAlleleTolerance tempTolerance = (IAlleleTolerance) (active ? butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE) : butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.climate"), GuiElementAlignment.CENTER);
    elementHelper.addToleranceInfo(tempTolerance, primarySpecies, AlleleManager.climateHelper.toDisplay(primarySpecies.getTemperature()));
    IAlleleTolerance humidTolerance = (IAlleleTolerance) (active ? butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE) : butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.humidity"), GuiElementAlignment.CENTER);
    elementHelper.addToleranceInfo(humidTolerance, primarySpecies, AlleleManager.climateHelper.toDisplay(primarySpecies.getHumidity()));
    String yes = Translator.translateToLocal("for.yes");
    String no = Translator.translateToLocal("for.no");
    String diurnal, nocturnal;
    if (active) {
        if (butterfly.getGenome().getNocturnal()) {
            nocturnal = diurnal = yes;
        } else {
            nocturnal = butterfly.getGenome().getPrimary().isNocturnal() ? yes : no;
            diurnal = !butterfly.getGenome().getPrimary().isNocturnal() ? yes : no;
        }
    } else {
        if (((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.NOCTURNAL)).getValue()) {
            nocturnal = diurnal = yes;
        } else {
            nocturnal = butterfly.getGenome().getSecondary().isNocturnal() ? yes : no;
            diurnal = !butterfly.getGenome().getSecondary().isNocturnal() ? yes : no;
        }
    }
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.diurnal"), GuiElementAlignment.CENTER);
    elementHelper.addText(diurnal, GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(false));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.nocturnal"), GuiElementAlignment.CENTER);
    elementHelper.addText(nocturnal, GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(false));
    String flyer = StringUtil.readableBoolean(active ? butterfly.getGenome().getTolerantFlyer() : ((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TOLERANT_FLYER)).getValue(), yes, no);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.flyer"), (a) -> flyer, butterfly, EnumButterflyChromosome.TOLERANT_FLYER, active);
    String fireresist = StringUtil.readableBoolean(active ? butterfly.getGenome().getFireResist() : ((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FIRE_RESIST)).getValue(), yes, no);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.fireresist"), (a) -> fireresist, butterfly, EnumButterflyChromosome.FIRE_RESIST, active);
}
Also used : IAlleleTolerance(forestry.api.genetics.IAlleleTolerance) IAlleleInteger(forestry.api.genetics.IAlleleInteger) AlleleBoolean(forestry.core.genetics.alleles.AlleleBoolean) IAlleleButterflySpecies(forestry.api.lepidopterology.IAlleleButterflySpecies)

Example 7 with IAlleleInteger

use of forestry.api.genetics.IAlleleInteger in project ForestryMC by ForestryMC.

the class AlleleFactory method createInteger.

@Override
public IAlleleInteger createInteger(String modId, String category, String valueName, int value, boolean isDominant, IChromosomeType... types) {
    IAlleleInteger alleleInteger = new AlleleInteger(modId, category, valueName, value, isDominant);
    AlleleManager.alleleRegistry.registerAllele(alleleInteger, types);
    return alleleInteger;
}
Also used : IAlleleInteger(forestry.api.genetics.IAlleleInteger) IAlleleInteger(forestry.api.genetics.IAlleleInteger)

Example 8 with IAlleleInteger

use of forestry.api.genetics.IAlleleInteger in project ForestryMC by ForestryMC.

the class BeeDatabaseTab method createElements.

@Override
public void createElements(IGuiElementHelper elementHelper, IBee bee, ItemStack itemStack) {
    EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
    if (type == null) {
        return;
    }
    IAlleleSpecies primarySpecies = bee.getGenome().getPrimary();
    boolean active = tab == EnumDatabaseTab.ACTIVE_SPECIES;
    elementHelper.addText(Translator.translateToLocal("for.gui.database.tab." + tab.name().toLowerCase() + ".name"), GuiElementAlignment.CENTER, 0xcfb53b);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.species"), bee, EnumBeeChromosome.SPECIES, active);
    IAlleleTolerance tempTolerance = (IAlleleTolerance) (active ? bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE) : bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.climate"), GuiElementAlignment.CENTER);
    elementHelper.addToleranceInfo(tempTolerance, primarySpecies, AlleleManager.climateHelper.toDisplay(primarySpecies.getTemperature()));
    IAlleleTolerance humidTolerance = (IAlleleTolerance) (active ? bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE) : bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.humidity"), GuiElementAlignment.CENTER);
    elementHelper.addToleranceInfo(humidTolerance, primarySpecies, AlleleManager.climateHelper.toDisplay(primarySpecies.getHumidity()));
    elementHelper.addAllele(Translator.translateToLocal("for.gui.lifespan"), bee, EnumBeeChromosome.LIFESPAN, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.speed"), bee, EnumBeeChromosome.SPEED, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.pollination"), bee, EnumBeeChromosome.FLOWERING, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER, active);
    IAlleleInteger primaryFertility = (IAlleleInteger) (active ? bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY) : bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.fertility"), GuiElementAlignment.CENTER);
    elementHelper.addFertilityInfo(primaryFertility, 0, 0);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.area"), bee, EnumBeeChromosome.TERRITORY, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.effect"), bee, EnumBeeChromosome.EFFECT, active);
    String yes = Translator.translateToLocal("for.yes");
    String no = Translator.translateToLocal("for.no");
    String diurnal, nocturnal;
    if (active) {
        if (bee.getGenome().getNeverSleeps()) {
            nocturnal = diurnal = yes;
        } else {
            nocturnal = bee.getGenome().getPrimary().isNocturnal() ? yes : no;
            diurnal = !bee.getGenome().getPrimary().isNocturnal() ? yes : no;
        }
    } else {
        if (((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumButterflyChromosome.NOCTURNAL)).getValue()) {
            nocturnal = diurnal = yes;
        } else {
            nocturnal = bee.getGenome().getSecondary().isNocturnal() ? yes : no;
            diurnal = !bee.getGenome().getSecondary().isNocturnal() ? yes : no;
        }
    }
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.diurnal"), GuiElementAlignment.CENTER);
    elementHelper.addText(diurnal, GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(false));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.nocturnal"), GuiElementAlignment.CENTER);
    elementHelper.addText(nocturnal, GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(false));
    String flyer = StringUtil.readableBoolean(active ? bee.getGenome().getToleratesRain() : ((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TOLERATES_RAIN)).getValue(), yes, no);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.flyer"), (a) -> flyer, bee, EnumButterflyChromosome.TOLERANT_FLYER, active);
    String cave = StringUtil.readableBoolean(active ? bee.getGenome().getCaveDwelling() : ((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue(), yes, no);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.fireresist"), (a) -> cave, bee, EnumButterflyChromosome.FIRE_RESIST, active);
    String displayText;
    if (type == EnumBeeType.PRINCESS || type == EnumBeeType.QUEEN) {
        String displayTextKey = "for.bees.stock.pristine";
        if (!bee.isNatural()) {
            displayTextKey = "for.bees.stock.ignoble";
        }
        displayText = Translator.translateToLocal(displayTextKey);
        elementHelper.addText(displayText, GuiElementAlignment.CENTER, ColourProperties.INSTANCE.get("gui.beealyzer.binomial"));
    }
}
Also used : IAlleleTolerance(forestry.api.genetics.IAlleleTolerance) IAlleleInteger(forestry.api.genetics.IAlleleInteger) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) EnumBeeType(forestry.api.apiculture.EnumBeeType) AlleleBoolean(forestry.core.genetics.alleles.AlleleBoolean)

Aggregations

IAlleleInteger (forestry.api.genetics.IAlleleInteger)8 GuiAlyzer (forestry.core.gui.GuiAlyzer)3 TextLayoutHelper (forestry.core.gui.TextLayoutHelper)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 EnumBeeType (forestry.api.apiculture.EnumBeeType)2 IAlleleTolerance (forestry.api.genetics.IAlleleTolerance)2 AlleleBoolean (forestry.core.genetics.alleles.AlleleBoolean)2 IBee (forestry.api.apiculture.IBee)1 EnumGermlingType (forestry.api.arboriculture.EnumGermlingType)1 IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)1 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)1 ITree (forestry.api.arboriculture.ITree)1 IAlleleBoolean (forestry.api.genetics.IAlleleBoolean)1 IAlleleFlowers (forestry.api.genetics.IAlleleFlowers)1 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)1 IFruitFamily (forestry.api.genetics.IFruitFamily)1 IAlleleButterflySpecies (forestry.api.lepidopterology.IAlleleButterflySpecies)1 IButterfly (forestry.api.lepidopterology.IButterfly)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1