diff --git a/Assets/Scripts/GenerateDemoFiles.cs b/Assets/Scripts/GenerateDemoFiles.cs index 33813d6c1ee266418464d2bf6aadda0bc0d712e0..58ee5d018f3c5a306d15f0c469973fbeaf1f7e14 100644 --- a/Assets/Scripts/GenerateDemoFiles.cs +++ b/Assets/Scripts/GenerateDemoFiles.cs @@ -76,8 +76,8 @@ public static void GenerateTreeStage() // Set Solution StageStatic.stage.solution.ValidationSet = - new List<SolutionOrganizer.SubSolution> - { new SolutionOrganizer.SubSolution(new HashSet<string> { target_Id }, null, null, new LineFactHightDirectionComparer()) }; + new List<SolutionRecorder.SubSolution> + { new SolutionRecorder.SubSolution(new HashSet<string> { target_Id }, null, null, new LineFactHightDirectionComparer()) }; // Set Gadgets/ Scrolls StageStatic.stage.AllowedGadgets = null; @@ -124,10 +124,10 @@ public static void GenerateRiverStage() // Set Solution StageStatic.stage.solution.ValidationSet = - new List<SolutionOrganizer.SubSolution> { - new SolutionOrganizer.SubSolution(new HashSet<string> { target_Id }, null, null, new LineFactHightDirectionComparer()), - new SolutionOrganizer.SubSolution(new HashSet<string> { target_Id }, null, null, new LineSpanningOverRiverWorldComparer()), - new SolutionOrganizer.SubSolution(null, new List<int> { 1 }, new List<int> { 0 }, new LineFactHightComparer()), + new List<SolutionRecorder.SubSolution> { + new SolutionRecorder.SubSolution(new HashSet<string> { target_Id }, null, null, new LineFactHightDirectionComparer()), + new SolutionRecorder.SubSolution(new HashSet<string> { target_Id }, null, null, new LineSpanningOverRiverWorldComparer()), + new SolutionRecorder.SubSolution(null, new List<int> { 1 }, new List<int> { 0 }, new LineFactHightComparer()), }; // Set Gadgets/ Scrolls diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactManager.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactAdder.cs similarity index 94% rename from Assets/Scripts/InteractionEngine/FactHandling/FactManager.cs rename to Assets/Scripts/InteractionEngine/FactHandling/FactAdder.cs index 6392f79eef5e211701748f62f711cf7697e409a5..18f2ac2e74c68f0e48e52ee6bdb8b71b6b259e2e 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactManager.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactAdder.cs @@ -5,9 +5,9 @@ /// Initiates named <see cref="Fact"/> and adds it to <see cref="StageStatic.stage.factState"/> /// </summary> /// <param name="samestep">set <c>true</c> if <see cref="Fact"/> creation happens as a subsequent/ consequent step of multiple <see cref="Fact"/> creations and/or deletions, -/// and you whish that these are affected by a single <see cref="FactOrganizer.undo"/>/ <see cref="FactOrganizer.redo"/> step</param> +/// and you whish that these are affected by a single <see cref="FactRecorder.undo"/>/ <see cref="FactRecorder.redo"/> step</param> /// <returns><see cref="Fact.Id"/> of generated <see cref="Fact"/> if not yet existent in <see cref="StageStatic.stage.factState"/>, else <see cref="Fact.Id"/> of existent equivalent <see cref="Fact"/> </returns> -public static class FactManager +public static class FactAdder { //TODO! communicate success/ failure + consequences //TODO: solution for parsed-functions @@ -26,7 +26,7 @@ public static Fact AddFactIfNotFound(Fact fact, out bool exists, bool samestep, return AddParsedAngleFactIfNotFound(AngleFact, out exists, samestep, null, scroll_label); else - return FactOrganizer.AllFacts[ + return FactRecorder.AllFacts[ StageStatic.stage.factState.Add( fact, out exists, samestep , gadget ?? (scroll_label == null ? GadgetBehaviour.ActiveGadget : null) @@ -63,9 +63,9 @@ public static OnLineFact AddOnLineFact(string pid, string lid, bool samestep = f { if (!is_certain) { - AbstractLineFact line = (AbstractLineFact)FactOrganizer.AllFacts[lid]; - PointFact line_point = (PointFact)FactOrganizer.AllFacts[line.Pid1]; - PointFact point = (PointFact)FactOrganizer.AllFacts[pid]; + AbstractLineFact line = (AbstractLineFact)FactRecorder.AllFacts[lid]; + PointFact line_point = (PointFact)FactRecorder.AllFacts[line.Pid1]; + PointFact point = (PointFact)FactRecorder.AllFacts[pid]; if (!Math3d.IsPointApproximatelyOnLine(line_point.Point, line.Dir, point.Point)) return null; @@ -104,8 +104,8 @@ public static RayFact AddRayFact(string pid1, string pid2, bool samestep = false return rayFact; //Add all PointFacts on Ray as OnLineFacts - PointFact rayP1 = (PointFact)FactOrganizer.AllFacts[rayFact.Pid1]; - PointFact rayP2 = (PointFact)FactOrganizer.AllFacts[rayFact.Pid2]; + PointFact rayP1 = (PointFact)FactRecorder.AllFacts[rayFact.Pid1]; + PointFact rayP2 = (PointFact)FactRecorder.AllFacts[rayFact.Pid2]; int layerMask = LayerMask.GetMask("Point"); RaycastHit[] hitsA = Physics.RaycastAll(rayP1.Point, rayFact.Dir, Mathf.Infinity, layerMask); RaycastHit[] hitsB = Physics.RaycastAll(rayP2.Point, -rayFact.Dir, Mathf.Infinity, layerMask); @@ -179,7 +179,7 @@ public static Fact AddParsedAngleCircleLineFactIfNotFound(AngleCircleLineFact fa , out _, samestep, gadget, scroll_label); } - return FactOrganizer.AllFacts[ + return FactRecorder.AllFacts[ StageStatic.stage.factState.Add( fact, out exists, samestep , gadget ?? (scroll_label == null ? GadgetBehaviour.ActiveGadget : null) @@ -193,7 +193,7 @@ public static Fact AddParsedAngleFactIfNotFound(AngleFact fact, out bool exists, new RightAngleFact(fact.Pid1, fact.Pid2, fact.Pid3, StageStatic.stage.factState) , out _, samestep, gadget, scroll_label); - return FactOrganizer.AllFacts[ + return FactRecorder.AllFacts[ StageStatic.stage.factState.Add( fact, out exists, samestep , gadget ?? (scroll_label == null ? GadgetBehaviour.ActiveGadget : null) diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactManager.cs.meta b/Assets/Scripts/InteractionEngine/FactHandling/FactAdder.cs.meta similarity index 83% rename from Assets/Scripts/InteractionEngine/FactHandling/FactManager.cs.meta rename to Assets/Scripts/InteractionEngine/FactHandling/FactAdder.cs.meta index 172218dae9a872d5826b8c36e5b2a0cc5d8c744d..1a639f40189f0f0e0fa4fd14be0d67f35665df40 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactManager.cs.meta +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactAdder.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c75823b1712c4914b987f0e1ba8a5cba +guid: aec18d3b2eee8d04db312f11b00d6357 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactComparer.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactComparer.cs index e25eda05a4b962109238d41b9035a32579130da0..4f29e9c00708f09b21270a1419e4a4af9505d508 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactComparer.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactComparer.cs @@ -5,9 +5,9 @@ /// <summary> /// Base class for all FactComparer to be used in conjucntion with <see cref="Stage.solution"/> -/// <seealso cref="SolutionOrganizer"/> -/// <seealso cref="SolutionOrganizer.ValidationSet"/> -/// <seealso cref="FactOrganizer.DynamiclySolved(SolutionOrganizer, out System.Collections.Generic.List<System.Collections.Generic.List<string>>, out System.Collections.Generic.List<System.Collections.Generic.List<string>>)"/> +/// <seealso cref="SolutionRecorder"/> +/// <seealso cref="SolutionRecorder.ValidationSet"/> +/// <seealso cref="FactRecorder.DynamiclySolved(SolutionRecorder, out System.Collections.Generic.List<System.Collections.Generic.List<string>>, out System.Collections.Generic.List<System.Collections.Generic.List<string>>)"/> /// </summary> public abstract class FactComparer : EqualityComparer<Fact> { @@ -151,7 +151,7 @@ protected override bool Compare(Fact solution, Fact fact) // get positions of anker points Vector3[] point_pos = factLine.DependentFactIds - .Select(id => FactOrganizer.AllFacts[id].Position) + .Select(id => FactRecorder.AllFacts[id].Position) .ToArray(); // check anker points *not within* RiverWall diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactRecorder.cs similarity index 94% rename from Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs rename to Assets/Scripts/InteractionEngine/FactHandling/FactRecorder.cs index 0fe2e8059c7e78037f3f5de49813f38b896435c5..841b78a6e54deadc39e279978fb37a2149b5072e 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactRecorder.cs @@ -14,11 +14,11 @@ /// Organizes (insertion/ deletion / etc. operations) and sepperates <see cref="Fact">Fact</see> spaces. /// Keeps track of insertion/ deletion actions for <see cref="undo"/> and <see cref="redo"/>. /// </summary> -public class FactOrganizer : IJSONsavable<FactOrganizer>, IDisposable +public class FactRecorder : IJSONsavable<FactRecorder>, IDisposable { /// <summary> /// Contains Immutable <see cref="Fact.Id"/>s; - /// e.g: From a <see cref="SolutionOrganizer"/> which are being exposed to the Player. + /// e.g: From a <see cref="SolutionRecorder"/> which are being exposed to the Player. /// <remarks> Will NOT be recorded in <see cref="Workflow"/>!</remarks> /// </summary> [JsonProperty] @@ -118,7 +118,7 @@ public IReadOnlyDictionary<string, Fact> MyFactSpace // TODO: put this stuff in Interface /// @{ <summary> - /// For <see cref="store(string, List<Directories>, bool, bool)"/> and <see cref="load(ref FactOrganizer, bool, string, List<Directories>, bool, out Dictionary<string, string>)"/> + /// For <see cref="store(string, List<Directories>, bool, bool)"/> and <see cref="load(ref FactRecorder, bool, string, List<Directories>, bool, out Dictionary<string, string>)"/> /// </summary> public string name { get; set; } = null; public string path { get; set; } = null; @@ -180,8 +180,8 @@ public struct stepnote /// <param name="Id"><see cref="Fact.Id"/></param> /// <param name="samestep">sets <see cref="samestep"/></param> /// <param name="creation">sets <see cref="creation"/></param> - /// <param name="that"><see cref="FactOrganizer"/> of which <c>this</c> will be added in its <see cref="FactOrganizer.Workflow"/></param> - public stepnote(FactOrganizer that, string Id, bool samestep, bool creation, Gadget gadget, string scroll_label) + /// <param name="that"><see cref="FactRecorder"/> of which <c>this</c> will be added in its <see cref="FactRecorder.Workflow"/></param> + public stepnote(FactRecorder that, string Id, bool samestep, bool creation, Gadget gadget, string scroll_label) { this.Id = Id; this.samestep = samestep; @@ -254,7 +254,7 @@ public struct meta public bool active; /// <summary> - /// if <c>true</c> <see cref="Fact"/> is imported from a <see cref="SolutionOrganizer"/> + /// if <c>true</c> <see cref="Fact"/> is imported from a <see cref="SolutionRecorder"/> /// </summary> public bool isImmutable; @@ -273,21 +273,21 @@ public meta(int workflow_id, bool active, bool isImmutable) } - static FactOrganizer() + static FactRecorder() { - IJSONsavable<FactOrganizer>.hierarchie = new List<Directories> { Directories.FactStateMachines }; + IJSONsavable<FactRecorder>.hierarchie = new List<Directories> { Directories.FactStateMachines }; } /// <summary> /// Only used by <see cref="JsonConverter"/> to initiate empty instance. /// </summary> - public FactOrganizer() + public FactRecorder() { GlobalFactDictionary.NewFactSpace(this); this.invoke = false; } - ~FactOrganizer() + ~FactRecorder() { Dispose(); } @@ -296,16 +296,16 @@ public void Dispose() => GlobalFactDictionary.FactSpaceDelete(this); /// <summary> - /// Standard Constructor for empty, ready to use <see cref="FactOrganizer"/> + /// Standard Constructor for empty, ready to use <see cref="FactRecorder"/> /// </summary> /// <param name="invoke">sets <see cref="invoke"/>.</param> - public FactOrganizer(bool invoke = false) : this() + public FactRecorder(bool invoke = false) : this() { this.invoke = invoke; } /// <summary> - /// Used to parse read-in <see cref="FactOrganizer"/> by <see cref="JsonReader"/> and make <see cref="Fact.Id"/> conform. + /// Used to parse read-in <see cref="FactRecorder"/> by <see cref="JsonReader"/> and make <see cref="Fact.Id"/> conform. /// Also poppulates <see cref="OldToNewURI"/> /// </summary> /// <param name="target">to be parsed into, will be overwritten. @@ -314,7 +314,7 @@ public FactOrganizer(bool invoke = false) : this() /// <param name="invoke">see <see cref="invoke"/></param> /// <param name="old_to_new">Generated to map <c>Key</c> outdated <see cref="Fact.Id"/>s to corresponding <c>Value</c> updatated <see cref="Fact.Id"/>s.</param> public static T ReInitializeFactOrganizer<T>(T source, bool invoke, out Dictionary<string, string> old_to_new) - where T : FactOrganizer, new() + where T : FactRecorder, new() { // TODO: other strategy needed when MMT save/load supported bool source_initialized = GlobalFactDictionary.AllFactSpaces.ContainsKey(source) @@ -531,7 +531,7 @@ private void PruneWorkflow(stepnote not_me) } /// <summary> - /// Call this to Add a <see cref="Fact"/> to <see cref="FactOrganizer">this</see> instance. + /// Call this to Add a <see cref="Fact"/> to <see cref="FactRecorder">this</see> instance. /// <remarks>*Warning*: If return_value != <paramref name="value"/><see cref="Fact.Id">.Id</see>, <paramref name="value"/> will be <see cref="Fact.delete(bool)">deleted</see> for good to reduce ressource usage!</remarks> /// </summary> /// <param name="value">to be added</param> @@ -584,7 +584,7 @@ public string Add(Fact value, out bool exists, bool samestep, Gadget gadget, str } /// <summary> - /// Call this to Remove a <see cref="Fact"/> from <see cref="FactOrganizer">this</see> instance. + /// Call this to Remove a <see cref="Fact"/> from <see cref="FactRecorder">this</see> instance. /// If other <see cref="Fact">Facts</see> depend on <paramref name="value"/> <see cref="Remove(Fact, bool)">Remove(/<depending Fact/>, <c>true</c>)</see> will be called recursively/ cascadingly. /// </summary> /// <remarks>this will not <see cref="Fact.delete(bool)">delete</see> a <see cref="Fact"/>, but sets it <see cref="meta.active">inactive</see> for later <see cref="Fact.delete(bool)">deletion</see> when <see cref="PruneWorkflow">pruned</see>.</remarks> @@ -592,7 +592,7 @@ public string Add(Fact value, out bool exists, bool samestep, Gadget gadget, str /// <param name="samestep">set <c>true</c> if <see cref="Fact"/> deletion happens as a subsequent/ consequent step of multiple <see cref="Fact"/> creations and/or deletions, /// and you whish that these are affected by a single <see cref="undo"/>/ <see cref="redo"/> step</param> /// <param name="gadget">the <see cref="Gadget"/>used to delete <paramref name="value"/> or <c>null</c></param> - /// <param name="deleteSolutionFact">can overwrite protection from <see cref="Fact"/>s imported from a <see cref="SolutionOrganizer"/></param> + /// <param name="deleteSolutionFact">can overwrite protection from <see cref="Fact"/>s imported from a <see cref="SolutionRecorder"/></param> /// <returns><c>true</c> iff <paramref name="value"/><see cref="Fact.Id">.Id</see> was found.</returns> public bool Remove(Fact value, bool samestep, Gadget gadget, bool deleteSolutionFact = false) => this.Remove(value.Id, samestep, gadget, deleteSolutionFact); @@ -823,10 +823,10 @@ public void fastforward() redo(); } - FactOrganizer IJSONsavable<FactOrganizer>._IJPostProcess(FactOrganizer raw_payload) - => raw_payload == null ? raw_payload : ReInitializeFactOrganizer<FactOrganizer>(raw_payload, false, out _); + FactRecorder IJSONsavable<FactRecorder>._IJPostProcess(FactRecorder raw_payload) + => raw_payload == null ? raw_payload : ReInitializeFactOrganizer<FactRecorder>(raw_payload, false, out _); - FactOrganizer IJSONsavable<FactOrganizer>._IJPreProcess(FactOrganizer payload) + FactRecorder IJSONsavable<FactRecorder>._IJPreProcess(FactRecorder payload) { if (GlobalFactDictionary.AllFactSpaces.ContainsKey(payload) && payload.MyFactSpace.Count > 0) payload.JsonFactSpace = payload.MyFactSpace; @@ -893,15 +893,15 @@ private void InvokeFactEvent(bool creation, string Id) } /// <summary> - /// Used to check wether <see cref="FactOrganizer">this</see> satisfies the constrains of an <see cref="SolutionOrganizer">Solution</see>. + /// Used to check wether <see cref="FactRecorder">this</see> satisfies the constrains of an <see cref="SolutionRecorder">Solution</see>. /// Only <see cref="meta.active"/> are accounted for. /// </summary> /// <param name="MinimalSolution">describes constrains</param> - /// <param name="MissingElements">elements which were *not* found in <see cref="SolutionOrganizer.ValidationSet"/> in a format reflecting that of <see cref="SolutionOrganizer.ValidationSet"/></param> - /// <param name="Solutions">elements which *were* found in <see cref="SolutionOrganizer.ValidationSet"/> in a format reflecting that of <see cref="SolutionOrganizer.ValidationSet"/></param> + /// <param name="MissingElements">elements which were *not* found in <see cref="SolutionRecorder.ValidationSet"/> in a format reflecting that of <see cref="SolutionRecorder.ValidationSet"/></param> + /// <param name="Solutions">elements which *were* found in <see cref="SolutionRecorder.ValidationSet"/> in a format reflecting that of <see cref="SolutionRecorder.ValidationSet"/></param> /// <returns><c>true</c> iff *all* constrains set by <paramref name="MinimalSolution"/> are met</returns> public bool DynamiclySolved( - SolutionOrganizer MinimalSolution, + SolutionRecorder MinimalSolution, out List<List<string>> MissingElements, out List<List<string>> Solutions) { @@ -981,18 +981,18 @@ protected static class GlobalFactDictionary private static readonly Dictionary<string, uint> FactReferences = new(); - private static readonly Dictionary<FactOrganizer, Dictionary<string, Fact>> FactSpaces = new(); - public static IReadOnlyDictionary<FactOrganizer, Dictionary<string, Fact>> AllFactSpaces => FactSpaces; + private static readonly Dictionary<FactRecorder, Dictionary<string, Fact>> FactSpaces = new(); + public static IReadOnlyDictionary<FactRecorder, Dictionary<string, Fact>> AllFactSpaces => FactSpaces; - public static IReadOnlyDictionary<string, Fact> MyFactSpace(FactOrganizer me) + public static IReadOnlyDictionary<string, Fact> MyFactSpace(FactRecorder me) => FactSpaces[me]; - public static void NewFactSpace(FactOrganizer me) + public static void NewFactSpace(FactRecorder me) { FactSpaces.Add(me, new()); } - public static void FactSpaceClear(FactOrganizer me) + public static void FactSpaceClear(FactRecorder me) { if (!FactSpaces.ContainsKey(me)) return; @@ -1001,13 +1001,13 @@ public static void FactSpaceClear(FactOrganizer me) FactSpaceRemove(me, key); } - public static void FactSpaceDelete(FactOrganizer me) + public static void FactSpaceDelete(FactRecorder me) { FactSpaceClear(me); FactSpaces.Remove(me); } - public static void FactSpaceAdd(FactOrganizer me, Fact fact) + public static void FactSpaceAdd(FactRecorder me, Fact fact) { if (!FactDict.ContainsKey(fact.Id)) { @@ -1023,7 +1023,7 @@ public static void FactSpaceAdd(FactOrganizer me, Fact fact) FactSpaces[me].Add(fact.Id, fact); } - public static void FactSpaceRemove(FactOrganizer me, string key) + public static void FactSpaceRemove(FactRecorder me, string key) { FactSpaces[me].Remove(key); diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs.meta b/Assets/Scripts/InteractionEngine/FactHandling/FactRecorder.cs.meta similarity index 83% rename from Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs.meta rename to Assets/Scripts/InteractionEngine/FactHandling/FactRecorder.cs.meta index 416cff32f6426b179e3f2a98e859445fd5512624..1ed28218ea0d42d3a87a9535ef40541824f8ba8c 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs.meta +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactRecorder.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a0a6a87e881e167488056f2f37ffd4cb +guid: c877b7b6e696a044eb26eacba128dbb9 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/FactObject.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/FactObject.cs index cd0ae95831636a700c7952696a1200b7768bc396..457ba8323b9cad900325e1a0e9e178a4f2951a91 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/FactObject.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/FactObject.cs @@ -131,7 +131,7 @@ private void ReLabel() string[] mother_child_labels = new[] { URI }.ShallowCloneAppend(Fact.DependentFactIds) .Select(fid => - FactOrganizer.AllFacts.TryGetValue(fid, out Fact fact) + FactRecorder.AllFacts.TryGetValue(fid, out Fact fact) ? fact.Label : "N/A") .ToArray(); diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/FactWrapper.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/FactWrapper.cs index e3fe4d168bfce4c0fd5f71a33037d0568b943d00..9f39c812e5037338f62c835a9a1c9ff85b529f36 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/FactWrapper.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/FactWrapper.cs @@ -30,14 +30,14 @@ public string URI protected string _URI; /// <summary> - /// Shorthand and Cache for <see cref="FactOrganizer.AllFacts.TryGetValue(string, out Fact)"/>. + /// Shorthand and Cache for <see cref="FactRecorder.AllFacts.TryGetValue(string, out Fact)"/>. /// </summary> public Fact Fact { get { if (_Fact == null && URI != null) - FactOrganizer.AllFacts.TryGetValue(URI, out _Fact); + FactRecorder.AllFacts.TryGetValue(URI, out _Fact); return _Fact; } set diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractAngleFact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractAngleFact.cs index 073bf9f373b229d8030509726d8b3284be5b4963..29f40959234283b74420fb120e5766049a2b823d 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractAngleFact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractAngleFact.cs @@ -15,11 +15,11 @@ public abstract class AbstractAngleFact : FactWrappedCRTP<AbstractAngleFact> /// @} [JsonIgnore] - public PointFact Point1 { get => (PointFact)FactOrganizer.AllFacts[Pid1]; } + public PointFact Point1 { get => (PointFact)FactRecorder.AllFacts[Pid1]; } [JsonIgnore] - public PointFact Point2 { get => (PointFact)FactOrganizer.AllFacts[Pid2]; } + public PointFact Point2 { get => (PointFact)FactRecorder.AllFacts[Pid2]; } [JsonIgnore] - public PointFact Point3 { get => (PointFact)FactOrganizer.AllFacts[Pid3]; } + public PointFact Point3 { get => (PointFact)FactRecorder.AllFacts[Pid3]; } /// <summary> <see langword="true"/>, if AngleFact is approximately 90° or 270°</summary> virtual public bool is_right_angle { get; set; } = false; @@ -39,11 +39,11 @@ protected AbstractAngleFact() : base() } /// <summary>\copydoc AbstractAngleFact.AbstractAngleFact(AbstractAngleFact, Dictionary{string, string}, FactOrganizer)</summary> - protected AbstractAngleFact(AbstractAngleFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected AbstractAngleFact(AbstractAngleFact fact, Dictionary<string, string> old_to_new, FactRecorder organizer) : this(old_to_new[fact.Pid1], old_to_new[fact.Pid2], old_to_new[fact.Pid3], organizer) { } /// <summary>\copydoc AbstractAngleFact.AbstractAngleFact(string, string, FactOrganizer)</summary> - protected AbstractAngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer) : base(organizer) + protected AbstractAngleFact(string pid1, string pid2, string pid3, FactRecorder organizer) : base(organizer) { this.Pid1 = pid1; this.Pid2 = pid2; @@ -51,7 +51,7 @@ protected AbstractAngleFact(string pid1, string pid2, string pid3, FactOrganizer } /// <summary>\copydoc AbstractAngleFact.AbstractAngleFact(string, string, string, FactOrganizer)</summary> - protected AbstractAngleFact(string pid1, string pid2, string pid3, float angle, string backendURI, FactOrganizer organizer) + protected AbstractAngleFact(string pid1, string pid2, string pid3, float angle, string backendURI, FactRecorder organizer) : this(pid1, pid2, pid3, organizer) { this.angle = angle == -0f @@ -95,13 +95,13 @@ public abstract class AbstractAngleFactWrappedCRTP<T> : AbstractAngleFact where protected AbstractAngleFactWrappedCRTP() : base() { } /// <summary>\copydoc AbstractAngleFactWrappedCRTP.AbstractAngleFactWrappedCRTP(AbstractAngleFactWrappedCRTP, Dictionary{string, string}, FactOrganizer)</summary> - protected AbstractAngleFactWrappedCRTP(AbstractAngleFactWrappedCRTP<T> fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, old_to_new, organizer) { } + protected AbstractAngleFactWrappedCRTP(AbstractAngleFactWrappedCRTP<T> fact, Dictionary<string, string> old_to_new, FactRecorder organizer) : base(fact, old_to_new, organizer) { } /// <summary>\copydoc AbstractAngleFactWrappedCRTP.AbstractAngleFactWrappedCRTP(string, string, FactOrganizer)</summary> - protected AbstractAngleFactWrappedCRTP(string pid1, string pid2, string pid3, FactOrganizer organizer) : base(pid1, pid2, pid3, organizer) { } + protected AbstractAngleFactWrappedCRTP(string pid1, string pid2, string pid3, FactRecorder organizer) : base(pid1, pid2, pid3, organizer) { } /// <summary>\copydoc AbstractAngleFactWrappedCRTP.AbstractAngleFactWrappedCRTP(string, string, string, FactOrganizer)</summary> - protected AbstractAngleFactWrappedCRTP(string pid1, string pid2, string pid3, float angle, string backendURI, FactOrganizer organizer) : base(pid1, pid2, pid3, angle, backendURI, organizer) { } + protected AbstractAngleFactWrappedCRTP(string pid1, string pid2, string pid3, float angle, string backendURI, FactRecorder organizer) : base(pid1, pid2, pid3, angle, backendURI, organizer) { } /// \copydoc Fact.Equivalent(Fact, Fact) protected override bool EquivalentWrapped(AbstractAngleFact f1, AbstractAngleFact f2) @@ -127,7 +127,7 @@ public AngleFact() : base() { } /// <param name="pid2">sets <see cref="Pid2"/></param> /// <param name="pid3">sets <see cref="Pid3"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public AngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer) : base(pid1, pid2, pid3, organizer) + public AngleFact(string pid1, string pid2, string pid3, FactRecorder organizer) : base(pid1, pid2, pid3, organizer) { angle = Vector3.Angle((Point1.Point - Point2.Point), (Point3.Point - Point2.Point)); @@ -146,7 +146,7 @@ public AngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer) /// <param name="Pid3">sets <see cref="Pid3"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public AngleFact(string Pid1, string Pid2, string Pid3, float angle, string backendURI, FactOrganizer organizer) + public AngleFact(string Pid1, string Pid2, string Pid3, float angle, string backendURI, FactRecorder organizer) : base(Pid1, Pid2, Pid3, angle, backendURI, organizer) { } public override MMTFact MakeMMTDeclaration() @@ -184,9 +184,9 @@ public override MMTFact MakeMMTDeclaration() string pointBUri = ((OMS)lhs.arguments[1]).uri; string pointCUri = ((OMS)lhs.arguments[2]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(pointAUri) - || !FactOrganizer.AllFacts.ContainsKey(pointBUri) - || !FactOrganizer.AllFacts.ContainsKey(pointCUri)) + if (!FactRecorder.AllFacts.ContainsKey(pointAUri) + || !FactRecorder.AllFacts.ContainsKey(pointBUri) + || !FactRecorder.AllFacts.ContainsKey(pointCUri)) return null; return new AngleFact(pointAUri, pointBUri, pointCUri, angle, fact.@ref.uri, StageStatic.stage.factState); @@ -200,7 +200,7 @@ protected override string generateLabel() protected override bool EquivalentWrapped(AngleFact f1, AngleFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new AngleFact(old_to_new[this.Pid1], old_to_new[this.Pid2], old_to_new[this.Pid3], organizer); } @@ -223,7 +223,7 @@ public RightAngleFact() : base() { } /// <param name="pid2">sets <see cref="Pid2"/></param> /// <param name="pid3">sets <see cref="Pid3"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public RightAngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer) : base(pid1, pid2, pid3, organizer) + public RightAngleFact(string pid1, string pid2, string pid3, FactRecorder organizer) : base(pid1, pid2, pid3, organizer) { angle = 90f; @@ -238,7 +238,7 @@ public RightAngleFact(string pid1, string pid2, string pid3, FactOrganizer organ /// <param name="Pid3">sets <see cref="Pid3"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public RightAngleFact(string Pid1, string Pid2, string Pid3, string backendURI, FactOrganizer organizer) + public RightAngleFact(string Pid1, string Pid2, string Pid3, string backendURI, FactRecorder organizer) : base(Pid1, Pid2, Pid3, 90f, backendURI, organizer) { } public override MMTFact MakeMMTDeclaration() @@ -284,9 +284,9 @@ is not OMS // rightAngle Arg0 string Point2Uri = ((OMS)rightAngleOMA.arguments[1]).uri; string Point3Uri = ((OMS)rightAngleOMA.arguments[2]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(Point1Uri) - || !FactOrganizer.AllFacts.ContainsKey(Point2Uri) - || !FactOrganizer.AllFacts.ContainsKey(Point3Uri)) + if (!FactRecorder.AllFacts.ContainsKey(Point1Uri) + || !FactRecorder.AllFacts.ContainsKey(Point2Uri) + || !FactRecorder.AllFacts.ContainsKey(Point3Uri)) return null; return new RightAngleFact(Point1Uri, Point2Uri, Point3Uri, fact.@ref.uri, StageStatic.stage.factState); @@ -300,6 +300,6 @@ protected override string generateLabel() protected override bool EquivalentWrapped(RightAngleFact f1, RightAngleFact f2) => DependentFactsEquivalent(f1, f2); -protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) +protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new RightAngleFact(old_to_new[this.Pid1], old_to_new[this.Pid2], old_to_new[this.Pid3], organizer); } \ No newline at end of file diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractLineFact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractLineFact.cs index 889b1c723a881504416411a228a9b3253e68bdf3..e8aca57e0428fb0c71966556fb045e9663956b16 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractLineFact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractLineFact.cs @@ -15,9 +15,9 @@ public abstract class AbstractLineFact : FactWrappedCRTP<AbstractLineFact> /// @} [JsonIgnore] - public PointFact Point1 { get => (PointFact)FactOrganizer.AllFacts[Pid1]; } + public PointFact Point1 { get => (PointFact)FactRecorder.AllFacts[Pid1]; } [JsonIgnore] - public PointFact Point2 { get => (PointFact)FactOrganizer.AllFacts[Pid2]; } + public PointFact Point2 { get => (PointFact)FactRecorder.AllFacts[Pid2]; } /// <summary> Distance between <see cref="AbstractLineFact.Pid1"/> and <see cref="AbstractLineFact.Pid2"/></summary> [JsonIgnore] @@ -44,7 +44,7 @@ protected AbstractLineFact() : base() /// <param name="pid1">sets <see cref="AbstractLineFact.Pid1"/></param> /// <param name="pid2">sets <see cref="AbstractLineFact.Pid2"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - protected AbstractLineFact(string pid1, string pid2, FactOrganizer organizer) : base(organizer) + protected AbstractLineFact(string pid1, string pid2, FactRecorder organizer) : base(organizer) { set_public_members(pid1, pid2); } @@ -56,7 +56,7 @@ protected AbstractLineFact(string pid1, string pid2, FactOrganizer organizer) : /// <param name="pid2">sets <see cref="Pid2"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - protected AbstractLineFact(string pid1, string pid2, string backendURI, FactOrganizer organizer) : base(organizer) + protected AbstractLineFact(string pid1, string pid2, string backendURI, FactRecorder organizer) : base(organizer) { this._URI = backendURI; set_public_members(pid1, pid2); @@ -101,10 +101,10 @@ public abstract class AbstractLineFactWrappedCRTP<T> : AbstractLineFact where T protected AbstractLineFactWrappedCRTP() : base() { } /// <summary>\copydoc AbstractLineFact.AbstractLineFact(string, string, FactOrganizer)</summary> - protected AbstractLineFactWrappedCRTP(string pid1, string pid2, FactOrganizer organizer) : base(pid1, pid2, organizer) { } + protected AbstractLineFactWrappedCRTP(string pid1, string pid2, FactRecorder organizer) : base(pid1, pid2, organizer) { } /// <summary>\copydoc AbstractLineFact.AbstractLineFact(string, string, string, FactOrganizer)</summary> - protected AbstractLineFactWrappedCRTP(string pid1, string pid2, string backendURI, FactOrganizer organizer) : base(pid1, pid2, backendURI, organizer) { } + protected AbstractLineFactWrappedCRTP(string pid1, string pid2, string backendURI, FactRecorder organizer) : base(pid1, pid2, backendURI, organizer) { } /// \copydoc Fact.Equivalent(Fact, Fact) protected override bool EquivalentWrapped(AbstractLineFact f1, AbstractLineFact f2) @@ -127,11 +127,11 @@ public class LineFact : AbstractLineFactWrappedCRTP<LineFact> public LineFact() : base() { } /// <summary> \copydoc AbstractLineFact.AbstractLineFact(string, string, string, FactOrganizer) </summary> - public LineFact(string pid1, string pid2, string backendURI, FactOrganizer organizer) : base(pid1, pid2, backendURI, organizer) + public LineFact(string pid1, string pid2, string backendURI, FactRecorder organizer) : base(pid1, pid2, backendURI, organizer) => _ = this.Label; /// <summary> \copydoc AbstractLineFact.AbstractLineFact(string, string, FactOrganizer) </summary> - public LineFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1, pid2, organizer) + public LineFact(string pid1, string pid2, FactRecorder organizer) : base(pid1, pid2, organizer) { SendToMMT(); } @@ -159,8 +159,8 @@ public override MMTFact MakeMMTDeclaration() string pointAUri = ((OMS)((OMA)((MMTValueFact)fact).lhs).arguments[0]).uri; string pointBUri = ((OMS)((OMA)((MMTValueFact)fact).lhs).arguments[1]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(pointAUri) - || !FactOrganizer.AllFacts.ContainsKey(pointBUri)) + if (!FactRecorder.AllFacts.ContainsKey(pointAUri) + || !FactRecorder.AllFacts.ContainsKey(pointBUri)) return null; return new LineFact(pointAUri, pointBUri, fact.@ref.uri, StageStatic.stage.factState); @@ -174,7 +174,7 @@ protected override string generateLabel() protected override bool EquivalentWrapped(LineFact f1, LineFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new LineFact(old_to_new[this.Pid1], old_to_new[this.Pid2], organizer); } @@ -191,11 +191,11 @@ public class RayFact : AbstractLineFactWrappedCRTP<RayFact> public RayFact() : base() { } /// <summary> \copydoc AbstractLineFact.AbstractLineFact(string, string, string, FactOrganizer) </summary> - public RayFact(string pid1, string pid2, string backendURI, FactOrganizer organizer) : base(pid1, pid2, backendURI, organizer) + public RayFact(string pid1, string pid2, string backendURI, FactRecorder organizer) : base(pid1, pid2, backendURI, organizer) => _ = this.Label; /// <summary> \copydoc AbstractLineFact.AbstractLineFact(string, string, FactOrganizer) </summary> - public RayFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1, pid2, organizer) + public RayFact(string pid1, string pid2, FactRecorder organizer) : base(pid1, pid2, organizer) { SendToMMT(); } @@ -223,8 +223,8 @@ public override MMTFact MakeMMTDeclaration() string pointAUri = ((OMS)defines.arguments[0]).uri; string pointBUri = ((OMS)defines.arguments[1]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(pointAUri) - || !FactOrganizer.AllFacts.ContainsKey(pointBUri)) + if (!FactRecorder.AllFacts.ContainsKey(pointAUri) + || !FactRecorder.AllFacts.ContainsKey(pointBUri)) return null; return new RayFact(pointAUri, pointBUri, fact.@ref.uri, StageStatic.stage.factState); @@ -254,6 +254,6 @@ protected override bool EquivalentWrapped(RayFact f1, RayFact f2) && Math3d.IsPointApproximatelyOnLine(f1.Point1.Point, f1.Dir, f2.Point2.Point); } - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new RayFact(old_to_new[this.Pid1], old_to_new[this.Pid2], organizer); } diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs index 3c40a1860ed57f843997b3c2003e6796c3e21b8d..2fa46e3e84c42154f8251dc28136934ebedcfe19 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs @@ -91,7 +91,7 @@ public static class ParsingDictionary [JsonSubtypes.KnownSubType(typeof(FunctionFact), nameof(FunctionFact))] [JsonSubtypes.KnownSubType(typeof(FunctionCallFact), nameof(FunctionCallFact))] [JsonSubtypes.KnownSubType(typeof(ListFact), nameof(ListFact))] -[JsonSubtypes.KnownSubType(typeof(TupelFact), nameof(TupelFact))] +[JsonSubtypes.KnownSubType(typeof(TupleFact), nameof(TupleFact))] //[JsonSubtypes.KnownSubType(typeof(FunctionFact<T0, TResult>), "FunctionFact<T0, TResult>")] //TODO: generics? => nameof does not work (generic agnostic) //[JsonSubtypes.KnownSubType(typeof(FunctionFactFloat<Vector3>), "FunctionFact<System.Single, UnityEngine.Vector3>")] public abstract class Fact @@ -194,10 +194,10 @@ public string Label public int LabelId { get; set; } /// <summary> - /// Reference to <see cref="FactOrganizer"/> in which this Fact and all its <see cref="getDependentFactIds">depending Facts</see> are beeing organized. + /// Reference to <see cref="FactRecorder"/> in which this Fact and all its <see cref="getDependentFactIds">depending Facts</see> are beeing organized. /// </summary> [JsonIgnore] - protected FactOrganizer _Facts; + protected FactRecorder _Facts; [JsonIgnore] bool ForceRecalculateTransform = true; @@ -269,7 +269,7 @@ protected Fact() /// Standard base-constructor. /// </summary> /// <param name="organizer"><see cref="_Facts"/></param> - protected Fact(FactOrganizer organizer) : this() + protected Fact(FactRecorder organizer) : this() { this._Facts = organizer; } @@ -280,7 +280,7 @@ protected Fact(FactOrganizer organizer) : this() /// <param name="fact">Fact to be copied</param> /// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param> /// <param name="organizer"><see cref="_Facts"/></param> - public Fact ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + public Fact ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) { Fact ret = _ReInitializeMe(old_to_new, organizer); @@ -290,7 +290,7 @@ public Fact ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer return ret; } - protected abstract Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer); + protected abstract Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer); /// <summary> /// Assignes a custom <see cref="Label"/>, if <paramref name="newLabel"/> is not yet taken; @@ -503,7 +503,7 @@ public abstract class FactWrappedCRTP<T> : Fact where T : FactWrappedCRTP<T> protected FactWrappedCRTP() : base() { } /// <summary>\copydoc Fact.Fact(FactOrganizer)</summary> - protected FactWrappedCRTP(FactOrganizer organizer) : base(organizer) { } + protected FactWrappedCRTP(FactRecorder organizer) : base(organizer) { } /// \copydoc Fact.Equivalent(Fact) public override bool Equivalent(Fact f2) @@ -521,7 +521,7 @@ protected bool DependentFactsEquivalent(T f1, T f2) .Zip(f2.DependentFactIds, (id1, id2) => id1 == id2 - || FactOrganizer.AllFacts[id1].Equivalent(FactOrganizer.AllFacts[id2]) + || FactRecorder.AllFacts[id1].Equivalent(FactRecorder.AllFacts[id2]) ) .All(b => b); } @@ -551,7 +551,7 @@ public PointFact() : base() /// <param name="P">sets <see cref="Point"/></param> /// <param name="N">sets <see cref="Normal"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public PointFact(Vector3 P, Vector3 N, FactOrganizer organizer) : base(organizer) + public PointFact(Vector3 P, Vector3 N, FactRecorder organizer) : base(organizer) { this.Point = P; this.Normal = N; @@ -578,7 +578,7 @@ protected override void RecalculateTransform() /// <param name="point">sets <see cref="Point"/></param> /// <param name="uri">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public PointFact(Vector3 point, string uri, FactOrganizer organizer) : base(organizer) + public PointFact(Vector3 point, string uri, FactRecorder organizer) : base(organizer) { this.Point = point; this.Normal = Vector3.up; @@ -593,7 +593,7 @@ public PointFact(Vector3 point, string uri, FactOrganizer organizer) : base(orga return null; ParsingDictionary.parseTermsToId.TryAdd(defines.ToString(), fact.@ref.uri); - Vector3 point = (defines.GetLambdaExpression().Compile() as Func<Vector3>)(); + Vector3 point = SOMDoc.MakeVector3(defines); return new PointFact(point, fact.@ref.uri, StageStatic.stage.factState); } @@ -612,7 +612,7 @@ public override int GetHashCode() protected override bool EquivalentWrapped(PointFact f1, PointFact f2) => Math3d.IsApproximatelyEqual(f1.Point, f2.Point); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new PointFact(this.Point, this.Normal, organizer); public override MMTFact MakeMMTDeclaration() @@ -639,12 +639,12 @@ public class OnLineFact : FactWrappedCRTP<OnLineFact> /// <summary> <see cref="PointFact"/>.<see cref="Fact.Id">Id</see> </summary> public string Pid; [JsonIgnore] - public PointFact Point { get => (PointFact)FactOrganizer.AllFacts[Pid]; } + public PointFact Point { get => (PointFact)FactRecorder.AllFacts[Pid]; } /// <summary> <see cref="AbstractLineFact"/>.<see cref="Fact.Id">Id</see> </summary> public string Rid; [JsonIgnore] - public AbstractLineFact Ray { get => (AbstractLineFact)FactOrganizer.AllFacts[Rid]; } + public AbstractLineFact Ray { get => (AbstractLineFact)FactRecorder.AllFacts[Rid]; } /// <summary> \copydoc Fact.Fact </summary> public OnLineFact() : base() @@ -660,7 +660,7 @@ public OnLineFact() : base() /// <param name="pid">sets <see cref="Pid"/></param> /// <param name="rid">sets <see cref="Rid"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public OnLineFact(string pid, string rid, FactOrganizer organizer) : base(organizer) + public OnLineFact(string pid, string rid, FactRecorder organizer) : base(organizer) { this.Pid = pid; this.Rid = rid; @@ -695,7 +695,7 @@ protected override void RecalculateTransform() /// <param name="rid">sets <see cref="Rid"/></param> /// <param name="uri">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public OnLineFact(string pid, string rid, string uri, FactOrganizer organizer) : base(organizer) + public OnLineFact(string pid, string rid, string uri, FactRecorder organizer) : base(organizer) { this.Pid = pid; this.Rid = rid; @@ -713,8 +713,8 @@ public OnLineFact(string pid, string rid, string uri, FactOrganizer organizer) : // case when line Uri has a projl on the line Argument : ((OMS)((OMA)((OMA)((OMA)((MMTGeneralFact)fact).type).arguments[0]).arguments[0]).arguments[0]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(pointUri) - || !FactOrganizer.AllFacts.ContainsKey(lineUri)) + if (!FactRecorder.AllFacts.ContainsKey(pointUri) + || !FactRecorder.AllFacts.ContainsKey(lineUri)) return null; return new OnLineFact(pointUri, lineUri, fact.@ref.uri, StageStatic.stage.factState); @@ -734,7 +734,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(OnLineFact f1, OnLineFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new OnLineFact(old_to_new[this.Pid], old_to_new[this.Rid], organizer); public override MMTFact MakeMMTDeclaration() @@ -767,9 +767,9 @@ public class ParallelLineFact : FactWrappedCRTP<ParallelLineFact> /// @} [JsonIgnore] - public AbstractLineFact Ray1 { get => (AbstractLineFact)FactOrganizer.AllFacts[Lid1]; } + public AbstractLineFact Ray1 { get => (AbstractLineFact)FactRecorder.AllFacts[Lid1]; } [JsonIgnore] - public AbstractLineFact Ray2 { get => (AbstractLineFact)FactOrganizer.AllFacts[Lid2]; } + public AbstractLineFact Ray2 { get => (AbstractLineFact)FactRecorder.AllFacts[Lid2]; } /// <summary> \copydoc Fact.Fact </summary> public ParallelLineFact() : base() @@ -784,7 +784,7 @@ public ParallelLineFact() : base() /// <param name="lid1">sets <see cref="Lid1"/></param> /// <param name="lid2">sets <see cref="Lid2"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public ParallelLineFact(string lid1, string lid2, FactOrganizer organizer) : base(organizer) + public ParallelLineFact(string lid1, string lid2, FactRecorder organizer) : base(organizer) { this.Lid1 = lid1; this.Lid2 = lid2; @@ -801,7 +801,7 @@ protected override void RecalculateTransform() { } /// <param name="Lid2">sets <see cref="Lid2"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public ParallelLineFact(string Lid1, string Lid2, string backendURI, FactOrganizer organizer) : base(organizer) + public ParallelLineFact(string Lid1, string Lid2, string backendURI, FactRecorder organizer) : base(organizer) { this.Lid1 = Lid1; this.Lid2 = Lid2; @@ -821,8 +821,8 @@ public ParallelLineFact(string Lid1, string Lid2, string backendURI, FactOrganiz string lineAUri = ((OMS)parallel_lines_OMA.arguments[0]).uri; string lineBUri = ((OMS)parallel_lines_OMA.arguments[1]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(lineAUri) - || !FactOrganizer.AllFacts.ContainsKey(lineBUri)) + if (!FactRecorder.AllFacts.ContainsKey(lineAUri) + || !FactRecorder.AllFacts.ContainsKey(lineBUri)) return null; return new ParallelLineFact(lineAUri, lineBUri, fact.@ref.uri, StageStatic.stage.factState); @@ -863,7 +863,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(ParallelLineFact f1, ParallelLineFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new ParallelLineFact(old_to_new[this.Lid1], old_to_new[this.Lid2], organizer); } @@ -878,9 +878,9 @@ public class CircleFact : FactWrappedCRTP<CircleFact> public string Pid2; [JsonIgnore] - public PointFact Point1 { get => (PointFact)FactOrganizer.AllFacts[Pid1]; } + public PointFact Point1 { get => (PointFact)FactRecorder.AllFacts[Pid1]; } [JsonIgnore] - public PointFact Point2 { get => (PointFact)FactOrganizer.AllFacts[Pid2]; } + public PointFact Point2 { get => (PointFact)FactRecorder.AllFacts[Pid2]; } /// <summary> radius of the circle </summary> public float radius; @@ -905,7 +905,7 @@ public CircleFact() : base() /// <param name="radius">sets <see cref="radius"/></param> /// <param name="normal">sets <see cref="normal"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public CircleFact(string pid1, string pid2, float radius, Vector3 normal, FactOrganizer organizer) : base(organizer) + public CircleFact(string pid1, string pid2, float radius, Vector3 normal, FactRecorder organizer) : base(organizer) { this.Pid1 = pid1; this.Pid2 = pid2; @@ -937,7 +937,7 @@ protected override void RecalculateTransform() /// <param name="normal">sets <see cref="normal"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public CircleFact(string Pid1, string Pid2, float radius, Vector3 normal, string backendURI, FactOrganizer organizer) : base(organizer) + public CircleFact(string Pid1, string Pid2, float radius, Vector3 normal, string backendURI, FactRecorder organizer) : base(organizer) { this.Pid1 = Pid1; this.Pid2 = Pid2; @@ -967,13 +967,13 @@ public CircleFact(string Pid1, string Pid2, float radius, Vector3 normal, string if (planeApplicant.Equals(MMTConstants.pointNormalPlane)) { //OMA pointAOMA = (OMA)planeOMA.arguments[0]; - normal = (planeOMA.arguments[1].GetLambdaExpression().Compile() as Func<Vector3>)(); + normal = SOMDoc.MakeVector3((OMA)planeOMA.arguments[1]); } // In case of parametrized plane else if (planeApplicant.Equals(MMTConstants.ParametrizedPlane)) { - Vector3 v = (planeOMA.arguments[1].GetLambdaExpression().Compile() as Func<Vector3>)(); - Vector3 w = (planeOMA.arguments[2].GetLambdaExpression().Compile() as Func<Vector3>)(); + Vector3 v = SOMDoc.MakeVector3((OMA)planeOMA.arguments[1]); + Vector3 w = SOMDoc.MakeVector3((OMA)planeOMA.arguments[2]); normal = Vector3.Cross(v, w).normalized; } @@ -986,8 +986,8 @@ public CircleFact(string Pid1, string Pid2, float radius, Vector3 normal, string string A_uri = ParsingDictionary.parseTermsToId[planeOMA.arguments[0].ToString()]; float radius = ((OMF)df.arguments[2]).@float; - if (!FactOrganizer.AllFacts.ContainsKey(M_uri) - || !FactOrganizer.AllFacts.ContainsKey(A_uri)) + if (!FactRecorder.AllFacts.ContainsKey(M_uri) + || !FactRecorder.AllFacts.ContainsKey(A_uri)) return null; //If dependent facts do not exist return null return new CircleFact(M_uri, A_uri, radius, normal, fact.@ref.uri, StageStatic.stage.factState); @@ -1055,7 +1055,7 @@ protected override bool EquivalentWrapped(CircleFact f1, CircleFact f2) && Math3d.IsApproximatelyEqual(f1.normal, f2.normal) && Mathf.Approximately(f1.radius, f2.radius); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new CircleFact(old_to_new[this.Pid1], old_to_new[this.Pid2], this.radius, this.normal, organizer); } @@ -1070,9 +1070,9 @@ public class OnCircleFact : FactWrappedCRTP<OnCircleFact> public string Cid; [JsonIgnore] - public PointFact Point { get => (PointFact)FactOrganizer.AllFacts[Pid]; } + public PointFact Point { get => (PointFact)FactRecorder.AllFacts[Pid]; } [JsonIgnore] - public CircleFact Circle { get => (CircleFact)FactOrganizer.AllFacts[Cid]; } + public CircleFact Circle { get => (CircleFact)FactRecorder.AllFacts[Cid]; } /// <summary> \copydoc Fact.Fact </summary> public OnCircleFact() : base() @@ -1088,7 +1088,7 @@ public OnCircleFact() : base() /// <param name="pid">sets <see cref="Pid"/></param> /// <param name="cid">sets <see cref="Cid"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public OnCircleFact(string pid, string cid, FactOrganizer organizer) : base(organizer) + public OnCircleFact(string pid, string cid, FactRecorder organizer) : base(organizer) { this.Pid = pid; this.Cid = cid; ; @@ -1109,7 +1109,7 @@ protected override void RecalculateTransform() /// <param name="cid">sets <see cref="Cid"/></param> /// <param name="uri">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public OnCircleFact(string pid, string cid, string uri, FactOrganizer organizer) : base(organizer) + public OnCircleFact(string pid, string cid, string uri, FactRecorder organizer) : base(organizer) { this.Pid = pid; this.Cid = cid; @@ -1126,8 +1126,8 @@ public OnCircleFact(string pid, string cid, string uri, FactOrganizer organizer) string circleUri = ((OMS)((OMA)type.arguments[0]).arguments[0]).uri; string pointUri = ((OMS)((OMA)type.arguments[0]).arguments[1]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(pointUri) - || !FactOrganizer.AllFacts.ContainsKey(circleUri)) + if (!FactRecorder.AllFacts.ContainsKey(pointUri) + || !FactRecorder.AllFacts.ContainsKey(circleUri)) return null; return new OnCircleFact(pointUri, circleUri, fact.@ref.uri, StageStatic.stage.factState); @@ -1148,7 +1148,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(OnCircleFact c1, OnCircleFact c2) => DependentFactsEquivalent(c1, c2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new OnCircleFact(old_to_new[this.Pid], old_to_new[this.Cid], organizer); public override MMTFact MakeMMTDeclaration() @@ -1182,9 +1182,9 @@ public class AngleCircleLineFact : FactWrappedCRTP<AngleCircleLineFact> /// @} [JsonIgnore] - public AbstractLineFact Ray { get => (AbstractLineFact)FactOrganizer.AllFacts[Rid2]; } + public AbstractLineFact Ray { get => (AbstractLineFact)FactRecorder.AllFacts[Rid2]; } [JsonIgnore] - public CircleFact Circle { get => (CircleFact)FactOrganizer.AllFacts[Cid1]; } + public CircleFact Circle { get => (CircleFact)FactRecorder.AllFacts[Cid1]; } //TODO? deg or rad? [JsonIgnore] @@ -1209,7 +1209,7 @@ public AngleCircleLineFact() : base() /// <param name="rid2">sets <see cref="Rid2"/></param> /// <param name="angle"> sets the angle </param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public AngleCircleLineFact(string cid1, string rid2, FactOrganizer organizer) : base(organizer) + public AngleCircleLineFact(string cid1, string rid2, FactRecorder organizer) : base(organizer) { this.Cid1 = cid1; this.Rid2 = rid2; @@ -1252,7 +1252,7 @@ protected override void RecalculateTransform() /// <param name="angle"> sets the angle </param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public AngleCircleLineFact(string Cid1, string Rid2, float angle, string backendURI, FactOrganizer organizer) : base(organizer) + public AngleCircleLineFact(string Cid1, string Rid2, float angle, string backendURI, FactRecorder organizer) : base(organizer) { this.Cid1 = Cid1; this.Rid2 = Rid2; @@ -1278,8 +1278,8 @@ public AngleCircleLineFact(string Cid1, string Rid2, float angle, string backend string CircleUri = ((OMS)lhs.arguments[0]).uri; string RayUri = ((OMS)lhs.arguments[1]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(CircleUri) - || !FactOrganizer.AllFacts.ContainsKey(RayUri)) + if (!FactRecorder.AllFacts.ContainsKey(CircleUri) + || !FactRecorder.AllFacts.ContainsKey(RayUri)) return null; return new AngleCircleLineFact(CircleUri, RayUri, angle, fact.@ref.uri, StageStatic.stage.factState); @@ -1317,7 +1317,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(AngleCircleLineFact f1, AngleCircleLineFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new AngleCircleLineFact(old_to_new[this.Cid1], old_to_new[this.Rid2], organizer); } @@ -1330,7 +1330,7 @@ public class RadiusFact : FactWrappedCRTP<RadiusFact> public string Cid1; [JsonIgnore] - public CircleFact Circle { get => (CircleFact)FactOrganizer.AllFacts[Cid1]; } + public CircleFact Circle { get => (CircleFact)FactRecorder.AllFacts[Cid1]; } /// <summary> The radius as a float </summary> public float rad; @@ -1348,7 +1348,7 @@ public RadiusFact() : base() /// </summary> /// <param name="cid1">sets <see cref="Cid1"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public RadiusFact(string cid1, FactOrganizer organizer) : base(organizer) + public RadiusFact(string cid1, FactRecorder organizer) : base(organizer) { this.Cid1 = cid1; this.rad = Circle.radius; @@ -1368,7 +1368,7 @@ protected override void RecalculateTransform() /// <param name="Cid1">sets <see cref="Cid1"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public RadiusFact(string Cid1, string backendURI, FactOrganizer organizer) : base(organizer) + public RadiusFact(string Cid1, string backendURI, FactRecorder organizer) : base(organizer) { this.Cid1 = Cid1; @@ -1381,7 +1381,7 @@ public RadiusFact(string Cid1, string backendURI, FactOrganizer organizer) : bas { string CircleUri = ((OMS)((OMA)((MMTValueFact)fact).lhs).arguments[0]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(CircleUri)) + if (!FactRecorder.AllFacts.ContainsKey(CircleUri)) return null; return new RadiusFact(CircleUri, fact.@ref.uri, StageStatic.stage.factState); @@ -1424,7 +1424,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(RadiusFact f1, RadiusFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new RadiusFact(old_to_new[this.Cid1], organizer); } @@ -1437,7 +1437,7 @@ public class AreaCircleFact : FactWrappedCRTP<AreaCircleFact> public string Cid1; [JsonIgnore] - public CircleFact Circle { get => (CircleFact)FactOrganizer.AllFacts[Cid1]; } + public CircleFact Circle { get => (CircleFact)FactRecorder.AllFacts[Cid1]; } /// <summary> the area which is contained by the circle </summary> public float A; @@ -1456,7 +1456,7 @@ public AreaCircleFact() : base() /// </summary> /// <param name="cid1">sets <see cref="Cid1"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public AreaCircleFact(string cid1, FactOrganizer organizer) : base(organizer) + public AreaCircleFact(string cid1, FactRecorder organizer) : base(organizer) { this.Cid1 = cid1; @@ -1477,7 +1477,7 @@ protected override void RecalculateTransform() /// <param name="Cid1">sets <see cref="Cid1"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public AreaCircleFact(string Cid1, string backendURI, FactOrganizer organizer) : base(organizer) + public AreaCircleFact(string Cid1, string backendURI, FactRecorder organizer) : base(organizer) { this.Cid1 = Cid1; @@ -1490,7 +1490,7 @@ public AreaCircleFact(string Cid1, string backendURI, FactOrganizer organizer) : { string CircleUri = ((OMS)((OMA)((MMTValueFact)fact).lhs).arguments[0]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(CircleUri)) + if (!FactRecorder.AllFacts.ContainsKey(CircleUri)) return null; return new AreaCircleFact(CircleUri, fact.@ref.uri, StageStatic.stage.factState); @@ -1531,7 +1531,7 @@ public override int GetHashCode() protected override bool EquivalentWrapped(AreaCircleFact f1, AreaCircleFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new AreaCircleFact(old_to_new[this.Cid1], organizer); } @@ -1543,12 +1543,12 @@ public class ConeVolumeFact : FactWrappedCRTP<ConeVolumeFact> /// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary> public string Cid1; [JsonIgnore] - public CircleFact Circle { get => (CircleFact)FactOrganizer.AllFacts[Cid1]; } + public CircleFact Circle { get => (CircleFact)FactRecorder.AllFacts[Cid1]; } /// <summary> a <see cref="PointFact">PointFact</see> describing the apex point </summary> public string Pid1; [JsonIgnore] - public PointFact Point { get => (PointFact)FactOrganizer.AllFacts[Pid1]; } + public PointFact Point { get => (PointFact)FactRecorder.AllFacts[Pid1]; } /// <summary> the volume of the cone as a float </summary> public float vol; @@ -1569,7 +1569,7 @@ public ConeVolumeFact() : base() /// <param name="pid1">sets <see cref="Pid1"/></param> /// <param name="vol">sets <see cref="vol"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public ConeVolumeFact(string cid1, string pid1, float vol, FactOrganizer organizer) : base(organizer) + public ConeVolumeFact(string cid1, string pid1, float vol, FactRecorder organizer) : base(organizer) { this.Cid1 = cid1; this.Pid1 = pid1; @@ -1592,7 +1592,7 @@ protected override void RecalculateTransform() /// <param name="volume">sets <see cref="vol"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public ConeVolumeFact(string Cid1, string Pid1, float volume, string backendURI, FactOrganizer organizer) : base(organizer) + public ConeVolumeFact(string Cid1, string Pid1, float volume, string backendURI, FactRecorder organizer) : base(organizer) { this.Cid1 = Cid1; this.Pid1 = Pid1; @@ -1615,8 +1615,8 @@ public ConeVolumeFact(string Cid1, string Pid1, float volume, string backendURI, if (((MMTValueFact)fact).value is OMF oMFvolume) volume = oMFvolume.@float; - if (!FactOrganizer.AllFacts.ContainsKey(CircleUri) - || !FactOrganizer.AllFacts.ContainsKey(PointUri)) + if (!FactRecorder.AllFacts.ContainsKey(CircleUri) + || !FactRecorder.AllFacts.ContainsKey(PointUri)) return null; return new ConeVolumeFact(CircleUri, PointUri, volume, fact.@ref.uri, StageStatic.stage.factState); @@ -1659,7 +1659,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(ConeVolumeFact f1, ConeVolumeFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new ConeVolumeFact(old_to_new[this.Cid1], old_to_new[this.Pid1], this.vol, organizer); } @@ -1671,12 +1671,12 @@ public class OrthogonalCircleLineFact : FactWrappedCRTP<OrthogonalCircleLineFact /// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary> public string Cid1; [JsonIgnore] - public CircleFact Circle { get => (CircleFact)FactOrganizer.AllFacts[Cid1]; } + public CircleFact Circle { get => (CircleFact)FactRecorder.AllFacts[Cid1]; } /// <summary> a <see cref="RayFact">Rayfact</see> describing the line </summary> public string Lid1; [JsonIgnore] - public AbstractLineFact Ray { get => (AbstractLineFact)FactOrganizer.AllFacts[Lid1]; } + public AbstractLineFact Ray { get => (AbstractLineFact)FactRecorder.AllFacts[Lid1]; } //TODO? deg or rad? [JsonIgnore] @@ -1700,7 +1700,7 @@ public OrthogonalCircleLineFact() : base() /// <param name="cid1">sets <see cref="Cid1"/></param> /// <param name="lid1">sets <see cref="Lid1"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public OrthogonalCircleLineFact(string cid1, string lid1, FactOrganizer organizer) : base(organizer) + public OrthogonalCircleLineFact(string cid1, string lid1, FactRecorder organizer) : base(organizer) { this.Cid1 = cid1; this.Lid1 = lid1; @@ -1733,7 +1733,7 @@ protected override void RecalculateTransform() /// <param name="Lid1">sets <see cref="Lid1"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public OrthogonalCircleLineFact(string Cid1, string Lid1, string backendURI, FactOrganizer organizer) : base(organizer) + public OrthogonalCircleLineFact(string Cid1, string Lid1, string backendURI, FactRecorder organizer) : base(organizer) { this.Cid1 = Cid1; this.Lid1 = Lid1; @@ -1751,8 +1751,8 @@ public OrthogonalCircleLineFact(string Cid1, string Lid1, string backendURI, Fac string CircleUri = ((OMS)((OMA)type.arguments[0]).arguments[0]).uri; string LineUri = ((OMS)((OMA)type.arguments[0]).arguments[1]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(CircleUri) - || !FactOrganizer.AllFacts.ContainsKey(LineUri)) + if (!FactRecorder.AllFacts.ContainsKey(CircleUri) + || !FactRecorder.AllFacts.ContainsKey(LineUri)) return null; return new OrthogonalCircleLineFact(CircleUri, LineUri, fact.@ref.uri, StageStatic.stage.factState); @@ -1793,7 +1793,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(OrthogonalCircleLineFact f1, OrthogonalCircleLineFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new OrthogonalCircleLineFact(old_to_new[this.Cid1], old_to_new[this.Lid1], organizer); } @@ -1805,12 +1805,12 @@ public class TruncatedConeVolumeFact : FactWrappedCRTP<TruncatedConeVolumeFact> /// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary> public string Cid1; [JsonIgnore] - public CircleFact Circle1 { get => (CircleFact)FactOrganizer.AllFacts[Cid1]; } + public CircleFact Circle1 { get => (CircleFact)FactRecorder.AllFacts[Cid1]; } /// <summary> a <see cref="CircleFact">CircleFact</see> describing the top area </summary> public string Cid2; [JsonIgnore] - public CircleFact Circle2 { get => (CircleFact)FactOrganizer.AllFacts[Cid2]; } + public CircleFact Circle2 { get => (CircleFact)FactRecorder.AllFacts[Cid2]; } /// <summary> the volume of Truncated the cone as a float </summary> public float vol; @@ -1839,7 +1839,7 @@ public TruncatedConeVolumeFact() : base() /// <param name="vol">sets <see cref="vol"/></param> /// <param name="proof">sets <see cref="proof"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public TruncatedConeVolumeFact(string cid1, string cid2, float vol, string unequalproof, OMA proof, FactOrganizer organizer) : base(organizer) + public TruncatedConeVolumeFact(string cid1, string cid2, float vol, string unequalproof, OMA proof, FactRecorder organizer) : base(organizer) { this.Cid1 = cid1; this.Cid2 = cid2; @@ -1865,7 +1865,7 @@ protected override void RecalculateTransform() /// <param name="proof">sets <see cref="proof"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public TruncatedConeVolumeFact(string Cid1, string Cid2, float volume, string unequalproof, OMA proof, string backendURI, FactOrganizer organizer) : base(organizer) + public TruncatedConeVolumeFact(string Cid1, string Cid2, float volume, string unequalproof, OMA proof, string backendURI, FactRecorder organizer) : base(organizer) { this.Cid1 = Cid1; this.Cid2 = Cid2; @@ -1887,8 +1887,8 @@ public TruncatedConeVolumeFact(string Cid1, string Cid2, float volume, string un string UnEqualCirclesProof = ((OMS)(((OMA)((OMA)((MMTValueFact)fact).lhs).arguments[0]).arguments[2])).uri; OMA proof = (OMA)(((OMA)((OMA)((MMTValueFact)fact).lhs).arguments[0]).arguments[3]); - if (!FactOrganizer.AllFacts.ContainsKey(Circle1Uri) - || !FactOrganizer.AllFacts.ContainsKey(Circle2Uri)) + if (!FactRecorder.AllFacts.ContainsKey(Circle1Uri) + || !FactRecorder.AllFacts.ContainsKey(Circle2Uri)) return null; return new TruncatedConeVolumeFact(Circle1Uri, Circle2Uri, volume, UnEqualCirclesProof, proof, fact.@ref.uri, StageStatic.stage.factState); @@ -1928,7 +1928,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(TruncatedConeVolumeFact f1, TruncatedConeVolumeFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new TruncatedConeVolumeFact(old_to_new[this.Cid1], old_to_new[this.Cid2], this.vol, old_to_new[this.unequalCirclesProof], this.proof, organizer); } @@ -1940,12 +1940,12 @@ public class CylinderVolumeFact : FactWrappedCRTP<CylinderVolumeFact> /// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary> public string Cid1; [JsonIgnore] - public CircleFact Circle1 { get => (CircleFact)FactOrganizer.AllFacts[Cid1]; } + public CircleFact Circle1 { get => (CircleFact)FactRecorder.AllFacts[Cid1]; } /// <summary> a <see cref="CircleFact">CircleFact</see> describing the top area </summary> public string Cid2; [JsonIgnore] - public CircleFact Circle2 { get => (CircleFact)FactOrganizer.AllFacts[Cid2]; } + public CircleFact Circle2 { get => (CircleFact)FactRecorder.AllFacts[Cid2]; } /// <summary> the volume of the cylinder as a float </summary> public float vol; @@ -1973,7 +1973,7 @@ public CylinderVolumeFact() : base() /// <param name="vol">sets <see cref="vol"/></param> /// <param name="proof">sets <see cref="proof"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public CylinderVolumeFact(string cid1, string cid2, float vol, string eqProof, OMA proof, FactOrganizer organizer) : base(organizer) + public CylinderVolumeFact(string cid1, string cid2, float vol, string eqProof, OMA proof, FactRecorder organizer) : base(organizer) { this.Cid1 = cid1; this.Cid2 = cid2; @@ -1999,7 +1999,7 @@ protected override void RecalculateTransform() /// <param name="proof">sets <see cref="proof"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public CylinderVolumeFact(string Cid1, string Cid2, float volume, string eqProof, OMA proof, string backendURI, FactOrganizer organizer) : base(organizer) + public CylinderVolumeFact(string Cid1, string Cid2, float volume, string eqProof, OMA proof, string backendURI, FactRecorder organizer) : base(organizer) { this.Cid1 = Cid1; this.Cid2 = Cid2; @@ -2021,8 +2021,8 @@ public CylinderVolumeFact(string Cid1, string Cid2, float volume, string eqProof OMA proof = (OMA)(((OMA)((OMA)((MMTValueFact)fact).lhs).arguments[0]).arguments[3]); - if (!FactOrganizer.AllFacts.ContainsKey(Circle1Uri) - || !FactOrganizer.AllFacts.ContainsKey(Circle2Uri)) + if (!FactRecorder.AllFacts.ContainsKey(Circle1Uri) + || !FactRecorder.AllFacts.ContainsKey(Circle2Uri)) return null; return new CylinderVolumeFact(Circle1Uri, Circle2Uri, volume, EqualCirclesProof, proof, fact.@ref.uri, StageStatic.stage.factState); @@ -2063,7 +2063,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(CylinderVolumeFact f1, CylinderVolumeFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new CylinderVolumeFact(old_to_new[this.Cid1], old_to_new[this.Cid2], this.vol, old_to_new[this.equalCirclesProof], this.proof, organizer); } @@ -2079,9 +2079,9 @@ public class EqualCirclesFact : FactWrappedCRTP<EqualCirclesFact> /// @} [JsonIgnore] - public CircleFact Circle1 { get => (CircleFact)FactOrganizer.AllFacts[Cid1]; } + public CircleFact Circle1 { get => (CircleFact)FactRecorder.AllFacts[Cid1]; } [JsonIgnore] - public CircleFact Circle2 { get => (CircleFact)FactOrganizer.AllFacts[Cid2]; } + public CircleFact Circle2 { get => (CircleFact)FactRecorder.AllFacts[Cid2]; } /// <summary> \copydoc Fact.Fact </summary> public EqualCirclesFact() : base() @@ -2097,7 +2097,7 @@ public EqualCirclesFact() : base() /// <param name="cid1">sets <see cref="Cid1"/></param> /// <param name="cid2">sets <see cref="Cid2"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public EqualCirclesFact(string cid1, string cid2, FactOrganizer organizer) : base(organizer) + public EqualCirclesFact(string cid1, string cid2, FactRecorder organizer) : base(organizer) { this.Cid1 = cid1; this.Cid2 = cid2; @@ -2118,7 +2118,7 @@ protected override void RecalculateTransform() /// <param name="Cid2">sets <see cref="Cid2"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public EqualCirclesFact(string Cid1, string Cid2, string backendURI, FactOrganizer organizer) : base(organizer) + public EqualCirclesFact(string Cid1, string Cid2, string backendURI, FactRecorder organizer) : base(organizer) { this.Cid1 = Cid1; this.Cid2 = Cid2; @@ -2138,8 +2138,8 @@ public EqualCirclesFact(string Cid1, string Cid2, string backendURI, FactOrganiz string circleAUri = ((OMS)parallel_circles_OMA.arguments[0]).uri; string circleBUri = ((OMS)parallel_circles_OMA.arguments[1]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(circleAUri) - || !FactOrganizer.AllFacts.ContainsKey(circleBUri)) + if (!FactRecorder.AllFacts.ContainsKey(circleAUri) + || !FactRecorder.AllFacts.ContainsKey(circleBUri)) return null; return new EqualCirclesFact(circleAUri, circleBUri, fact.@ref.uri, StageStatic.stage.factState); @@ -2180,7 +2180,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(EqualCirclesFact f1, EqualCirclesFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new EqualCirclesFact(old_to_new[this.Cid1], old_to_new[this.Cid2], organizer); } @@ -2196,9 +2196,9 @@ public class UnEqualCirclesFact : FactWrappedCRTP<UnEqualCirclesFact> /// @} [JsonIgnore] - public CircleFact Circle1 { get => (CircleFact)FactOrganizer.AllFacts[Cid1]; } + public CircleFact Circle1 { get => (CircleFact)FactRecorder.AllFacts[Cid1]; } [JsonIgnore] - public CircleFact Circle2 { get => (CircleFact)FactOrganizer.AllFacts[Cid2]; } + public CircleFact Circle2 { get => (CircleFact)FactRecorder.AllFacts[Cid2]; } /// <summary> \copydoc Fact.Fact </summary> public UnEqualCirclesFact() : base() @@ -2214,7 +2214,7 @@ public UnEqualCirclesFact() : base() /// <param name="cid1">sets <see cref="Cid1"/></param> /// <param name="cid2">sets <see cref="Cid2"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public UnEqualCirclesFact(string cid1, string cid2, FactOrganizer organizer) : base(organizer) + public UnEqualCirclesFact(string cid1, string cid2, FactRecorder organizer) : base(organizer) { this.Cid1 = cid1; this.Cid2 = cid2; @@ -2235,7 +2235,7 @@ protected override void RecalculateTransform() /// <param name="Cid2">sets <see cref="Cid2"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public UnEqualCirclesFact(string Cid1, string Cid2, string backendURI, FactOrganizer organizer) : base(organizer) + public UnEqualCirclesFact(string Cid1, string Cid2, string backendURI, FactRecorder organizer) : base(organizer) { this.Cid1 = Cid1; this.Cid2 = Cid2; @@ -2255,8 +2255,8 @@ public UnEqualCirclesFact(string Cid1, string Cid2, string backendURI, FactOrgan string circleAUri = ((OMS)unequal_circles_OMA.arguments[0]).uri; string circleBUri = ((OMS)unequal_circles_OMA.arguments[1]).uri; - if (!FactOrganizer.AllFacts.ContainsKey(circleAUri) - || !FactOrganizer.AllFacts.ContainsKey(circleBUri)) + if (!FactRecorder.AllFacts.ContainsKey(circleAUri) + || !FactRecorder.AllFacts.ContainsKey(circleBUri)) return null; return new UnEqualCirclesFact(circleAUri, circleBUri, fact.@ref.uri, StageStatic.stage.factState); @@ -2293,7 +2293,7 @@ protected override string[] GetGetDependentFactIds() protected override bool EquivalentWrapped(UnEqualCirclesFact f1, UnEqualCirclesFact f2) => DependentFactsEquivalent(f1, f2); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new UnEqualCirclesFact(old_to_new[this.Cid1], old_to_new[this.Cid2], organizer); } @@ -2322,7 +2322,7 @@ public TestFact() : base() /// <param name="radius">sets <see cref="radius"/></param> /// <param name="normal">sets <see cref="normal"/></param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public TestFact(FactOrganizer organizer) : base(organizer) + public TestFact(FactRecorder organizer) : base(organizer) { SendToMMT(); } @@ -2338,7 +2338,7 @@ protected override void RecalculateTransform() { } /// <param name="normal">sets <see cref="normal"/></param> /// <param name="backendURI">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public TestFact(string backendURI, FactOrganizer organizer) : base(organizer) + public TestFact(string backendURI, FactRecorder organizer) : base(organizer) { this._URI = backendURI; @@ -2377,7 +2377,7 @@ protected override bool EquivalentWrapped(TestFact f1, TestFact f2) return DependentFactsEquivalent(f1, f2); } - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new TestFact(organizer); public override MMTFact MakeMMTDeclaration() diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs index 95efd1f26ebad967b7291c43126cd64879ad84d8..cdda3745718dc8ece334841a82422f3b5326fe01 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs @@ -17,16 +17,16 @@ public class FunctionCallFact : FactWrappedCRTP<FunctionCallFact> [JsonIgnore] public FunctionFact Function_in - => (FunctionFact)FactOrganizer.AllFacts[func_id]; + => (FunctionFact)FactRecorder.AllFacts[func_id]; [JsonIgnore] public FunctionFact Function_args - => (FunctionFact)FactOrganizer.AllFacts[arg_func_id]; + => (FunctionFact)FactRecorder.AllFacts[arg_func_id]; public FunctionCallFact() : base() { } - public FunctionCallFact(string func_id, string arg_func_id, (float t_0, float t_n) Domain, FactOrganizer organizer) : base(organizer) + public FunctionCallFact(string func_id, string arg_func_id, (float t_0, float t_n) Domain, FactRecorder organizer) : base(organizer) { this.func_id = func_id; this.arg_func_id = arg_func_id; @@ -69,7 +69,7 @@ protected override void RecalculateTransform() LocalScale = Function_in.LocalScale; } - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new FunctionCallFact(old_to_new[this.func_id], old_to_new[this.arg_func_id], this.Domain, organizer); } @@ -92,7 +92,7 @@ public FunctionFact() : base() { } /// </summary> /// <param name="Function_SOMDoc">sets <see cref="Function_SOMDoc"/> and contains the Abstract Syntax Tree</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public FunctionFact(SOMDoc Function_SOMDoc, FactOrganizer organizer) : base(organizer) + public FunctionFact(SOMDoc Function_SOMDoc, FactRecorder organizer) : base(organizer) { this.Function_SOMDoc = Function_SOMDoc; @@ -119,7 +119,7 @@ public FunctionFact(SOMDoc Function_SOMDoc, FactOrganizer organizer) : base(orga /// <param name="function_expression">sets <see cref="Function_expression"/> and contains the Abstract Syntax Tree</param> /// <param name="uri">MMT URI</param> /// <param name="organizer">sets <see cref="Fact._Facts"/></param> - public FunctionFact(SOMDoc Function_SOMDoc, string uri, FactOrganizer organizer) : base(organizer) + public FunctionFact(SOMDoc Function_SOMDoc, string uri, FactRecorder organizer) : base(organizer) { this.Function_SOMDoc = Function_SOMDoc; @@ -158,7 +158,7 @@ public override int GetHashCode() protected override bool EquivalentWrapped(FunctionFact f1, FunctionFact f2) => f1.Function_SOMDoc.Equivalent(f2.Function_SOMDoc); - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new FunctionFact(this.Function_SOMDoc.MapURIs(old_to_new), organizer); public override MMTFact MakeMMTDeclaration() @@ -176,7 +176,7 @@ public class AttachedPositionFunction : FactWrappedCRTP<AttachedPositionFunction //public string func_calls_list_id; [JsonIgnore] - public Fact Fact => FactOrganizer.AllFacts[fid]; + public Fact Fact => FactRecorder.AllFacts[fid]; //[JsonIgnore] //public ListFact FunctionCallFactsList => (ListFact) FactOrganizer.AllFacts[func_calls_list_id]; @@ -186,7 +186,7 @@ public class AttachedPositionFunction : FactWrappedCRTP<AttachedPositionFunction [JsonIgnore] public FunctionCallFact[] FunctionCallFacts - => func_calls_ids.Select(f => FactOrganizer.AllFacts[f] as FunctionCallFact).ToArray(); + => func_calls_ids.Select(f => FactRecorder.AllFacts[f] as FunctionCallFact).ToArray(); //=> FuncCallIds.Select(f => FactOrganizer.AllFacts[f] as FunctionCallFact).ToArray(); /// <summary>\copydoc Fact.Fact()</summary> @@ -196,7 +196,7 @@ public AttachedPositionFunction() : base() } /// <summary>\copydoc Fact.Fact(FactOrganizer)</summary> - public AttachedPositionFunction(string fid, string[] funcids, FactOrganizer organizer) : base(organizer) + public AttachedPositionFunction(string fid, string[] funcids, FactRecorder organizer) : base(organizer) { init(fid, funcids, organizer); //TODO: call MMT, set URI @@ -211,7 +211,7 @@ public AttachedPositionFunction(string fid, string[] funcids, FactOrganizer orga // _URI = Fact.Id + "{" + string.Join(", ", FunctionCallFacts.Select(f => f.Id)) + "}"; //} - private void init(string fid, string[] func_calls_ids, FactOrganizer organizer) + private void init(string fid, string[] func_calls_ids, FactRecorder organizer) { this.fid = fid; this.func_calls_ids = func_calls_ids; @@ -229,7 +229,7 @@ private void init(string fid, string[] func_calls_ids, FactOrganizer organizer) // this.func_calls_list_id = func_calls_list_id; //} - protected AttachedPositionFunction(string fid, string[] funcids, string uri, FactOrganizer organizer) : base(organizer) + protected AttachedPositionFunction(string fid, string[] funcids, string uri, FactRecorder organizer) : base(organizer) { init(fid, funcids, organizer); _URI = uri; @@ -278,7 +278,7 @@ protected override void RecalculateTransform() LocalScale = Fact.LocalScale; } - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) // => new AttachedPositionFunction(old_to_new[this.fid], old_to_new[func_calls_list_id], organizer); => new AttachedPositionFunction(old_to_new[this.fid], this.func_calls_ids.Select(id => old_to_new[id]).ToArray(), organizer); } diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/MMTTypes.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/MMTTypes.cs index e856e0c6d3e24f490a73a0223b96ef91131c9475..adc880b49b6207ea94ee838f6dc305028c5cd29b 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/MMTTypes.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/MMTTypes.cs @@ -19,13 +19,13 @@ public class ListFact : FactWrappedCRTP<ListFact> public ListFact() : base() { } - public ListFact(string[] lids, SOMDoc[] payload, SOMDoc ElementType, FactOrganizer organizer) : base(organizer) + public ListFact(string[] lids, SOMDoc[] payload, SOMDoc ElementType, FactRecorder organizer) : base(organizer) { Init(lids, payload, ElementType); SendToMMT(); } - public ListFact(string[] lids, SOMDoc[] payload, SOMDoc ElementType, string backendURI, FactOrganizer organizer) : base(organizer) + public ListFact(string[] lids, SOMDoc[] payload, SOMDoc ElementType, string backendURI, FactRecorder organizer) : base(organizer) { Init(lids, payload, ElementType); _URI = backendURI; @@ -67,10 +67,10 @@ private void Init(string[] lids, SOMDoc[] payload, SOMDoc ElementType) ); } - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) => new ListFact( lids.Select(id => id == null ? null : old_to_new[id]).ToArray(), - payload.Select(somdoc => somdoc == null ? null : somdoc.MapURIs(old_to_new)).ToArray(), + payload.Select(somdoc => somdoc?.MapURIs(old_to_new)).ToArray(), ListType.arguments[0], organizer); @@ -188,22 +188,22 @@ protected override bool EquivalentWrapped(ListFact f1, ListFact f2) /// </summary> /// <seealso cref="SOMDoc.MakeTupel(SOMDoc[])"/> /// <remarks>Needed to refere to tupels serverside</remarks> -public class TupelFact : FactWrappedCRTP<TupelFact> +public class TupleFact : FactWrappedCRTP<TupleFact> { public string[] lids = new string[0]; public SOMDoc[] payload = new SOMDoc[0]; - public TupelFact() : base() { } + public TupleFact() : base() { } - public TupelFact(string[] lids, SOMDoc[] payload, FactOrganizer organizer) : base(organizer) + public TupleFact(string[] lids, SOMDoc[] payload, FactRecorder organizer) : base(organizer) { Init(lids, payload); SendToMMT(); } - public TupelFact(string[] lids, SOMDoc[] payload, string backendURI, FactOrganizer organizer) : base(organizer) + public TupleFact(string[] lids, SOMDoc[] payload, string backendURI, FactRecorder organizer) : base(organizer) { Init(lids, payload); _URI = backendURI; @@ -228,17 +228,17 @@ private void Init(string[] lids, SOMDoc[] payload) payload[i] = new OMS(lids[i]); else if (lids[i] == null && payload[i] == null) - throw new ArgumentException(nameof(lids) + " and " + nameof(payload) + " have to be complementary not null!"); + throw new ArgumentException(nameof(lids) + " and " + nameof(payload) + " have to be complementary-not-null!"); } } - protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactOrganizer organizer) - => new TupelFact( + protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new, FactRecorder organizer) + => new TupleFact( lids.Select(id => id == null ? null : old_to_new[id]).ToArray(), payload.Select(somdoc => somdoc == null ? null : somdoc.MapURIs(old_to_new)).ToArray(), organizer); - public static new TupelFact parseFact(MMTFact fact) + public static new TupleFact parseFact(MMTFact fact) { if (fact is not MMTGeneralFact MMTSymbol || MMTSymbol.defines is not OMA defineOMA) @@ -264,7 +264,7 @@ protected override string[] GetGetDependentFactIds() protected override void RecalculateTransform() { } - protected override bool EquivalentWrapped(TupelFact f1, TupelFact f2) + protected override bool EquivalentWrapped(TupleFact f1, TupleFact f2) => f1.payload.Length == f2.payload.Length && DependentFactsEquivalent(f1, f2) && f1.payload diff --git a/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs b/Assets/Scripts/InteractionEngine/FactHandling/SolutionRecorder.cs similarity index 68% rename from Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs rename to Assets/Scripts/InteractionEngine/FactHandling/SolutionRecorder.cs index 480d521faf4db645024874438f34ea190a252c19..f7c3b896c8dc5ae7fc861325a19b6019b66642c5 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/SolutionRecorder.cs @@ -1,20 +1,18 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; -using UnityEngine; using Newtonsoft.Json; using static CommunicationEvents; /// <summary> /// Solution of a <see cref="Stage"/> /// </summary> -public class SolutionOrganizer : FactOrganizer, IJSONsavable<SolutionOrganizer> +public class SolutionRecorder : FactRecorder, IJSONsavable<SolutionRecorder> { /// @{ <summary> adds to the end of the file name of a </summary> private const string - /// <summary> SolutionFile (stores <see cref="SolutionOrganizer">this</see>) </summary> + /// <summary> SolutionFile (stores <see cref="SolutionRecorder">this</see>) </summary> endingVal = "_val"; /// @} @@ -22,7 +20,7 @@ private const string /// <summary> /// A collection of constrains of which *all* have to be <see langword="true"/> /// <seealso cref="SubSolution"/> - /// <seealso cref="FactOrganizer.DynamiclySolved(SolutionOrganizer, out List<List<string>>, out List<List<string>>)"/> + /// <seealso cref="FactRecorder.DynamiclySolved(SolutionRecorder, out List<List<string>>, out List<List<string>>)"/> /// </summary> public List<SubSolution> ValidationSet = new(); @@ -38,31 +36,31 @@ public class SubSolution // needs to be public for JSONWriter { /// <summary> - /// entails <b>{<see cref="FactOrganizer.MyFactSpace">SolutionOrganizer.FacDict.Values</see>}</b> <br/> - /// <see cref="FactOrganizer.MyFactSpace">SolutionFacts</see> to relate from. + /// entails <b>{<see cref="FactRecorder.MyFactSpace">SolutionOrganizer.FacDict.Values</see>}</b> <br/> + /// <see cref="FactRecorder.MyFactSpace">SolutionFacts</see> to relate from. /// </summary> public HashSet<string> MasterIDs = new HashSet<string>(); /// <summary> - /// entails <b>{[],[0, <see cref="SolutionOrganizer.ValidationSet"/><c>.IndexOf(<see cref="SubSolution">this</see>)</c> - 2]}</b> <br/> - /// Marks LevelFacts (<see cref="StageStatic.stage.factState"/>) found as solution (<see cref="FactOrganizer.DynamiclySolved(SolutionOrganizer, out List<List<string>>, out List<List<string>>)"/>) - /// in a previous entry of <see cref="SolutionOrganizer.ValidationSet"/><br/> + /// entails <b>{[],[0, <see cref="SolutionRecorder.ValidationSet"/><c>.IndexOf(<see cref="SubSolution">this</see>)</c> - 2]}</b> <br/> + /// Marks LevelFacts (<see cref="StageStatic.stage.factState"/>) found as solution (<see cref="FactRecorder.DynamiclySolved(SolutionRecorder, out List<List<string>>, out List<List<string>>)"/>) + /// in a previous entry of <see cref="SolutionRecorder.ValidationSet"/><br/> /// to relate from *in addition* to <see cref="MasterIDs"/> <br/> /// or _none_ if <c>empty</c> /// </summary> public List<int> SolutionIndex = new List<int>(); /// <summary> - /// entails <b>{[],[0, <see cref="SolutionOrganizer.ValidationSet"/><c>.IndexOf(<see cref="SubSolution">this</see>)</c> - 2]}</b> <br/> - /// Marks LevelFacts (<see cref="StageStatic.stage.factState"/>) found as solution (<see cref="FactOrganizer.DynamiclySolved(SolutionOrganizer, out List<List<string>>, out List<List<string>>)"/>) - /// in a previous entry of <see cref="SolutionOrganizer.ValidationSet"/><br/> + /// entails <b>{[],[0, <see cref="SolutionRecorder.ValidationSet"/><c>.IndexOf(<see cref="SubSolution">this</see>)</c> - 2]}</b> <br/> + /// Marks LevelFacts (<see cref="StageStatic.stage.factState"/>) found as solution (<see cref="FactRecorder.DynamiclySolved(SolutionRecorder, out List<List<string>>, out List<List<string>>)"/>) + /// in a previous entry of <see cref="SolutionRecorder.ValidationSet"/><br/> /// to relate to *instead of* all LevelFacts (<see cref="StageStatic.stage.factState"/>) <br/> /// or _none_ if <c>empty</c> /// </summary> public List<int> RelationIndex = new List<int>(); /// <summary> - /// Comparer defining relation between <see cref="FactOrganizer.MyFactSpace">SolutionFacts</see> and LevelFacts (<see cref="StageStatic.stage.factState"/>) + /// Comparer defining relation between <see cref="FactRecorder.MyFactSpace">SolutionFacts</see> and LevelFacts (<see cref="StageStatic.stage.factState"/>) /// </summary> [JsonIgnore] public FactComparer Comparer = new FactEquivalentsComparer(); @@ -73,8 +71,8 @@ public class SubSolution public string ComparerString { get { return Comparer.ToString(); } - set { - // Select and create FactComparer by name + set + { // Select and create FactComparer by name Type typ = fact_comparer.First(t => t.Name == value); Comparer = Activator.CreateInstance(typ) as FactComparer; } @@ -122,16 +120,16 @@ public bool IsEmpty() } } - static SolutionOrganizer() + static SolutionRecorder() { - IJSONsavable<SolutionOrganizer>.hierarchie = new List<Directories> { Directories.ValidationSets }; + IJSONsavable<SolutionRecorder>.hierarchie = new List<Directories> { Directories.ValidationSets }; } /// \copydoc FactOrganizer.FactOrganizer() - public SolutionOrganizer(): base() { } + public SolutionRecorder() : base() { } /// \copydoc FactOrganizer.FactOrganizer(bool) - public SolutionOrganizer(bool invoke = false) : base(invoke) { } + public SolutionRecorder(bool invoke = false) : base(invoke) { } /* public List<Fact> getMasterFactsByIndex (int i) @@ -140,15 +138,15 @@ public List<Fact> getMasterFactsByIndex (int i) } */ - string IJSONsavable<SolutionOrganizer>._IJGetName(string name) + string IJSONsavable<SolutionRecorder>._IJGetName(string name) => name + endingVal; - SolutionOrganizer IJSONsavable<SolutionOrganizer>._IJPostProcess(SolutionOrganizer raw_payload) + SolutionRecorder IJSONsavable<SolutionRecorder>._IJPostProcess(SolutionRecorder raw_payload) { if (raw_payload == null) return raw_payload; - SolutionOrganizer payload = ReInitializeFactOrganizer<SolutionOrganizer> (raw_payload, false, out Dictionary<string, string> old_to_new); + SolutionRecorder payload = ReInitializeFactOrganizer<SolutionRecorder>(raw_payload, false, out Dictionary<string, string> old_to_new); // Parse and add foreach (var element in raw_payload.ValidationSet) @@ -164,6 +162,6 @@ SolutionOrganizer IJSONsavable<SolutionOrganizer>._IJPostProcess(SolutionOrganiz return payload; } - SolutionOrganizer IJSONsavable<SolutionOrganizer>._IJPreProcess(SolutionOrganizer payload) - => (SolutionOrganizer)IJSONsavable<FactOrganizer>.preprocess(payload); + SolutionRecorder IJSONsavable<SolutionRecorder>._IJPreProcess(SolutionRecorder payload) + => (SolutionRecorder)IJSONsavable<FactRecorder>.preprocess(payload); } diff --git a/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs.meta b/Assets/Scripts/InteractionEngine/FactHandling/SolutionRecorder.cs.meta similarity index 100% rename from Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs.meta rename to Assets/Scripts/InteractionEngine/FactHandling/SolutionRecorder.cs.meta diff --git a/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs b/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs index b38acaf2fb5f711a7fced537e1b67b65217115c3..cfadba54c105a7bb6cf3d50dc62e1048a3bde784 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs @@ -34,7 +34,7 @@ protected override void _Hit(RaycastHit[] hit) break; case 3: - FactManager.AddAngleFact(Workflow[0], Workflow[1], Workflow[2], gadget: this); + FactAdder.AddAngleFact(Workflow[0], Workflow[1], Workflow[2], gadget: this); ResetGadget(); return; diff --git a/Assets/Scripts/InteractionEngine/Gadgets/EqualCircleGadget.cs b/Assets/Scripts/InteractionEngine/Gadgets/EqualCircleGadget.cs index 7bf4cd79de16308cb996f1c4b70a5c549e69bf56..61abf7534e8174b270a0a653b066b79cdbe6a788 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/EqualCircleGadget.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/EqualCircleGadget.cs @@ -23,14 +23,14 @@ protected override void _Hit(RaycastHit[] hit) case 2: //If the first circle got already selected - CircleFact tempFact = (CircleFact)FactOrganizer.AllFacts[Workflow[0]]; - CircleFact FirstCircle = (CircleFact)FactOrganizer.AllFacts[tempFactId]; + CircleFact tempFact = (CircleFact)FactRecorder.AllFacts[Workflow[0]]; + CircleFact FirstCircle = (CircleFact)FactRecorder.AllFacts[tempFactId]; if (Mathf.Approximately(FirstCircle.radius, tempFact.radius)) - FactManager.AddEqualCirclesFact (Workflow[0], tempFactId); + FactAdder.AddEqualCirclesFact (Workflow[0], tempFactId); else - FactManager.AddUnEqualCirclesFact(Workflow[0], tempFactId); + FactAdder.AddUnEqualCirclesFact(Workflow[0], tempFactId); ResetGadget(); break; diff --git a/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs b/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs index 84855ae9686d9671c875cf6ce9d6cfe83d43f884..350d70ac93ff516d418f5a478872f4e997c46051 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs @@ -25,7 +25,7 @@ protected override void _Hit(RaycastHit[] hit) break; case 2: - FactManager.AddRayFact(Workflow[0], Workflow[1], gadget: this); + FactAdder.AddRayFact(Workflow[0], Workflow[1], gadget: this); ResetGadget(); return; } diff --git a/Assets/Scripts/InteractionEngine/Gadgets/LotTool.cs b/Assets/Scripts/InteractionEngine/Gadgets/LotTool.cs index e6a86047054a21b8dbd9b536c78e8ba497292829..51d90a01b147826eebba1f8f2af8dd52406d5837 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/LotTool.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/LotTool.cs @@ -22,10 +22,10 @@ protected override void _Hit(RaycastHit[] hit) { void CreateRayAndAngles(string IntersectionId, string LotPointId, bool samestep) { - FactManager.AddRayFact(IntersectionId, LotPointId, samestep, gadget: this); + FactAdder.AddRayFact(IntersectionId, LotPointId, samestep, gadget: this); //TODO? create at all? / for all points on basline? - FactManager.AddAngleFact( + FactAdder.AddAngleFact( BaseLine.Pid1 == IntersectionId ? BaseLine.Pid2 : BaseLine.Pid1 , IntersectionId, LotPointId, samestep: true, gadget: this); } @@ -37,7 +37,7 @@ void CreateRayAndAngles(string IntersectionId, string LotPointId, bool samestep) Fact tempFact = tempFactId == null ? null - : FactOrganizer.AllFacts[tempFactId]; + : FactRecorder.AllFacts[tempFactId]; switch (Workflow.Count) { @@ -47,7 +47,7 @@ void CreateRayAndAngles(string IntersectionId, string LotPointId, bool samestep) Workflow.Add(tempFactId); BaseLine = (AbstractLineFact) tempFact; - BaseLineRoot = ((PointFact)FactOrganizer.AllFacts[BaseLine.Pid1]).Point; + BaseLineRoot = ((PointFact)FactRecorder.AllFacts[BaseLine.Pid1]).Point; BaseLineHit = hit[0].point; ActivateLineDrawing(); @@ -67,10 +67,10 @@ void CreateRayAndAngles(string IntersectionId, string LotPointId, bool samestep) { // create perpendicular through existing Point off Line Vector3 normal = Vector3.Cross(BaseLine.Dir, hit[0].transform.position - IntersectionPoint).normalized; normal *= Mathf.Sign(Vector3.Dot(normal, Vector3.up)); // point up - var intersectionId = FactManager.AddPointFact(IntersectionPoint, normal, gadget: this).Id; + var intersectionId = FactAdder.AddPointFact(IntersectionPoint, normal, gadget: this).Id; if (BaseLine is RayFact) // Add OnLineFact only on Ray not Line - FactManager.AddOnLineFact(intersectionId, Workflow[0], true, gadget: this, is_certain: true); + FactAdder.AddOnLineFact(intersectionId, Workflow[0], true, gadget: this, is_certain: true); CreateRayAndAngles(intersectionId, tempFactId, true); ResetGadget(); @@ -82,7 +82,7 @@ void CreateRayAndAngles(string IntersectionId, string LotPointId, bool samestep) return; Vector3 LotPoint = Math3d.ProjectPointOnLine(hit[0].point, BaseLine.Dir, IntersectionPoint); - CreateRayAndAngles(Workflow[1], FactManager.AddPointFact(LotPoint, hit[0].normal, gadget: this).Id, true); + CreateRayAndAngles(Workflow[1], FactAdder.AddPointFact(LotPoint, hit[0].normal, gadget: this).Id, true); ResetGadget(); return; diff --git a/Assets/Scripts/InteractionEngine/Gadgets/Pendulum.cs b/Assets/Scripts/InteractionEngine/Gadgets/Pendulum.cs index f97fa0bb1ce3a6e265e468af56584f1e7e1a4bb7..7bb4222bccc3b550e82a82349eec48a13e581a06 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/Pendulum.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/Pendulum.cs @@ -19,7 +19,7 @@ protected override void _Hit(RaycastHit[] hit) { string tempFactId = hit[0].transform.GetComponent<FactObject>().URI; Workflow.Add(tempFactId); - FactManager.AddPointFact(ground, gadget: this); + FactAdder.AddPointFact(ground, gadget: this); ResetGadget(); } } diff --git a/Assets/Scripts/InteractionEngine/Gadgets/Pointer.cs b/Assets/Scripts/InteractionEngine/Gadgets/Pointer.cs index 657a93c5db4508a11643f06929f30f155771e247..b636b89e892690b3af9feb406b08b3daf60af354 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/Pointer.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/Pointer.cs @@ -9,7 +9,7 @@ public class Pointer : Gadget protected override void _Hit(RaycastHit[] hit) { - string pid = FactManager.AddPointFact(hit[0], gadget: this).Id; + string pid = FactAdder.AddPointFact(hit[0], gadget: this).Id; for (int i = 0; i < hit.Length; i++) { @@ -19,7 +19,7 @@ protected override void _Hit(RaycastHit[] hit) if (hit[i].transform.gameObject.layer == LayerMask.NameToLayer("Ray")) { Workflow.Add(hit[i].transform.GetComponent<FactObject>().URI); - FactManager.AddOnLineFact + FactAdder.AddOnLineFact (pid , Workflow[i] , samestep: true diff --git a/Assets/Scripts/InteractionEngine/Gadgets/PoleTool.cs b/Assets/Scripts/InteractionEngine/Gadgets/PoleTool.cs index 9d9972be470034adeb19e9a31822bf1b5644c51e..ecc3e7351c2dde4a8ee6a212e5a8cac850057edd 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/PoleTool.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/PoleTool.cs @@ -29,12 +29,12 @@ protected override void _Hit(RaycastHit[] hit) { Workflow.Add(hit[0].transform.gameObject.GetComponent<FactObject>().URI); - string pid2 = FactManager.AddPointFact(GetPosition(1), Vector3.up, gadget: this).Id; - FactManager.AddLineFact(Workflow[0], pid2, true, gadget: this); + string pid2 = FactAdder.AddPointFact(GetPosition(1), Vector3.up, gadget: this).Id; + FactAdder.AddLineFact(Workflow[0], pid2, true, gadget: this); } else { - FactManager.AddPointFact(hit[0], gadget: this); + FactAdder.AddPointFact(hit[0], gadget: this); } ResetGadget(); diff --git a/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs b/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs index 763f8da0720df63575bc6c729e3c36324aee64e2..a03f21ac6c89a14e4523e1f0b0689524ef194f0e 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs @@ -24,7 +24,7 @@ protected override void _Hit(RaycastHit[] hit) break; case 2: - FactManager.AddLineFact(Workflow[0], Workflow[1], gadget: this); + FactAdder.AddLineFact(Workflow[0], Workflow[1], gadget: this); ResetGadget(); return; diff --git a/Assets/Scripts/InteractionEngine/Gadgets/TestMiddlePoint.cs b/Assets/Scripts/InteractionEngine/Gadgets/TestMiddlePoint.cs index 721adf57fdbdbf0bb932ae29bccf23efa1933d5e..30d221f9b995a687b4bb6cd5b4e318df2c5ee148 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/TestMiddlePoint.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/TestMiddlePoint.cs @@ -23,12 +23,12 @@ protected override void _Hit(RaycastHit[] hit) break; case 2: //Insert point in the middle - PointFact p1 = (PointFact)FactOrganizer.AllFacts[Workflow[0]]; - PointFact p2 = (PointFact)FactOrganizer.AllFacts[Workflow[1]]; + PointFact p1 = (PointFact)FactRecorder.AllFacts[Workflow[0]]; + PointFact p2 = (PointFact)FactRecorder.AllFacts[Workflow[1]]; Vector3 middle = p1.Point + (p2.Point - p1.Point) * 0.5f; - FactManager.AddPointFact(middle, Vector3.up); + FactAdder.AddPointFact(middle, Vector3.up); ResetGadget(); return; } diff --git a/Assets/Scripts/InteractionEngine/TBD/CanonBallCalculator.cs b/Assets/Scripts/InteractionEngine/TBD/CanonBallCalculator.cs index 38f4c8161acfb67be22e23db73dc52322139a16d..b49998561d94c5bbd62bd418aa58476a43af911f 100644 --- a/Assets/Scripts/InteractionEngine/TBD/CanonBallCalculator.cs +++ b/Assets/Scripts/InteractionEngine/TBD/CanonBallCalculator.cs @@ -9,7 +9,7 @@ public class CanonBallProblemCalculator private int Dim_const, Dim_A, Dim_B; private int MaxIter; - private FactOrganizer FactOrganizer; + private FactRecorder FactOrganizer; private Vector3 StartPos; private Vector3 StartVel; @@ -32,7 +32,7 @@ public Wall(LineFact Topology, float Bounce) } } - public CanonBallProblemCalculator(List<Wall> walls, Vector3 starPos, Vector3 starVec, Vector3 gravity, int dim_const, int dim_A, int dim_B, FactOrganizer factOrganizer, int maxIter = 256) + public CanonBallProblemCalculator(List<Wall> walls, Vector3 starPos, Vector3 starVec, Vector3 gravity, int dim_const, int dim_A, int dim_B, FactRecorder factOrganizer, int maxIter = 256) { Walls = walls; Dim_const = dim_const; diff --git a/Assets/Scripts/InteractionEngine/WorldCursor.cs b/Assets/Scripts/InteractionEngine/WorldCursor.cs index bbc26561dd7b1abf6b4da7ea236eb94d698e549b..b5689c10c562b974ddfea34bd2259b0d500f29b9 100644 --- a/Assets/Scripts/InteractionEngine/WorldCursor.cs +++ b/Assets/Scripts/InteractionEngine/WorldCursor.cs @@ -80,8 +80,8 @@ void Update() { // find first acceptable hit Fact fact = Hits[i].transform.TryGetComponent(out FactObject factObj) - && FactOrganizer.AllFacts.ContainsKey(factObj.URI) - ? FactOrganizer.AllFacts[factObj.URI] + && FactRecorder.AllFacts.ContainsKey(factObj.URI) + ? FactRecorder.AllFacts[factObj.URI] : null; if (fact is AbstractLineFact lineFact) @@ -130,7 +130,7 @@ void Update() HitFacts = Hits .Select(h => h.transform.TryGetComponent(out FactObject factObj) - ? FactOrganizer.AllFacts[factObj.URI] + ? FactRecorder.AllFacts[factObj.URI] : null) .ToArray(); } diff --git a/Assets/Scripts/InteractionEngine/WorldFactInteraction.cs b/Assets/Scripts/InteractionEngine/WorldFactInteraction.cs index 70d9c5e9317e15ef88f5e98eb47029c597a25e00..dfd86eb52efa00d2404598df4d987ae21ad1ce44 100644 --- a/Assets/Scripts/InteractionEngine/WorldFactInteraction.cs +++ b/Assets/Scripts/InteractionEngine/WorldFactInteraction.cs @@ -73,7 +73,7 @@ private void InstantiateNewDisplay(FactObject factObj) { if (currentDisplay) Destroy(currentDisplay); - Fact fact = FactOrganizer.AllFacts[factObj.URI]; + Fact fact = FactRecorder.AllFacts[factObj.URI]; // TODO: this link to DisplayFacts is not ideal: maybe refactor to SciptableObject or such currentDisplay = DisplayFacts.InstantiateDisplay(fact, HidingCanvas); } diff --git a/Assets/Scripts/InventoryStuff/ScrollDetails.cs b/Assets/Scripts/InventoryStuff/ScrollDetails.cs index 1092399b23a6c794d05c264a87b0500715ac257b..ba3c91c4bd67fbbc5714510ed35f3a476f848f3b 100644 --- a/Assets/Scripts/InventoryStuff/ScrollDetails.cs +++ b/Assets/Scripts/InventoryStuff/ScrollDetails.cs @@ -336,7 +336,7 @@ private void GeneratePushoutFacts(List<MMTFact> pushoutFacts) if (newFact != null) { AnimateExistingFactEvent.Invoke - (FactManager.AddFactIfNotFound(newFact, out _, samestep, null, ActiveScroll.label).Id + (FactAdder.AddFactIfNotFound(newFact, out _, samestep, null, ActiveScroll.label).Id , FactWrapper.FactMaterials.Solution); samestep = true; @@ -405,7 +405,7 @@ void _processRenderedScroll(Scroll rendered, List<string> hintUris) public void animateHint(string scrollParameterUri) { - if (FactOrganizer.AllFacts.ContainsKey(scrollParameterUri)) + if (FactRecorder.AllFacts.ContainsKey(scrollParameterUri)) AnimateExistingFactEvent.Invoke( scrollParameterUri, FactWrapper.FactMaterials.Hint @@ -418,7 +418,7 @@ public void animateHint(string scrollParameterUri) if (suitableCompletion != null && suitableCompletion.assignment is OMS assignment) { - if (FactOrganizer.AllFacts.ContainsKey(assignment.uri)) + if (FactRecorder.AllFacts.ContainsKey(assignment.uri)) { AnimateExistingFactEvent.Invoke( assignment.uri, @@ -428,7 +428,7 @@ public void animateHint(string scrollParameterUri) } else if (hintFact != null) { - if (FactOrganizer.FindEquivalent(StageStatic.stage.factState.MyFactSpace, hintFact, out string found_key, out Fact _, out bool _, false)) + if (FactRecorder.FindEquivalent(StageStatic.stage.factState.MyFactSpace, hintFact, out string found_key, out Fact _, out bool _, false)) // existing fact -> Animate that AnimateExistingFactEvent.Invoke( found_key, diff --git a/Assets/Scripts/Loading/Stage.cs b/Assets/Scripts/Loading/Stage.cs index 1af21c00f166017289f856067278edd1b2dea62c..055f3707bcbaec6d835959d3bc71b273046e2624 100644 --- a/Assets/Scripts/Loading/Stage.cs +++ b/Assets/Scripts/Loading/Stage.cs @@ -36,10 +36,10 @@ public class Stage : IJSONsavable<Stage> /// <summary> /// Defining when this <see cref="Stage.player_record"/> is considered as solved. - /// <seealso cref="FactOrganizer.DynamiclySolved(SolutionOrganizer, out List{List{string}}, out List{List{string}})"/> + /// <seealso cref="FactRecorder.DynamiclySolved(SolutionRecorder, out List{List{string}}, out List{List{string}})"/> /// </summary> [JSONsavable.JsonAutoPreProcess, JSONsavable.JsonAutoPostProcess] - public SolutionOrganizer solution = null; + public SolutionRecorder solution = null; /// <summary> /// A single class containing all savegame-data. @@ -91,7 +91,7 @@ public Dictionary<string, PlayerRecord> player_record_list /// - <c>set</c> initiates <see cref="player_record"/> /// </summary> [JsonIgnore] - public FactOrganizer factState + public FactRecorder factState { get => player_record.factState; set => (player_record ??= new(record_name, this)).factState = value; @@ -107,7 +107,7 @@ public FactOrganizer factState public bool creatorMode = false; /// <summary> Tempory variable storing <see cref="factState"/> when <see cref="creatorMode"/> == <see langword="true"/>. </summary> - private FactOrganizer hiddenState; + private FactRecorder hiddenState; static Stage() { @@ -167,7 +167,7 @@ public void InitFields(string category, int number, string name, string descript /// </summary> private void InitOOP() { - solution = new SolutionOrganizer(); + solution = new SolutionRecorder(); savegame = new(); player_record = new PlayerRecord(record_name, this); } @@ -187,17 +187,17 @@ public void ClearAll() /// <summary> /// Resets <see cref="solution"/> and calling <see cref="solution.hardreset(bool)"/>. - /// <seealso cref="FactOrganizer.hardreset(bool)"/> + /// <seealso cref="FactRecorder.hardreset(bool)"/> /// </summary> public void ClearSolution() { solution.hardreset(false); - solution = new SolutionOrganizer(); + solution = new SolutionRecorder(); } /// <summary> /// Resets current <see cref="player_record"/> and calling <see cref="player_record.factState.hardreset(bool)"/>. - /// <seealso cref="FactOrganizer.hardreset(bool)"/> + /// <seealso cref="FactRecorder.hardreset(bool)"/> /// </summary> public void ClearPlay() { @@ -220,7 +220,7 @@ public void ClearALLRecords() /// <summary> /// <see cref="PlayerRecord.delete(List<Directories>)">Deletes</see> <paramref name="record"/> and calls <see cref="PlayerRecord.factState.hardreset()"/>. /// <seealso cref="PlayerRecord.delete(List<Directories>)"/> - /// <seealso cref="FactOrganizer.hardreset(bool)"/> + /// <seealso cref="FactRecorder.hardreset(bool)"/> /// </summary> /// <param name="record">to be deleted</param> /// <param name="b_store">iff <see langword="true"/> <see cref="store(bool)">stores</see> changes made to this <see cref="Stage"/></param> @@ -305,13 +305,13 @@ public void SetMode(bool create) hiddenState = factState; factState.Undraw(); - factState = solution as FactOrganizer; + factState = solution as FactRecorder; factState.invoke = true; factState.Draw(); } else { - solution = factState as SolutionOrganizer; + solution = factState as SolutionRecorder; factState.Undraw(); //solution.invoke = false; @@ -456,7 +456,7 @@ public void ResetSaves() /// <see cref="push_record(double, bool)">Pushes</see> current <see cref="player_record"/> to <see cref="player_record_list"/> and sets <see cref="PlayerRecord.solved"/> to <see langword="true"/>. /// </summary> /// <returns><see langword="true"/> iff current <see cref="player_record"/> is solved.</returns> - /// <seealso cref="FactOrganizer.DynamiclySolved(SolutionOrganizer, out List<List<string>>, out List<List<string>>)"/> + /// <seealso cref="FactRecorder.DynamiclySolved(SolutionRecorder, out List<List<string>>, out List<List<string>>)"/> public bool CheckSolved() { double time_s = Time.timeSinceLevelLoadAsDouble; @@ -528,7 +528,7 @@ public class PlayerRecord : IJSONsavable<PlayerRecord> /// <summary> Stage progress. </summary> [JSONsavable.JsonAutoPreProcess, JSONsavable.JsonAutoPostProcess] - public FactOrganizer factState = new(); + public FactRecorder factState = new(); /// <summary> save game file name </summary> public string name { get; set; } = null; public string path { get; set; } = null; @@ -552,7 +552,7 @@ public PlayerRecord() { } public PlayerRecord(string name, Stage mother) { this.name = name; - factState = new FactOrganizer(invoke: true); + factState = new FactRecorder(invoke: true); if (mother != null) CopyExposedSolutionFacts(mother); @@ -569,14 +569,14 @@ public PlayerRecord Clone() solved = this.solved, seconds = this.seconds }; - ret.factState = IJSONsavable<FactOrganizer>.postprocess(this.factState); + ret.factState = IJSONsavable<FactRecorder>.postprocess(this.factState); return ret; } /// <summary> /// Copies all elements from - /// <paramref name="mother"/><see cref="Stage.solution">.solution</see><see cref="SolutionOrganizer.ExposedSolutionFacts">.ExposedSolutionFacts</see> + /// <paramref name="mother"/><see cref="Stage.solution">.solution</see><see cref="SolutionRecorder.ExposedSolutionFacts">.ExposedSolutionFacts</see> /// to <see cref="factState"/> /// </summary> /// <param name="mother">copies from here</param> diff --git a/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs b/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs index b632bd3ceaf9b8473f7cb3ed7a221f970fd73fb4..61695802a6f93b2cde7a0971b153ba80d011a451 100644 --- a/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs +++ b/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs @@ -152,7 +152,7 @@ public static class MMTConstants { RealLit, typeof(float) }, { Tuple, - typeof(TupelFact) }, + typeof(TupleFact) }, { Product, typeof(Tuple) }, { TupelToVector, diff --git a/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs b/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs index 9fda495a940b369735ee65e5768799413c701afd..42cbbb68c27e63a8ae2f2ff57bade8705cdbe9f7 100644 --- a/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs +++ b/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs @@ -11,7 +11,6 @@ namespace REST_JSON_API { [JsonConverter(typeof(JsonSubtypes), "kind")] [JsonSubtypes.KnownSubType(typeof(OMA), "OMA")] - [JsonSubtypes.KnownSubType(typeof(OMBINDC), "OMBINDC")] [JsonSubtypes.KnownSubType(typeof(OMS), "OMS")] [JsonSubtypes.KnownSubType(typeof(OMSTR), "OMSTR")] [JsonSubtypes.KnownSubType(typeof(OMF), "OMF")] @@ -107,6 +106,16 @@ public LambdaExpression GetLambdaExpression() public abstract SOMDoc MapURIs(Dictionary<string, string> old_to_new); #region MakeMMT_OMS_URItoSOMDoc + public static Vector3 MakeVector3(OMA tuple) + { + if (tuple.arguments is not OMF[] xyz + || xyz.Length < 3) + throw new FormatException("Argument " + nameof(tuple) + "." + nameof(OMA.arguments) + + " expected to be: " + nameof(OMF) + "[3]"); + + return new Vector3(xyz[0].@float, xyz[1].@float, xyz[2].@float); + } + public static OMA MakeVector3(Vector3 vec) => new OMA( new OMS(MMTConstants.TupelToVector), @@ -296,62 +305,41 @@ protected internal override Type ToType(Type[] args) => SOMDocType().ToType(); } - public class OMBINDC : SOMDocCRTP<OMBINDC> + public class OMV : SOMDocCRTP<OMV> { - public new string kind = "OMBINDC"; + public new string kind = "VAR"; public string name; - public SOMDoc lambdabody; - - /// <summary>@Type of this variable</summary> - [JsonIgnore] - public Type type; - - /// <summary>Enables (especially <see cref="JsonConverter"/>) to read and set <see cref="type"/> by its <c>string</c> representation.</summary> - public string typeString - { - get => MMTConstants.TYPE_TO_OMS[type]; - set => type = MMTConstants.OMS_TO_TYPE[value]; - } - [JsonConstructor] - public OMBINDC(string name, string typeString, SOMDoc lambdabody) : base() + public OMV(string name) : base() { this.name = name; - this.typeString = typeString; - this.lambdabody = lambdabody; } protected internal override SOMDoc SOMDocType(SOMDoc[] args) => throw new NotImplementedException(); - public OMBINDC(string name, Type type, SOMDoc lambdabody) : base() - { - this.name = name; - this.type = type; - this.lambdabody = lambdabody; - } - - protected override bool EquivalentWrapped(OMBINDC sd2) - => this.type == sd2.type - && this.name.Equals(sd2.name) - && this.lambdabody.Equivalent(sd2.lambdabody); + protected override bool EquivalentWrapped(OMV sd2) + => this.name == sd2.name; protected internal override LambdaExpression GetLambdaExpression(LambdaExpression[] lambda_applicant, LambdaExpression[] lambda_arguments, ParameterExpression[] bound_params) { - ParameterExpression[] bind_me = bound_params.ShallowCloneAppend( - new[] { Expression.Parameter(type, name) } - ); - - return lambdabody.GetLambdaExpression(lambda_applicant, lambda_arguments, bind_me); + ParameterExpression v = bound_params.FirstOrDefault(param => param.Name.Equals(name)); + if (v == null) + { + Debug.LogErrorFormat("Unable to find {0} for {1} with name: {2}", nameof(FUN.Param), nameof(OMV), name); + return Expression.Lambda(Expression.Empty(), null); + } + else + return Expression.Lambda(v, new[] { v }); } public override string ToString() - => "OMBINDC(" + name + ", " + typeString + ")->"; + => "Variable_" + "(" + name + ")"; - protected override OMBINDC MapURIsWrapped(Dictionary<string, string> old_to_new) - => new(name, type, lambdabody.MapURIs(old_to_new)); + protected override OMV MapURIsWrapped(Dictionary<string, string> old_to_new) + => (OMV)this.MemberwiseClone(); protected internal override Type ToType(Type[] args) { @@ -416,7 +404,7 @@ public OMS(string uri) : base() protected internal override SOMDoc SOMDocType(SOMDoc[] args) { - if (FactOrganizer.AllFacts.TryGetValue(uri, out Fact found)) + if (FactRecorder.AllFacts.TryGetValue(uri, out Fact found)) return new OMS(MMTConstants.TYPE_TO_OMS[found.GetType()]); if (MMTConstants.HeterogenApplication_TO_TypeOF.TryGetValue(uri, out string type)) @@ -456,7 +444,7 @@ protected override OMS MapURIsWrapped(Dictionary<string, string> old_to_new) protected internal override Type ToType(Type[] args) { - if (FactOrganizer.AllFacts.TryGetValue(uri, out Fact found)) + if (FactRecorder.AllFacts.TryGetValue(uri, out Fact found)) return found.GetType(); if (MMTConstants.HeterogenApplication_TO_TypeOF.TryGetValue(uri, out string s_type)) @@ -550,120 +538,79 @@ protected internal override Type ToType(Type[] args) => typeof(float); } - public class OMC<T> : SOMDocCRTP<OMC<T>> + public class RAW : SOMDocCRTP<RAW> { - public new string kind = "OMC<" + typeof(T) + ">"; + public new string kind = "RAW"; - public T value; + public string xml; [JsonConstructor] - public OMC(T value) : base() + public RAW(string xml) : base() { - this.value = value; + this.xml = xml; } protected internal override SOMDoc SOMDocType(SOMDoc[] args) - => new OMS(MMTConstants.TYPE_TO_OMS[typeof(T)]); + => throw new NotImplementedException(); - protected override bool EquivalentWrapped(OMC<T> sd2) + protected override RAW MapURIsWrapped(Dictionary<string, string> old_to_new) { - Debug.LogWarning("Cannot check Equivalency for " + this.GetType() + "; only whether it's exact!"); - return this.value.Equals(value); - } - - protected internal override LambdaExpression GetLambdaExpression(LambdaExpression[] lambda_applicant, LambdaExpression[] lambda_arguments, ParameterExpression[] bound_params) - => Expression.Lambda(Expression.Constant(value, typeof(T)), null); - - public override string ToString() - => "C_" + typeof(T) + "(" + value.ToString() + ")"; - - protected override OMC<T> MapURIsWrapped(Dictionary<string, string> old_to_new) - => (OMC<T>)this.MemberwiseClone(); - - protected internal override Type ToType(Type[] args) - => typeof(T); - } - - public class OMV : SOMDocCRTP<OMV> - { - public new string kind = "VAR"; - - public string name; + string copy = xml; + foreach (KeyValuePair<string, string> KeyVal in old_to_new) + copy = copy.Replace(KeyVal.Key, KeyVal.Value); - [JsonConstructor] - public OMV(string name) : base() - { - this.name = name; + return new RAW(copy); } - protected internal override SOMDoc SOMDocType(SOMDoc[] args) - => throw new NotImplementedException(); + public override string ToString() + => xml; - protected override bool EquivalentWrapped(OMV sd2) - => this.name == sd2.name; + protected override bool EquivalentWrapped(RAW sd2) + => throw new NotImplementedException(); //xml == sd2.xml; // only exact protected internal override LambdaExpression GetLambdaExpression(LambdaExpression[] lambda_applicant, LambdaExpression[] lambda_arguments, ParameterExpression[] bound_params) { - ParameterExpression v = bound_params.FirstOrDefault(param => param.Name.Equals(name)); - if (v == null) - { - Debug.LogErrorFormat("Unable to find {0} for {1} with name: {2}", nameof(OMBINDC), nameof(OMV), name); - return Expression.Lambda(Expression.Empty(), null); - } - else - return Expression.Lambda(v, new[] { v }); + throw new NotImplementedException(); } - public override string ToString() - => "Variable_" + "(" + name + ")"; - - protected override OMV MapURIsWrapped(Dictionary<string, string> old_to_new) - => (OMV)this.MemberwiseClone(); - protected internal override Type ToType(Type[] args) { throw new NotImplementedException(); } } - public class RAW : SOMDocCRTP<RAW> + // internal use only + public class OMC<T> : SOMDocCRTP<OMC<T>> { - public new string kind = "RAW"; + public new string kind = "OMC<" + typeof(T) + ">"; - public string xml; + public T value; [JsonConstructor] - public RAW(string xml) : base() + public OMC(T value) : base() { - this.xml = xml; + this.value = value; } protected internal override SOMDoc SOMDocType(SOMDoc[] args) - => throw new NotImplementedException(); + => new OMS(MMTConstants.TYPE_TO_OMS[typeof(T)]); - protected override RAW MapURIsWrapped(Dictionary<string, string> old_to_new) + protected override bool EquivalentWrapped(OMC<T> sd2) { - string copy = xml; - foreach (KeyValuePair<string, string> KeyVal in old_to_new) - copy = copy.Replace(KeyVal.Key, KeyVal.Value); - - return new RAW(copy); + Debug.LogWarning("Cannot check Equivalency for " + this.GetType() + "; only whether it's exact!"); + return this.value.Equals(value); } - public override string ToString() - => xml; + protected internal override LambdaExpression GetLambdaExpression(LambdaExpression[] lambda_applicant, LambdaExpression[] lambda_arguments, ParameterExpression[] bound_params) + => Expression.Lambda(Expression.Constant(value, typeof(T)), null); - protected override bool EquivalentWrapped(RAW sd2) - => throw new NotImplementedException(); //xml == sd2.xml; // only exact + public override string ToString() + => "C_" + typeof(T) + "(" + value.ToString() + ")"; - protected internal override LambdaExpression GetLambdaExpression(LambdaExpression[] lambda_applicant, LambdaExpression[] lambda_arguments, ParameterExpression[] bound_params) - { - throw new NotImplementedException(); - } + protected override OMC<T> MapURIsWrapped(Dictionary<string, string> old_to_new) + => (OMC<T>)this.MemberwiseClone(); protected internal override Type ToType(Type[] args) - { - throw new NotImplementedException(); - } + => typeof(T); } } \ No newline at end of file diff --git a/Assets/Scripts/UI/FactExplorer/FactExplorer.cs b/Assets/Scripts/UI/FactExplorer/FactExplorer.cs index 34f39f3add6159f42246266e30fea5f99b7ddb3f..d023e9639348cc80fe7baf7eaef3afed5fd43b58 100644 --- a/Assets/Scripts/UI/FactExplorer/FactExplorer.cs +++ b/Assets/Scripts/UI/FactExplorer/FactExplorer.cs @@ -49,13 +49,13 @@ public void Initialize(Fact fact, Vector3 factPosition) private List<Fact> GetParentFacts() { StageStatic.stage.factState.safe_dependencies(MainFact.Id, out var parentFactIds); - return parentFactIds.Distinct().Select(factId => FactOrganizer.AllFacts[factId]).Where(f => f != MainFact).ToList(); + return parentFactIds.Distinct().Select(factId => FactRecorder.AllFacts[factId]).Where(f => f != MainFact).ToList(); } private List<Fact> GetChildFacts() => MainFact.DependentFactIds .Distinct() - .Select(factId => FactOrganizer.AllFacts[factId]) + .Select(factId => FactRecorder.AllFacts[factId]) .ToList(); private void UpdateFactExplorerUI()