From aedf57259ed743033abb77db16ae697a31660440 Mon Sep 17 00:00:00 2001 From: tinyhoot <78366332+tinyhoot@users.noreply.github.com> Date: Tue, 27 Dec 2022 20:15:19 +0100 Subject: [PATCH 1/4] Fix scanner room upgrades not counting as upgrades. --- SubnauticaRandomiser/Logic/Recipes/Mode.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SubnauticaRandomiser/Logic/Recipes/Mode.cs b/SubnauticaRandomiser/Logic/Recipes/Mode.cs index 44621e9..0dcd412 100644 --- a/SubnauticaRandomiser/Logic/Recipes/Mode.cs +++ b/SubnauticaRandomiser/Logic/Recipes/Mode.cs @@ -150,6 +150,7 @@ protected void UpdateBlacklist(LogicEntity entity) _blacklist.Add(ETechTypeCategory.Tools); if (_config.iUpgradesAsIngredients == 0 || (_config.iUpgradesAsIngredients == 1 && entity.CanFunctionAsIngredient())) { + _blacklist.Add(ETechTypeCategory.ScannerRoom); _blacklist.Add(ETechTypeCategory.VehicleUpgrades); _blacklist.Add(ETechTypeCategory.WorkBenchUpgrades); } From 9b9a1c1ecac932297b93a717a61b8afc7c427b89 Mon Sep 17 00:00:00 2001 From: tinyhoot <78366332+tinyhoot@users.noreply.github.com> Date: Fri, 30 Dec 2022 07:48:47 +0100 Subject: [PATCH 2/4] Fix priority entities ignoring requirements too early. --- SubnauticaRandomiser/Logic/ProgressionTree.cs | 13 +++++++++---- SubnauticaRandomiser/Logic/Recipes/RecipeLogic.cs | 2 +- .../Objects/Enums/EProgressionNode.cs | 10 ++++++++++ Tests/UnitTests/Logic/ProgressionTreeTest.cs | 4 ++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/SubnauticaRandomiser/Logic/ProgressionTree.cs b/SubnauticaRandomiser/Logic/ProgressionTree.cs index bfb27c7..7cbc7c9 100644 --- a/SubnauticaRandomiser/Logic/ProgressionTree.cs +++ b/SubnauticaRandomiser/Logic/ProgressionTree.cs @@ -421,15 +421,20 @@ public List GetElectiveItems(int depth) } /// - /// Check whether the given entity is part of any essential or elective items in any node. + /// Check whether the given entity is part of any essential or elective items in any node up to the given depth. /// /// The entity to check. + /// Consider entities up to this depth. /// True if the entity is part of essential or elective items, false otherwise. - public bool IsPriorityEntity(LogicEntity entity) + public bool IsPriorityEntity(LogicEntity entity, int depth) { - if (_essentialItems.Values.Any(list => list.Contains(entity.TechType))) + if (_essentialItems + .Where(kv => !kv.Key.isDeeperThan(depth)) + .Any(kv => kv.Value.Contains(entity.TechType))) return true; - if (_electiveItems.Values.Any(list => list.Any(arr => arr.Contains(entity.TechType)))) + if (_electiveItems + .Where(kv => !kv.Key.isDeeperThan(depth)) + .Any(kv => kv.Value.Any(arr => arr.Contains(entity.TechType)))) return true; return false; diff --git a/SubnauticaRandomiser/Logic/Recipes/RecipeLogic.cs b/SubnauticaRandomiser/Logic/Recipes/RecipeLogic.cs index 8fe67cf..05f8c83 100644 --- a/SubnauticaRandomiser/Logic/Recipes/RecipeLogic.cs +++ b/SubnauticaRandomiser/Logic/Recipes/RecipeLogic.cs @@ -50,7 +50,7 @@ public RecipeLogic(CoreLogic coreLogic) internal bool RandomiseRecipe(LogicEntity entity, Dictionary unlockedProgressionItems, int reachableDepth) { // Does this recipe have all of its prerequisites fulfilled? Skip this check if the recipe is a priority. - if (!(_tree.IsPriorityEntity(entity) + if (!(_tree.IsPriorityEntity(entity, reachableDepth) || (entity.CheckBlueprintFulfilled(_logic, reachableDepth) && entity.CheckPrerequisitesFulfilled(_logic)))) { _log.Debug($"[R] --- Recipe [{entity}] did not fulfill requirements, skipping."); diff --git a/SubnauticaRandomiser/Objects/Enums/EProgressionNode.cs b/SubnauticaRandomiser/Objects/Enums/EProgressionNode.cs index efc717e..dfa3aff 100644 --- a/SubnauticaRandomiser/Objects/Enums/EProgressionNode.cs +++ b/SubnauticaRandomiser/Objects/Enums/EProgressionNode.cs @@ -27,5 +27,15 @@ public static class EProgressionNodeExtensions EProgressionNode.Depth1300m, EProgressionNode.Depth1700m }; + + /// + /// Is this node deeper the given depth? + /// + public static bool isDeeperThan(this EProgressionNode node, int depth) + { + if (node.Equals(EProgressionNode.None)) + return false; + return (int)node > depth; + } } } diff --git a/Tests/UnitTests/Logic/ProgressionTreeTest.cs b/Tests/UnitTests/Logic/ProgressionTreeTest.cs index 5e46a8e..53fee18 100644 --- a/Tests/UnitTests/Logic/ProgressionTreeTest.cs +++ b/Tests/UnitTests/Logic/ProgressionTreeTest.cs @@ -216,7 +216,7 @@ public void TestGetBaseOfUpgrade_Entity_Null() } [TestCase(TechType.Seaglide, ExpectedResult = true)] - [TestCase(TechType.Battery, ExpectedResult = true)] + [TestCase(TechType.Battery, ExpectedResult = false)] [TestCase(TechType.Seamoth, ExpectedResult = false)] public bool TestIsPriorityEntity(TechType techType) { @@ -224,7 +224,7 @@ public bool TestIsPriorityEntity(TechType techType) _tree._electiveItems.Add(EProgressionNode.Depth300m, new List{ new [] { TechType.Battery }}); LogicEntity entity = new LogicEntity(techType, ETechTypeCategory.None); - return _tree.IsPriorityEntity(entity); + return _tree.IsPriorityEntity(entity, 128); } [TestCase(TechType.Benzene, ExpectedResult = true)] From 5e906ee7b7cea69ab2429f26fbc9c4100babcfca Mon Sep 17 00:00:00 2001 From: tinyhoot <78366332+tinyhoot@users.noreply.github.com> Date: Fri, 30 Dec 2022 08:01:29 +0100 Subject: [PATCH 3/4] Fix BaseRoom randomised before the builder. --- SubnauticaRandomiser/Logic/ProgressionTree.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SubnauticaRandomiser/Logic/ProgressionTree.cs b/SubnauticaRandomiser/Logic/ProgressionTree.cs index 7cbc7c9..b02466a 100644 --- a/SubnauticaRandomiser/Logic/ProgressionTree.cs +++ b/SubnauticaRandomiser/Logic/ProgressionTree.cs @@ -162,12 +162,11 @@ public void SetupRecipes(bool useVanillaUpgradeChains) AddEssentialItem(EProgressionNode.Depth0m, TechType.BaseHatch); AddEssentialItem(EProgressionNode.Depth0m, TechType.Fabricator); + AddEssentialItem(EProgressionNode.Depth100m, TechType.Builder); AddEssentialItem(EProgressionNode.Depth100m, TechType.BaseRoom); AddEssentialItem(EProgressionNode.Depth100m, TechType.Seaglide); AddEssentialItem(EProgressionNode.Depth100m, TechType.Tank); - AddEssentialItem(EProgressionNode.Depth200m, TechType.Builder); - AddEssentialItem(EProgressionNode.Depth300m, TechType.BaseWaterPark); // From among these, at least one has to be accessible by the provided From eb62107dac170c7a0cbc5949d427c60298d89caf Mon Sep 17 00:00:00 2001 From: tinyhoot <78366332+tinyhoot@users.noreply.github.com> Date: Fri, 30 Dec 2022 17:07:22 +0100 Subject: [PATCH 4/4] Version bump to v0.9.1 --- SubnauticaRandomiser/InitMod.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SubnauticaRandomiser/InitMod.cs b/SubnauticaRandomiser/InitMod.cs index 0fc2311..c93294b 100644 --- a/SubnauticaRandomiser/InitMod.cs +++ b/SubnauticaRandomiser/InitMod.cs @@ -21,7 +21,7 @@ namespace SubnauticaRandomiser public class InitMod : BaseUnityPlugin { public const string GUID = "com.github.tinyhoot.SubnauticaRandomiser"; - public const string VERSION = "0.9.0"; + public const string VERSION = "0.9.1"; internal static string s_modDirectory; internal static RandomiserConfig s_config;