private bool DeleteObject <T> (T node) { if (node is Zone zone) { try { var _z = Zones.SingleOrDefault(a => a.ID == zone.ID); _z.KillMe(); RemoveChild(zone); Zones.Remove(_z); return(true); } catch (System.Exception) { return(false); } } else if (node is Building building) { try { var _z = Buildings.SingleOrDefault(a => a.Position == building.Position); _z.QueueFree(); RemoveChild(building); Buildings.Remove(_z); return(true); } catch (System.Exception) { return(false); } } else if (node is Road road) { try { var _z = Roads.SingleOrDefault(a => a.Position == road.Position); _z.QueueFree(); RemoveChild(road); Roads.Remove(_z); return(true); } catch (System.Exception) { return(false); } } else { return(false); } }