diff --git a/Assets/Resources/Prefabs/Facts/Circle.prefab b/Assets/Resources/Prefabs/Facts/Circle.prefab index aece8bb6c2a5f424fafa2d6a9959d4ab6b9d99ab..dffff6e9f95c3a2115460120bdbfea00a77778b9 100644 --- a/Assets/Resources/Prefabs/Facts/Circle.prefab +++ b/Assets/Resources/Prefabs/Facts/Circle.prefab @@ -1,5 +1,187 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &3319392661904935552 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7541265271928914416} + - component: {fileID: 1312883106029576503} + - component: {fileID: 5284903402926663935} + - component: {fileID: 2574848627300415222} + m_Layer: 15 + m_Name: Mesh Down + m_TagString: SnapZone + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7541265271928914416 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3319392661904935552} + m_LocalRotation: {x: 1, y: 0, z: 0, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 0.01, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 6787775389045427190} + m_Father: {fileID: 3390467403729316765} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 180, y: 0, z: 0} +--- !u!33 &1312883106029576503 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3319392661904935552} + m_Mesh: {fileID: 0} +--- !u!23 &5284903402926663935 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3319392661904935552} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 8ae9adf4dc782964387385c1e8c0eb72, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!64 &2574848627300415222 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3319392661904935552} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 4 + m_Convex: 1 + m_CookingOptions: 30 + m_Mesh: {fileID: 0} +--- !u!1 &4682201382595328041 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6787775389045427190} + - component: {fileID: 6626359674163989219} + - component: {fileID: 4818731436791451552} + m_Layer: 15 + m_Name: CircleHighlight + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &6787775389045427190 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4682201382595328041} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.96, y: 1, z: 0.96} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7541265271928914416} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &6626359674163989219 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4682201382595328041} + m_Mesh: {fileID: 0} +--- !u!23 &4818731436791451552 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4682201382595328041} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 8ae9adf4dc782964387385c1e8c0eb72, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &5866155945383417828 GameObject: m_ObjectHideFlags: 0 @@ -11,7 +193,6 @@ GameObject: - component: {fileID: 8554957501859850914} - component: {fileID: 3164742056485930267} - component: {fileID: 1460740696286669547} - - component: {fileID: 6716233798214228857} m_Layer: 15 m_Name: CircleHighlight m_TagString: Untagged @@ -84,21 +265,6 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} ---- !u!114 &6716233798214228857 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5866155945383417828} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 405087c38b8537e43bcc99727c5325ec, type: 3} - m_Name: - m_EditorClassIdentifier: - radius: 1 - sideCount: 500 - circleMesh: {fileID: 3164742056485930267} --- !u!1 &6262947649539239553 GameObject: m_ObjectHideFlags: 0 @@ -110,11 +276,9 @@ GameObject: - component: {fileID: 142224692930156368} - component: {fileID: 7167210412035754299} - component: {fileID: 1078883255209641429} - - component: {fileID: 5602986836502461330} - - component: {fileID: 8419554499757686208} - component: {fileID: 8526453253978894086} m_Layer: 15 - m_Name: Mesh + m_Name: Mesh Up m_TagString: SnapZone m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -186,51 +350,6 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} ---- !u!114 &5602986836502461330 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6262947649539239553} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 626c435b76e0d334f959ede8b54b07ac, type: 3} - m_Name: - m_EditorClassIdentifier: - URI: - materials: - - {fileID: 2100000, guid: 8ae9adf4dc782964387385c1e8c0eb72, type: 2} - - {fileID: 2100000, guid: 34a95baef388bb8458c97a626b732f9f, type: 2} - - {fileID: 2100000, guid: 8621b710d7d1d5041bc6bfd0cc37cdff, type: 2} - - {fileID: 2100000, guid: 2a003f0807acc1142965bb21bdc824f6, type: 2} - renderer: - - {fileID: 1078883255209641429} - cascade: [] - Default: {fileID: 2100000, guid: 8ae9adf4dc782964387385c1e8c0eb72, type: 2} - Selected: {fileID: 2100000, guid: 34a95baef388bb8458c97a626b732f9f, type: 2} - Hint: {fileID: 2100000, guid: 8621b710d7d1d5041bc6bfd0cc37cdff, type: 2} - Solution: {fileID: 2100000, guid: 2a003f0807acc1142965bb21bdc824f6, type: 2} ---- !u!95 &8419554499757686208 -Animator: - serializedVersion: 4 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6262947649539239553} - m_Enabled: 1 - m_Avatar: {fileID: 0} - m_Controller: {fileID: 9100000, guid: 7f5a2c4324ecb83488857feb7887b5a7, type: 2} - m_CullingMode: 0 - m_UpdateMode: 0 - m_ApplyRootMotion: 0 - m_LinearVelocityBlending: 0 - m_StabilizeFeet: 0 - m_WarningMessage: - m_HasTransformHierarchy: 1 - m_AllowConstantClipSamplingOptimization: 1 - m_KeepAnimatorControllerStateOnDisable: 0 --- !u!64 &8526453253978894086 MeshCollider: m_ObjectHideFlags: 0 @@ -242,7 +361,7 @@ MeshCollider: m_IsTrigger: 0 m_Enabled: 1 serializedVersion: 4 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 0} --- !u!1 &6839596689016440457 @@ -255,6 +374,7 @@ GameObject: m_Component: - component: {fileID: 3390467403729316765} - component: {fileID: 1812690906255965161} + - component: {fileID: 6950663371922587874} m_Layer: 15 m_Name: Circle m_TagString: Selectable @@ -275,6 +395,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 142224692930156368} + - {fileID: 7541265271928914416} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -292,4 +413,33 @@ MonoBehaviour: m_EditorClassIdentifier: radius: 1 sideCount: 500 - circleMesh: {fileID: 7167210412035754299} + circleMesh: + - {fileID: 7167210412035754299} + - {fileID: 3164742056485930267} + - {fileID: 1312883106029576503} + - {fileID: 6626359674163989219} +--- !u!114 &6950663371922587874 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6839596689016440457} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 626c435b76e0d334f959ede8b54b07ac, type: 3} + m_Name: + m_EditorClassIdentifier: + URI: + materials: + - {fileID: 2100000, guid: 8ae9adf4dc782964387385c1e8c0eb72, type: 2} + - {fileID: 2100000, guid: 34a95baef388bb8458c97a626b732f9f, type: 2} + - {fileID: 2100000, guid: 8621b710d7d1d5041bc6bfd0cc37cdff, type: 2} + - {fileID: 2100000, guid: 2a003f0807acc1142965bb21bdc824f6, type: 2} + renderer: + - {fileID: 1078883255209641429} + cascade: [] + Default: {fileID: 2100000, guid: 8ae9adf4dc782964387385c1e8c0eb72, type: 2} + Selected: {fileID: 2100000, guid: 34a95baef388bb8458c97a626b732f9f, type: 2} + Hint: {fileID: 2100000, guid: 8621b710d7d1d5041bc6bfd0cc37cdff, type: 2} + Solution: {fileID: 2100000, guid: 2a003f0807acc1142965bb21bdc824f6, type: 2} diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactManager.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactManager.cs index 4c79495609d2d5eae21cfff7c0a4cef109050415..df998731fa91df4801aa37b4d286baeab158b1c8 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactManager.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactManager.cs @@ -19,11 +19,11 @@ public static class FactManager /// \copydetails FactManager public static Fact AddFactIfNotFound(Fact fact, out bool exists, bool samestep, Gadget gadget, string scroll_label) { - if (fact is AngleCircleLineFact) - return AddParsedAngleCircleLineFactIfNotFound((AngleCircleLineFact)fact, out exists, samestep, null, scroll_label); + if (fact is AngleCircleLineFact ACLFact) + return AddParsedAngleCircleLineFactIfNotFound(ACLFact, out exists, samestep, null, scroll_label); - else if (fact is AngleFact) - return AddParsedAngleFactIfNotFound((AngleFact)fact, out exists, samestep, null, scroll_label); + else if (fact is AngleFact AngleFact) + return AddParsedAngleFactIfNotFound(AngleFact, out exists, samestep, null, scroll_label); else return FactOrganizer.AllFacts[ diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs index 7dac82e5389dcbc38f0f022ca45d336810222088..624eee3e3ac27284c8e84d438e5a8280719d3045 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs @@ -61,7 +61,7 @@ protected IReadOnlyDictionary<string, Fact> MyFactSpace /// - <c>Key</c>: <see cref="Fact.Id"/> /// - <c>Value</c>: <see cref="Fact"/> /// </summary> - public static IReadOnlyDictionary<string, Fact> AllFacts { get => GlobalFactDictionary.Facts; } + public static IReadOnlyDictionary<string, Fact> AllFacts { get => GlobalFactDictionary.AllFacts; } /// <summary> /// - <c>Key</c>: <see cref="Fact.Id"/> @@ -324,7 +324,8 @@ public static T ReInitializeFactOrganizer<T>(T source, bool invoke, out Dictiona where T : FactOrganizer, new() { // TODO: other strategy needed when MMT save/load supported - bool source_initialized = source.MyFactSpace.Count > 0; + bool source_initialized = GlobalFactDictionary.AllFactSpaces.ContainsKey(source) + && source.MyFactSpace.Count > 0; Dictionary<string, string> _old_to_new = source_initialized ? source.MyFactSpace.Keys.ToDictionary(id => id) @@ -858,7 +859,8 @@ FactOrganizer IJSONsavable<FactOrganizer>._IJPostProcess(FactOrganizer raw_paylo FactOrganizer IJSONsavable<FactOrganizer>._IJPreProcess(FactOrganizer payload) { - payload.JsonFactSpace = payload.MyFactSpace; + if (GlobalFactDictionary.AllFactSpaces.ContainsKey(payload) && payload.MyFactSpace.Count > 0) + payload.JsonFactSpace = payload.MyFactSpace; return payload; } @@ -1004,13 +1006,12 @@ protected static class GlobalFactDictionary /// - <c>Value</c>: <see cref="Fact"/> /// </summary> private static readonly Dictionary<string, Fact> FactDict = new(); - - public static IReadOnlyDictionary<string, Fact> Facts { get => FactDict; } + public static IReadOnlyDictionary<string, Fact> AllFacts { get => FactDict; } 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; public static IReadOnlyDictionary<string, Fact> MyFactSpace(FactOrganizer me) => FactSpaces[me]; diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs index e5d6616a396103318965bf3206ea15229e0de347..d4cda826c22fad49f58a9189ca6da819bb679e77 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs @@ -57,8 +57,7 @@ public void SpawnAttachedPositionFunction(AttachedPositionFunction fact) public void SpawnPoint(PointFact fact) { GameObject point = GameObject.Instantiate(Sphere); - point.transform.position = fact.Position; - point.transform.rotation = fact.Rotation; + point.transform.SetPositionAndRotation(fact.Position, fact.Rotation); point.GetComponentInChildren<TextMeshPro>().text = fact.Label; point.GetComponent<FactObject>().URI = fact.Id; fact.Representation = point; @@ -138,7 +137,7 @@ public void SpawnRingAndCircle(CircleFact fact) SpawnCircle(fact, ringAndCircleGO.transform); //Move Ring to middlePoint - ringAndCircleGO.transform.position = fact.Position; + ringAndCircleGO.transform.SetPositionAndRotation(fact.Position, fact.Rotation); fact.Representation = ringAndCircleGO; } @@ -162,12 +161,9 @@ public void SpawnRing(CircleFact circleFact, Transform parent = null) public void SpawnCircle(CircleFact circleFact, Transform parent = null) { GameObject circle = Instantiate(Circle, parent); - var FactObj = circle.GetComponentInChildren<FactObject>(); - + circle.GetComponent<FactObject>().URI = circleFact.Id; //Set radius circle.transform.localScale = Vector3.Scale(circle.transform.localScale, circleFact.LocalScale); - - FactObj.URI = circleFact.Id; } diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractAngleFact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractAngleFact.cs index 63605802ad0a97b557a0297134681f80ef708afc..6a0b2d498b950f806a3c848f1eebbd60171a7e7a 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractAngleFact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractAngleFact.cs @@ -167,10 +167,10 @@ protected override MMTDeclaration MakeMMTDeclaration() return new MMTValueDeclaration(this.Label, lhs, valueTp, value); } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static AngleFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static AngleFact parseFact(MMTDeclaration fact) { - if (fact is not Scroll.ScrollValueFact value_fact) //If angle is a 90Degree-Angle + if (fact is not MMTValueDeclaration value_fact) //If angle is a 90Degree-Angle throw new ArgumentException("Angle 90 degrees parsed. This shouldn't happen anymore"); if (value_fact.lhs is not OMA df) @@ -271,10 +271,10 @@ protected override MMTDeclaration MakeMMTDeclaration() return new MMTSymbolDeclaration(this.Label, tp, df); } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static RightAngleFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static RightAngleFact parseFact(MMTDeclaration fact) { - if (((Scroll.ScrollSymbolFact)fact).tp + if (((MMTSymbolDeclaration)fact).tp is not OMA proof_OMA // proof DED || proof_OMA.arguments[0] is not OMA rightAngleOMA // rightAngle OMA diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractLineFact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractLineFact.cs index ca74ddcf031158c4d643bee3e74504fa2de7b2a2..ce0d25743d2260ae4db217f8f457275d89e78730 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractLineFact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/AbstractLineFact.cs @@ -156,12 +156,12 @@ protected override MMTDeclaration MakeMMTDeclaration() return new MMTValueDeclaration(this.Label, lhs, valueTp, value); } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static LineFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static LineFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; - string pointAUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri; - string pointBUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[1]).uri; + string pointAUri = ((OMS)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).uri; + string pointBUri = ((OMS)((OMA)((MMTValueDeclaration)fact).lhs).arguments[1]).uri; if (StageStatic.stage.factState.ContainsKey(pointAUri) && StageStatic.stage.factState.ContainsKey(pointBUri)) @@ -225,7 +225,6 @@ protected override MMTDeclaration MakeMMTDeclaration() new OMS(Pid2) }); - ParsingDictionary.parseTermsToId[df.ToString()] = this._URI; return new MMTSymbolDeclaration(this.Label, tp, df); } @@ -235,16 +234,16 @@ protected override void RecalculateTransform() LocalScale = new Vector3(1, 1, 2048); } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static RayFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static RayFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; - if ((OMA)((Scroll.ScrollSymbolFact)fact).df == null) + if ((OMA)((MMTSymbolDeclaration)fact).df == null) return null; - string pointAUri = ((OMS)((OMA)((Scroll.ScrollSymbolFact)fact).df).arguments[0]).uri; - string pointBUri = ((OMS)((OMA)((Scroll.ScrollSymbolFact)fact).df).arguments[1]).uri; + string pointAUri = ((OMS)((OMA)((MMTSymbolDeclaration)fact).df).arguments[0]).uri; + string pointBUri = ((OMS)((OMA)((MMTSymbolDeclaration)fact).df).arguments[1]).uri; if (StageStatic.stage.factState.ContainsKey(pointAUri) && StageStatic.stage.factState.ContainsKey(pointBUri)) diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs index dd896a0af985f68547c4c35af6d4735df6ceff9a..cc89cea2220f5644c723b4b420f4dd8a2789679b 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs @@ -15,8 +15,8 @@ public class ParsingDictionary //TODO? get rid of this, use reflection? instead, if possible //TODO: docu - //public static Dictionary<string, Func<Scroll.ScrollFact, Fact>> parseFactDictionary = new Dictionary<string, Func<Scroll.ScrollFact, Fact>>() { - public static Dictionary<string, Func<Scroll.ScrollFact, Fact>> parseFactDictionary = new() { + //public static Dictionary<string, Func<ScrollFact, Fact>> parseFactDictionary = new Dictionary<string, Func<ScrollFact, Fact>>() { + public static Dictionary<string, Func<MMTDeclaration, Fact>> parseFactDictionary = new() { {SOMDocManager.MMT_OMS_URI.Point, PointFact.parseFact}, {SOMDocManager.MMT_OMS_URI.Metric, LineFact.parseFact}, {SOMDocManager.MMT_OMS_URI.Angle, AngleFact.parseFact}, @@ -58,7 +58,11 @@ public class AddFactResponse public static bool sendAdd(MMTDeclaration mmtDecl, out string uri) { string body = MMTSymbolDeclaration.ToJson(mmtDecl); - return sendAdd(CommunicationEvents.ServerAdress + "/fact/add", body, out uri); + bool success = sendAdd(CommunicationEvents.ServerAdress + "/fact/add", body, out uri); + + if (mmtDecl is MMTSymbolDeclaration mMTSymbol && mMTSymbol.df != null) + ParsingDictionary.parseTermsToId[mMTSymbol.df.ToString()] = uri; + return success; } public static bool sendAdd(string path, string body, out string uri) @@ -432,11 +436,11 @@ protected virtual string generateLabel() } /// <summary> - /// Parses <see cref="Scroll.ScrollFact"/> to actual Fact + /// Parses <see cref="MMTDeclaration"/> to actual Fact /// </summary> /// <param name="fact">instance to be parsed</param> /// <returns>parsed Fact</returns> - public static Fact parseFact(Scroll.ScrollFact fact) + public static Fact parseFact(MMTDeclaration fact) => null; /// <summary> @@ -559,10 +563,10 @@ public PointFact(float a, float b, float c, string uri, FactOrganizer organizer) _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static PointFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static PointFact parseFact(MMTDeclaration fact) { - if (((Scroll.ScrollSymbolFact)fact).df is not OMA df) + if (((MMTSymbolDeclaration)fact).df is not OMA df) return null; string parse_id = df.ToString(); @@ -616,7 +620,6 @@ protected override MMTDeclaration MakeMMTDeclaration() } ); - ParsingDictionary.parseTermsToId[df.ToString()] = _URI; return new MMTSymbolDeclaration(Label, tp, df); } } @@ -693,17 +696,17 @@ public OnLineFact(string pid, string rid, string uri, FactOrganizer organizer) : _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static OnLineFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static OnLineFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; - string pointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri; - string lineUri = ((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0] is OMS + string pointUri = ((OMS)((OMA)((OMA)((MMTSymbolDeclaration)fact).tp).arguments[0]).arguments[1]).uri; + string lineUri = ((OMA)((OMA)((MMTSymbolDeclaration)fact).tp).arguments[0]).arguments[0] is OMS // standard case - ? ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri + ? ((OMS)((OMA)((OMA)((MMTSymbolDeclaration)fact).tp).arguments[0]).arguments[0]).uri // case when line Uri has a projl on the line Argument - : ((OMS)((OMA)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).arguments[0]).uri; + : ((OMS)((OMA)((OMA)((OMA)((MMTSymbolDeclaration)fact).tp).arguments[0]).arguments[0]).arguments[0]).uri; if (StageStatic.stage.factState.ContainsKey(pointUri) && StageStatic.stage.factState.ContainsKey(lineUri)) @@ -815,10 +818,10 @@ public ParallelLineFact(string Lid1, string Lid2, string backendURI, FactOrganiz _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static ParallelLineFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static ParallelLineFact parseFact(MMTDeclaration fact) { - OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp; + OMA tp = (OMA)((MMTSymbolDeclaration)fact).tp; if (tp == null) return null; @@ -828,7 +831,7 @@ public ParallelLineFact(string Lid1, string Lid2, string backendURI, FactOrganiz string lineAUri; string lineBUri; - OMA proof_OMA = (OMA)((Scroll.ScrollSymbolFact)fact).tp; // proof DED + OMA proof_OMA = (OMA)((MMTSymbolDeclaration)fact).tp; // proof DED OMA parallel_lines_OMA = (OMA)proof_OMA.arguments[0]; // parallel if (parallel_lines_OMA.arguments[0] is OMS) @@ -958,7 +961,12 @@ public CircleFact(string pid1, string pid2, float radius, Vector3 normal, FactOr protected override void RecalculateTransform() { Position = Point1.Position; - Rotation = Quaternion.LookRotation(normal); + { //Rotation + Vector3 arbitary_not_normal = normal == Vector3.forward ? Vector3.right : Vector3.forward; + Vector3 forwoard = Vector3.Cross(arbitary_not_normal, normal); + + Rotation = Quaternion.LookRotation(forwoard, normal); + } LocalScale = new Vector3(radius, 1, radius); } @@ -986,16 +994,16 @@ public CircleFact(string Pid1, string Pid2, float radius, Vector3 normal, string /// <summary> /// parses the Circlefact response of the MMT-Server /// </summary> - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static CircleFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static CircleFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; - OMA df = (OMA)((Scroll.ScrollSymbolFact)fact).df; + OMA df = (OMA)((MMTSymbolDeclaration)fact).df; if (df == null) return null; - Scroll.ScrollSymbolFact scoll_symbol_fact = (Scroll.ScrollSymbolFact)fact; + MMTSymbolDeclaration scoll_symbol_fact = (MMTSymbolDeclaration)fact; // get the radius float radius = ((OMF)((OMA)scoll_symbol_fact.df).arguments[2]).f; @@ -1181,17 +1189,17 @@ public OnCircleFact(string pid, string cid, string uri, FactOrganizer organizer) _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static OnCircleFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static OnCircleFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; - OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp; + OMA tp = (OMA)((MMTSymbolDeclaration)fact).tp; if (tp == null) return null; - string circleUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri; - string pointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri; + string circleUri = ((OMS)((OMA)((OMA)((MMTSymbolDeclaration)fact).tp).arguments[0]).arguments[0]).uri; + string pointUri = ((OMS)((OMA)((OMA)((MMTSymbolDeclaration)fact).tp).arguments[0]).arguments[1]).uri; if (StageStatic.stage.factState.ContainsKey(pointUri) && StageStatic.stage.factState.ContainsKey(circleUri)) @@ -1343,15 +1351,15 @@ public AngleCircleLineFact(string Cid1, string Rid2, float angle, string backend _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static AngleCircleLineFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static AngleCircleLineFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; string CircleUri, RayUri; - OMA df = (OMA)((Scroll.ScrollValueFact)fact).lhs; + OMA df = (OMA)((MMTValueDeclaration)fact).lhs; if (df == null) return null; @@ -1359,12 +1367,12 @@ public AngleCircleLineFact(string Cid1, string Rid2, float angle, string backend // and the parsing works correctly if smb ever adds a scroll for this float angle = 0.0f; - if ((((Scroll.ScrollValueFact)fact).value) != null) - angle = ((OMF)(((Scroll.ScrollValueFact)fact).value)).f; + if ((((MMTValueDeclaration)fact).value) != null) + angle = ((OMF)(((MMTValueDeclaration)fact).value)).f; - CircleUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri; - RayUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[1]).uri; + CircleUri = ((OMS)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).uri; + RayUri = ((OMS)((OMA)((MMTValueDeclaration)fact).lhs).arguments[1]).uri; if (StageStatic.stage.factState.ContainsKey(CircleUri) && StageStatic.stage.factState.ContainsKey(RayUri)) @@ -1476,11 +1484,11 @@ public RadiusFact(string Cid1, string backendURI, FactOrganizer organizer) : bas _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static RadiusFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static RadiusFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; - string CircleUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri; + string CircleUri = ((OMS)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).uri; if (StageStatic.stage.factState.ContainsKey(CircleUri)) @@ -1599,11 +1607,11 @@ public AreaCircleFact(string Cid1, string backendURI, FactOrganizer organizer) : _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static AreaCircleFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static AreaCircleFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; - string CircleUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri; + string CircleUri = ((OMS)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).uri; if (StageStatic.stage.factState.ContainsKey(CircleUri)) return new AreaCircleFact(CircleUri, uri, StageStatic.stage.factState); @@ -1729,19 +1737,19 @@ public ConeVolumeFact(string Cid1, string Pid1, float volume, string backendURI, _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static ConeVolumeFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static ConeVolumeFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; - if (((Scroll.ScrollValueFact)fact).lhs == null) + if (((MMTValueDeclaration)fact).lhs == null) return null; - string CircleUri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[0]).uri; - string PointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[1]).uri; + string CircleUri = ((OMS)((OMA)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).arguments[0]).uri; + string PointUri = ((OMS)((OMA)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).arguments[1]).uri; float volume = 0.0f; - if ((((Scroll.ScrollValueFact)fact).value) != null) - volume = ((OMF)((Scroll.ScrollValueFact)fact).value).f; + if ((((MMTValueDeclaration)fact).value) != null) + volume = ((OMF)((MMTValueDeclaration)fact).value).f; if (StageStatic.stage.factState.ContainsKey(CircleUri) && StageStatic.stage.factState.ContainsKey(PointUri)) @@ -1883,17 +1891,17 @@ public OrthogonalCircleLineFact(string Cid1, string Lid1, string backendURI, Fac _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static OrthogonalCircleLineFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static OrthogonalCircleLineFact parseFact(MMTDeclaration fact) { - OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp; + OMA tp = (OMA)((MMTSymbolDeclaration)fact).tp; if (tp == null) return null; string uri = fact.@ref.uri; - string CircleUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri; - string LineUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri; + string CircleUri = ((OMS)((OMA)((OMA)((MMTSymbolDeclaration)fact).tp).arguments[0]).arguments[0]).uri; + string LineUri = ((OMS)((OMA)((OMA)((MMTSymbolDeclaration)fact).tp).arguments[0]).arguments[1]).uri; if (StageStatic.stage.factState.ContainsKey(CircleUri) && StageStatic.stage.factState.ContainsKey(LineUri)) @@ -2041,17 +2049,17 @@ public TruncatedConeVolumeFact(string Cid1, string Cid2, float volume, string un _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static TruncatedConeVolumeFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static TruncatedConeVolumeFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; - string Circle1Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[0]).uri; - string Circle2Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[1]).uri; - float volume = ((OMF)((Scroll.ScrollValueFact)fact).value).f; + string Circle1Uri = ((OMS)((OMA)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).arguments[0]).uri; + string Circle2Uri = ((OMS)((OMA)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).arguments[1]).uri; + float volume = ((OMF)((MMTValueDeclaration)fact).value).f; - string UnEqualCirclesProof = ((OMS)(((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[2])).uri; - OMA proof = (OMA)(((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[3]); + string UnEqualCirclesProof = ((OMS)(((OMA)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).arguments[2])).uri; + OMA proof = (OMA)(((OMA)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).arguments[3]); if (StageStatic.stage.factState.ContainsKey(Circle1Uri) && StageStatic.stage.factState.ContainsKey(Circle2Uri)) @@ -2192,17 +2200,17 @@ public CylinderVolumeFact(string Cid1, string Cid2, float volume, string eqProof _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static CylinderVolumeFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static CylinderVolumeFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; - string Circle1Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[0]).uri; - string Circle2Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[1]).uri; - float volume = ((OMF)((Scroll.ScrollValueFact)fact).value).f; - string EqualCirclesProof = ((OMS)(((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[2])).uri; + string Circle1Uri = ((OMS)((OMA)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).arguments[0]).uri; + string Circle2Uri = ((OMS)((OMA)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).arguments[1]).uri; + float volume = ((OMF)((MMTValueDeclaration)fact).value).f; + string EqualCirclesProof = ((OMS)(((OMA)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).arguments[2])).uri; - OMA proof = (OMA)(((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[3]); + OMA proof = (OMA)(((OMA)((OMA)((MMTValueDeclaration)fact).lhs).arguments[0]).arguments[3]); if (StageStatic.stage.factState.ContainsKey(Circle1Uri) && StageStatic.stage.factState.ContainsKey(Circle2Uri)) @@ -2323,10 +2331,10 @@ public EqualCirclesFact(string Cid1, string Cid2, string backendURI, FactOrganiz _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static EqualCirclesFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static EqualCirclesFact parseFact(MMTDeclaration fact) { - OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp; + OMA tp = (OMA)((MMTSymbolDeclaration)fact).tp; if (tp == null) return null; @@ -2334,15 +2342,15 @@ public EqualCirclesFact(string Cid1, string Cid2, string backendURI, FactOrganiz string circleBUri = ""; string uri = fact.@ref.uri; - OMA proof_OMA = (OMA)((Scroll.ScrollSymbolFact)fact).tp; // proof DED + OMA proof_OMA = (OMA)((MMTSymbolDeclaration)fact).tp; // proof DED OMA parallel_circles_OMA = (OMA)proof_OMA.arguments[0]; // parallel if (parallel_circles_OMA.arguments[0] is OMS) { // Normaler Fall - circleAUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri; - circleBUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri; + circleAUri = ((OMS)((OMA)((OMA)((MMTSymbolDeclaration)fact).tp).arguments[0]).arguments[0]).uri; + circleBUri = ((OMS)((OMA)((OMA)((MMTSymbolDeclaration)fact).tp).arguments[0]).arguments[1]).uri; } if (StageStatic.stage.factState.ContainsKey(circleAUri) @@ -2465,10 +2473,10 @@ public UnEqualCirclesFact(string Cid1, string Cid2, string backendURI, FactOrgan _ = this.Label; } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static UnEqualCirclesFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static UnEqualCirclesFact parseFact(MMTDeclaration fact) { - if (((Scroll.ScrollSymbolFact)fact).tp is not OMA proof_OMA) // proof DED + if (((MMTSymbolDeclaration)fact).tp is not OMA proof_OMA) // proof DED return null; OMA unequal_circles_OMA = (OMA)proof_OMA.arguments[0]; // unequal @@ -2589,8 +2597,8 @@ public TestFact(string backendURI, FactOrganizer organizer) : base(organizer) /// <summary> /// parses the Circlefact response of the MMT-Server /// </summary> - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static TestFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static TestFact parseFact(MMTDeclaration fact) { string uri = fact.@ref.uri; Debug.Log("TestFact Uri:" + uri); diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs index 793d2d8c08cf932049bf72b98e745ff2add89227..eb42065ea132484e4abf45567a0ac7fd74bfa9cd 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs @@ -5,7 +5,6 @@ using static SOMDocManager; using System.Linq.Expressions; using System.Linq; -using Characters.FirstPerson; public class FunctionCallFact : FactWrappedCRTP<FunctionCallFact> { @@ -148,11 +147,11 @@ public FunctionFact(SOMDoc Function_SOMDoc, string uri, FactOrganizer organizer) protected override void RecalculateTransform() { } - /// \copydoc Fact.parseFact(Scroll.ScrollFact) - public new static FunctionFact parseFact(Scroll.ScrollFact fact) + /// \copydoc Fact.parseFact(ScrollFact) + public new static FunctionFact parseFact(MMTDeclaration fact) {// TODO Correctness string uri = fact.@ref.uri; - OMA df = (OMA)((Scroll.ScrollSymbolFact)fact).df; + OMA df = (OMA)((MMTSymbolDeclaration)fact).df; if (df == null) return null; @@ -239,10 +238,10 @@ protected AttachedPositionFunction(string fid, string[] funcids, string uri, Fac _URI = uri; } - public new static AttachedPositionFunction parseFact(Scroll.ScrollFact fact) + public new static AttachedPositionFunction parseFact(MMTDeclaration fact) {// TODO Correctness string uri = fact.@ref.uri; - OMA df = (OMA)((Scroll.ScrollSymbolFact)fact).df; + OMA df = (OMA)((MMTSymbolDeclaration)fact).df; if (df == null) return null; diff --git a/Assets/Scripts/InteractionEngine/TBD/CanonBallCalculator.cs b/Assets/Scripts/InteractionEngine/TBD/CanonBallCalculator.cs index 7b2ee96a785759edd9dc2cc7876c6ac8570a6a17..0110a1dc9cdfc45df80b8b687607e6d8ac6199ae 100644 --- a/Assets/Scripts/InteractionEngine/TBD/CanonBallCalculator.cs +++ b/Assets/Scripts/InteractionEngine/TBD/CanonBallCalculator.cs @@ -102,7 +102,7 @@ SOMDoc BuildOMAPath(Vector3 Pos, Vector3 Vel) //Pos = Pos + Vel * t + 0.5 * g * t**2 Vector3 UpdatePos(Vector3 Pos, Vector3 Vel, float t) - => Pos + Vel * t + Gravity * 0.5f * t * t; + => Pos + Vel * t + 0.5f * t * t * Gravity; //Vel = Vel + g * t Vector3 UpdateVel(Vector3 Vel, float t) diff --git a/Assets/Scripts/InteractionEngine/WorldCursor.cs b/Assets/Scripts/InteractionEngine/WorldCursor.cs index d5ef2abb6df31730297d31d2c2fa31682f076be3..53b7b88396119741bdb85045869313d7018a0d9e 100644 --- a/Assets/Scripts/InteractionEngine/WorldCursor.cs +++ b/Assets/Scripts/InteractionEngine/WorldCursor.cs @@ -107,10 +107,7 @@ void Update() } - RaycastHit buffer = multipleHits[minIdx]; - multipleHits[minIdx] = multipleHits[i]; - multipleHits[i] = buffer; - + (multipleHits[i], multipleHits[minIdx]) = (multipleHits[minIdx], multipleHits[i]); } @@ -140,60 +137,37 @@ void Update() #region Ring var id = multipleHits[i].transform.GetComponent<FactObject>().URI; CircleFact circleFact = FactOrganizer.AllFacts[id] as CircleFact; - Vector3 middlePoint = ((PointFact)FactOrganizer.AllFacts[circleFact.Pid1]).Point; - Vector3 edgePoint = ((PointFact)FactOrganizer.AllFacts[circleFact.Pid2]).Point; - var normal = circleFact.normal; - var radius = circleFact.radius; + Vector3 middlePoint = circleFact.Point1.Point; // project p on circlePlane - var q = multipleHits[i].point - middlePoint; - var dist = Vector3.Dot(q, normal); - var pPlane = multipleHits[i].point - (normal * dist); // p on circlePlane + var pPlane = + Math3d.ProjectPointOnPlane(circleFact.normal, circleFact.Point1.Point, multipleHits[i].point); // check if projectedPoint and circleCenter are identical - // should never happen in practice due to floating point precision if (pPlane == middlePoint) - { - // can be set to any point on the ring -> set to edgePoint - multipleHits[i].point = edgePoint; - return; - - } - else - { - var direction = (pPlane - middlePoint).normalized; - multipleHits[i].point = middlePoint + direction * radius; - } + pPlane = circleFact.Point2.Point; + multipleHits[i].point = middlePoint + (pPlane - middlePoint).normalized * circleFact.radius; // cursor orientation should match circle orientation; dont face downwards - if (normal.y < 0) // if normal faces downwards use inverted normal instead - multipleHits[i].normal = -normal; - else - multipleHits[i].normal = normal; + multipleHits[i].normal = circleFact.normal.y < 0 + ? -circleFact.normal + : circleFact.normal; #endregion Ring } else if (multipleHits[i].collider.gameObject.layer == LayerMask.NameToLayer("Circle")) { #region Circle - var id = multipleHits[i].transform.GetComponent<FactObject>().URI; + var id = multipleHits[i].transform.parent.GetComponent<FactObject>().URI; CircleFact circleFact = FactOrganizer.AllFacts[id] as CircleFact; - Vector3 middlePoint = ((PointFact)FactOrganizer.AllFacts[circleFact.Pid1]).Point; - Vector3 edgePoint = ((PointFact)FactOrganizer.AllFacts[circleFact.Pid2]).Point; - var normal = circleFact.normal; - var radius = circleFact.radius; - // project p on circlePlane - var q = multipleHits[i].point - middlePoint; - var dist = Vector3.Dot(q, normal); - var pPlane = multipleHits[i].point - (normal * dist); // p on circlePlane - multipleHits[i].point = pPlane; + multipleHits[i].point = + Math3d.ProjectPointOnPlane(circleFact.normal, circleFact.Point1.Point, multipleHits[i].point); // cursor orientation should match circle orientation; dont face downwards - if (normal.y < 0) // if normal faces downwards use inverted normal instead - multipleHits[i].normal = -normal; - else - multipleHits[i].normal = normal; + multipleHits[i].normal = circleFact.normal.y < 0 + ? -circleFact.normal + : circleFact.normal; #endregion Circle } else @@ -209,7 +183,7 @@ void Update() continue; // we probably have two objects intersecting - + // check for line x line intersection and if they actually intersect adjust the points coordinates :) if (multipleHits[i].collider.gameObject.layer == LayerMask.NameToLayer("Ray") && multipleHits[0].collider.gameObject.layer == LayerMask.NameToLayer("Ray")) @@ -234,7 +208,7 @@ void Update() //TODO: check for other types of intersection. Future Work } - transform.up = multipleHits[0].normal ; + transform.up = multipleHits[0].normal; //TODO check whether this is needed //if (!((multipleHits[0].collider.transform.CompareTag("SnapZone") || multipleHits[0].collider.transform.CompareTag("Selectable")) // && !Input.GetButton(this.deactivateSnapKey))) @@ -250,7 +224,6 @@ void Update() } - void updateMaxRange() { switch (UIconfig.GameplayMode) @@ -280,10 +253,6 @@ void updateMaxRange() } - - - - //Check if left Mouse-Button was pressed and handle it void CheckMouseButtons() { @@ -300,7 +269,7 @@ void CheckMouseButtons1(bool OnSnap = false, bool onLine = false) //TODO edit for the multiple hits. Right now it only checks the first hit if (Input.GetMouseButtonDown(0) && checkClickPermission()) - { + { //other Things todo first? if (Hit.collider.transform.CompareTag("NPC1_text") && UIconfig.nextDialogPlease < 2) diff --git a/Assets/Scripts/InventoryStuff/Scroll.cs b/Assets/Scripts/InventoryStuff/Scroll.cs index d7bb24d35c8308e0bd87d3d48e336fce419a6299..f1336a6e295d57fdb30acb5a99a95de40294ab92 100644 --- a/Assets/Scripts/InventoryStuff/Scroll.cs +++ b/Assets/Scripts/InventoryStuff/Scroll.cs @@ -1,6 +1,4 @@ -using JsonSubTypes; -using Newtonsoft.Json; -using System; +using Newtonsoft.Json; using System.Collections.Generic; using static SOMDocManager; @@ -10,8 +8,8 @@ public class Scroll public string @ref; public string label; public string description; - public List<ScrollFact> requiredFacts; - public List<ScrollFact> acquiredFacts; + public List<MMTDeclaration> requiredFacts; + public List<MMTDeclaration> acquiredFacts; public class FilledScroll { @@ -31,20 +29,6 @@ public class ScrollTheoryReference public string solutionTheory; } - [JsonConverter(typeof(JsonSubtypes), "kind")] - [JsonSubtypes.KnownSubType(typeof(ScrollSymbolFact), "general")] - [JsonSubtypes.KnownSubType(typeof(ScrollValueFact), "veq")] - public abstract class ScrollFact - { - public string kind; - public UriReference @ref; - public string label; - - public abstract String getType(); - - public abstract String getApplicant(); - } - public class UriReference { public string uri; @@ -55,91 +39,40 @@ public UriReference(string uri) } } - /** - * Class used for deserializing incoming symbol-declarations from mmt - */ - public class ScrollSymbolFact : ScrollFact + public class ScrollAssignment { - public SOMDoc tp; - public SOMDoc df; - - public override String getType() - { - return tp switch - { - OMS oMS => oMS.uri, - OMA oMA => ((oMA.arguments[0] as OMA).applicant as OMS).uri, - _ => null - }; - } - - public override String getApplicant() - { - //Debug.Log(" Check " + this.tp is OMS + " and " + this.tp is OMA + " and " + this.tp is OMSTR + " or " + this.tp is OMF); - // return ((OMS)((OMA)((OMA)this.tp).arguments[0]).arguments[0]).uri; - return df switch - { - OMA oMA when oMA.applicant is OMS oMS => oMS.uri, - _ => null // ((OMS)((OMA)((OMA)this.df).arguments[0]).applicant).uri; - }; - } - } + public UriReference fact; + public OMS assignment; - /** - * Class used for deserializing incoming value-declarations from mmt - */ - public class ScrollValueFact : ScrollFact - { - public SOMDoc lhs; - public SOMDoc valueTp; - public SOMDoc value; - public SOMDoc proof; + [JsonConstructor] + private ScrollAssignment() { } - public override String getType() + public ScrollAssignment(string fact_id, string assignment_id) { - return lhs switch - { - OMA oMA when oMA.applicant is OMS oMS => oMS.uri, - _ => null - }; + this.fact = new UriReference(fact_id); + this.assignment = new OMS(assignment_id); } - public override String getApplicant() - { - // TODO Test this - return lhs switch - { - OMA oMA when oMA.applicant is OMS oMS => oMS.uri, - _ => null - }; - } - - } - - public class ScrollAssignment - { - public UriReference fact; - public OMS assignment; } public class ScrollApplicationInfo { - public Boolean valid; + public bool valid; public ScrollApplicationCheckingError[] errors; - public List<Scroll.ScrollFact> acquiredFacts; + public List<MMTDeclaration> acquiredFacts; } public class ScrollDynamicInfo { public Scroll original; public Scroll rendered; - public List<List<Scroll.ScrollAssignment>> completions; - public Boolean valid; + public List<List<ScrollAssignment>> completions; + public bool valid; public ScrollApplicationCheckingError[] errors; } public class ScrollApplicationCheckingError { - public String kind; + public string kind; public string msg; public SOMDoc fact; } diff --git a/Assets/Scripts/InventoryStuff/ScrollDetails.cs b/Assets/Scripts/InventoryStuff/ScrollDetails.cs index 563ea19856e354abdb89df6ec3147488c3def8ab..132824add148476934b8e6f8e51d9d4fabd72b2d 100644 --- a/Assets/Scripts/InventoryStuff/ScrollDetails.cs +++ b/Assets/Scripts/InventoryStuff/ScrollDetails.cs @@ -5,6 +5,8 @@ using UnityEngine.Networking; using Newtonsoft.Json; using static CommunicationEvents; +using System.Linq; +using static SOMDocManager; public class ScrollDetails : MonoBehaviour { @@ -25,13 +27,23 @@ public class ScrollDetails : MonoBehaviour // Start is called before the first frame update void Start() { - if (cursor == null) cursor = GameObject.FindObjectOfType<WorldCursor>(); + cursor ??= GameObject.FindObjectOfType<WorldCursor>(); + + mmtAnswerPopUp.GetComponent<PopupBehavior>().hidePopUp(); + } + private void OnEnable() + { ScrollFactHintEvent.AddListener(animateHint); NewAssignmentEvent.AddListener(newAssignmentTrigger); RemoveFactEvent.AddListener(removeFactFromAssignment); + } - mmtAnswerPopUp.GetComponent<PopupBehavior>().hidePopUp(); + private void OnDisable() + { + ScrollFactHintEvent.RemoveListener(animateHint); + NewAssignmentEvent.RemoveListener(newAssignmentTrigger); + RemoveFactEvent.RemoveListener(removeFactFromAssignment); } public void setScroll(Scroll s) @@ -44,9 +56,7 @@ public void setScroll(Scroll s) originalScroll.GetChild(0).GetComponent<TextMeshProUGUI>().text = s.description; //Clear all current ScrollFacts - for (int i = 0; i < originalViewport.GetChild(0).childCount; i++) { - GameObject.Destroy(originalViewport.GetChild(0).transform.GetChild(i).gameObject); - } + originalViewport.GetChild(0).gameObject.DestroyAllChildren(); ParameterDisplays = new List<GameObject>(); for (int i = 0; i < s.requiredFacts.Count; i++) @@ -68,49 +78,51 @@ public void setScroll(Scroll s) popup.setParameterDisplays(ParameterDisplays); } - public void magicButtonTrigger() { + public void magicButtonTrigger() + { StartCoroutine(magicButton()); - } - IEnumerator magicButton() - { - //Non blocking wait till sendView() is finished - yield return sendView("/scroll/apply"); - if (currentMmtAnswer == null) + IEnumerator magicButton() { - Debug.Log("DAS HAT NICHT GEKLAPPT"); - PushoutFactFailEvent.Invoke(null, null); - } - else - { - Debug.Log(currentMmtAnswer); - Scroll.ScrollApplicationInfo pushout = JsonConvert.DeserializeObject<Scroll.ScrollApplicationInfo>(currentMmtAnswer); - if (pushout.acquiredFacts.Count == 0) - PushoutFactFailEvent.Invoke(null, pushout); - readPushout(pushout.acquiredFacts); + //Non blocking wait till sendView() is finished + yield return sendView("/scroll/apply"); + if (currentMmtAnswer == null) + { + Debug.Log("DAS HAT NICHT GEKLAPPT"); + PushoutFactFailEvent.Invoke(null, null); + } + else + { + Debug.Log(currentMmtAnswer); + Scroll.ScrollApplicationInfo pushout = JsonConvert.DeserializeObject<Scroll.ScrollApplicationInfo>(currentMmtAnswer); + if (pushout.acquiredFacts.Count == 0) + PushoutFactFailEvent.Invoke(null, pushout); + readPushout(pushout.acquiredFacts); + } } } - public void newAssignmentTrigger() { - if(this.automaticHintGenerationActive || this.dynamicScrollDescriptionsActive) - StartCoroutine(newAssignment()); - } - - IEnumerator newAssignment() + public void newAssignmentTrigger() { - //Non blocking wait till sendView() is finished - yield return sendView("/scroll/dynamic"); + if (this.automaticHintGenerationActive || this.dynamicScrollDescriptionsActive) + StartCoroutine(newAssignment()); - if (currentMmtAnswer == null) + IEnumerator newAssignment() { - Debug.Log("DAS HAT NICHT GEKLAPPT"); - } - else - { - // Todo delte maybe - Debug.Log("Current mmt answer: "+currentMmtAnswer); - Scroll.ScrollDynamicInfo scrollDynamicInfo = JsonConvert.DeserializeObject<Scroll.ScrollDynamicInfo>(currentMmtAnswer); - processScrollDynamicInfo(scrollDynamicInfo); + //Non blocking wait till sendView() is finished + yield return sendView("/scroll/dynamic"); + + if (currentMmtAnswer == null) + { + Debug.Log("DAS HAT NICHT GEKLAPPT"); + } + else + { + // Todo delte maybe + Debug.Log("Current mmt answer: " + currentMmtAnswer); + Scroll.ScrollDynamicInfo scrollDynamicInfo = JsonConvert.DeserializeObject<Scroll.ScrollDynamicInfo>(currentMmtAnswer); + processScrollDynamicInfo(scrollDynamicInfo); + } } } @@ -123,18 +135,10 @@ IEnumerator sendView(string endpoint) www.method = UnityWebRequest.kHttpVerbPOST; www.SetRequestHeader("Content-Type", "application/json"); yield return www.SendWebRequest(); - //TODO delete below if above works fine - // UnityWebRequest www = UnityWebRequest.Put(ServerAdress + endpoint, body); - // www.method = UnityWebRequest.kHttpVerbPOST; - // www.SetRequestHeader("Content-Type", "application/json"); - // var async = www.SendWebRequest(); - // while (!async.isDone) { - //Non blocking wait for one frame, for letting the game do other things - // yield return null; - // } + System.DateTime twoTime = System.DateTime.UtcNow; - if (www.result == UnityWebRequest.Result.ConnectionError + if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError) { Debug.Log(www.error); @@ -147,84 +151,55 @@ IEnumerator sendView(string endpoint) } System.DateTime endTime = System.DateTime.UtcNow; - string diffInSeconds = (endTime -startTime).TotalMilliseconds.ToString(); + string diffInSeconds = (endTime - startTime).TotalMilliseconds.ToString(); string diff = (twoTime - startTime).TotalMilliseconds.ToString(); - - } private string prepareScrollAssignments() { - Fact tempFact; List<Scroll.ScrollAssignment> assignmentList = new(); for (int i = 0; i < ParameterDisplays.Count; i++) { - tempFact = ParameterDisplays[i].GetComponentInChildren<DropHandling>().currentFact; + Fact tempFact = ParameterDisplays[i].GetComponentInChildren<DropHandling>().currentFact; if (tempFact != null) - { - Scroll.ScrollAssignment listEntry = new() - { - fact = new Scroll.UriReference(ActiveScroll.requiredFacts[i].@ref.uri), - assignment = new SOMDocManager.OMS(tempFact.Id) - }; - assignmentList.Add(listEntry); - } + assignmentList.Add(new Scroll.ScrollAssignment(ActiveScroll.requiredFacts[i].@ref.uri, tempFact.Id)); } - Scroll.FilledScroll filledScroll = new(ActiveScroll.@ref, assignmentList); - return JsonConvert.SerializeObject(filledScroll); + return JsonConvert.SerializeObject(new Scroll.FilledScroll(ActiveScroll.@ref, assignmentList)); } - private void readPushout(List<Scroll.ScrollFact> pushoutFacts) + private void readPushout(List<MMTDeclaration> pushoutFacts) { + mmtAnswerPopUp.GetComponent<PopupBehavior>().hidePopUp(); //close error Window + bool samestep = false; for (int i = 0; i < pushoutFacts.Count; i++, samestep = true) { - //TODO Delete - //Debug.Log(pushoutFacts.Count); - //Debug.Log("StartUri " +pushoutFacts[i].getType()+ " over"); - //Debug.Log("Applicant" + pushoutFacts[i].getApplicant() + " over"); - - //close error Window - this.mmtAnswerPopUp.GetComponent<PopupBehavior>().hidePopUp(); - - string type = pushoutFacts[i].getType(); Fact newFact = ParsingDictionary.parseFactDictionary[pushoutFacts[i].getType()].Invoke(pushoutFacts[i]); if (newFact != null) - { PushoutFactEvent.Invoke(FactManager.AddFactIfNotFound(newFact, out _, samestep, null, ActiveScroll.label), FactObject.FactMaterials.Solution); - //PushoutFactEvent.Invoke(FactManager.AddFactIfNotFound(newFact, out _, samestep, null, ActiveScroll.label)); - - } - else { + + else Debug.Log("Parsing on pushout-fact returned null -> One of the dependent facts does not exist"); - } } } - public void processScrollDynamicInfo(Scroll.ScrollDynamicInfo scrollDynamicInfo) { - - if (scrollDynamicInfo.completions.Count != 0) - LatestCompletions = scrollDynamicInfo.completions[0]; - else - LatestCompletions = new List<Scroll.ScrollAssignment>(); + public void processScrollDynamicInfo(Scroll.ScrollDynamicInfo scrollDynamicInfo) + { + LatestCompletions = scrollDynamicInfo.completions.Count > 0 + ? scrollDynamicInfo.completions[0] + : new List<Scroll.ScrollAssignment>(); - LatestRenderedHints = new List<Fact>(); - List<string> hintUris = new(); - foreach (Scroll.ScrollAssignment currentCompletion in LatestCompletions) { - hintUris.Add(currentCompletion.fact.uri); - } + List<string> hintUris = LatestCompletions.Select(completion => completion.fact.uri).ToList(); //Update Scroll, process data for later hints and update Uri-List for which hints are available hintUris = processRenderedScroll(scrollDynamicInfo.rendered, hintUris); - if (this.automaticHintGenerationActive) - { + if (automaticHintGenerationActive) //Show that Hint is available for ScrollParameter HintAvailableEvent.Invoke(hintUris); - } } public List<string> processRenderedScroll(Scroll rendered, List<string> hintUris) @@ -232,14 +207,13 @@ public List<string> processRenderedScroll(Scroll rendered, List<string> hintUris Transform scroll = gameObject.transform.GetChild(1).transform; if (this.dynamicScrollDescriptionsActive) - { //Update scroll-description scroll.GetChild(0).GetComponent<TextMeshProUGUI>().text = rendered.description; - } + LatestRenderedHints = new List<Fact>(); for (int i = 0; i < rendered.requiredFacts.Count; i++) { - var obj = ParameterDisplays.Find(x => x.transform.GetChild(0).GetComponent<RenderedScrollFact>().factUri.Equals(rendered.requiredFacts[i].@ref.uri)); + GameObject obj = ParameterDisplays.Find(x => x.transform.GetChild(0).GetComponent<RenderedScrollFact>().factUri.Equals(rendered.requiredFacts[i].@ref.uri)); if (this.dynamicScrollDescriptionsActive) { @@ -249,9 +223,10 @@ public List<string> processRenderedScroll(Scroll rendered, List<string> hintUris //Check Hint Informations //If ScrollFact is assigned -> No Hint - if (obj.transform.GetChild(0).GetComponent<DropHandling>().currentFact == null) { + if (obj.transform.GetChild(0).GetComponent<DropHandling>().currentFact == null) + { - // Debug.Log(" print out " + rendered.requiredFacts[i].getType()); + // Debug.Log(" print out " + rendered.requiredFacts[i].getType()); Fact currentFact = ParsingDictionary.parseFactDictionary[rendered.requiredFacts[i].getType()].Invoke(rendered.requiredFacts[i]); //If currentFact could be parsed: this fact maybe not yet exists in the global fact-list but there must be a fact // of the same type and the same dependent facts in the fact-list, otherwise currentFact could not have been parsed @@ -270,8 +245,9 @@ public List<string> processRenderedScroll(Scroll rendered, List<string> hintUris return hintUris; } - public void animateHint(GameObject scrollParameter, string scrollParameterUri) { - Scroll.ScrollAssignment suitableCompletion = LatestCompletions.Find(x => x.fact.uri.Equals(scrollParameterUri) ); + public void animateHint(GameObject scrollParameter, string scrollParameterUri) + { + Scroll.ScrollAssignment suitableCompletion = LatestCompletions.Find(x => x.fact.uri.Equals(scrollParameterUri)); Fact fact; if (suitableCompletion != null) @@ -310,10 +286,10 @@ public void animateHint(GameObject scrollParameter, string scrollParameterUri) { } } } - + //this is called whenever a Fact is Deleted in the world, to make sure it is removed from the scroll public void removeFactFromAssignment(Fact fact) - { + { Transform originalScroll = gameObject.transform.GetChild(1).transform; Transform originalScrollView = originalScroll.GetChild(1); Transform originalViewport = originalScrollView.GetChild(0); diff --git a/Assets/Scripts/Loading/Stage.cs b/Assets/Scripts/Loading/Stage.cs index 33f2be13e9d5d6e4a3c42c5da53c464c4a320391..b8629b4a51068154c370993be1b64881619447a1 100644 --- a/Assets/Scripts/Loading/Stage.cs +++ b/Assets/Scripts/Loading/Stage.cs @@ -471,6 +471,7 @@ public class SaveGame : IJSONsavable<SaveGame> [JSONsavable.JsonAutoPreProcess, JSONsavable.JsonAutoPostProcess] public PlayerRecord player_record = null; + //[JSONsavable.JsonAutoPreProcess] //does not yet work public Dictionary<string, PlayerRecord> player_record_list = new(); //entries are "PostProcess"ed when accessed/Cloned static SaveGame() @@ -486,6 +487,14 @@ SaveGame IJSONsavable<SaveGame>._IJPostProcess(SaveGame payload) payload.player_record = null; return payload; } + SaveGame IJSONsavable<SaveGame>._IJPreProcess(SaveGame payload) { + Dictionary<string, PlayerRecord> player_record_list_processed = new (payload.player_record_list.Count); + foreach (KeyValuePair<string, PlayerRecord> record in payload.player_record_list) + player_record_list_processed.Add(record.Key, IJSONsavable<PlayerRecord>.preprocess(record.Value)); + + payload.player_record_list = player_record_list_processed; + return payload; + } } /// <summary> diff --git a/Assets/Scripts/MeshGenerator/CircleGenerator.cs b/Assets/Scripts/MeshGenerator/CircleGenerator.cs index 6d81d959d8ab9a9c50b2d252f847743a5dcda0d1..db4ef9f45958203825705059676db5a3c5e39f87 100644 --- a/Assets/Scripts/MeshGenerator/CircleGenerator.cs +++ b/Assets/Scripts/MeshGenerator/CircleGenerator.cs @@ -14,22 +14,25 @@ public class CircleGenerator : ShapeGenerator [Range(3,1000)] public int sideCount = 500; [Header("Parts")] - public MeshFilter circleMesh; + public List<MeshFilter> circleMesh; #endregion InspectorVariables #region Implementation protected override void GenerateShape() { - if (circleMesh == null) return; + foreach (MeshFilter filter in circleMesh) + { + if (filter == null) continue; - var circle = CreateCircle(radius, sideCount); + var circle = CreateCircle(radius, sideCount); - if (circleMesh.sharedMesh != null) - circleMesh.sharedMesh.Clear(); - circleMesh.mesh = CreateMesh(circle); + if (filter.sharedMesh != null) + filter.sharedMesh.Clear(); + filter.mesh = CreateMesh(circle); - if (circleMesh.transform.TryGetComponent(out MeshCollider meshCol)) - meshCol.sharedMesh = circleMesh.sharedMesh; + if (filter.transform.TryGetComponent(out MeshCollider meshCol)) + meshCol.sharedMesh = filter.sharedMesh; + } } /// <summary> diff --git a/Assets/Scripts/SOMDocManager.cs b/Assets/Scripts/SOMDocManager.cs index 5f644ba299291d4768f17f256f130ea06becbc07..3c9562965f9fca371988f2ca444d7740a27b12e0 100644 --- a/Assets/Scripts/SOMDocManager.cs +++ b/Assets/Scripts/SOMDocManager.cs @@ -6,7 +6,7 @@ using System.Linq; using MoreLinq; using UnityEngine; -using static UnityEditor.PlayerSettings; +using static Scroll; public static class SOMDocManager { @@ -290,10 +290,10 @@ private static LambdaExpression MakeArray(LambdaExpression[] args_lamda, Paramet [JsonSubtypes.KnownSubType(typeof(OMC<double>), "OMC<System.Double>")] abstract public class SOMDoc { - string kind; + public string kind; [JsonIgnore] - protected static readonly Dictionary<string, Type> StringToType = new(){ + protected static readonly IReadOnlyDictionary<string, Type> StringToType = new Dictionary<string, Type>() { {"R", typeof(float)}, {typeof(float).ToString(), @@ -306,16 +306,18 @@ abstract public class SOMDoc typeof(UnityEngine.Vector3)}, }; [JsonIgnore] - protected static readonly Dictionary<Type, string> TypeToString; + protected static readonly IReadOnlyDictionary<Type, string> TypeToString; static SOMDoc() { - TypeToString = new(); + Dictionary<Type, string> _TypeToString = new(); foreach (KeyValuePair<string, Type> KeyVal in StringToType) - TypeToString.TryAdd(KeyVal.Value, KeyVal.Key); + _TypeToString.TryAdd(KeyVal.Value, KeyVal.Key); + + TypeToString = _TypeToString; } - protected SOMDoc() { } + protected SOMDoc() { kind = this.GetType().Name; } public static bool Equivalent(SOMDoc sd1, SOMDoc sd2) => sd1.Equivalent(sd2); @@ -342,7 +344,7 @@ public LambdaExpression PartialInvokeCastingLambdaExpression(out Type[] signatur continue; } - signature_args[n_params] = lambda_orig.Parameters[i].Type; + signature_args[n_params++] = lambda_orig.Parameters[i].Type; cast_new_to_signature[i] = Expression.Convert( @@ -350,15 +352,12 @@ public LambdaExpression PartialInvokeCastingLambdaExpression(out Type[] signatur object_arr, Expression.Constant(i) ), - signature_args[n_params] + lambda_orig.Parameters[i].Type ); - - n_params++; } signature_args[n_params] = lambda_orig.ReturnType; signature_args = signature_args.Slice(0, n_params + 1).ToArray(); - return Expression.Lambda( typeof(Array).IsAssignableFrom(lambda_orig.ReturnType) ? Expression.Convert( @@ -414,7 +413,7 @@ public override SOMDoc MapURIs(Dictionary<string, string> old_to_new) public class OMBINDC : SOMDocCRTP<OMBINDC> { - public string kind = "OMBINDC"; + public new string kind = "OMBINDC"; public string name; @@ -461,7 +460,7 @@ protected internal override LambdaExpression GetLambdaExpression(LambdaExpressio } public override string ToString() - => "OMBINDC(" + name + ", " + typeString + ")"; + => "OMBINDC(" + name + ", " + typeString + ")->"; public override OMBINDC MapURIsWrapped(Dictionary<string, string> old_to_new) => new(name, type, lambdabody.MapURIs(old_to_new)); @@ -469,7 +468,7 @@ public override OMBINDC MapURIsWrapped(Dictionary<string, string> old_to_new) public class OMA : SOMDocCRTP<OMA> { - public string kind = "OMA"; + public new string kind = "OMA"; public SOMDoc applicant; public List<SOMDoc> arguments; @@ -505,7 +504,7 @@ public override OMA MapURIsWrapped(Dictionary<string, string> old_to_new) public class OMS : SOMDocCRTP<OMS> //OMSTR? { - public string kind = "OMS"; + public new string kind = "OMS"; public string uri; @@ -535,7 +534,7 @@ public override OMS MapURIsWrapped(Dictionary<string, string> old_to_new) public class OMSTR : SOMDocCRTP<OMSTR> { - public string kind = "OMSTR"; + public new string kind = "OMSTR"; [JsonProperty("float")] public string s; @@ -561,7 +560,7 @@ public override OMSTR MapURIsWrapped(Dictionary<string, string> old_to_new) public class OMF : SOMDocCRTP<OMF> { - public string kind = "OMF"; + public new string kind = "OMF"; [JsonProperty("float")] public float f; @@ -587,7 +586,7 @@ public override OMF MapURIsWrapped(Dictionary<string, string> old_to_new) public class OMC<T> : SOMDocCRTP<OMC<T>> { - public string kind = "OMC<" + typeof(T) + ">"; + public new string kind = "OMC<" + typeof(T) + ">"; public T value; @@ -615,7 +614,7 @@ public override OMC<T> MapURIsWrapped(Dictionary<string, string> old_to_new) public class OMV : SOMDocCRTP<OMV> { - public string kind = "OMV"; + public new string kind = "OMV"; public string name; @@ -648,9 +647,14 @@ public override OMV MapURIsWrapped(Dictionary<string, string> old_to_new) } - public class MMTDeclaration + [JsonConverter(typeof(JsonSubtypes), "kind")] + [JsonSubtypes.KnownSubType(typeof(MMTSymbolDeclaration), "general")] + [JsonSubtypes.KnownSubType(typeof(MMTValueDeclaration), "veq")] + public abstract class MMTDeclaration { + public string kind; public string label; + public UriReference @ref; public static MMTDeclaration FromJson(string json) { @@ -663,51 +667,94 @@ public static MMTDeclaration FromJson(string json) public static string ToJson(MMTDeclaration mmtDecl) { mmtDecl.label ??= string.Empty; - string json = JsonConvert.SerializeObject(mmtDecl); + return json; } + + public abstract string getType(); + + public abstract string getApplicant(); } - /** - * MMTSymbolDeclaration: Class for facts without values, e.g. Points - */ + /// <summary>MMTSymbolDeclaration: Class for facts without values, e.g. Points</summary> public class MMTSymbolDeclaration : MMTDeclaration { - public string kind = "general"; + public new string kind = "general"; + public SOMDoc tp; public SOMDoc df; - /** - * Constructor used for sending new declarations to mmt - */ + [JsonConstructor] + private MMTSymbolDeclaration() { } + + /// <summary>Constructor used for sending new declarations to mmt</summary> public MMTSymbolDeclaration(string label, SOMDoc tp, SOMDoc df) { this.label = label; this.tp = tp; this.df = df; } + + public override string getType() + { + return tp switch + { + OMS oMS => oMS.uri, + OMA oMA => ((oMA.arguments[0] as OMA).applicant as OMS).uri, + _ => null + }; + } + + public override string getApplicant() + { + return df switch + { + OMA oMA when oMA.applicant is OMS oMS => oMS.uri, + _ => null + }; + } } - /** - * MMTValueDeclaration: Class for facts with values, e.g. Distances or Angles - */ + /// <summary>MMTValueDeclaration: Class for facts with values, e.g. Distances or Angles</summary> public class MMTValueDeclaration : MMTDeclaration { - public string kind = "veq"; + public new string kind = "veq"; + public SOMDoc lhs; public SOMDoc valueTp; public SOMDoc value; + public SOMDoc proof; - /** - * Constructor used for sending new declarations to mmt - */ - public MMTValueDeclaration(string label, SOMDoc lhs, SOMDoc valueTp, SOMDoc value) + [JsonConstructor] + private MMTValueDeclaration() { } + + /// <summary>Constructor used for sending new declarations to mmt</summary> + public MMTValueDeclaration(string label, SOMDoc lhs, SOMDoc valueTp, SOMDoc value, SOMDoc proof = null) { this.label = label; this.lhs = lhs; this.valueTp = valueTp; this.value = value; + this.proof = proof; + } + + public override string getType() + { + return lhs switch + { + OMA oMA when oMA.applicant is OMS oMS => oMS.uri, + _ => null + }; + } + + public override string getApplicant() + { + return lhs switch + { + OMA oMA when oMA.applicant is OMS oMS => oMS.uri, + _ => null + }; } } } diff --git a/Assets/Scripts/UI/Characters/ThirdPersonCharacter/Scripts/ThirdPersonMovementScript.cs b/Assets/Scripts/UI/Characters/ThirdPersonCharacter/Scripts/ThirdPersonMovementScript.cs index 710597b1c1619814c6f4d163cde086f3861ab14c..ba3ee1b01ebba6f75d300854e1be6c02d5701389 100644 --- a/Assets/Scripts/UI/Characters/ThirdPersonCharacter/Scripts/ThirdPersonMovementScript.cs +++ b/Assets/Scripts/UI/Characters/ThirdPersonCharacter/Scripts/ThirdPersonMovementScript.cs @@ -23,20 +23,19 @@ public class ThirdPersonMovementScript : MonoBehaviour float turnSmoothVelocity; public float turnSmoothTime = 0.1f; - [SerializeField] [Range(0f, 1f)] private float m_RunstepLenghten; - [SerializeField] private float m_StickToGroundForce=10; + [SerializeField][Range(0f, 1f)] private float m_RunstepLenghten; + [SerializeField] private float m_StickToGroundForce = 10; [SerializeField] private float m_JumpSpeed; [SerializeField] private AudioClip[] m_FootstepSounds; // an array of footstep sounds that will be randomly selected from. [SerializeField] private AudioClip m_JumpSound; // the sound played when character leaves the ground. [SerializeField] private AudioClip m_LandSound; // the sound played when character touches back on ground. - [SerializeField] private float m_StepInterval=5; - [SerializeField] private float m_GravityMultiplier=2; + [SerializeField] private float m_StepInterval = 5; + [SerializeField] private float m_GravityMultiplier = 2; [SerializeField] private bool m_IsWalking; [SerializeField] private float m_WalkSpeed; [SerializeField] private float m_RunSpeed; - private bool m_Jumping; private AudioSource m_AudioSource; private bool m_Jump; @@ -48,7 +47,7 @@ public class ThirdPersonMovementScript : MonoBehaviour private float m_StepCycle; private float m_NextStep; private bool m_PreviouslyGrounded; - + private void Start() { @@ -119,13 +118,10 @@ private void Update3() m_PreviouslyGrounded = m_CharacterController.isGrounded; } - - private void FixedUpdate() { - float speed; - GetInput(out speed); - + GetInput(out float speed); + // always move along the camera forward as it is the direction that it being aimed at //Vector3 desiredMove = transform.forward * m_Input.y + transform.right * m_Input.x; @@ -158,8 +154,9 @@ private void FixedUpdate() } else { - m_MoveDir += Physics.gravity * m_GravityMultiplier * Time.fixedDeltaTime; + m_MoveDir += m_GravityMultiplier * Time.fixedDeltaTime * Physics.gravity; } + m_CollisionFlags = m_CharacterController.Move(m_MoveDir * Time.fixedDeltaTime); float horizontal = m_Input.x;// Input.GetAxisRaw("Horizontal"); @@ -167,7 +164,6 @@ private void FixedUpdate() Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized; - //ProgressStepCycle(speed); //UpdateCameraPosition(speed); @@ -177,28 +173,18 @@ private void FixedUpdate() if (direction.magnitude >= 0.1f) { - - float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y; - float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime); - transform.rotation = Quaternion.Euler(0f, angle, 0f); - - Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward; - controller.Move(moveDir.normalized * speed * Time.deltaTime); - - } - + float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y; + float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime); + transform.rotation = Quaternion.Euler(0f, angle, 0f); + Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward; + controller.Move(speed * Time.deltaTime * moveDir.normalized); + } } - - - - private void GetInput(out float speed) { - - if (UIconfig.InputManagerVersion == 1) { // Read input @@ -208,10 +194,7 @@ private void GetInput(out float speed) // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); - - #endif - m_Input = new Vector2(horizontal, vertical); } if (UIconfig.InputManagerVersion == 2) @@ -226,7 +209,6 @@ private void GetInput(out float speed) bool waswalking = m_IsWalking; // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; - } private void PlayJumpSound() @@ -234,6 +216,7 @@ private void PlayJumpSound() m_AudioSource.clip = m_JumpSound; m_AudioSource.Play(); } + private void PlayLandingSound() { m_AudioSource.clip = m_LandSound; @@ -249,15 +232,14 @@ private void ProgressStepCycle(float speed) Time.fixedDeltaTime; } - if (!(m_StepCycle > m_NextStep)) - { + if (m_StepCycle <= m_NextStep) return; - } m_NextStep = m_StepCycle + m_StepInterval; PlayFootStepAudio(); } + private void PlayFootStepAudio() { if (!m_CharacterController.isGrounded) @@ -273,7 +255,4 @@ private void PlayFootStepAudio() m_FootstepSounds[n] = m_FootstepSounds[0]; m_FootstepSounds[0] = m_AudioSource.clip; } -} - - - +} \ No newline at end of file diff --git a/Assets/Scripts/UI/InGame/PopupBehavior.cs b/Assets/Scripts/UI/InGame/PopupBehavior.cs index 03669200acb4c4fe64ddacac61b8449a87aa50c0..94de23fbb689a4cd7502183c86a8d8f98bdac2f4 100644 --- a/Assets/Scripts/UI/InGame/PopupBehavior.cs +++ b/Assets/Scripts/UI/InGame/PopupBehavior.cs @@ -91,7 +91,7 @@ private string generateHelpfulMessageAndAnimateScrollParam(Scroll.ScrollApplicat } else if (error.kind == "invalidAssignment") { invAssCount++; - Scroll.ScrollFact fact = parseFactFromError(error); + MMTDeclaration fact = parseFactFromError(error); //animate all invalidly assigned facts if (parameterDisplays != null && fact != null) @@ -130,7 +130,7 @@ private string generateHelpfulMessageAndAnimateScrollParam(Scroll.ScrollApplicat } //this should be changed, the Fact Object should be parsed by JSON. This is a workaround because the MMT servers JSON serialization contains a bug - private Scroll.ScrollFact parseFactFromError(Scroll.ScrollApplicationCheckingError error) + private MMTDeclaration parseFactFromError(Scroll.ScrollApplicationCheckingError error) { if(error == null || error.msg == null) { @@ -159,7 +159,7 @@ private Scroll.ScrollFact parseFactFromError(Scroll.ScrollApplicationCheckingErr { return null; } - foreach (Scroll.ScrollFact f in activeScroll.requiredFacts) + foreach (MMTDeclaration f in activeScroll.requiredFacts) { if (f.@ref.uri.Equals(factUri)) { diff --git a/Assets/Scripts/Utility/IJSONsavable.cs b/Assets/Scripts/Utility/IJSONsavable.cs index c789ebc2cd1ab61e52c61248f7cf632bb9dde287..27f66e8bd82f8c3fa10108f1d5dda0a6c7c854ab 100644 --- a/Assets/Scripts/Utility/IJSONsavable.cs +++ b/Assets/Scripts/Utility/IJSONsavable.cs @@ -325,6 +325,7 @@ private static bool delete(string path) } +/// <remarks>Does not yet work with collections</remarks> public static class JSONsavable { [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] @@ -332,7 +333,7 @@ public sealed class JsonSeparateAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public sealed class JsonAutoPostProcessAttribute : Attribute { } - + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public sealed class JsonAutoPreProcessAttribute : Attribute { } diff --git a/Assets/Scripts/Utility/Math3d.cs b/Assets/Scripts/Utility/Math3d.cs index 613a3c4eb4fa37fbb87f725f7a0252282f39675d..290e301e9af827c6f9d3fc823973c96892a0f145 100644 --- a/Assets/Scripts/Utility/Math3d.cs +++ b/Assets/Scripts/Utility/Math3d.cs @@ -612,7 +612,7 @@ public static Vector3 ProjectPointOnPlane(Vector3 planeNormal, Vector3 planePoin distance *= -1; //Get a translation vector - translationVector = SetVectorLength(planeNormal, distance); + translationVector = planeNormal * distance; //Translate the point to form a projection return point + translationVector;