1111 protected TextMesh [ , ] debugTextArray ;
1212
1313 // --- Events ---
14- public Action < Vector3 , T > OnValueChange ;
14+ public Action < Vector2Int , T > OnCellChange ;
1515 public bool showDebug ;
1616
1717 public int Width { get ; set ; }
@@ -52,7 +52,7 @@ public GridBase(int width, int height, float cellSize = 10f, Vector3 origin = de
5252 {
5353 if ( DefaultConstructor != null )
5454 {
55- gridArray [ x , y ] = ( T ) DefaultConstructor . Invoke ( new object [ ] { this , x , y } ) ;
55+ gridArray [ x , y ] = ( T ) DefaultConstructor . Invoke ( new object [ ] { this , x , y } ) ;
5656 } else
5757 {
5858 gridArray [ x , y ] = new T ( ) ;
@@ -63,12 +63,12 @@ public GridBase(int width, int height, float cellSize = 10f, Vector3 origin = de
6363 {
6464 var worldPosition = CellToWorld ( x , y ) ;
6565
66- debugTextArray [ x , y ] = UtilsClass . CreateWorldText (
67- text : gridArray [ x , y ] . ToString ( ) ,
68- parent : null ,
69- localPosition : worldPosition + new Vector3 ( cellSize , cellSize ) * 0.5f ,
70- fontSize : 20 ,
71- color : Color . white ,
66+ debugTextArray [ x , y ] = UtilsClass . CreateWorldText (
67+ text : gridArray [ x , y ] . ToString ( ) ,
68+ parent : null ,
69+ localPosition : worldPosition + new Vector3 ( cellSize , cellSize ) * 0.5f ,
70+ fontSize : 20 ,
71+ color : Color . white ,
7272 textAnchor : TextAnchor . MiddleCenter
7373 ) ;
7474
@@ -85,6 +85,11 @@ public GridBase(int width, int height, float cellSize = 10f, Vector3 origin = de
8585 }
8686 }
8787
88+ public virtual void TriggerCellChange ( Vector2Int cellPosition , T value = default )
89+ {
90+ OnCellChange ? . Invoke ( cellPosition , value ) ;
91+ }
92+
8893 public void SetCell ( int x , int y , T value )
8994 {
9095 if ( x >= 0 && y >= 0 && x < Width && y < Height )
@@ -93,7 +98,7 @@ public void SetCell(int x, int y, T value)
9398 debugTextArray [ x , y ] . text = value . ToString ( ) ;
9499 }
95100
96- OnValueChange ? . Invoke ( new Vector3 ( x , y ) , value ) ;
101+ OnCellChange ? . Invoke ( new Vector2Int ( x , y ) , value ) ;
97102 }
98103
99104 public void SetCell ( Vector3 worldPosition , T value )
0 commit comments