Skip to content

Commit

Permalink
Merge pull request #44 from tinyhoot/dev
Browse files Browse the repository at this point in the history
Update to v0.8.1
  • Loading branch information
tinyhoot authored Oct 8, 2022
2 parents 17ee395 + 9d9f045 commit c499a7f
Show file tree
Hide file tree
Showing 38 changed files with 489 additions and 292 deletions.
4 changes: 2 additions & 2 deletions DataFiles/alternateStarts.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ CrashZone,250/-650/700/-1100,700/-900/1200/-1300,1100/-650/1400/-1000,1350/550/1
Dunes,-1600/300/-1100/0,-1600/900/-1300/300,-1200/800/-1100/700
FloatingIsland,-712/-1072/-708/-1076
GrandReef,-1400/-1100/-900/-1500,-900/-1300/-300/-1600,,
GrassyPlateaus,-400/600/-300/500,-800/0/-500/200,250/350/350/150,0/-600/100/-700
GrassyPlateaus,-400/600/-300/500,-800/200/-500/0,250/350/350/150,0/-600/100/-700
Kelp,-550/320/-250/280,100/700/400/600,-300/-500/-200/-600,280/-380/320/-420
KooshZone,900/800/1400/600,,,
Mountains,600/1500/1300/1100,,,
MushroomForest,-1000/700/-700/500,600/600/700/300,,
SeaTreaderPath,-1500/-500/-1200/-800,,,
SparseReef,-800/-500/-600/-850,,,
UnderwaterIslands,-250/1150/0/800,,,
None,-1540/-1000/1500/-1040,1580/-580/1620/-620,-1410/1410/-1390/1390,
None,-1540/-1000/-1500/-1040,1580/-580/1620/-620,-1410/1410/-1390/1390,
20 changes: 10 additions & 10 deletions DataFiles/biomeSlots.csv
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CrashZone_EscapePod,2,0,0,
CrashZone_OpenDeep_CreatureOnly,0,0,762,
CrashZone_OpenShallow_CreatureOnly,0,0,1255,
CrashZone_Rock,804,804,682,
CrashZone_Sand,927,927,797,0.05
CrashZone_Sand,927,927,797,0.08
CrashZone_TrenchSand,179,179,185,0.2
DeepGrandReef_AbandonedBase_Exterior,28,0,0,0.1
DeepGrandReef_AbandonedBase_Interior,44,13,0,
Expand All @@ -85,7 +85,7 @@ Dunes_ThermalVent_Grass,9,9,9,
Dunes_ThermalVent_Rock,23,23,25,
Dunes_ThermalVent_Sand,30,30,33,
FloatingIslands_AbandonedBase_Inside,27,0,0,
FloatingIslands_AbandonedBase_Outside,60,8,0,
FloatingIslands_AbandonedBase_Outside,60,8,0,0.12
FloatingIslands_Birds,0,0,37,
GhostTree_Ceiling,51,51,25,
GhostTree_Ground,37,37,0,
Expand Down Expand Up @@ -115,11 +115,11 @@ GrassyPlateaus_CaveEntrance,1,1,2,
GrassyPlateaus_CaveFloor,1,1,3,
GrassyPlateaus_CaveWall,36,36,25,
GrassyPlateaus_EscapePod,11,7,0,
GrassyPlateaus_Grass,126,126,115,0.03
GrassyPlateaus_Grass,126,126,115,0.05
GrassyPlateaus_OpenDeep_CreatureOnly,0,0,753,
GrassyPlateaus_OpenShallow_CreatureOnly,0,0,960,
GrassyPlateaus_PlateauTop_Obsolete,7,7,26,
GrassyPlateaus_Sand,375,375,180,0.045
GrassyPlateaus_Sand,375,375,180,0.08
GrassyPlateaus_TechSite,110,31,0,0.17
GrassyPlateaus_TechSite_Barrier,78,19,0,0.5700001
GrassyPlateaus_TechSite_Scattered,345,235,0,0.16
Expand Down Expand Up @@ -163,8 +163,8 @@ Kelp_CaveSpecial,1,1,0,
Kelp_CaveWall,40,40,23,
Kelp_DenseVine,0,0,133,
Kelp_EscapePod,13,10,0,
Kelp_GrassDense,34,34,33,
Kelp_GrassSparse,44,44,77,
Kelp_GrassDense,34,34,33,0.15
Kelp_GrassSparse,44,44,77,0.1
Kelp_Outcropping_Obsolete,0,0,9,
Kelp_Sand,143,143,139,
Kelp_SandRocky_Obsolete,0,0,3,
Expand Down Expand Up @@ -210,7 +210,7 @@ Mountains_Birds,0,0,34,
Mountains_CaveCeiling,9,9,3,
Mountains_CaveFloor,27,27,19,
Mountains_CaveWall,42,42,20,
Mountains_Grass,96,96,79,0.07
Mountains_Grass,96,96,79,0.1
Mountains_IslandCaveCeiling,8,8,1,
Mountains_IslandCaveFloor,24,24,6,
Mountains_IslandCaveWall,54,54,17,
Expand All @@ -220,7 +220,7 @@ Mountains_IslandSand,17,17,0,
Mountains_OpenDeep_CreatureOnly,0,0,3078,
Mountains_OpenShallow_CreatureOnly,0,0,5183,
Mountains_Rock,886,886,701,
Mountains_Sand,480,480,392,0.03
Mountains_Sand,480,480,392,0.05
Mountains_TechSite,35,14,0,0.24
Mountains_TechSite_Barrier,31,18,0,0.43
Mountains_TechSite_Scatter,79,79,0,0.27
Expand Down Expand Up @@ -261,7 +261,7 @@ SafeShallows_PlateauTop_Obsolete,0,0,2,
SafeShallows_SandFlat,75,75,56,
SafeShallows_ShellTunnel,5,5,31,
SafeShallows_ShellTunnelHuge,2,2,2,
SafeShallows_TechSite,12,2,0,0.12
SafeShallows_TechSite,12,2,0,0.16
SafeShallows_TechSite_Barrier,9,0,0,0.2
SafeShallows_TechSite_Hidden_Obsolete,2,0,0,
SafeShallows_TechSite_Scattered,101,59,0,0.08
Expand All @@ -277,7 +277,7 @@ SeaTreaderPath_OpenDeep_CreatureOnly,0,0,1038,
SeaTreaderPath_OpenShallow_CreatureOnly,0,0,2194,
SeaTreaderPath_Path,47,47,43,
SeaTreaderPath_Rock,180,180,215,
SeaTreaderPath_Sand,139,139,131,0.09999999
SeaTreaderPath_Sand,139,139,131,0.12
SeaTreaderPath_TechSite,15,10,0,0.7
SeaTreaderPath_TechSite_Barrier,8,3,0,1.5
SeaTreaderPath_TechSite_Scatter,34,34,0,0.26
Expand Down
25 changes: 12 additions & 13 deletions DataFiles/recipeInformation.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
,CraftBonus:,,,5,,,
TechType,Category,Depth,Prerequisites,Value,MaxUsesPerGame,BlueprintUnlockCondition,BlueprintUnlockDepth
AluminumOxide,RawMaterials,180,,15,,,
CrashPowder,RawMaterials,25,,20,3,,
Expand Down Expand Up @@ -244,28 +243,28 @@ SpadeFishEgg,Eggs,160,BaseWaterPark,15,,,
Stalker,Eggs,100,BaseWaterPark,20,,,
StalkerEgg,Eggs,100,BaseWaterPark,20,,,
BaseBioReactorFragment,Fragments,,,75,,,
BaseNuclearReactorFragment,Fragments,,,295,,,
BaseNuclearReactorFragment,Fragments,150,,295,,,
BatteryChargerFragment,Fragments,,,65,,,
BeaconFragment,Fragments,,,25,,,
ConstructorFragment,Fragments,,,215,,,
CyclopsBridgeFragment,Fragments,,,800,,,
CyclopsEngineFragment,Fragments,,,800,,,
CyclopsHullFragment,Fragments,,,800,,,
ExosuitFragment,Fragments,,,475,,,
ExosuitDrillArmFragment,Fragments,,,130,,,
ExosuitGrapplingArmFragment,Fragments,,,225,,,
ExosuitPropulsionArmFragment,Fragments,,,180,,,
ExosuitTorpedoArmFragment,Fragments,,,105,,,
CyclopsBridgeFragment,Fragments,200,,800,,,
CyclopsEngineFragment,Fragments,200,,800,,,
CyclopsHullFragment,Fragments,200,,800,,,
ExosuitFragment,Fragments,100,,475,,,
ExosuitDrillArmFragment,Fragments,100,,130,,,
ExosuitGrapplingArmFragment,Fragments,100,,225,,,
ExosuitPropulsionArmFragment,Fragments,100,,180,,,
ExosuitTorpedoArmFragment,Fragments,100,,105,,,
GravSphereFragment,Fragments,,,60,,,
LaserCutterFragment,Fragments,,,100,,,
LEDLightFragment,Fragments,,,75,,,
MoonpoolFragment,Fragments,,,250,,,
PowerCellChargerFragment,Fragments,,,175,,,
PowerCellChargerFragment,Fragments,150,,175,,,
PowerTransmitterFragment,Fragments,,,25,,,
PropulsionCannonFragment,Fragments,,,75,,,
BaseMapRoomFragment,Fragments,,,90,,,
SeaglideFragment,Fragments,,,90,,,
SeamothFragment,Fragments,,,275,,,
StasisRifleFragment,Fragments,,,160,,,
ThermalPlantFragment,Fragments,,,130,,,
WorkBenchFragment,Fragments,,,110,,,
ThermalPlantFragment,Fragments,100,,130,,,
WorkBenchFragment,Fragments,100,,110,,,
18 changes: 9 additions & 9 deletions SubnauticaRandomiser/CSVReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Security.Cryptography;
using JetBrains.Annotations;
using SubnauticaRandomiser.RandomiserObjects;
using SubnauticaRandomiser.RandomiserObjects.Enums;
using UnityEngine;

