24 lines
820 B
C#
24 lines
820 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Grid {
|
|
public class GridObject {
|
|
public GridObject(GridSystem<GridObject> gridSystem, GridPosition gridPosition) {
|
|
GridSystem = gridSystem;
|
|
GridPosition = gridPosition;
|
|
UnitList = new();
|
|
}
|
|
|
|
private GridSystem<GridObject> GridSystem { get; }
|
|
private GridPosition GridPosition { get; }
|
|
public List<Unit> UnitList { get; }
|
|
public IInteractable Interactable { get; set; }
|
|
|
|
public override string ToString() {
|
|
string unitString = UnitList.Aggregate("", (current, unit) => current + (unit + "\n"));
|
|
return $"{GridPosition.ToString()}\n{unitString}";
|
|
}
|
|
|
|
public Unit GetUnit() => UnitList.Count > 0 ? UnitList[0] : null;
|
|
}
|
|
} |