Skip to content
This repository was archived by the owner on Jul 11, 2024. It is now read-only.

Commit 9882dbc

Browse files
author
Grant Moore
authored
Merge pull request #7 from grantmoore3d/readme_docs
Readme docs
2 parents 9164580 + 77e15b8 commit 9882dbc

11 files changed

Lines changed: 930 additions & 329 deletions

File tree

CubeCoordinates/Runtime/Container.cs

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,109 @@
33

44
namespace CubeCoordinates
55
{
6+
/// <summary>
7+
/// Used to manage lists of Coordinate instances for a given label
8+
/// </summary>
69
public class Container
710
{
811
private string _label;
9-
public string label { get { return label; } }
12+
13+
public string label
14+
{
15+
get
16+
{
17+
return label;
18+
}
19+
}
1020

1121
private Dictionary<Vector3, Coordinate> _contents;
1222

23+
/// <summary>
24+
/// Constructor for Container which accepts a label and prepares the internal Dictionary
25+
/// </summary>
26+
/// <param name="label">Label string to name the Container</param>
1327
public Container(string label)
1428
{
1529
_label = label;
1630
_contents = new Dictionary<Vector3, Coordinate>();
1731
}
1832

33+
/// <summary>
34+
/// Add a Coordinate instance to the Container
35+
/// </summary>
36+
/// <param name="coordinate">Coordinate</param>
1937
public void AddCoordinates(Coordinate coordinate)
2038
{
21-
AddCoordinates(new List<Coordinate>{coordinate});
39+
AddCoordinates(new List<Coordinate> { coordinate });
2240
}
2341

42+
/// <summary>
43+
/// Add a Coordinate List instances to the Container
44+
/// </summary>
45+
/// <param name="coordinates">Coordinate List</param>
2446
public void AddCoordinates(List<Coordinate> coordinates)
2547
{
2648
foreach (Coordinate coordinate in coordinates)
27-
if (!_contents.ContainsKey(coordinate.cube))
28-
_contents.Add(coordinate.cube, coordinate);
49+
if (!_contents.ContainsKey(coordinate.cube))
50+
_contents.Add(coordinate.cube, coordinate);
2951
}
3052

53+
/// <summary>
54+
/// Remove a Coordinate instance from the Container
55+
/// </summary>
56+
/// <param name="coordinate">Coordinate</param>
3157
public void RemoveCoordinates(Coordinate coordinate)
3258
{
33-
RemoveCoordinates(new List<Coordinate>{coordinate});
59+
RemoveCoordinates(new List<Coordinate> { coordinate });
3460
}
3561

62+
/// <summary>
63+
/// Remove a Coordinate List from the Container
64+
/// </summary>
65+
/// <param name="coordinates">Coordinate List</param>
3666
public void RemoveCoordinates(List<Coordinate> coordinates)
3767
{
3868
foreach (Coordinate coordinate in coordinates)
39-
if (_contents.ContainsKey(coordinate.cube))
40-
_contents.Remove(coordinate.cube);
69+
if (_contents.ContainsKey(coordinate.cube))
70+
_contents.Remove(coordinate.cube);
4171
}
4272

73+
/// <summary>
74+
/// Remove all Coordinate instances from the Container
75+
/// </summary>
4376
public void RemoveAllCoordinates()
4477
{
4578
_contents.Clear();
4679
}
4780

81+
/// <summary>
82+
/// Gets a Coordinate matching the cube coordinate supplied, if found
83+
/// </summary>
84+
/// <param name="cube">Vector3 cube coordinate</param>
85+
/// <returns>Coordinate instance if found, null otherwise</returns>
4886
public Coordinate GetCoordinate(Vector3 cube)
4987
{
5088
Coordinate coordinate = null;
5189
_contents.TryGetValue(cube, out coordinate);
5290
return coordinate;
5391
}
5492

93+
/// <summary>
94+
/// Gets a Coordinate matching the closest rounded cube coordinate to the world transform position (Coordinate may not exist at rounded cube coordinate)
95+
/// </summary>
96+
/// <param name="position">Vector3 transform position in world space</param>
97+
/// <returns>Coordinate instance if found</returns>
5598
public Coordinate GetCoordinateFromWorldPosition(Vector3 position)
5699
{
57100
Vector3 cube = Cubes.ConvertWorldPositionToCube(position);
58101
return GetCoordinate(cube);
59102
}
60103

104+
/// <summary>
105+
/// Get a Coordinate List that match any of the supplied cube coordinates
106+
/// </summary>
107+
/// <param name="cubes">Vector3 List of cube coordinates</param>
108+
/// <returns>List of Coordinate instances found</returns>
61109
public List<Coordinate> GetCoordinates(List<Vector3> cubes)
62110
{
63111
List<Coordinate> results = new List<Coordinate>();
@@ -69,11 +117,19 @@ public List<Coordinate> GetCoordinates(List<Vector3> cubes)
69117
return results;
70118
}
71119

120+
/// <summary>
121+
/// Gets a Coordinate List of all Coordinate instances in the Container
122+
/// </summary>
123+
/// <returns>List of Coordinate instances</returns>
72124
public List<Coordinate> GetAllCoordinates()
73125
{
74126
return new List<Coordinate>(_contents.Values);
75127
}
76128

129+
/// <summary>
130+
/// Gets a Vector3 cube coordinate List for all Coordinate instances in the Container
131+
/// </summary>
132+
/// <returns>List of Vector3 cube coordinates</returns>
77133
public List<Vector3> GetAllCubes()
78134
{
79135
return new List<Vector3>(_contents.Keys);

CubeCoordinates/Runtime/Coordinate.cs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace CubeCoordinates
44
{
5+
/// <summary>
6+
/// Individual representation of a cube coordinate in the system
7+
/// </summary>
58
public class Coordinate
69
{
710
public enum Type
@@ -12,24 +15,62 @@ public enum Type
1215
}
1316

1417
private Vector3 _cube = Vector3.zero;
15-
public Vector3 cube { get { return _cube; } }
18+
19+
public Vector3 cube
20+
{
21+
get
22+
{
23+
return _cube;
24+
}
25+
}
1626

1727
private Vector3 _position = Vector3.zero;
18-
public Vector3 position { get { return _position; } }
28+
29+
public Vector3 position
30+
{
31+
get
32+
{
33+
return _position;
34+
}
35+
}
1936

2037
public float gCost = 0.0f;
38+
2139
public float hCost = 0.0f;
22-
public float fCost { get { return gCost + hCost; } }
40+
41+
public float fCost
42+
{
43+
get
44+
{
45+
return gCost + hCost;
46+
}
47+
}
2348

2449
private GameObject _go;
25-
public GameObject go { get { return _go; } }
2650

51+
public GameObject go
52+
{
53+
get
54+
{
55+
return _go;
56+
}
57+
}
58+
59+
/// <summary>
60+
/// Sets the Coordinate cube coordinate and world position
61+
/// </summary>
62+
/// <param name="cube"></param>
63+
/// <param name="position"></param>
2764
public Coordinate(Vector3 cube, Vector3 position)
2865
{
2966
_cube = cube;
3067
_position = position;
3168
}
3269

70+
/// <summary>
71+
/// Sets the GameObject which is associated with the Coordinate
72+
/// </summary>
73+
/// <param name="gameObject"></param>
3374
public void SetGameObject(GameObject gameObject)
3475
{
3576
_go = gameObject;

0 commit comments

Comments
 (0)