namespace SubnauticaRandomiser
Expand Down Expand Up @@ -277,8 +278,8 @@ private LogicEntity ParseRecipeFileLine(string line)
if (category.CanHaveRecipe())
recipe = new Recipe(type);

LogHandler.Debug("Registering entity: " + type.AsString() + ", " + category.ToString() + ", "
+ depth + ", "+ prereqList.Count + " prerequisites, " + value + ", " + maxUses + ", ...");
LogHandler.Debug($"Registering entity: {type.AsString()}, {category}, {depth}, {prereqList.Count}"
+ $" prerequisites, {value}, {maxUses}, ...");

var entity = new LogicEntity(type, category, blueprint, recipe, null, prereqList, false, value)
{
Expand Down Expand Up @@ -328,12 +329,12 @@ internal List<BiomeCollection> ParseBiomeFile(string fileName)
try
{
Biome biome = ParseBiomeFileLine(line);
BiomeCollection collection = _csvBiomeList.Find(x => x.BiomeType.Equals(biome.BiomeType));
BiomeCollection collection = _csvBiomeList.Find(x => x.BiomeType.Equals(biome.Region));

// Initiate a BiomeCollection if it does not already exist.
if (collection is null)
{
collection = new BiomeCollection(biome.BiomeType);
collection = new BiomeCollection(biome.Region);
_csvBiomeList.Add(collection);
}

Expand Down Expand Up @@ -400,8 +401,7 @@ private Biome ParseBiomeFileLine(string line)
fragmentRate = StringToFloat(cellsFragmentRate, "fragmentRate");

biome = new Biome(name, biomeType, creatureCount, mediumCount, smallCount, fragmentRate);
LogHandler.Debug("Registering biome: " + name + ", " + biomeType.ToString() + ", " + creatureCount
+ ", " + mediumCount + ", " + smallCount);
LogHandler.Debug($"Registering biome: {name}, {biomeType}, {creatureCount}, {mediumCount}, {smallCount}");

return biome;
}
Expand Down Expand Up @@ -527,8 +527,8 @@ private Databox ParseWreckageFileLine(string line)
if (!string.IsNullOrEmpty(cellsPropulsionCannon))
propulsionCannon = StringToBool(cellsPropulsionCannon, "NeedsPropulsionCannon");

LogHandler.Debug("Registering databox: " + type + ", " + coordinates.ToString() + ", "
+ wreck.ToString() + ", " + laserCutter + ", " + propulsionCannon);
LogHandler.Debug($"Registering databox: {type.AsString()}, {coordinates}, {wreck}, {laserCutter}, "
+ propulsionCannon);
Databox databox = new Databox(type, coordinates, wreck, laserCutter, propulsionCannon);

return databox;
Expand Down Expand Up @@ -600,7 +600,7 @@ private static EBiomeType StringToEBiomeType(string str)
{
foreach (string type in Enum.GetNames(typeof(EBiomeType)))
{
if (str.Contains(type))
if (str.ToLower().Contains(type.ToLower()))
{
try
{
Expand Down
20 changes: 16 additions & 4 deletions SubnauticaRandomiser/ConfigDefaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ internal static class ConfigDefaults
{ "bRandomiseRecipes", new[] { true, true, true } },
{ "bVanillaUpgradeChains", new[] { false, false, false } },
{ "bDoBaseTheming", new[] { false, false, false } },
{ "iEquipmentAsIngredients", new[] { 1, 0, 2 } },
{ "iToolsAsIngredients", new[] { 1, 0, 2 } },
{ "iEquipmentAsIngredients", new[] { 0, 0, 2 } },
{ "iToolsAsIngredients", new[] { 0, 0, 2 } },
{ "iUpgradesAsIngredients", new[] { 1, 0, 2 } },
{ "iMaxAmountPerIngredient", new[] { 5, 1, 10 } },
{ "iMaxIngredientsPerRecipe", new[] { 7, 1, 10 } },
Expand All @@ -34,12 +34,14 @@ internal static class ConfigDefaults
// Advanced settings start here.
{ "iDepthSearchTime", new[] { 15, 0, 45 } },
{ "iMaxBasicOutpostSize", new[] { 24, 4, 48 } },
{ "iMaxDepthWithoutVehicle", new[] { 200, 100, 500 } },
{ "iMaxDuplicateScanYield", new[] { 2, 1, 10 } },
{ "iMaxEggsAsSingleIngredient", new[] { 1, 1, 10 } },
{ "iMaxFragmentsPerBiome", new[] { 4, 1, 10 } },
{ "iMaxInventorySizePerRecipe", new[] { 24, 4, 100 } },
{ "iMinFragmentsToUnlock", new[] { 2, 1, 30 } },
{ "dFuzziness", new[] { 0.2, 0.0, 1.0 } },
{ "dIngredientRatio", new[] { 0.45, 0.0, 1.0 } },
{ "dPrimaryIngredientValue", new[] { 0.45, 0.0, 1.0 } },
{ "dRecipeValueVariance", new[] { 0.2, 0.0, 1.0 } },
{ "fFragmentSpawnChanceMin", new[] { 0.3f, 0.01f, 10.0f } },
{ "fFragmentSpawnChanceMax", new[] { 0.6f, 0.01f, 10.0f } },
};
Expand All @@ -61,11 +63,21 @@ internal static object GetDefault(string key)

internal static object GetMax(string key)
{
if (!s_defaults.ContainsKey(key))
{
LogHandler.Warn("Tried to get invalid key from config default dictionary: " + key);
return null;
}
return s_defaults[key][2];
}

internal static object GetMin(string key)
{
if (!s_defaults.ContainsKey(key))
{
LogHandler.Warn("Tried to get invalid key from config default dictionary: " + key);
return null;
}
return s_defaults[key][1];
}
}
Expand Down
6 changes: 3 additions & 3 deletions SubnauticaRandomiser/EntitySerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public bool AddFragmentUnlockNum(TechType type, int number)
{
if (NumFragmentsToUnlock.ContainsKey(type))
{
LogHandler.Warn("Tried to add duplicate key " + type.AsString() + " to FragmentNum master dictionary!");
LogHandler.Warn($"[ES] Tried to add duplicate key {type.AsString()} to FragmentNum master dictionary!");
return false;
}
NumFragmentsToUnlock.Add(type, number);
Expand All @@ -111,7 +111,7 @@ public bool AddRecipe(TechType type, Recipe r)
{
if (RecipeDict.ContainsKey(type))
{
LogHandler.Warn("Tried to add duplicate key " + type.AsString() + " to Recipe master dictionary!");
LogHandler.Warn($"[ES] Tried to add duplicate key {type.AsString()} to Recipe master dictionary!");
return false;
}
RecipeDict.Add(type, r);
Expand All @@ -128,7 +128,7 @@ public bool AddSpawnData(TechType type, List<SpawnData> data)
{
if (SpawnDataDict.ContainsKey(type))
{
LogHandler.Warn("Tried to add duplicate key " + type.AsString() + "to SpawnData master dictionary!");
LogHandler.Warn($"Tried to add duplicate key {type.AsString()} to SpawnData master dictionary!");
return false;
}
SpawnDataDict.Add(type, data);
Expand Down
21 changes: 18 additions & 3 deletions SubnauticaRandomiser/InitMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using SubnauticaRandomiser.Logic.Recipes;
using SubnauticaRandomiser.Patches;
using SubnauticaRandomiser.RandomiserObjects;
using SubnauticaRandomiser.RandomiserObjects.Enums;
using SubnauticaRandomiser.RandomiserObjects.Exceptions;

namespace SubnauticaRandomiser
{
Expand All @@ -21,14 +23,14 @@ public static class InitMod
internal const string s_biomeFile = "biomeSlots.csv";
internal const string s_recipeFile = "recipeInformation.csv";
internal const string s_wreckageFile = "wreckInformation.csv";
internal const string s_expectedRecipeMD5 = "4ab1b7a019037f76c0d508f1c2aee5f8";
internal const string s_expectedRecipeMD5 = "fb1f4990a52976c72ec957f82bf15bf4";
internal const int s_expectedSaveVersion = 4;
internal static readonly Dictionary<int, string> s_versionDict = new Dictionary<int, string>
{
[1] = "v0.5.1",
[2] = "v0.6.1",
[3] = "v0.7.0",
[4] = "v0.8.0"
[4] = "v0.8.1"
};

// The master list of everything that is modified by the mod.
Expand Down Expand Up @@ -103,7 +105,20 @@ internal static void Randomise()

// Randomise!
CoreLogic logic = new CoreLogic(random, s_config, materials, alternateStarts, biomes, databoxes);
s_masterDict = logic.Randomise();
try
{
s_masterDict = logic.Randomise();
}
catch (Exception ex)
{
LogHandler.MainMenuMessage("ERROR: Something went wrong. Please report this error with the config.json"
+ " from your mod folder on NexusMods.");
LogHandler.Fatal($"{ex.GetType()}: {ex.Message}");

// Ensure that the randomiser crashes completely if things go wrong this badly.
throw;
}

ApplyAllChanges();
LogHandler.Info("Randomisation successful!");

Expand Down
9 changes: 7 additions & 2 deletions SubnauticaRandomiser/Logic/AlternateStartLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using SubnauticaRandomiser.RandomiserObjects;
using SubnauticaRandomiser.RandomiserObjects.Enums;
using Random = System.Random;

namespace SubnauticaRandomiser.Logic
Expand Down Expand Up @@ -35,6 +36,10 @@ private EBiomeType GetBiome()
switch (_config.sSpawnPoint)
{
case "Random":
// Only use starts where you can actually reach the ground.
return _logic.GetRandom(_alternateStarts.Keys.ToList()
.FindAll(biome => !biome.Equals(EBiomeType.None) && biome.GetAccessibleDepth() <= 100));
case "Chaotic Random":
return _logic.GetRandom(_alternateStarts.Keys.ToList());
case "BulbZone":
return EBiomeType.KooshZone;
Expand All @@ -59,7 +64,7 @@ private RandomiserVector GetRandomStart()
EBiomeType biome = GetBiome();
if (!_alternateStarts.ContainsKey(biome))
{
LogHandler.Error("No information found on chosen starting biome " + biome);
LogHandler.Error("[AS] No information found on chosen starting biome " + biome);
return new RandomiserVector(0, 0, 0);
}

Expand All @@ -70,7 +75,7 @@ private RandomiserVector GetRandomStart()
int x = _random.Next((int)box[0], (int)box[2] + 1);
int z = _random.Next((int)box[3], (int)box[1] + 1);

LogHandler.Debug("Chosen new lifepod spawnpoint at x:" + x + " y:0" + " z:" + z);
LogHandler.Debug("[AS] Chosen new lifepod spawnpoint at x:" + x + " y:0" + " z:" + z);
return new RandomiserVector(x, 0, z);
}
}
Expand Down
Loading

0 comments on commit c499a7f

Please sign in to comment.