33
44namespace 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 ) ;
0 commit comments