Use generics for Chromosome type, begin unifying code

This commit is contained in:
mezz committed 2016-02-27 00:14:22 -08:00
1 parent a8270ef365
commit 43e41034f6
217 files changed
+3148 -2417

No files matched your search

@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nonnull;
/**
* An {@link IIndividual}'s {@link IGenome} is composed of {@link IChromosome}s consisting each of a primary and secondary {@link IAllele}.
*
@@ -19,6 +21,7 @@ public interface IAllele {
/**
* @return A unique string identifier for this allele.
*/
@Nonnull
String getUID();
/**
@@ -29,11 +32,13 @@ public interface IAllele {
/**
* @return Localized short, human-readable identifier used in tooltips and beealyzer.
*/
@Nonnull
String getName();
/**
* @return The unlocalized identifier
*/
@Nonnull
String getUnlocalizedName();
}
@@ -31,7 +31,7 @@ public interface IAlleleFactory {
* @param valueName allele value name for uid and localization (i.e. "smallest")
* @param value allele float value
* @param isDominant allele dominance
* @param types allele chromosome type for registration (i.e. EnumTreeChromosome.HEIGHT)
* @param types allele chromosome type for registration (i.e. TreeChromosome.HEIGHT)
* @return a new IAlleleFloat, registered with the allele registry.
* @since Forestry 4.2
*/
@@ -45,7 +45,7 @@ public interface IAlleleFactory {
* @param yDimValue allele area Y Size
* @param zDimValue allele area Z Size
* @param isDominant allele dominance
* @param types allele chromosome type for registration (i.e. EnumBeeChromosome.TERRITORY)
* @param types allele chromosome type for registration (i.e. BeeChromosome.TERRITORY)
* @return a new IAlleleArea, registered with the allele registry.
* @since Forestry 4.2
*/
@@ -57,7 +57,7 @@ public interface IAlleleFactory {
* @param valueName allele value name for uid and localization (i.e. "low")
* @param value allele int value
* @param isDominant allele dominance
* @param types allele chromosome type for registration (i.e. EnumBeeChromosome.FERTILITY)
* @param types allele chromosome type for registration (i.e. BeeChromosome.FERTILITY)
* @return a new IAlleleInteger, registered with the allele registry.
* @since Forestry 4.2
*/
@@ -68,7 +68,7 @@ public interface IAlleleFactory {
* @param category allele category for uid and localization (i.e. "fireproof")
* @param value allele boolean value
* @param isDominant allele dominance
* @param types allele chromosome type for registration (i.e. EnumTreeChromosome.FIREPROOF)
* @param types allele chromosome type for registration (i.e. TreeChromosome.FIREPROOF)
* @return a new IAlleleBoolean, registered with the allele registry.
* Note that valueName will always be "true" or "false"
* @since Forestry 4.2
@@ -81,7 +81,7 @@ public interface IAlleleFactory {
* @param valueName allele value name for uid (i.e. "vanilla")
* @param value allele IFlowerProvider value
* @param isDominant allele dominance
* @param types allele chromosome type for registration (i.e. EnumBeeChromosome.FLOWER_PROVIDER)
* @param types allele chromosome type for registration (i.e. BeeChromosome.FLOWER_PROVIDER)
* @return a new IAlleleFlowers, registered with the allele registry.
* IAlleleFlowers localization is handled by the IFlowerProvider.getDescription(), unlike the other alleles.
* @since Forestry 4.2
@@ -5,6 +5,7 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Map;
@@ -27,7 +28,7 @@ public interface IAlleleRegistry {
* Register a {@link ISpeciesRoot}.
* @param root {@link ISpeciesRoot} to register.
*/
void registerSpeciesRoot(ISpeciesRoot root);
void registerSpeciesRoot(ISpeciesRoot<?> root);
/**
* @return Map of all registered {@link ISpeciesRoot}.
@@ -39,21 +40,21 @@ public interface IAlleleRegistry {
* @param uid Unique id for the species class, i.e. "rootBees", "rootTrees", "rootButterflies".
* @return {@link ISpeciesRoot} if it exists, null otherwise.
*/
ISpeciesRoot getSpeciesRoot(String uid);
ISpeciesRoot<?> getSpeciesRoot(String uid);
/**
* Retrieve a matching {@link ISpeciesRoot} for the given itemstack.
* @param stack An itemstack possibly containing NBT data which can be converted by a species root.
* @return {@link ISpeciesRoot} if found, null otherwise.
*/
ISpeciesRoot getSpeciesRoot(ItemStack stack);
ISpeciesRoot<?> getSpeciesRoot(ItemStack stack);
/**
* Retrieve a matching {@link ISpeciesRoot} for the given {@link IIndividual}-class.
* @param clz Class extending {@link IIndividual}.
* @param individualClass Class extending {@link IIndividual}.
* @return {@link ISpeciesRoot} if found, null otherwise.
*/
ISpeciesRoot getSpeciesRoot(Class<? extends IIndividual> clz);
ISpeciesRoot<?> getSpeciesRoot(Class<? extends IIndividual> individualClass);
/* INDIVIDUAL */
@@ -72,7 +73,8 @@ public interface IAlleleRegistry {
* Stack to retrieve genetic information for.
* @return IIndividual containing genetic information, null if none could be extracted.
*/
IIndividual getIndividual(ItemStack stack);
@Nullable
IIndividual<?> getIndividual(ItemStack stack);
/* ALLELES */
@@ -91,7 +93,7 @@ public interface IAlleleRegistry {
* @param chromosomeTypes valid chromosomeTypes for this allele.
* @since Forestry 4.2
*/
void registerAllele(IAllele allele, IChromosomeType... chromosomeTypes);
void registerAllele(IAllele allele, IChromosomeType<?>... chromosomeTypes);
/**
* @return HashMap of all registered deprecated alleles and their corresponding replacements
@@ -121,7 +123,9 @@ public interface IAlleleRegistry {
* @return unmodifiable collection of all the known allele variations for the given chromosome type.
* @since Forestry 4.2
*/
Collection<IAllele> getRegisteredAlleles(IChromosomeType type);
Collection<IAllele> getRegisteredAlleles(IChromosomeType<?> type);
Collection<IChromosomeType<?>> getChromosomeTypes(IAllele allele);
/* CLASSIFICATIONS */
@@ -20,12 +20,12 @@ import forestry.api.core.IModelProvider;
/**
* Basic species allele.
*/
public interface IAlleleSpecies extends IAllele {
public interface IAlleleSpecies<C extends IChromosomeType> extends IAllele {
/**
* @return the {@link ISpeciesRoot} associated with this species.
*/
ISpeciesRoot getRoot();
ISpeciesRoot<C> getRoot();
/**
* @return Localized short description of this species. (May be null.)
@@ -74,7 +74,7 @@ public interface IAlleleSpecies extends IAllele {
* @param bountyLevel
* @return Array of itemstacks representing the bounty for this research success.
*/
ItemStack[] getResearchBounty(World world, GameProfile gameProfile, IIndividual individual, int bountyLevel);
ItemStack[] getResearchBounty(World world, GameProfile gameProfile, IIndividual<C> individual, int bountyLevel);
/* CLIMATE */
@@ -8,17 +8,19 @@ package forestry.api.genetics;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
public interface IAlleleSpeciesCustom extends IAlleleSpecies {
public interface IAlleleSpeciesBuilder<C extends IChromosomeType<C>> {
IAlleleSpeciesCustom setTemperature(EnumTemperature temperature);
IAlleleSpecies<C> build();
IAlleleSpeciesCustom setHumidity(EnumHumidity humidity);
IAlleleSpeciesBuilder<C> setTemperature(EnumTemperature temperature);
IAlleleSpeciesCustom setHasEffect();
IAlleleSpeciesBuilder<C> setHumidity(EnumHumidity humidity);
IAlleleSpeciesBuilder<C> setHasEffect();
/** Secret species are not shown in creative mode. */
IAlleleSpeciesCustom setIsSecret();
IAlleleSpeciesBuilder<C> setIsSecret();
/** Uncounted species do not count toward total species discovered. */
IAlleleSpeciesCustom setIsNotCounted();
IAlleleSpeciesBuilder<C> setIsNotCounted();
}
@@ -15,7 +15,7 @@ import forestry.api.apiculture.IBeekeepingMode;
*
* @author SirSengir
*/
public interface IBreedingTracker {
public interface IBreedingTracker<C extends IChromosomeType> {
/**
* @return Name of the current {@link IBeekeepingMode}.
@@ -37,28 +37,28 @@ public interface IBreedingTracker {
*
* @param individual
*/
void registerBirth(IIndividual individual);
void registerBirth(IIndividual<C> individual);
/**
* Register the pickup of an individual.
*
* @param individual
*/
void registerPickup(IIndividual individual);
void registerPickup(IIndividual<C> individual);
/**
* Marks a species as discovered. Should only be called from registerIndividual normally.
*
* @param species
*/
void registerSpecies(IAlleleSpecies species);
void registerSpecies(IAlleleSpecies<C> species);
/**
* Register a successful mutation. Will mark it as discovered.
*
* @param mutation
*/
void registerMutation(IMutation mutation);
void registerMutation(IMutation<C> mutation);
/**
* Queries the tracker for discovered species.
@@ -67,7 +67,7 @@ public interface IBreedingTracker {
* Mutation to query for.
* @return true if the mutation has been discovered.
*/
boolean isDiscovered(IMutation mutation);
boolean isDiscovered(IMutation<C> mutation);
/**
* Queries the tracker for discovered species.
@@ -76,7 +76,7 @@ public interface IBreedingTracker {
* Species to check.
* @return true if the species has been bred.
*/
boolean isDiscovered(IAlleleSpecies species);
boolean isDiscovered(IAlleleSpecies<C> species);
/**
* Register a successfully researched mutation.
@@ -84,12 +84,12 @@ public interface IBreedingTracker {
* Researched mutations may have bonuses such as occurring at a higher rate.
* Researched mutations count as discovered.
*/
void researchMutation(IMutation mutation);
void researchMutation(IMutation<C> mutation);
/**
* @return true if the mutation has been researched.
*/
boolean isResearched(IMutation mutation);
boolean isResearched(IMutation<C> mutation);
/**
* Synchronizes the tracker to the client side.
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nonnull;
import forestry.api.core.INbtWritable;
/**
@@ -14,12 +16,16 @@ import forestry.api.core.INbtWritable;
*/
public interface IChromosome extends INbtWritable {
@Nonnull
IAllele getPrimaryAllele();
@Nonnull
IAllele getSecondaryAllele();
@Nonnull
IAllele getInactiveAllele();
@Nonnull
IAllele getActiveAllele();
}
@@ -5,20 +5,25 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nonnull;
/*
* Interface to be implemented by the enums representing the various chromosomes
*/
public interface IChromosomeType {
public interface IChromosomeType<C extends IChromosomeType<C>> {
/*
* Get class which all alleles on this chromosome must interface
*/
@Nonnull
Class<? extends IAllele> getAlleleClass();
@Nonnull
String getName();
ISpeciesRoot getSpeciesRoot();
@Nonnull
ISpeciesRoot<C> getSpeciesRoot();
int ordinal();
byte getUid();
}
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.genetics;
import java.util.Collection;
/**
* Biological classifications from domain down to genus.
*
@@ -74,7 +76,7 @@ public interface IClassification {
/**
* @return Member groups of this one.
*/
IClassification[] getMemberGroups();
Collection<IClassification> getMemberGroups();
/**
* Adds subgroups to this group.
@@ -84,14 +86,14 @@ public interface IClassification {
/**
* @return Member species of this group.
*/
IAlleleSpecies[] getMemberSpecies();
Collection<IAlleleSpecies<?>> getMemberSpecies();
/**
* Used by the allele registry to populate internal collection of branch members on the fly.
*
* @param species
*/
void addMemberSpecies(IAlleleSpecies species);
void addMemberSpecies(IAlleleSpecies<?> species);
/**
* @return Parent classification, null if this is root.
@@ -5,23 +5,27 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public interface IFlowerProvider {
boolean isAcceptedPollinatable(World world, IPollinatable pollinatable);
boolean isAcceptedPollinatable(@Nonnull World world, @Nonnull IPollinatable pollinatable);
/**
* @return The unique type used for the IFlowerRegistry
* @since Forestry 4.0.0
*/
@Nonnull
String getFlowerType();
/**
* @return Short, human-readable identifier used in the beealyzer.
*/
@Nonnull
String getDescription();
/**
@@ -29,5 +33,6 @@ public interface IFlowerProvider {
* If this flowerProvider does not affect the products, it should return the products unchanged.
* @return Array of itemstacks being the (modified or unmodified) produce.
*/
@Nonnull
ItemStack[] affectProducts(World world, IIndividual individual, BlockPos pos, ItemStack[] products);
}
@@ -5,6 +5,10 @@
******************************************************************************/
package forestry.api.genetics;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import forestry.api.core.INbtWritable;
/**
@@ -12,19 +16,25 @@ import forestry.api.core.INbtWritable;
*
* Only the default implementation is supported.
*/
public interface IGenome extends INbtWritable {
public interface IGenome<C extends IChromosomeType> extends INbtWritable {
IAlleleSpecies getPrimary();
@Nonnull
IAlleleSpecies<C> getPrimary();
IAlleleSpecies getSecondary();
@Nonnull
IAlleleSpecies<C> getSecondary();
IChromosome[] getChromosomes();
@Nonnull
ImmutableMap<C, IChromosome> getChromosomes();
IAllele getActiveAllele(IChromosomeType chromosomeType);
@Nonnull
IAllele getActiveAllele(C chromosomeType);
IAllele getInactiveAllele(IChromosomeType chromosomeType);
@Nonnull
IAllele getInactiveAllele(C chromosomeType);
boolean isGeneticEqual(IGenome other);
ISpeciesRoot getSpeciesRoot();
boolean isGeneticEqual(IGenome<C> other);
@Nonnull
ISpeciesRoot<C> getSpeciesRoot();
}
@@ -6,6 +6,9 @@
package forestry.api.genetics;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
/**
* Any housing, hatchery or nest with a location in the world.
@@ -14,4 +17,8 @@ public interface IHousing {
BlockPos getCoordinates();
World getWorld();
GameProfile getOwner();
}
@@ -15,7 +15,7 @@ import forestry.api.core.INbtWritable;
*
* Only the default implementation is supported.
*/
public interface IIndividual extends INbtWritable {
public interface IIndividual<C extends IChromosomeType> extends INbtWritable {
String getIdent();
@@ -36,20 +36,20 @@ public interface IIndividual extends INbtWritable {
boolean isSecret();
@Nonnull
IGenome getGenome();
IGenome<C> getGenome();
/**
* Check whether the genetic makeup of two IIndividuals is identical. Ignores additional data like generations, irregular mating, etc..
* @param other
* @return true if the given other IIndividual has the amount of chromosomes and their alleles are identical.
*/
boolean isGeneticEqual(IIndividual other);
boolean isGeneticEqual(IIndividual<C> other);
/**
* @return A deep copy of this individual.
*/
IIndividual copy();
IIndividual<C> copy();
boolean isPureBred(IChromosomeType chromosomeType);
boolean isPureBred(C chromosomeType);
}
@@ -7,7 +7,7 @@ package forestry.api.genetics;
import net.minecraft.world.World;
public interface IIndividualLiving extends IIndividual {
public interface IIndividualLiving<C extends IChromosomeType> extends IIndividual<C> {
/**
* @return Genetic information of the mate, null if unmated.
@@ -5,8 +5,17 @@
******************************************************************************/
package forestry.api.genetics;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.core.INbtWritable;
/**
* Individuals can be seeded either as hive drops or as mutation results.
*
@@ -14,38 +23,43 @@ import java.util.Collection;
*
* @author SirSengir
*/
public interface IMutation {
public interface IMutation<C extends IChromosomeType> extends INbtWritable {
/**
* @return {@link ISpeciesRoot} this mutation is associated with.
*/
ISpeciesRoot getRoot();
@Nonnull
ISpeciesRoot<C> getRoot();
/**
* @return first of the alleles implementing IAlleleSpecies required for this mutation.
*/
IAlleleSpecies getAllele0();
@Nonnull
IAlleleSpecies<C> getSpecies0();
/**
* @return second of the alleles implementing IAlleleSpecies required for this mutation.
*/
IAlleleSpecies getAllele1();
@Nonnull
IAlleleSpecies<C> getSpecies1();
/**
* @return Array of {@link IAllele} representing the full default genome of the mutated side.
*
* Make sure to return a proper array for the species class. Returning an allele of the wrong type will cause cast errors on runtime.
* @return The full default genome of the mutated side.
*/
IAllele[] getTemplate();
@Nonnull
ImmutableMap<C, IAllele> getResultTemplate();
/**
* @return Unmodified base chance for mutation to fire.
*/
float getBaseChance();
float getChance(World world, BlockPos pos, IAlleleSpecies<C> species0, IAlleleSpecies<C> species1, IGenome<C> genome0, IGenome<C> genome1);
/**
* @return Collection of localized, human-readable strings describing special mutation conditions, if any.
*/
@Nonnull
Collection<String> getSpecialConditions();
/**
@@ -58,6 +72,7 @@ public interface IMutation {
* @param allele
* @return the other allele which was not passed as argument.
*/
@Nullable
IAllele getPartner(IAllele allele);
/**
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraftforge.common.BiomeDictionary;
@@ -13,40 +15,42 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
/** Set custom mutation requirements */
public interface IMutationCustom extends IMutation {
public interface IMutationBuilder<C extends IChromosomeType<C>> {
@Nonnull
IMutation<C> build();
/** Prevent this mutation from being shown in the analyzers */
IMutationCustom setIsSecret();
IMutationBuilder<C> setIsSecret();
/** Require a specific temperature for this mutation to occur */
IMutationCustom restrictTemperature(EnumTemperature temperature);
IMutationBuilder<C> restrictTemperature(EnumTemperature temperature);
IMutationCustom restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature);
IMutationBuilder<C> restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature);
/** Require a specific humidity for this mutation to occur */
IMutationCustom restrictHumidity(EnumHumidity humidity);
IMutationBuilder<C> restrictHumidity(EnumHumidity humidity);
IMutationCustom restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity);
IMutationBuilder<C> restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity);
/**
* Restrict this mutation to certain types of biomes.
* @param types The types of biomes this mutation can occur.
*/
IMutationCustom restrictBiomeType(BiomeDictionary.Type... types);
IMutationBuilder<C> restrictBiomeType(BiomeDictionary.Type... types);
/** Restrict the days of the year that this mutation can occur */
IMutationCustom restrictDateRange(int startMonth, int startDay, int endMonth, int endDay);
IMutationBuilder<C> restrictDateRange(int startMonth, int startDay, int endMonth, int endDay);
/** Restrict the time of day that this mutation can occur */
IMutationCustom requireDay();
IMutationBuilder<C> requireDay();
IMutationCustom requireNight();
IMutationBuilder<C> requireNight();
/** Require a specific resource to be under the location of the mutation */
IMutationCustom requireResource(Block block, int meta);
IMutationBuilder<C> requireResource(Block block, int meta);
IMutationCustom requireResource(String oreDictName);
IMutationBuilder<C> requireResource(String oreDictName);
/** Require some other custom mutation condition */
IMutationCustom addMutationCondition(IMutationCondition mutationCondition);
IMutationBuilder<C> addMutationCondition(IMutationCondition mutationCondition);
}
@@ -15,7 +15,7 @@ public interface IMutationCondition {
* Most will return 1 if the condition is met and 0 otherwise,
* but the float offers flexibility for more advanced conditions.
*/
float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
<C extends IChromosomeType> float getChance(World world, BlockPos pos, IAlleleSpecies<C> species0, IAlleleSpecies<C> species1, IGenome<C> genome0, IGenome<C> genome1);
/**
* A localized description of the mutation condition. (i.e. "A temperature of HOT is required.")
@@ -9,6 +9,8 @@ import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.arboriculture.ITree;
/**
* Can be implemented by tile entities, if they wish to be pollinatable.
*
@@ -24,7 +26,7 @@ public interface IPollinatable {
/**
* @return IIndividual containing the genetic information of this IPollinatable
*/
IIndividual getPollen();
ITree getPollen();
/**
* Checks whether this {@link IPollinatable} can mate with the given pollen.
@@ -35,7 +37,7 @@ public interface IPollinatable {
* IIndividual representing the pollen.
* @return true if mating is possible, false otherwise.
*/
boolean canMateWith(IIndividual pollen);
boolean canMateWith(ITree pollen);
/**
* Pollinates this entity.
@@ -43,7 +45,7 @@ public interface IPollinatable {
* @param pollen
* IIndividual representing the pollen.
*/
void mateWith(IIndividual pollen);
void mateWith(ITree pollen);
/**
* @return true if this IPollinatable has already been pollinated.
@@ -0,0 +1,17 @@
package forestry.api.genetics;
import javax.annotation.Nonnull;
public interface ISpeciesMode<C extends IChromosomeType> {
/**
* @return Localized name of this mode.
*/
@Nonnull
String getName();
/**
* @return Float used to modify the base mutation chance.
*/
float getMutationModifier(IGenome<C> genome, IGenome<C> mate);
}
@@ -5,7 +5,10 @@
******************************************************************************/
package forestry.api.genetics;
import java.util.ArrayList;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -20,7 +23,7 @@ import com.mojang.authlib.GameProfile;
/**
* Describes a class of species (i.e. bees, trees, butterflies), provides helper functions and access to common functionality.
*/
public interface ISpeciesRoot {
public interface ISpeciesRoot<C extends IChromosomeType> {
/**
* @return A unique identifier for the species class. Should consist of "root" + a common name for the species class in camel-case, i.e. "rootBees", "rootTrees", "rootButterflies".
@@ -30,7 +33,7 @@ public interface ISpeciesRoot {
/**
* @return Class of the sub-interface inheriting from {@link IIndividual}.
*/
Class<? extends IIndividual> getMemberClass();
Class<? extends IIndividual<C>> getMemberClass();
/**
* @return Integer denoting the number of (counted) species of this type in the world.
@@ -59,29 +62,38 @@ public interface ISpeciesRoot {
*/
boolean isMember(IIndividual individual);
IIndividual getMember(ItemStack stack);
@Nullable
IIndividual<C> getMember(ItemStack stack);
IIndividual getMember(NBTTagCompound compound);
@Nullable
IIndividual<C> getMember(NBTTagCompound compound);
@Nullable
ISpeciesType getType(ItemStack itemStack);
ItemStack getMemberStack(IIndividual individual, int type);
ItemStack getMemberStack(IIndividual<C> individual, int type);
/* BREEDING TRACKER */
IBreedingTracker getBreedingTracker(World world, GameProfile player);
@Nonnull
IBreedingTracker<C> getBreedingTracker(@Nonnull World world, @Nonnull GameProfile player);
/* GENOME MANIPULATION */
IIndividual templateAsIndividual(IAllele[] template);
@Nonnull
IIndividual<C> templateAsIndividual(ImmutableMap<C, IAllele> template);
IIndividual templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
@Nonnull
IIndividual<C> templateAsIndividual(ImmutableMap<C, IAllele> templateActive, ImmutableMap<C, IAllele> templateInactive);
IChromosome[] templateAsChromosomes(IAllele[] template);
ImmutableMap<C, IChromosome> templateAsChromosomes(ImmutableMap<C, IAllele> template);
IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive);
ImmutableMap<C, IChromosome> templateAsChromosomes(ImmutableMap<C, IAllele> templateActive, ImmutableMap<C, IAllele> templateInactive);
IGenome templateAsGenome(IAllele[] template);
IGenome<C> templateAsGenome(ImmutableMap<C, IAllele> template);
IGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
IGenome<C> templateAsGenome(ImmutableMap<C, IAllele> templateActive, ImmutableMap<C, IAllele> templateInactive);
@Nonnull
IGenome<C> chromosomesAsGenome(ImmutableMap<C, IChromosome> chromosomes);
/* TEMPLATES */
@@ -90,37 +102,38 @@ public interface ISpeciesRoot {
*
* @param template
*/
void registerTemplate(IAllele[] template);
void registerTemplate(ImmutableMap<C, IAllele> template);
/**
* Registers a bee template using the passed identifier.
*
* @param template
*/
void registerTemplate(String identifier, IAllele[] template);
void registerTemplate(String identifier, ImmutableMap<C, IAllele> template);
/**
* Retrieves a registered template using the passed identifier.
*
* @param identifier
* @return Array of {@link IAllele} representing a genome.
* @return Map of {@link IAllele} representing a genome.
*/
IAllele[] getTemplate(String identifier);
@Nullable
ImmutableMap<C, IAllele> getTemplate(String identifier);
/**
* @return Default individual template for use when stuff breaks.
*/
IAllele[] getDefaultTemplate();
ImmutableMap<C, IAllele> getDefaultTemplate();
/**
* @param rand Random to use.
* @return A random template from the pool of registered species templates.
*/
IAllele[] getRandomTemplate(Random rand);
ImmutableMap<C, IAllele> getRandomTemplate(Random rand);
Map<String, IAllele[]> getGenomeTemplates();
Map<String, ImmutableMap<C, IAllele>> getGenomeTemplates();
ArrayList<? extends IIndividual> getIndividualTemplates();
List<? extends IIndividual<C>> getIndividualTemplates();
/* MUTATIONS */
@@ -129,26 +142,26 @@ public interface ISpeciesRoot {
*
* @param mutation
*/
void registerMutation(IMutation mutation);
void registerMutation(IMutation<C> mutation);
/**
* @return All registered mutations.
*/
Collection<? extends IMutation> getMutations(boolean shuffle);
Collection<? extends IMutation<C>> getMutations(boolean shuffle);
/**
* @param other Allele to match mutations against.
* @return All registered mutations the given allele is part of.
*/
Collection<? extends IMutation> getCombinations(IAllele other);
List<IMutation<C>> getCombinations(IAllele other);
/**
* @since Forestry 3.7
* @return all possible mutations that result from breeding two species
*/
List<IMutation> getCombinations(IAlleleSpecies parentSpecies0, IAlleleSpecies parentSpecies1, boolean shuffle);
List<IMutation<C>> getCombinations(IAlleleSpecies<C> parentSpecies0, IAlleleSpecies<C> parentSpecies1, boolean shuffle);
Collection<? extends IMutation> getPaths(IAllele result, IChromosomeType chromosomeType);
Collection<? extends IMutation<C>> getPaths(IAllele result, C chromosomeType);
/* RESEARCH */
@@ -167,10 +180,29 @@ public interface ISpeciesRoot {
/**
* @return Array of {@link IChromosomeType} which are in this species genome
*/
IChromosomeType[] getKaryotype();
@Nonnull
C[] getKaryotype();
/**
* @return {@link IChromosomeType} which is the "key" for this species class, usually the species chromosome.
*/
IChromosomeType getKaryotypeKey();
@Nonnull
C getKaryotypeKey();
C getChromosomeTypeForUid(byte uid);
/* GAME MODE */
void resetMode();
@Nonnull
List<? extends ISpeciesMode<C>> getModes();
@Nonnull
ISpeciesMode<C> getMode(@Nonnull World world);
@Nonnull
ISpeciesMode<C> getMode(@Nonnull String name);
void setMode(@Nonnull World world, @Nonnull String name);
}