From b87a7e0188499661e8883a6a683c0a1bafa1c10c Mon Sep 17 00:00:00 2001
From: unknown <john.schihada@hotmail.com>
Date: Tue, 14 Jul 2020 22:33:04 +0200
Subject: [PATCH] Refactored LineTool/Tape

---
 Assets/InteractionEngine/FactManager.cs       |   4 -
 Assets/InteractionEngine/Gadgets/Pointer.cs   |   1 -
 Assets/InteractionEngine/ShinyThings.cs       |  48 +--
 Assets/LineTool.cs                            | 170 +++++++-
 .../Inventory.meta => RiverScene.unity.meta}  |   3 +-
 Assets/StreamingAssets.meta                   |   8 -
 Assets/Tape.cs                                | 168 +++++++-
 Assets/TreeWorld_02.unity                     |  42 +-
 Packages/manifest.json                        |   2 +-
 Packages/packages-lock.json                   | 387 ++++++++++++++++++
 ProjectSettings/ProjectVersion.txt            |   4 +-
 11 files changed, 742 insertions(+), 95 deletions(-)
 rename Assets/{InventoryStuff/Inventory.meta => RiverScene.unity.meta} (67%)
 delete mode 100644 Assets/StreamingAssets.meta
 create mode 100644 Packages/packages-lock.json

diff --git a/Assets/InteractionEngine/FactManager.cs b/Assets/InteractionEngine/FactManager.cs
index 9383cb4b..d734f614 100644
--- a/Assets/InteractionEngine/FactManager.cs
+++ b/Assets/InteractionEngine/FactManager.cs
@@ -9,10 +9,6 @@ public class FactManager : MonoBehaviour
     public GameObject SmartMenu;
     private List<int> NextEmpties = new List<int>();
 
-    //Variables for LineMode distinction
-    public bool lineModeIsFirstPointSelected = false;
-    public Fact lineModeFirstPointSelected = null;
-
     //Variables for AngleMode distinction
     public bool angleModeIsFirstPointSelected = false;
     public Fact angleModeFirstPointSelected = null;
