12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace KairoEngine.Grids
- {
- public class GridObject
- {
- private Grid<GridObject> grid;
- private int x;
- private int y;
- private int z;
- private PlacedObject placedObject;
- public GridObject(Grid<GridObject> grid, int x, int y, int z)
- {
- this.grid = grid;
- this.x = x;
- this.y = y;
- this.z = z;
- }
- public PlacedObject GetPlacedObject() => this.placedObject;
- public void SetPlacedObject(PlacedObject placedObject)
- {
- this.placedObject = placedObject;
- grid.TriggerGridObjectChanged(x, z);
- }
- public void ClearPlacedObject() => this.placedObject = null;
- public bool CanBuild() => this.placedObject == null;
- public override string ToString() => $"{x}, {z}";
- public Vector3Int GetPosition() => new Vector3Int(x, y, z);
- }
- }
|