-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vertex.cs
54 lines (46 loc) · 1.14 KB
/
Vertex.cs
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
51
52
53
54
using System.Collections.Generic;
using UnityEngine;
public class Vertex
{
public Vector3 Position;
public HashSet<Edge> Edges;
public SelectableVertex Selectable;
public VertexRenderer Renderer;
public Vertex(Vector3 position)
{
Position = position;
Edges = new HashSet<Edge>();
Selectable = new SelectableVertex(this);
Renderer = new VertexRenderer(this);
}
public Edge AddEdge(Vertex target)
{
Edge edge = new Edge(this, target);
Edges.Add(edge);
return edge;
}
public void RemoveEdge(Vertex target)
{
foreach (Edge edge in Edges)
{
if (edge.Destination == target)
{
Edges.Remove(edge);
return;
}
}
}
public List<Vertex> GetConnectedVertices()
{
List<Vertex> connectedVertices = new List<Vertex>();
foreach (Edge edge in Edges)
{
connectedVertices.Add(edge.Destination);
}
return connectedVertices;
}
public void MoveTo(Vector3 position)
{
Position = position;
}
}