All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mmb.engine.craft.rgroups.CatSingleRecipeGroup Maven / Gradle / Ivy

Go to download

Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world. THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<

There is a newer version: 0.6
Show newest version
/**
 * 
 */
package mmb.engine.craft.rgroups;

import io.vavr.Tuple2;
import mmb.NN;
import mmb.Nil;
import mmb.content.electric.VoltageTier;
import mmb.engine.chance.Chance;
import mmb.engine.craft.RecipeOutput;
import mmb.engine.craft.singles.SimpleRecipe;
import mmb.engine.craft.singles.SimpleRecipeGroup;
import mmb.engine.item.ItemEntry;
import mmb.menu.world.craft.SimpleCatalyzedRecipeView;
import monniasza.collects.Identifiable;

/**
 * A group of recipes with single input and a catalyst
 * @author oskar
 */
public class CatSingleRecipeGroup extends AbstractRecipeGroupCatalyzed<@NN ItemEntry, @NN CatSingleRecipeGroup.CatalyzedSimpleRecipe>
implements SimpleRecipeGroup{
	/**
	 * Creates a list of catalyzed single-item recipes
	 * @param id group ID
	 */
	public CatSingleRecipeGroup(String id) {
		super(id, CatalyzedSimpleRecipe.class);
	}
	
	/**
	 * @author oskar
	 * A recipe with single input and a catlayst
	 */
	public class CatalyzedSimpleRecipe extends BaseElectricRecipe implements Identifiable>, SimpleRecipe<@NN CatalyzedSimpleRecipe>{
		/** The input item */
		@NN public final ItemEntry input;
		/** Required catalyst */
		@Nil public final ItemEntry catalyst;
		/** Item tuple */
		@NN public final Tuple2 tuple;
		
		/**
		 * Creates a single catalyzed recipe
		 * @param energy energy required for completion in joules
		 * @param voltage voltage tier required for this recipe
		 * @param input the input item
		 * @param output deterministic output of this recipe
		 * @param catalyst required catalyst
		 * @param luck randomized output of this recipe
		 */
		public CatalyzedSimpleRecipe(double energy, VoltageTier voltage, ItemEntry input, @Nil ItemEntry catalyst, RecipeOutput output, Chance luck) {
			super(energy, voltage, output, luck);
			this.input = input;
			this.catalyst = catalyst;
			this.tuple = new Tuple2<>(input, catalyst);
		}
		@Override
		public Tuple2 id() {
			return tuple;
		}
		@Override
		public ItemEntry inputs() {
			return input;
		}
		@Override
		public ItemEntry catalyst() {
			return catalyst;
		}
		@Override
		public CatSingleRecipeGroup group() {
			return CatSingleRecipeGroup.this;
		}
		@Override
		public CatalyzedSimpleRecipe that() {
			return this;
		}
	}
	
	//Recipe addition
	/**
	 * Adds a recipes to this recipe group
	 * @param in input item
	 * @param out output
	 * @param catalyst catalyst required to run the recipe
	 * @param voltage voltage tier required by this recipe
	 * @param energy energy consumed by this recipe
	 * @param luck random chanced items
	 * @return a new recipe
	 */
	public CatalyzedSimpleRecipe add(ItemEntry in, RecipeOutput out, @Nil ItemEntry catalyst, VoltageTier voltage, double energy, Chance luck) {
		@NN CatalyzedSimpleRecipe recipe = new CatalyzedSimpleRecipe(energy, voltage, in, catalyst, out, luck);
		insert(recipe);
		return recipe;
	}
	/**
	 * @param in input item
	 * @param out output item
	 * @param catalyst catalyst required to run the recipe
	 * @param amount amount of output item
	 * @param voltage voltage tier required by this recipe
	 * @param energy energy consumed by this recipe
	 * @param luck random chanced items
	 * @return a new recipe
	 */
	public CatalyzedSimpleRecipe add(ItemEntry in, ItemEntry out, @Nil ItemEntry catalyst, int amount, VoltageTier voltage, double energy, Chance luck) {
		return add(in, out.stack(amount), catalyst, voltage, energy, luck);
	}
	/**
	 * Adds a recipes to this recipe group
	 * @param in input item
	 * @param out output
	 * @param catalyst catalyst required to run the recipe
	 * @param voltage voltage tier required by this recipe
	 * @param energy energy consumed by this recipe
	 * @return a new recipe
	 */
	public CatalyzedSimpleRecipe add(ItemEntry in, RecipeOutput out, @Nil ItemEntry catalyst, VoltageTier voltage, double energy) {
		return add(in, out, catalyst, voltage, energy, Chance.NONE);
	}
	/**
	 * @param in input item
	 * @param out output item
	 * @param catalyst catalyst required to run the recipe
	 * @param amount amount of output item
	 * @param voltage voltage tier required by this recipe
	 * @param energy energy consumed by this recipe
	 * @return a new recipe
	 */
	public CatalyzedSimpleRecipe add(ItemEntry in, ItemEntry out, @Nil ItemEntry catalyst, int amount, VoltageTier voltage, double energy) {
		return add(in, out.stack(amount), catalyst, voltage, energy, Chance.NONE);
	}
	
	//Others
	@Override
	public SimpleCatalyzedRecipeView createView() {
		return new SimpleCatalyzedRecipeView();
	}
	@Override
	public CatalyzedSimpleRecipe findRecipe(@Nil ItemEntry catalyst, ItemEntry in) {
		return recipes().get(new Tuple2<>(in, catalyst));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy