Skip to content

Commit

Permalink
Added eggs to logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyhoot committed May 29, 2021
1 parent 1894446 commit 1911b70
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
14 changes: 12 additions & 2 deletions SubnauticaRandomiser/ProgressionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public bool AddMaterialsToReachableList(params Recipe[] additions)
return success;
}

// Deprecated.
public void RandomSubstituteMaterials(RecipeDictionary masterDict, bool useFish, bool useSeeds)
{
// This is the simplest way of randomisation. Merely take all materials
Expand Down Expand Up @@ -202,7 +203,8 @@ public void RandomSmart(RecipeDictionary masterDict, RandomiserConfig config)

foreach (Recipe r in _allMaterials.FindAll(x => !x.Category.Equals(ETechTypeCategory.RawMaterials)
&& !x.Category.Equals(ETechTypeCategory.Fish)
&& !x.Category.Equals(ETechTypeCategory.Seeds)))
&& !x.Category.Equals(ETechTypeCategory.Seeds)
&& !x.Category.Equals(ETechTypeCategory.Eggs)))
{
toBeRandomised.Add(r.TechType);
}
Expand Down Expand Up @@ -246,6 +248,8 @@ public void RandomSmart(RecipeDictionary masterDict, RandomiserConfig config)
AddMaterialsToReachableList(ETechTypeCategory.Fish, reachableDepth);
if (config.bUseSeeds && unlockedProgressionItems.ContainsKey(TechType.Knife))
AddMaterialsToReachableList(ETechTypeCategory.Seeds, reachableDepth);
if (config.bUseEggs && masterDict.DictionaryInstance.ContainsKey((int)TechType.BaseWaterPark))
AddMaterialsToReachableList(ETechTypeCategory.Eggs, reachableDepth);
}

// Grab a random recipe which has not yet been randomised.
Expand All @@ -263,7 +267,7 @@ public void RandomSmart(RecipeDictionary masterDict, RandomiserConfig config)
_reachableMaterials.Add(nextRecipe);
ApplyRandomisedRecipe(masterDict, nextRecipe);
toBeRandomised.Remove(nextType);

// Handling knives as a special case.
if ((nextType.Equals(TechType.Knife) || nextType.Equals(TechType.HeatBlade)) && !unlockedProgressionItems.ContainsKey(TechType.Knife))
{
Expand All @@ -274,6 +278,9 @@ public void RandomSmart(RecipeDictionary masterDict, RandomiserConfig config)
if (config.bUseSeeds)
AddMaterialsToReachableList(ETechTypeCategory.Seeds, reachableDepth);
}
// Similarly, Alien Containment is a special case for eggs.
if (nextType.Equals(TechType.BaseWaterPark) && config.bUseEggs)
AddMaterialsToReachableList(ETechTypeCategory.Eggs, reachableDepth);

// If it is a central progression item, consider it unlocked.
if (tree.depthProgressionItems.ContainsKey(nextType) && !unlockedProgressionItems.ContainsKey(nextType))
Expand Down Expand Up @@ -349,6 +356,9 @@ public Recipe RandomiseIngredients(Recipe recipe, List<Recipe> materials, Random
// Figure out how many, but no more than 5.
int amount = _random.Next(1, max);
amount = amount > 5 ? 5 : amount;
// Never require more than one (default) egg. That's tedious.
if (r.Category.Equals(ETechTypeCategory.Eggs))
amount = config.iMaxEggsAsSingleIngredient;

RandomiserIngredient ing = new RandomiserIngredient((int)r.TechType, amount);
ingredients.Add(ing);
Expand Down
10 changes: 8 additions & 2 deletions SubnauticaRandomiser/RandomiserConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ public class RandomiserConfig : ConfigFile
public int iRandomiserMode = 0;

[Toggle("Use fish in logic?")]
public bool bUseFish = false;
public bool bUseFish = true;

[Toggle("Use eggs in logic?")]
public bool bUseEggs = false;

[Toggle("Use seeds in logic?")]
public bool bUseSeeds = false;
public bool bUseSeeds = true;

[Button("Randomise Again")]
public void NewRandomisation()
Expand All @@ -45,6 +48,7 @@ public void NewRandomisation()
_timeButtonPressed = DateTime.UtcNow;
}

