using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class GridObject
{
private GridSystem<GridObject> gridSystem;
private GridPosition gridPosition;
private List<Unit> unitList;
public IInteractable interactable;
public void AddUnit(Unit unit) {
unitList.Add(unit);
}
public void RemoveUnit(Unit unit) {
unitList.Remove(unit);
}
public bool HasAnyUnitOnGridPosition() {
return (unitList.Count > 0);
}
public List<Unit> GetUnitList() => unitList;
public Unit GetUnit() {
Unit unitOnGridPosition = null;
if (HasAnyUnitOnGridPosition()) {
unitOnGridPosition = unitList[0];
}
return unitOnGridPosition;
}
public GridObject(GridSystem<GridObject> gridSystem, GridPosition gridPosition)
{
this.gridSystem = gridSystem;
this.gridPosition = gridPosition;
this.unitList = new List<Unit>();
}
public override string ToString()
{
string units = "";
foreach (Unit unit in unitList) {
units += $"\n {unit}";
}
return $"{gridPosition.ToString()}{units}";
}
}