diff --git a/Assets/ScriptableObjects/Gadgets/GadgetDataContainerGadgetCollection.asset b/Assets/ScriptableObjects/Gadgets/GadgetDataContainerGadgetCollection.asset index 47177f03c4aff70e1c7b8d2d913afa1305d32420..9542b6a61ba2a7de632d5f2991ee044ebec108a2 100644 --- a/Assets/ScriptableObjects/Gadgets/GadgetDataContainerGadgetCollection.asset +++ b/Assets/ScriptableObjects/Gadgets/GadgetDataContainerGadgetCollection.asset @@ -27,8 +27,8 @@ MonoBehaviour: - {fileID: 21300000, guid: d456617ba2282854d9570dcebcc2b279, type: 3} - {fileID: 21300000, guid: e35797aede3d7bd449ca9195a409b0cc, type: 3} - {fileID: 21300000, guid: 9831128faf2531e4cba52f58894091be, type: 3} - - {fileID: 21300000, guid: e706f1d2fb068e342b1c80c357d84b40, type: 3} - GadgetType: ffffffff00000000010000000200000003000000040000000500000006000000070000000800000009000000 + - {fileID: 21300000, guid: 13f4e064448182b49ba38b5035a1f45a, type: 3} + GadgetType: ffffffff000000000100000002000000030000000400000005000000060000000700000008000000090000000a000000 GadgetData: - {fileID: 11400000, guid: 7431ff31b707d2a4082b65b61e15e5df, type: 2} - {fileID: 11400000, guid: c149a1e468d3b3b48a0732c2e0811856, type: 2} @@ -41,3 +41,4 @@ MonoBehaviour: - {fileID: 11400000, guid: 06736b134e21b50488990025c33c9c2e, type: 2} - {fileID: 11400000, guid: 6bc4e283502549d428d3c9ce74e91757, type: 2} - {fileID: 11400000, guid: 35d3197399dc8374280464a237271ac5, type: 2} + - {fileID: 11400000, guid: 23a852b1469eeba4ebacccac54ec0f59, type: 2} diff --git a/Assets/ScriptableObjects/Gadgets/SphereGadgetData.asset b/Assets/ScriptableObjects/Gadgets/SphereGadgetData.asset new file mode 100644 index 0000000000000000000000000000000000000000..26f908470827b0b04d41bd75eaa8726098a60808 --- /dev/null +++ b/Assets/ScriptableObjects/Gadgets/SphereGadgetData.asset @@ -0,0 +1,26 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 262a3c8caea4a7741b65ef20c568f5c2, type: 3} + m_Name: SphereGadgetData + m_EditorClassIdentifier: Assembly-CSharp::DataContainerGadgetInit + Rank: 11 + MaxRange: 10 + MaxHeight: 10 + UiName: Sphere Gadget + MaterialIndx: 0 + ButtonIndx: 11 + LayerHitMask: + serializedVersion: 2 + m_Bits: 1637393 + SecondaryLayerMask: + serializedVersion: 2 + m_Bits: 0 diff --git a/Assets/ScriptableObjects/Gadgets/SphereGadgetData.asset.meta b/Assets/ScriptableObjects/Gadgets/SphereGadgetData.asset.meta new file mode 100644 index 0000000000000000000000000000000000000000..f9a037d0c98474fdec95af5e24ee9eab5c248250 --- /dev/null +++ b/Assets/ScriptableObjects/Gadgets/SphereGadgetData.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 23a852b1469eeba4ebacccac54ec0f59 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactAdder.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactAdder.cs index 778b0ff927e0100e6147a09d627b199ea12c26a9..ed7e288fd25206318baf9e0098f8590c7ab37eca 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactAdder.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactAdder.cs @@ -54,6 +54,12 @@ public static PointFact AddPointFact(Vector3 point, Vector3 normal, bool sameste , out _, samestep, gadget, scroll_label); } + public static SphereFact AddSphereFact(string pid1, string pid2, bool samestep = false, Gadget gadget = null, string scroll_label = null){ + + return (SphereFact)AddFactIfNotFound( + new SphereFact(pid1, pid2), out _, samestep, gadget, scroll_label); + } + /// \copybrief FactManager <summary></summary> /// <param name="pid"><see cref="Fact.Id"/> of <see cref="PointFact"/> which lies on <paramref name="lid"/></param> /// <param name="lid"><see cref="Fact.Id"/> of <see cref="LineFact"/> on which <paramref name="pid"/> lies</param> diff --git a/Assets/Scripts/InteractionEngine/Gadgets/Gadget.cs b/Assets/Scripts/InteractionEngine/Gadgets/Gadget.cs index ec1cfc14e2a8c65b8c0498ca4a75ff21c0dd3a01..9ab1093ad2a2eee763ddb342549b70d04d49b5cc 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/Gadget.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/Gadget.cs @@ -20,6 +20,7 @@ [JsonSubtypes.KnownSubType(typeof(PoleTool), "PoleTool")] [JsonSubtypes.KnownSubType(typeof(Remover), "Remover")] [JsonSubtypes.KnownSubType(typeof(EqualCircleGadget), "EqualCircles")] +[JsonSubtypes.KnownSubType(typeof(SphereGadget), "SphereGadget")] [JsonSubtypes.FallBackSubType(typeof(UndefinedGadget))] public abstract class Gadget { @@ -47,6 +48,7 @@ public enum GadgetIDs Remover = 7, EqualCircles = 8, MiddlePoint = 9, + SphereGadget = 10, } @@ -62,6 +64,7 @@ public enum GadgetIDs {typeof(Remover) , GadgetIDs.Remover }, {typeof(EqualCircleGadget) , GadgetIDs.EqualCircles }, {typeof(TestMiddlePoint) , GadgetIDs.MiddlePoint }, + {typeof(SphereGadget) , GadgetIDs.SphereGadget}, }; /// <summary> Position in tool belt. </summary> diff --git a/Assets/Scripts/InteractionEngine/Gadgets/SphereGadget.cs b/Assets/Scripts/InteractionEngine/Gadgets/SphereGadget.cs new file mode 100644 index 0000000000000000000000000000000000000000..e44b735a77ebf38266f383b1d467330f784aff5a --- /dev/null +++ b/Assets/Scripts/InteractionEngine/Gadgets/SphereGadget.cs @@ -0,0 +1,32 @@ +using Newtonsoft.Json; +using UnityEngine; + +public class SphereGadget : Gadget +{ + /// \copydoc Gadget.s_type + [JsonProperty] + protected static new string s_type = "SphereTool"; + + //Cache for collecting the line + private readonly Vector3[] LineOrigin = new Vector3[1]; + + + protected override void _Hit(RaycastHit[] hit) + { + string tempFactId = hit[0].transform.GetComponent<FactObject>().URI; + if (!Workflow.Contains(tempFactId)) + Workflow.Add(tempFactId); + + switch (Workflow.Count) + { + case 1: + LineOrigin[0] = hit[0].transform.position; + break; + + case 2: + FactAdder.AddSphereFact(Workflow[0], Workflow[1], gadget: this); + ResetGadget(); + return; + } + } +} diff --git a/Assets/Scripts/InteractionEngine/Gadgets/SphereGadget.cs.meta b/Assets/Scripts/InteractionEngine/Gadgets/SphereGadget.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a6d11e839d5579ac1bce2ed65b881a731c48d07a --- /dev/null +++ b/Assets/Scripts/InteractionEngine/Gadgets/SphereGadget.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b82608d3a00b8fd49bb3cf9f24d9dc28 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: