public void SetMode(bool create) { if (create == creatorMode) { return; } creatorMode = create; if (create) { hiddenState = factState; factState.Undraw(); factState = solution as FactOrganizer; factState.invoke = true; factState.Draw(); } else { solution = factState as SolutionOrganizer; factState.Undraw(); //solution.invoke = false; factState = hiddenState; factState.Draw(); } }
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; InitFields(category, number, name, description, scene, local); hierarchie ??= new List <Directories>(); hierarchie.AddRange(hierStage.AsEnumerable()); player_record.load(hierarchie); player_record.name = player_record.name.Replace(get.record_name, record_name); player_record.store(hierarchie, false); //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); store(false); }
public bool DynamiclySolved( SolutionOrganizer MinimalSolution, out List<List<string>> MissingElements, out List<List<string>> Solutions) { MissingElements = new List<List<string>>(); // need to work not on ref/out List<List<string>> Solution_L = new List<List<string>>(); int MissingElementsCount = 0; var activeList = FactDict.Values.Where(f => MetaInf[f.Id].active); 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 = relateList.Where(active => part_minimal.Contains(active, ValidationSet.Comparer.SetSearchRight())) .ToList(); // needed for some reason var part_missing = part_minimal.Except(part_solution, ValidationSet.Comparer.SetSearchLeft()); // SolutionIndex may include current index Solution_L.Add(part_solution.Select(fact => fact.Id).ToList()); MissingElements.Add(part_missing.Select(fact => fact.Id).ToList()); MissingElementsCount += part_missing.Count(); // check by previous solutions // at least ONE member must relate var part_consequential_minimal = ValidationSet.SolutionIndex.Select(i => Solution_L[i]) // Select by Index .SelectMany(i => i) // Flatten structure .Select(URI => this[URI]); // Get Facts var part_consequential_solution = relateList.Where(active => part_consequential_minimal.Contains(active, ValidationSet.Comparer.SetSearchRight())); 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); } Solutions = Solution_L; return MissingElementsCount == 0; }
public static bool load(ref SolutionOrganizer set, bool draw, string name, List <Directories> hierarchie = null, bool use_install_folder = false) { hierarchie ??= new List <Directories>(); hierarchie.AddRange(hierVal.AsEnumerable()); string path = CreatePathToFile(out bool loadable, name + endingVal, "JSON", hierarchie, use_install_folder); if (!loadable) { hierarchie.RemoveRange(hierarchie.Count - hierVal.Count, hierVal.Count); return(false); } FactOrganizer save = StageStatic.stage.factState; StageStatic.stage.factState = new SolutionOrganizer(false) as FactOrganizer; loadable = FactOrganizer.load(ref StageStatic.stage.player_record.factState , draw, name + endingSol, hierarchie, use_install_folder, out Dictionary <string, string> old_to_new); if (loadable) { set = (SolutionOrganizer)StageStatic.stage.factState; set.path_Val = path; } StageStatic.stage.factState = save; hierarchie.RemoveRange(hierarchie.Count - hierVal.Count, hierVal.Count); if (!loadable) { return(false); } var JsonTmp = JSONManager.ReadFromJsonFile <List <SubSolution> > (path); foreach (var element in JsonTmp) // Parse and add { element.MasterIDs = new HashSet <string>(element.MasterIDs.Select(k => old_to_new[k])); set.ValidationSet.Add(element); } return(true); }
public bool DeepLoad() { hierarchie ??= new List <Directories>(); hierarchie.AddRange(hierStage.AsEnumerable()); bool loadable; solution ??= new SolutionOrganizer(false); loadable = SolutionOrganizer.load(ref solution, false, name, hierarchie, use_install_folder); if (!loadable) { return(false); } player_record.load(hierarchie); hierarchie.RemoveRange(hierarchie.Count - hierStage.Count, hierStage.Count); return(true); }
public void ClearSolution() { solution.hardreset(false); solution = new SolutionOrganizer(); }
private void InitOOP() { solution = new SolutionOrganizer(); player_record = new PlayerRecord(record_name); player_record_list = new Dictionary <string, PlayerRecord>(); }