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,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);
/**