public int iMaxEggsAsSingleIngredient = 1;
public double dFuzziness = 0.2;
public double dIngredientRatio = 0.5;
// Way down here since it tends to take up some space and scrolling is annoying.
Expand All @@ -54,6 +58,8 @@ public void SanitiseConfigValues()
{
if (iRandomiserMode > 1 || iRandomiserMode < 0)
iRandomiserMode = 0;
if (iMaxEggsAsSingleIngredient > 10 || iMaxEggsAsSingleIngredient < 1)
iMaxEggsAsSingleIngredient = 1;
if (dFuzziness > 1 || dFuzziness < 0)
dFuzziness = 0.2;
if (dIngredientRatio > 1 || dIngredientRatio < 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace SubnauticaRandomiser
public enum ETechTypeCategory
{
None,
Eggs,
Fish,
Seeds,
RawMaterials,
Expand Down
2 changes: 1 addition & 1 deletion SubnauticaRandomiser/RandomiserObjects/Recipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Recipe(TechType type, ETechTypeCategory category, int depth = 0, List<Tec
// recipe already loaded by the game. Raw materials do not have any
// recipes to load this data from and *will* cause a NullReference.
TechData techdata = CraftDataHandler.GetTechData(type);
if (!category.Equals(ETechTypeCategory.RawMaterials) && !category.Equals(ETechTypeCategory.Fish) && !category.Equals(ETechTypeCategory.Seeds))
if (!category.Equals(ETechTypeCategory.RawMaterials) && !category.Equals(ETechTypeCategory.Fish) && !category.Equals(ETechTypeCategory.Seeds) && !category.Equals(ETechTypeCategory.Eggs))
{
if (techdata.ingredientCount > 0)
{
Expand Down
27 changes: 27 additions & 0 deletions recipeInformation.csv
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,30 @@ SpikePlantSeed,,Seeds,30,Knife,10,,
SpottedLeavesPlantSeed,,Seeds,180,Knife,20,,
TreeMushroomPiece,,Seeds,150,Knife,15,,
WhiteMushroomSpore,,Seeds,180,Knife,20,,
BoneShark,,Eggs,180,BaseWaterPark,30,,
BoneSharkEgg,,Eggs,180,BaseWaterPark,30,,
CrabSnake,,Eggs,200,BaseWaterPark,40,,
CrabSnakeEgg,,Eggs,200,BaseWaterPark,40,,
CrabSquid,,Eggs,250,BaseWaterPark,40,,
CrabSquidEgg,,Eggs,250,BaseWaterPark,40,,
Crash,,Eggs,20,BaseWaterPark,15,,
CrashEgg,,Eggs,20,BaseWaterPark,15,,
CuteFish,,Eggs,500,BaseWaterPark,80,,
CuteFishEgg,,Eggs,500,BaseWaterPark,80,,
Gasopod,,Eggs,20,BaseWaterPark,15,,
GasopodEgg,,Eggs,20,BaseWaterPark,15,,
JellyRay,,Eggs,180,BaseWaterPark,30,,
JellyRayEgg,,Eggs,180,BaseWaterPark,30,,
LavaLizard,,Eggs,1200,BaseWaterPark,40,,
LavaLizardEgg,,Eggs,1200,BaseWaterPark,40,,
Mesmer,,Eggs,200,BaseWaterPark,20,,
MesmerEgg,,Eggs,200,BaseWaterPark,20,,
RabbitRay,,Eggs,20,BaseWaterPark,15,,
RabbitRayEgg,,Eggs,20,BaseWaterPark,15,,
SandShark,,Eggs,80,BaseWaterPark,20,,
SandSharkEgg,,Eggs,80,BaseWaterPark,20,,
Shocker,,Eggs,200,BaseWaterPark,40,,
ShockerEgg,,Eggs,200,BaseWaterPark,40,,
SpadeFishEgg,,Eggs,160,BaseWaterPark,15,,
Stalker,,Eggs,100,BaseWaterPark,20,,
StalkerEgg,,Eggs,100,BaseWaterPark,20,,

0 comments on commit 1911b70

Please sign in to comment.