diff --git a/Assets/InteractionEngine/Gadgets/Pointer.cs b/Assets/InteractionEngine/Gadgets/Pointer.cs
index 90727552..c4b859cb 100644
--- a/Assets/InteractionEngine/Gadgets/Pointer.cs
+++ b/Assets/InteractionEngine/Gadgets/Pointer.cs
@@ -5,7 +5,6 @@
 
 public class Pointer : Gadget
 {
-    // Start is called before the first frame update
 
     public override void OnHit(RaycastHit hit)
     {
diff --git a/Assets/InteractionEngine/ShinyThings.cs b/Assets/InteractionEngine/ShinyThings.cs
index 95b5913d..98401fd7 100644
--- a/Assets/InteractionEngine/ShinyThings.cs
+++ b/Assets/InteractionEngine/ShinyThings.cs
@@ -18,10 +18,8 @@ public class ShinyThings : MonoBehaviour
     //Attributes for simulating the drawing of a line/curve
     public LineRenderer lineRenderer;
     private List<Vector3> linePositions = new List<Vector3>();
-    public Material linePreviewMaterial;
     public Material anglePreviewMaterial;
-
-    private bool lineDrawingActivated;
+    
     private bool curveDrawingActivated;
     //These are only the vertices for the Curve
     private int curveDrawingVertexCount = 36;
@@ -55,8 +53,6 @@ public class ShinyThings : MonoBehaviour
     public void Start()
     {
         if (Cursor == null) Cursor = GetComponent<WorldCursor>();
-        CommunicationEvents.StartLineDrawingEvent.AddListener(ActivateLineDrawing);
-        CommunicationEvents.StopLineDrawingEvent.AddListener(DeactivateLineDrawing);
         CommunicationEvents.StartCurveDrawingEvent.AddListener(ActivateCurveDrawing);
         CommunicationEvents.StopCurveDrawingEvent.AddListener(DeactivateCurveDrawing);
         CommunicationEvents.StopPreviewsEvent.AddListener(StopPreviews);
@@ -88,10 +84,8 @@ public void Update()
         //@John before:  hit.point
 
         //Debug.Log(this.transform.position);
-
-        if (this.lineDrawingActivated)
-            UpdateLineDrawing(this.transform.position);
-        else if (this.curveDrawingActivated)
+        
+        if (this.curveDrawingActivated)
             UpdateCurveDrawing(this.transform.position);
 
         //If the Timer is Active, check Pushout-Highlighting
@@ -372,40 +366,6 @@ public void slowDownAnimation(ParticleSystem main1, ParticleSystem main2) {
         }
     }
 
-    public void ActivateLineDrawing(Fact startFact)
-    {
-        this.lineRenderer.positionCount = 2;
-        this.lineRenderer.material = this.linePreviewMaterial;
-
-        lineRenderer.startWidth = 0.095f;
-        lineRenderer.endWidth = 0.095f;
-        //Set LineDrawing activated
-        this.lineDrawingActivated = true;
-        //Add the position of the Fact for the start of the Line
-        linePositions.Add(startFact.Representation.transform.position);
-        //The second point is the same point at the moment
-        linePositions.Add(startFact.Representation.transform.position);
-
-        this.lineRenderer.SetPosition(0, linePositions[0]);
-        this.lineRenderer.SetPosition(1, linePositions[1]);
-
-    }
-
-    //Updates the second-point of the Line when First Point was selected in LineMode
-    public void UpdateLineDrawing(Vector3 currentPosition)
-    {
-        this.linePositions[1] = currentPosition;
-        this.lineRenderer.SetPosition(1, this.linePositions[1]);
-    }
-
-    //Deactivate LineDrawing so that no Line gets drawn when Cursor changes
-    public void DeactivateLineDrawing(Fact startFact)
-    {
-        this.lineRenderer.positionCount = 0;
-        this.linePositions = new List<Vector3>();
-        this.lineDrawingActivated = false;
-    }
-
     //Expect a LineFact here, where Line.Pid2 will be the Basis-Point of the angle
     public void ActivateCurveDrawing(Fact startFact)
     {
@@ -490,8 +450,6 @@ public void DeactivateCurveDrawing(Fact startFact)
     }
 
     public void StopPreviews(Fact startFact) {
-        if (lineDrawingActivated)
-            DeactivateLineDrawing(null);
         if (curveDrawingActivated)
             DeactivateCurveDrawing(null);
     }
diff --git a/Assets/LineTool.cs b/Assets/LineTool.cs
index 7721c7ec..09a1e61e 100644
--- a/Assets/LineTool.cs
+++ b/Assets/LineTool.cs
@@ -5,6 +5,30 @@
 
 public class LineTool : Gadget
 {
+    //Variables for LineMode distinction
+    private bool LineModeIsFirstPointSelected = false;
+    private Fact LineModeFirstPointSelected = null;
+
+    //Attributes for simulating the drawing of a line
+    private bool lineDrawingActivated;
+    public WorldCursor Cursor;
+    public LineRenderer lineRenderer;
+    private List<Vector3> linePositions = new List<Vector3>();
+    public Material linePreviewMaterial;
+
+    //Initialize Gadget when enabled AND activated
+    void OnEnable()
+    {
+        this.ResetGadget();
+    }
+
+    void Start()
+    {
+        if (FactManager == null) FactManager = GameObject.FindObjectOfType<FactManager>();
+        CommunicationEvents.TriggerEvent.AddListener(OnHit);
+        if (this.Cursor == null) this.Cursor = GameObject.FindObjectOfType<WorldCursor>();
+    }
+
     public override void OnHit(RaycastHit hit)
     {
         if (!this.isActiveAndEnabled) return;
@@ -13,36 +37,152 @@ public override void OnHit(RaycastHit hit)
             Fact tempFact = Facts[hit.transform.GetComponent<FactObject>().Id];
 
             //we can only reach points that are lower than that with the measuring tape
-            if (ActiveToolMode == ToolMode.CreateLineMode && tempFact.Representation.transform.position.y > 2.5f)
+            if (/*ActiveToolMode == ToolMode.CreateLineMode && */tempFact.Representation.transform.position.y > 2.5f)
                 return;
 
-            //no 0 distances
-            if (FactManager.lineModeIsFirstPointSelected && FactManager.lineModeFirstPointSelected.Id != tempFact.Id)
+            //If first point was already selected AND second point != first point
+            if (this.LineModeIsFirstPointSelected && this.LineModeFirstPointSelected.Id != tempFact.Id)
             {
-                //Event for end of line-drawing in "ShinyThings"
-                CommunicationEvents.StopLineDrawingEvent.Invoke(null);
+                this.DeactivateLineDrawing();
                 //Create LineFact
-                //Check if exactle the same line/distance already exists
-                if (!FactManager.factAlreadyExists(new int[] { FactManager.lineModeFirstPointSelected.Id, tempFact.Id }))
+                //Check if exactly the same line/distance already exists
+                if (!FactManager.factAlreadyExists(new int[] { this.LineModeFirstPointSelected.Id, tempFact.Id }))
+                    //TODO: That won't work anymore because of gadget-refactoring
                     if (ActiveToolMode == ToolMode.CreateLineMode)
-                        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(FactManager.lineModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
+                        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(this.LineModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
                     else
                     {
-                        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddRayFact(FactManager.lineModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
+                        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddRayFact(this.LineModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
 
                     }
 
-                FactManager.lineModeIsFirstPointSelected = false;
-                FactManager.lineModeFirstPointSelected = null;
+                this.ResetGadget();
             }
             else
             {
                 //Activate LineDrawing for preview
-                FactManager.lineModeIsFirstPointSelected = true;
-                FactManager.lineModeFirstPointSelected = tempFact;
-                //Event for start line-drawing in "ShinyThings"
-                CommunicationEvents.StartLineDrawingEvent.Invoke(FactManager.lineModeFirstPointSelected);
+                this.LineModeIsFirstPointSelected = true;
+                this.LineModeFirstPointSelected = tempFact;
+                this.ActivateLineDrawing();
+            }
+        }
+        /*
+        //if we want to spawn a new point
+        else if (Input.GetKey(KeyCode.LeftShift))
+        {
+            if (this.TapeModeIsFirstPointSelected)
+            {
+            
+                this.DeactivateLineDrawing();
+
+                SmallRocket(hit, this.TapeModeFirstPointSelected.Id);
+
+                this.ResetGadget();
+            }
+        }
+        */
+        //if we hit the top snap zone
+        else if (hit.transform.gameObject.tag == "SnapZone")
+        {
+            if (this.LineModeIsFirstPointSelected)
+            {
+
+                RaycastHit downHit;
+
+                if (Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out downHit))
+                {
+                    int idA = downHit.transform.gameObject.GetComponent<FactObject>().Id;
+                    int idB = this.LineModeFirstPointSelected.Id;
+                    int idC = FactManager.GetFirstEmptyID();
+                    CommunicationEvents.AddFactEvent.Invoke(FactManager.AddPointFact(hit, idC));
+                    this.DeactivateLineDrawing();
+                    //Create LineFact
+                    CommunicationEvents.AddFactEvent.Invoke(FactManager.AddAngleFact(idA, idB, idC, FactManager.GetFirstEmptyID()));
+                    this.LineModeIsFirstPointSelected = false;
+                    this.LineModeFirstPointSelected = null;
+                }
+            }
+        }
+        //If no Point was hit
+        else
+        {
+            if (this.LineModeIsFirstPointSelected)
+            {
+                //Deactivate LineDrawing and first point selection
+                this.ResetGadget();
+                this.DeactivateLineDrawing();
             }
+
+            //TODO: Hint that only a line can be drawn between already existing points
         }
     }
+
+    /*
+    //Creating 90-degree Angles
+    public void SmallRocket(RaycastHit hit, int idA)
+    {
+        //enable collider to measure angle to the treetop
+        int idB = this.GetFirstEmptyID();
+        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddPointFact(hit, idB));
+        Facts[idB].Representation.GetComponentInChildren<Collider>().enabled = true;
+        //third point with unknown height
+        int idC = FactManager.GetFirstEmptyID();
+        var skyHit = hit;
+        skyHit.point = (Facts[idA] as PointFact).Point + Vector3.up * 20;
+        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddPointFact(skyHit, idC));
+        //lines
+        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(idA, idB, this.GetFirstEmptyID()));
+        //lines
+        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(idA, idC, this.GetFirstEmptyID()));
+        //90degree angle
+        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddAngleFact(idB, idA, idC, GetFirstEmptyID()));
+    }*/
+
+    void Update()
+    {
+        if (!this.isActiveAndEnabled) return;
+        if (this.lineDrawingActivated)
+            UpdateLineDrawing();
+    }
+
+    private void ResetGadget()
+    {
+        this.LineModeIsFirstPointSelected = false;
+        this.LineModeFirstPointSelected = null;
+        DeactivateLineDrawing();
+    }
+
+    private void ActivateLineDrawing()
+    {
+        this.lineRenderer.positionCount = 2;
+        this.lineRenderer.material = this.linePreviewMaterial;
+
+        lineRenderer.startWidth = 0.095f;
+        lineRenderer.endWidth = 0.095f;
+        //Set LineDrawing activated
+        this.lineDrawingActivated = true;
+        //Add the position of the Fact for the start of the Line
+        linePositions.Add(this.LineModeFirstPointSelected.Representation.transform.position);
+        //The second point is the same point at the moment
+        linePositions.Add(this.LineModeFirstPointSelected.Representation.transform.position);
+
+        this.lineRenderer.SetPosition(0, linePositions[0]);
+        this.lineRenderer.SetPosition(1, linePositions[1]);
+
+    }
+
+    //Updates the second-point of the Line when First Point was selected in LineMode
+    private void UpdateLineDrawing()
+    {
+        this.linePositions[1] = this.Cursor.transform.position;
+        this.lineRenderer.SetPosition(1, this.linePositions[1]);
+    }
+
+    //Deactivate LineDrawing so that no Line gets drawn when Cursor changes
+    private void DeactivateLineDrawing()
+    {
+        this.lineRenderer.positionCount = 0;
+        this.linePositions = new List<Vector3>();
+        this.lineDrawingActivated = false;
+    }
 }
diff --git a/Assets/InventoryStuff/Inventory.meta b/Assets/RiverScene.unity.meta
similarity index 67%
rename from Assets/InventoryStuff/Inventory.meta
rename to Assets/RiverScene.unity.meta
index 354d69c1..aedd3378 100644
--- a/Assets/InventoryStuff/Inventory.meta
+++ b/Assets/RiverScene.unity.meta
@@ -1,6 +1,5 @@
 fileFormatVersion: 2
-guid: 8c00acf0711308b4eac44fb21f04a06f
-folderAsset: yes
+guid: ce8df78dfa3eaec4aba324235400c8dd
 DefaultImporter:
   externalObjects: {}
   userData: 
diff --git a/Assets/StreamingAssets.meta b/Assets/StreamingAssets.meta
deleted file mode 100644
index 7a25ae40..00000000
--- a/Assets/StreamingAssets.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 809deaa1d951e5741bce0ace20cdaed8
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 
diff --git a/Assets/Tape.cs b/Assets/Tape.cs
index 9c7aa5d3..f9e25478 100644
--- a/Assets/Tape.cs
+++ b/Assets/Tape.cs
@@ -5,6 +5,29 @@
 
 public class Tape : Gadget
 {
+    //Variables for LineMode distinction
+    private bool TapeModeIsFirstPointSelected = false;
+    private Fact TapeModeFirstPointSelected = null;
+
+    //Attributes for simulating the drawing of a line
+    private bool lineDrawingActivated;
+    public WorldCursor Cursor;
+    public LineRenderer lineRenderer;
+    private List<Vector3> linePositions = new List<Vector3>();
+    public Material linePreviewMaterial;
+
+    //Initialize Gadget when enabled AND activated
+    void OnEnable()
+    {
+        this.ResetGadget();
+    }
+
+    void Start()
+    {
+        if (FactManager == null) FactManager = GameObject.FindObjectOfType<FactManager>();
+        CommunicationEvents.TriggerEvent.AddListener(OnHit);
+        if (this.Cursor == null) this.Cursor = GameObject.FindObjectOfType<WorldCursor>();
+    }
 
     public override void OnHit(RaycastHit hit)
     {
@@ -14,37 +37,152 @@ public override void OnHit(RaycastHit hit)
             Fact tempFact = Facts[hit.transform.GetComponent<FactObject>().Id];
 
             //we can only reach points that are lower than that with the measuring tape
-            if (ActiveToolMode == ToolMode.CreateLineMode && tempFact.Representation.transform.position.y > 2.5f)
+            if (/*ActiveToolMode == ToolMode.CreateLineMode && */tempFact.Representation.transform.position.y > 2.5f)
                 return;
 
-            //no 0 distances
-            if (FactManager.lineModeIsFirstPointSelected && FactManager.lineModeFirstPointSelected.Id != tempFact.Id)
+            //If first point was already selected AND second point != first point
+            if (this.TapeModeIsFirstPointSelected && this.TapeModeFirstPointSelected.Id != tempFact.Id)
             {
-                //Event for end of line-drawing in "ShinyThings"
-                CommunicationEvents.StopLineDrawingEvent.Invoke(null);
+                this.DeactivateLineDrawing();
                 //Create LineFact
-                //Check if exactle the same line/distance already exists
-                if (!FactManager.factAlreadyExists(new int[] { FactManager.lineModeFirstPointSelected.Id, tempFact.Id }))
+                //Check if exactly the same line/distance already exists
+                if (!FactManager.factAlreadyExists(new int[] { this.TapeModeFirstPointSelected.Id, tempFact.Id }))
+                    //TODO: That won't work anymore because of gadget-refactoring
                     if (ActiveToolMode == ToolMode.CreateLineMode)
-                        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(FactManager.lineModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
+                        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(this.TapeModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
                     else
                     {
-                        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddRayFact(FactManager.lineModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
+                        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddRayFact(this.TapeModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
 
                     }
 
-                FactManager.lineModeIsFirstPointSelected = false;
-                FactManager.lineModeFirstPointSelected = null;
+                this.ResetGadget();
             }
             else
             {
                 //Activate LineDrawing for preview
-                FactManager.lineModeIsFirstPointSelected = true;
-                FactManager.lineModeFirstPointSelected = tempFact;
-                //Event for start line-drawing in "ShinyThings"
-                CommunicationEvents.StartLineDrawingEvent.Invoke(FactManager.lineModeFirstPointSelected);
+                this.TapeModeIsFirstPointSelected = true;
+                this.TapeModeFirstPointSelected = tempFact;
+                this.ActivateLineDrawing();
+            }
+        }
+        /*
+        //if we want to spawn a new point
+        else if (Input.GetKey(KeyCode.LeftShift))
+        {
+            if (this.TapeModeIsFirstPointSelected)
+            {
+            
+                this.DeactivateLineDrawing();
+
+                SmallRocket(hit, this.TapeModeFirstPointSelected.Id);
+
+                this.ResetGadget();
+            }
+        }
+        */
+        //if we hit the top snap zone
+        else if (hit.transform.gameObject.tag == "SnapZone")
+        {
+            if (this.TapeModeIsFirstPointSelected)
+            {
+
+                RaycastHit downHit;
+
+                if (Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out downHit))
+                {
+                    int idA = downHit.transform.gameObject.GetComponent<FactObject>().Id;
+                    int idB = this.TapeModeFirstPointSelected.Id;
+                    int idC = FactManager.GetFirstEmptyID();
+                    CommunicationEvents.AddFactEvent.Invoke(FactManager.AddPointFact(hit, idC));
+                    this.DeactivateLineDrawing();
+                    //Create LineFact
+                    CommunicationEvents.AddFactEvent.Invoke(FactManager.AddAngleFact(idA, idB, idC, FactManager.GetFirstEmptyID()));
+                    this.TapeModeIsFirstPointSelected = false;
+                    this.TapeModeFirstPointSelected = null;
+                }
+            }
+        }
+        //If no Point was hit
+        else
+        {
+            if (this.TapeModeIsFirstPointSelected)
+            {
+                //Deactivate LineDrawing and first point selection
+                this.ResetGadget();
+                this.DeactivateLineDrawing();
             }
+
+            //TODO: Hint that only a line can be drawn between already existing points
         }
     }
 
+    /*
+    //Creating 90-degree Angles
+    public void SmallRocket(RaycastHit hit, int idA)
+    {
+        //enable collider to measure angle to the treetop
+        int idB = this.GetFirstEmptyID();
+        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddPointFact(hit, idB));
+        Facts[idB].Representation.GetComponentInChildren<Collider>().enabled = true;
+        //third point with unknown height
+        int idC = FactManager.GetFirstEmptyID();
+        var skyHit = hit;
+        skyHit.point = (Facts[idA] as PointFact).Point + Vector3.up * 20;
+        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddPointFact(skyHit, idC));
+        //lines
+        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(idA, idB, this.GetFirstEmptyID()));
+        //lines
+        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(idA, idC, this.GetFirstEmptyID()));
+        //90degree angle
+        CommunicationEvents.AddFactEvent.Invoke(FactManager.AddAngleFact(idB, idA, idC, GetFirstEmptyID()));
+    }*/
+
+    void Update()
+    {
+        if (!this.isActiveAndEnabled) return;
+        if (this.lineDrawingActivated)
+            UpdateLineDrawing();
+    }
+
+    private void ResetGadget()
+    {
+        this.TapeModeIsFirstPointSelected = false;
+        this.TapeModeFirstPointSelected = null;
+        DeactivateLineDrawing();
+    }
+
+    private void ActivateLineDrawing()
+    {
+        this.lineRenderer.positionCount = 2;
+        this.lineRenderer.material = this.linePreviewMaterial;
+
+        lineRenderer.startWidth = 0.095f;
+        lineRenderer.endWidth = 0.095f;
+        //Set LineDrawing activated
+        this.lineDrawingActivated = true;
+        //Add the position of the Fact for the start of the Line
+        linePositions.Add(this.TapeModeFirstPointSelected.Representation.transform.position);
+        //The second point is the same point at the moment
+        linePositions.Add(this.TapeModeFirstPointSelected.Representation.transform.position);
+
+        this.lineRenderer.SetPosition(0, linePositions[0]);
+        this.lineRenderer.SetPosition(1, linePositions[1]);
+
+    }
+
+    //Updates the second-point of the Line when First Point was selected in LineMode
+    private void UpdateLineDrawing()
+    {
+        this.linePositions[1] = this.Cursor.transform.position;
+        this.lineRenderer.SetPosition(1, this.linePositions[1]);
+    }
+
+    //Deactivate LineDrawing so that no Line gets drawn when Cursor changes
+    private void DeactivateLineDrawing()
+    {
+        this.lineRenderer.positionCount = 0;
+        this.linePositions = new List<Vector3>();
+        this.lineDrawingActivated = false;
+    }
 }
diff --git a/Assets/TreeWorld_02.unity b/Assets/TreeWorld_02.unity
index 63fc63c0..9b5a621a 100644
--- a/Assets/TreeWorld_02.unity
+++ b/Assets/TreeWorld_02.unity
@@ -31464,7 +31464,6 @@ MonoBehaviour:
   defaultMaterial: {fileID: 2100000, guid: 8ae9adf4dc782964387385c1e8c0eb72, type: 2}
   highlightMaterial: {fileID: 2100000, guid: c7daa82e15f0cf04d92d0f41ce84f9df, type: 2}
   lineRenderer: {fileID: 1661088668}
-  linePreviewMaterial: {fileID: 2100000, guid: a8a7bf60a30970f469a9c9d3ae2de6ef, type: 2}
   anglePreviewMaterial: {fileID: 2100000, guid: 8a28cccde2536794c97ec91954e34e90,
     type: 2}
   directionalLight: {fileID: 138245305}
@@ -31483,7 +31482,6 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   SmartMenu: {fileID: 5601740127768851631, guid: e693bf633c633d243b0254d117ec3893,
     type: 3}
-  lineModeIsFirstPointSelected: 0
   angleModeIsFirstPointSelected: 0
   angleModeIsSecondPointSelected: 0
   snapZoneTop: {fileID: 1563243733}
@@ -40482,6 +40480,26 @@ PrefabInstance:
       propertyPath: GadgetUI
       value: 
       objectReference: {fileID: 339579026}
+    - target: {fileID: 1111866520, guid: 2ba8d552442ba664e8e567adee683a11, type: 3}
+      propertyPath: Cursor
+      value: 
+      objectReference: {fileID: 1661088666}
+    - target: {fileID: 1111866520, guid: 2ba8d552442ba664e8e567adee683a11, type: 3}
+      propertyPath: lineRenderer
+      value: 
+      objectReference: {fileID: 1661088668}
+    - target: {fileID: 1111866520, guid: 2ba8d552442ba664e8e567adee683a11, type: 3}
+      propertyPath: linePreviewMaterial
+      value: 
+      objectReference: {fileID: 2100000, guid: a8a7bf60a30970f469a9c9d3ae2de6ef, type: 2}
+    - target: {fileID: 1947773663, guid: 2ba8d552442ba664e8e567adee683a11, type: 3}
+      propertyPath: lineRenderer
+      value: 
+      objectReference: {fileID: 1661088668}
+    - target: {fileID: 1947773663, guid: 2ba8d552442ba664e8e567adee683a11, type: 3}
+      propertyPath: linePreviewMaterial
+      value: 
+      objectReference: {fileID: 2100000, guid: a8a7bf60a30970f469a9c9d3ae2de6ef, type: 2}
     - target: {fileID: 2198523595365450379, guid: 2ba8d552442ba664e8e567adee683a11,
         type: 3}
       propertyPath: m_LocalPosition.x
@@ -40979,6 +40997,11 @@ PrefabInstance:
       propertyPath: m_textInfo.pageCount
       value: 0
       objectReference: {fileID: 0}
+    - target: {fileID: 1082980752285692745, guid: c1d50ceff6c06de40b71063574eba754,
+        type: 3}
+      propertyPath: m_AnchoredPosition.y
+      value: 67
+      objectReference: {fileID: 0}
     - target: {fileID: 1082980752374527135, guid: c1d50ceff6c06de40b71063574eba754,
         type: 3}
       propertyPath: m_textInfo.characterCount
@@ -41124,6 +41147,21 @@ PrefabInstance:
       propertyPath: CursorRenderer
       value: 
       objectReference: {fileID: 1661088671}
+    - target: {fileID: 1082980752622642939, guid: c1d50ceff6c06de40b71063574eba754,
+        type: 3}
+      propertyPath: m_AnchoredPosition.x
+      value: 145
+      objectReference: {fileID: 0}
+    - target: {fileID: 1082980752622642939, guid: c1d50ceff6c06de40b71063574eba754,
+        type: 3}
+      propertyPath: m_AnchoredPosition.y
+      value: 1943
+      objectReference: {fileID: 0}
+    - target: {fileID: 1082980753171492196, guid: c1d50ceff6c06de40b71063574eba754,
+        type: 3}
+      propertyPath: m_AnchoredPosition.y
+      value: -242
+      objectReference: {fileID: 0}
     - target: {fileID: 1082980753599564270, guid: c1d50ceff6c06de40b71063574eba754,
         type: 3}
       propertyPath: m_textInfo.characterCount
diff --git a/Packages/manifest.json b/Packages/manifest.json
index 9592e4d3..16c70bc4 100644
--- a/Packages/manifest.json
+++ b/Packages/manifest.json
@@ -2,7 +2,7 @@
   "dependencies": {
     "com.unity.2d.sprite": "1.0.0",
     "com.unity.2d.tilemap": "1.0.0",
-    "com.unity.ads": "3.4.5",
+    "com.unity.ads": "3.4.7",
     "com.unity.analytics": "3.3.5",
     "com.unity.collab-proxy": "1.2.16",
     "com.unity.ide.rider": "1.1.4",
diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json
new file mode 100644
index 00000000..4313fec1
--- /dev/null
+++ b/Packages/packages-lock.json
@@ -0,0 +1,387 @@
+{
+  "dependencies": {
+    "com.unity.2d.sprite": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.2d.tilemap": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.ads": {
+      "version": "3.4.7",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {
+        "com.unity.ugui": "1.0.0"
+      },
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.analytics": {
+      "version": "3.3.5",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {
+        "com.unity.ugui": "1.0.0"
+      },
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.collab-proxy": {
+      "version": "1.2.16",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {},
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.ext.nunit": {
+      "version": "1.0.0",
+      "depth": 1,
+      "source": "registry",
+      "dependencies": {},
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.ide.rider": {
+      "version": "1.1.4",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {
+        "com.unity.test-framework": "1.1.1"
+      },
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.ide.vscode": {
+      "version": "1.2.1",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {},
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.multiplayer-hlapi": {
+      "version": "1.0.6",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {
+        "nuget.mono-cecil": "0.1.6-preview"
+      },
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.probuilder": {
+      "version": "4.2.1",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {
+        "com.unity.settings-manager": "1.0.0"
+      },
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.purchasing": {
+      "version": "2.0.6",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {},
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.settings-manager": {
+      "version": "1.0.0",
+      "depth": 1,
+      "source": "registry",
+      "dependencies": {},
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.test-framework": {
+      "version": "1.1.14",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {
+        "com.unity.ext.nunit": "1.0.0",
+        "com.unity.modules.imgui": "1.0.0",
+        "com.unity.modules.jsonserialize": "1.0.0"
+      },
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.textmeshpro": {
+      "version": "2.0.1",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {
+        "com.unity.ugui": "1.0.0"
+      },
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.timeline": {
+      "version": "1.2.6",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {},
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.ugui": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.ui": "1.0.0"
+      }
+    },
+    "com.unity.xr.legacyinputhelpers": {
+      "version": "2.1.4",
+      "depth": 0,
+      "source": "registry",
+      "dependencies": {},
+      "url": "https://packages.unity.com"
+    },
+    "nuget.mono-cecil": {
+      "version": "0.1.6-preview",
+      "depth": 1,
+      "source": "registry",
+      "dependencies": {},
+      "url": "https://packages.unity.com"
+    },
+    "com.unity.modules.ai": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.androidjni": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.animation": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.assetbundle": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.audio": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.cloth": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.physics": "1.0.0"
+      }
+    },
+    "com.unity.modules.director": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.audio": "1.0.0",
+        "com.unity.modules.animation": "1.0.0"
+      }
+    },
+    "com.unity.modules.imageconversion": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.imgui": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.jsonserialize": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.particlesystem": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.physics": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.physics2d": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.screencapture": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.imageconversion": "1.0.0"
+      }
+    },
+    "com.unity.modules.subsystems": {
+      "version": "1.0.0",
+      "depth": 1,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.jsonserialize": "1.0.0"
+      }
+    },
+    "com.unity.modules.terrain": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.terrainphysics": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.physics": "1.0.0",
+        "com.unity.modules.terrain": "1.0.0"
+      }
+    },
+    "com.unity.modules.tilemap": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.physics2d": "1.0.0"
+      }
+    },
+    "com.unity.modules.ui": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.uielements": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.imgui": "1.0.0",
+        "com.unity.modules.jsonserialize": "1.0.0"
+      }
+    },
+    "com.unity.modules.umbra": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.unityanalytics": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.unitywebrequest": "1.0.0",
+        "com.unity.modules.jsonserialize": "1.0.0"
+      }
+    },
+    "com.unity.modules.unitywebrequest": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.unitywebrequestassetbundle": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.assetbundle": "1.0.0",
+        "com.unity.modules.unitywebrequest": "1.0.0"
+      }
+    },
+    "com.unity.modules.unitywebrequestaudio": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.unitywebrequest": "1.0.0",
+        "com.unity.modules.audio": "1.0.0"
+      }
+    },
+    "com.unity.modules.unitywebrequesttexture": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.unitywebrequest": "1.0.0",
+        "com.unity.modules.imageconversion": "1.0.0"
+      }
+    },
+    "com.unity.modules.unitywebrequestwww": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.unitywebrequest": "1.0.0",
+        "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
+        "com.unity.modules.unitywebrequestaudio": "1.0.0",
+        "com.unity.modules.audio": "1.0.0",
+        "com.unity.modules.assetbundle": "1.0.0",
+        "com.unity.modules.imageconversion": "1.0.0"
+      }
+    },
+    "com.unity.modules.vehicles": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.physics": "1.0.0"
+      }
+    },
+    "com.unity.modules.video": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.audio": "1.0.0",
+        "com.unity.modules.ui": "1.0.0",
+        "com.unity.modules.unitywebrequest": "1.0.0"
+      }
+    },
+    "com.unity.modules.vr": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.jsonserialize": "1.0.0",
+        "com.unity.modules.physics": "1.0.0",
+        "com.unity.modules.xr": "1.0.0"
+      }
+    },
+    "com.unity.modules.wind": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {}
+    },
+    "com.unity.modules.xr": {
+      "version": "1.0.0",
+      "depth": 0,
+      "source": "builtin",
+      "dependencies": {
+        "com.unity.modules.physics": "1.0.0",
+        "com.unity.modules.jsonserialize": "1.0.0",
+        "com.unity.modules.subsystems": "1.0.0"
+      }
+    }
+  }
+}
diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt
index 7404e251..4b6255b4 100644
--- a/ProjectSettings/ProjectVersion.txt
+++ b/ProjectSettings/ProjectVersion.txt
@@ -1,2 +1,2 @@
-m_EditorVersion: 2019.4.1f1
-m_EditorVersionWithRevision: 2019.4.1f1 (e6c045e14e4e)
+m_EditorVersion: 2019.4.3f1
+m_EditorVersionWithRevision: 2019.4.3f1 (f880dceab6fe)
-- 
GitLab