use of forestry.api.genetics.IAlleleTolerance in project ForestryMC by ForestryMC.
the class FlutterlyzerPlugin method drawAnalyticsPage2.
@SideOnly(Side.CLIENT)
@Override
public void drawAnalyticsPage2(GuiScreen gui, ItemStack itemStack) {
if (gui instanceof GuiAlyzer) {
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
IButterfly butterfly = ButterflyManager.butterflyRoot.getMember(itemStack);
if (butterfly == null) {
return;
}
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
textLayout.newLine();
textLayout.newLine();
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.climate"), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getTemperature()), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getTemperature()), butterfly, EnumButterflyChromosome.SPECIES);
textLayout.newLine();
IAlleleTolerance tempToleranceActive = (IAlleleTolerance) butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance tempToleranceInactive = (IAlleleTolerance) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE);
textLayout.drawLine(" " + Translator.translateToLocal("for.gui.tolerance"), GuiAlyzer.COLUMN_0);
guiAlyzer.drawToleranceInfo(tempToleranceActive, GuiAlyzer.COLUMN_1);
guiAlyzer.drawToleranceInfo(tempToleranceInactive, GuiAlyzer.COLUMN_2);
textLayout.newLine();
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.humidity"), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getHumidity()), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getHumidity()), butterfly, EnumButterflyChromosome.SPECIES);
textLayout.newLine();
IAlleleTolerance humidToleranceActive = (IAlleleTolerance) butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE);
IAlleleTolerance humidToleranceInactive = (IAlleleTolerance) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE);
textLayout.drawLine(" " + Translator.translateToLocal("for.gui.tolerance"), GuiAlyzer.COLUMN_0);
guiAlyzer.drawToleranceInfo(humidToleranceActive, GuiAlyzer.COLUMN_1);
guiAlyzer.drawToleranceInfo(humidToleranceInactive, GuiAlyzer.COLUMN_2);
textLayout.newLine();
textLayout.newLine();
String yes = Translator.translateToLocal("for.yes");
String no = Translator.translateToLocal("for.no");
String diurnal0, diurnal1, nocturnal0, nocturnal1;
if (butterfly.getGenome().getNocturnal()) {
nocturnal0 = diurnal0 = yes;
} else {
nocturnal0 = butterfly.getGenome().getPrimary().isNocturnal() ? yes : no;
diurnal0 = !butterfly.getGenome().getPrimary().isNocturnal() ? yes : no;
}
if (((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.NOCTURNAL)).getValue()) {
nocturnal1 = diurnal1 = yes;
} else {
nocturnal1 = butterfly.getGenome().getSecondary().isNocturnal() ? yes : no;
diurnal1 = !butterfly.getGenome().getSecondary().isNocturnal() ? yes : no;
}
textLayout.drawLine(Translator.translateToLocal("for.gui.diurnal"), GuiAlyzer.COLUMN_0);
textLayout.drawLine(diurnal0, GuiAlyzer.COLUMN_1, guiAlyzer.getColorCoding(false));
textLayout.drawLine(diurnal1, GuiAlyzer.COLUMN_2, guiAlyzer.getColorCoding(false));
textLayout.newLine();
textLayout.drawLine(Translator.translateToLocal("for.gui.nocturnal"), GuiAlyzer.COLUMN_0);
textLayout.drawLine(nocturnal0, GuiAlyzer.COLUMN_1, guiAlyzer.getColorCoding(false));
textLayout.drawLine(nocturnal1, GuiAlyzer.COLUMN_2, guiAlyzer.getColorCoding(false));
textLayout.newLine();
String primary = StringUtil.readableBoolean(butterfly.getGenome().getTolerantFlyer(), yes, no);
String secondary = StringUtil.readableBoolean(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TOLERANT_FLYER)).getValue(), yes, no);
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.flyer"), primary, secondary, butterfly, EnumButterflyChromosome.TOLERANT_FLYER);
textLayout.newLine();
primary = StringUtil.readableBoolean(butterfly.getGenome().getFireResist(), yes, no);
secondary = StringUtil.readableBoolean(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FIRE_RESIST)).getValue(), yes, no);
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.fireresist"), primary, secondary, butterfly, EnumButterflyChromosome.FIRE_RESIST);
textLayout.endPage();
}
}
use of forestry.api.genetics.IAlleleTolerance in project ForestryMC by ForestryMC.
the class BeeAlyzerPlugin method drawAnalyticsPage2.
@SideOnly(Side.CLIENT)
@Override
public void drawAnalyticsPage2(GuiScreen gui, ItemStack itemStack) {
if (gui instanceof GuiAlyzer) {
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
IBee bee = BeeManager.beeRoot.getMember(itemStack);
if (bee == null) {
return;
}
EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
textLayout.newLine();
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.climate"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getTemperature()), AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getTemperature()), bee, EnumBeeChromosome.SPECIES);
textLayout.newLine();
IAlleleTolerance tempToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance tempToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
textLayout.drawLine(" " + Translator.translateToLocal("for.gui.tolerance"), GuiAlyzer.COLUMN_0);
guiAlyzer.drawToleranceInfo(tempToleranceActive, GuiAlyzer.COLUMN_1);
guiAlyzer.drawToleranceInfo(tempToleranceInactive, GuiAlyzer.COLUMN_2);
textLayout.newLine(16);
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.humidity"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getHumidity()), AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getHumidity()), bee, EnumBeeChromosome.SPECIES);
textLayout.newLine();
IAlleleTolerance humidToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
IAlleleTolerance humidToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
textLayout.drawLine(" " + Translator.translateToLocal("for.gui.tolerance"), GuiAlyzer.COLUMN_0);
guiAlyzer.drawToleranceInfo(humidToleranceActive, GuiAlyzer.COLUMN_1);
guiAlyzer.drawToleranceInfo(humidToleranceInactive, GuiAlyzer.COLUMN_2);
textLayout.newLine(16);
String yes = Translator.translateToLocal("for.yes");
String no = Translator.translateToLocal("for.no");
String diurnal0, diurnal1, nocturnal0, nocturnal1;
if (bee.getGenome().getNeverSleeps()) {
nocturnal0 = diurnal0 = yes;
} else {
nocturnal0 = bee.getGenome().getPrimary().isNocturnal() ? yes : no;
diurnal0 = !bee.getGenome().getPrimary().isNocturnal() ? yes : no;
}
if (((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.NEVER_SLEEPS)).getValue()) {
nocturnal1 = diurnal1 = yes;
} else {
nocturnal1 = bee.getGenome().getSecondary().isNocturnal() ? yes : no;
diurnal1 = !bee.getGenome().getSecondary().isNocturnal() ? yes : no;
}
textLayout.drawLine(Translator.translateToLocal("for.gui.diurnal"), GuiAlyzer.COLUMN_0);
textLayout.drawLine(diurnal0, GuiAlyzer.COLUMN_1, guiAlyzer.getColorCoding(false));
textLayout.drawLine(diurnal1, GuiAlyzer.COLUMN_2, guiAlyzer.getColorCoding(false));
textLayout.newLineCompressed();
textLayout.drawLine(Translator.translateToLocal("for.gui.nocturnal"), GuiAlyzer.COLUMN_0);
textLayout.drawLine(nocturnal0, GuiAlyzer.COLUMN_1, guiAlyzer.getColorCoding(false));
textLayout.drawLine(nocturnal1, GuiAlyzer.COLUMN_2, guiAlyzer.getColorCoding(false));
textLayout.newLineCompressed();
String primary = StringUtil.readableBoolean(bee.getGenome().getToleratesRain(), yes, no);
String secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TOLERATES_RAIN)).getValue(), yes, no);
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.flyer"), primary, secondary, bee, EnumBeeChromosome.TOLERATES_RAIN);
textLayout.newLineCompressed();
primary = StringUtil.readableBoolean(bee.getGenome().getCaveDwelling(), yes, no);
secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue(), yes, no);
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.cave"), primary, secondary, bee, EnumBeeChromosome.CAVE_DWELLING);
textLayout.newLine();
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);
textLayout.drawCenteredLine(displayText, 8, 208, guiAlyzer.getFontColor().get("gui.beealyzer.binomial"));
}
if (bee.getGeneration() >= 0) {
textLayout.newLineCompressed();
displayText = Translator.translateToLocalFormatted("for.gui.beealyzer.generations", bee.getGeneration());
textLayout.drawCenteredLine(displayText, 8, 208, guiAlyzer.getFontColor().get("gui.beealyzer.binomial"));
}
textLayout.endPage();
}
}
use of forestry.api.genetics.IAlleleTolerance in project Binnie by ForestryMC.
the class ToleranceSystem method canAlter.
public boolean canAlter(final ItemStack stack, final ItemStack acclim) {
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 float effect = this.type.getEffect(acclim);
return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
}
use of forestry.api.genetics.IAlleleTolerance in project ForestryMC by ForestryMC.
the class Butterfly method addTooltip.
@Override
public void addTooltip(List<String> list) {
IAlleleButterflySpecies primary = genome.getPrimary();
IAlleleButterflySpecies secondary = genome.getSecondary();
if (!isPureBred(EnumButterflyChromosome.SPECIES)) {
list.add(TextFormatting.BLUE + Translator.translateToLocal("for.butterflies.hybrid").replaceAll("%PRIMARY", primary.getAlleleName()).replaceAll("%SECONDARY", secondary.getAlleleName()));
}
if (getMate() != null) {
list.add(TextFormatting.RED + Translator.translateToLocal("for.gui.fecundated").toUpperCase(Locale.ENGLISH));
}
list.add(TextFormatting.YELLOW + genome.getActiveAllele(EnumButterflyChromosome.SIZE).getAlleleName());
list.add(TextFormatting.DARK_GREEN + genome.getActiveAllele(EnumButterflyChromosome.SPEED).getAlleleName());
list.add(genome.getActiveAllele(EnumButterflyChromosome.LIFESPAN).getAlleleName() + ' ' + Translator.translateToLocal("for.gui.life"));
IAlleleTolerance tempTolerance = (IAlleleTolerance) getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE);
list.add(TextFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getAlleleName());
IAlleleTolerance humidTolerance = (IAlleleTolerance) getGenome().getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE);
list.add(TextFormatting.GREEN + "H: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getAlleleName());
list.add(TextFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), genome.getPrimary().isNocturnal()));
if (genome.getTolerantFlyer()) {
list.add(TextFormatting.WHITE + Translator.translateToLocal("for.gui.flyer.tooltip"));
}
}
use of forestry.api.genetics.IAlleleTolerance 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);
}
Aggregations