Skip to content

Commit f417095

Browse files
Create README.md
1 parent 2eb13b0 commit f417095

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Quickstart Guide/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Important considerations
2+
3+
## Cells are structures
4+
In csharp structures are passed by value, and not by reference. This means the following code will **NOT** do anything. See the [C# reference](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct) for more information.
5+
```csharp
6+
var targetCell = _cellGrid.GetCell(target);
7+
//Both targetCell and targetCell.Transform are structures, meaning this code won't do anything.
8+
targetCell.Value.Transform.Position = new Vector2Int(0, 0);
9+
```
10+
11+
### Updating Cell Position
12+
To update a cell and replace it in the cell grid first remove the cell you want to edit, then add it back with it's updated properties.
13+
```csharp
14+
cellGrid.RemoveCell(cell);
15+
//Update cell transform without loosing cell direction
16+
cell.Transform = cell.Transform.SetPosition(new Vector2Int(0, 0));
17+
cellGrid.AddCell(cell);
18+
```
19+
20+
alternatively, you can use `cellGrid.MoveCell(cell, target);` for a much simpler implementation.
21+
```csharp
22+
//equivalent to previous example
23+
_cellGrid.MoveCell(useCell, target);
24+
```
25+
26+
### Updating Cell Rotation
27+
To update a cell and replace it in the cell grid first remove the cell you want to edit, then add it back with it's updated properties.
28+
```csharp
29+
cellGrid.RemoveCell(cell);
30+
//Update cell transform without loosing cell direction
31+
cell.Transform = cell.Transform.SetDirection(Direction.Up);
32+
cellGrid.AddCell(cell);
33+
```
34+
35+
alternatively, you can use `cellGrid.MoveCell(cell, target);` for a much simpler implementation.
36+
```csharp
37+
//equivalent to previous example
38+
_cellGrid.RotateCell(useCell, newRotation);
39+
```

0 commit comments

Comments
 (0)