diff --git a/Assets/Scripts/GenerateDemoFiles.cs b/Assets/Scripts/GenerateDemoFiles.cs index 0e52827f8b4773f84c8906a7a774315eae13b6ee..1f2847d999d35b8b417941db9a134b56425f158a 100644 --- a/Assets/Scripts/GenerateDemoFiles.cs +++ b/Assets/Scripts/GenerateDemoFiles.cs @@ -47,7 +47,7 @@ public static void GenerateDemoA() // Set Solution StageStatic.stage.solution.ValidationSet = new List<SolutionOrganizer.SubSolution> - { new SolutionOrganizer.SubSolution(new HashSet<string> { target_Id }, null, new LineFactHightDirectionComparer()) }; + { new SolutionOrganizer.SubSolution(new HashSet<string> { target_Id }, null, null, new LineFactHightDirectionComparer()) }; // Save StageStatic.stage.store(); diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs index 5bd54c5b6ab84e345f510c7b4aaf733da24209a7..531cf84da48286966c10654609eb2dccd305ceb7 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs @@ -599,13 +599,19 @@ public bool DynamiclySolved( foreach (var ValidationSet in MinimalSolution.ValidationSet) { + // List to relato to. Either all active facts or those defined in RelationIndex if not empty + var relateList = ValidationSet.RelationIndex.Count == 0 ? activeList : + ValidationSet.RelationIndex.Select(i => Solution_L[i]) // Select by Index + .SelectMany(i => i) // Flatten structure + .Select(URI => this[URI]); // Get Facts + // check by MasterIds // ALL Masters must relate var part_minimal = ValidationSet.MasterIDs.Select(URI => MinimalSolution[URI]); var part_solution = - activeList.Where(active => part_minimal.Contains(active, ValidationSet.Comparer.SetSearchRight())) + relateList.Where(active => part_minimal.Contains(active, ValidationSet.Comparer.SetSearchRight())) .ToList(); // needed for some reason var part_missing = @@ -621,12 +627,12 @@ public bool DynamiclySolved( var part_consequential_minimal = ValidationSet.SolutionIndex.Select(i => Solution_L[i]) // Select by Index .SelectMany(i => i) // Flatten structure - .Select(URI => MinimalSolution[URI]); // Get Facts + .Select(URI => this[URI]); // Get Facts var part_consequential_solution = - activeList.Where(active => part_consequential_minimal.Contains(active, ValidationSet.Comparer.SetSearchRight())); + relateList.Where(active => part_consequential_minimal.Contains(active, ValidationSet.Comparer.SetSearchRight())); - Solution_L.Last().Concat(part_consequential_solution.Select(fact => fact.Id).ToList()); + Solution_L.Last().AddRange(part_consequential_solution.Select(fact => fact.Id).ToList()); MissingElementsCount += Convert.ToInt32( part_consequential_solution.Count() == 0 && part_consequential_minimal.Count() != 0); } diff --git a/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs b/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs index d28a47036d37a66c8718f95cc67c8aea79d0c7ce..329ae8bfe288ff869f670030740b2b3a73474ed4 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs @@ -28,6 +28,12 @@ public class SubSolution // // List<int> SolutionIndex: int{[],[0, SolutionOrganizer.ValidationSet.IndexOf(this) - 2]} // marks LevelFacts found as solution in a previous entry + // to relate from in addition to MasterIDs + // or none if empty + // + // List<int> RelationIndex: int{[],[0, SolutionOrganizer.ValidationSet.IndexOf(this) - 2]} + // marks LevelFacts found as solution in a previous entry + // to relate to instead of all facts // or none if empty // // Comparer FactComparer: @@ -35,6 +41,7 @@ public class SubSolution public HashSet<string> MasterIDs = new HashSet<string>(); public List<int> SolutionIndex = new List<int>(); + public List<int> RelationIndex = new List<int>(); [JsonIgnore] public FactComparer Comparer = new FactEquivalentsComparer(); @@ -51,7 +58,7 @@ public string ComparerString public SubSolution() { } - public SubSolution(HashSet<string> MasterIDs, List<int> SolutionIndex, FactComparer Comparer) + public SubSolution(HashSet<string> MasterIDs, List<int> SolutionIndex, List<int> RelationIndex, FactComparer Comparer) { if (MasterIDs != null) this.MasterIDs = MasterIDs; @@ -59,6 +66,9 @@ public SubSolution(HashSet<string> MasterIDs, List<int> SolutionIndex, FactCompa if (SolutionIndex != null) this.SolutionIndex = SolutionIndex; + if (RelationIndex != null) + this.RelationIndex = RelationIndex; + if (Comparer != null) this.Comparer = Comparer; } diff --git a/Assets/Scripts/Loading/Stage.cs b/Assets/Scripts/Loading/Stage.cs index 5830eef2fd2036df69864a8bc2a4401bd58d17d6..9207b972df0bd6b5668d4045ad9f6986652bd0c7 100644 --- a/Assets/Scripts/Loading/Stage.cs +++ b/Assets/Scripts/Loading/Stage.cs @@ -63,13 +63,13 @@ public Stage(string category, int number, string name, string description, strin public Stage(Stage get, string category, int number, string name, string description, string scene, bool local = true) { + InitOOP(); Stage cpy = new Stage(); // "DeepCopy" of ref-types, 'cause screw c# and ICloneable load(ref cpy, get.name, null, get.use_install_folder); this.hierarchie = cpy.hierarchie; this.solution = cpy.solution; this.player_record = cpy.player_record; - this.player_record_list = cpy.player_record_list; InitFields(category, number, name, description, scene, local); @@ -80,11 +80,13 @@ public Stage(Stage get, string category, int number, string name, string descrip player_record.name = player_record.name.Replace(get.record_name, record_name); player_record.store(hierarchie, false); - foreach (var record in player_record_list.Values) + //this.player_record_list = cpy.player_record_list; + foreach (var record in cpy.player_record_list.Values) { record.load(hierarchie); record.name = record.name.Replace(get.record_name, record_name); record.store(hierarchie, false); + player_record_list.Add(record.name, record); } hierarchie.RemoveRange(hierarchie.Count - hierStage.Count, hierStage.Count); @@ -129,7 +131,7 @@ public void ClearPlay() public void ClearALLRecords() { - foreach (var record in player_record_list.Values) + foreach (var record in player_record_list.Values.ToList()) deletet_record(record, false); player_record_list = new Dictionary<string, PlayerRecord>(); @@ -175,8 +177,18 @@ public bool set_record(PlayerRecord record) return true; } - public void push_record(double seconds_s = -1) + public void push_record(double seconds_s = -1, bool force_push = false) { + if(!force_push && StageStatic.devel && creatorMode) + // store solution space + { + SetMode(false); + store(false); + //push_record(seconds_s, false); + SetMode(true); + return; + } + hierarchie ??= new List<Directories>(); hierarchie.AddRange(hierStage.AsEnumerable()); @@ -279,24 +291,14 @@ public static bool load(ref Stage set, string name, List<Directories> hierarchie { Stage ret = new Stage(); - hierarchie ??= new List<Directories>(); - hierarchie.AddRange(hierStage.AsEnumerable()); - bool loadable = ShallowLoad(ref ret, name, hierarchie, use_install_folder); if (!loadable) - { - hierarchie.RemoveRange(hierarchie.Count - hierStage.Count, hierStage.Count); return false; - } loadable = ret.DeepLoad(); if (!loadable) - { - hierarchie.RemoveRange(hierarchie.Count - hierStage.Count, hierStage.Count); return false; - } - hierarchie.RemoveRange(hierarchie.Count - hierStage.Count, hierStage.Count); set = ret; return true; } @@ -394,6 +396,7 @@ public void ResetSaves() public bool CheckSolved() { double time_s = Time.timeSinceLevelLoadAsDouble; + bool solved = factState.DynamiclySolved(solution, out _, out List<List<string>> hits); @@ -404,9 +407,10 @@ public bool CheckSolved() if (solved && player_record.seconds > 0) { - player_record.solved = solved; + player_record.solved = true; push_record(time_s); store(true); // reset player_record + player_record.solved = false; } return solved; diff --git a/Assets/Scripts/UI/MainMenue/PageLoader/EditLoader.cs b/Assets/Scripts/UI/MainMenue/PageLoader/EditLoader.cs index ed8f0a58e86fc20eeadd3a143808dcea07de2d68..c1a3491e90f31d9dd1cbcf9159868ba6ab488068 100644 --- a/Assets/Scripts/UI/MainMenue/PageLoader/EditLoader.cs +++ b/Assets/Scripts/UI/MainMenue/PageLoader/EditLoader.cs @@ -52,9 +52,11 @@ public void Delete() private bool _Clone(bool overwrite) { var error = StageStatic.Validate(category, id, name, description, scene); - if (overwrite && name == original_stage.name) { - error.name = false; - error.id = false; + if (overwrite) { + if(name == original_stage.name) + error.name = false; + if(id == original_stage.number) + error.id = false; } if (!error.pass) { Error(error);