Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static CommunicationEvents;
public class Tape : Gadget
{
public override void OnHit(RaycastHit hit)
{
if (!this.isActiveAndEnabled) return;
if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Point"))
{
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)
return;
//no 0 distances
if (FactManager.lineModeIsFirstPointSelected && FactManager.lineModeFirstPointSelected.Id != tempFact.Id)
{
//Event for end of line-drawing in "ShinyThings"
CommunicationEvents.StopLineDrawingEvent.Invoke(null);
//Create LineFact
//Check if exactle the same line/distance already exists
if (!FactManager.factAlreadyExists(new int[] { FactManager.lineModeFirstPointSelected.Id, tempFact.Id }))
if (ActiveToolMode == ToolMode.CreateLineMode)
CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(FactManager.lineModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
else
{
CommunicationEvents.AddFactEvent.Invoke(FactManager.AddRayFact(FactManager.lineModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
}
FactManager.lineModeIsFirstPointSelected = false;
FactManager.lineModeFirstPointSelected = null;
}
else
{
//Activate LineDrawing for preview
FactManager.lineModeIsFirstPointSelected = true;
FactManager.lineModeFirstPointSelected = tempFact;
//Event for start line-drawing in "ShinyThings"
CommunicationEvents.StartLineDrawingEvent.Invoke(FactManager.lineModeFirstPointSelected);
}
}
}
}