private IPlantCell ClosestTransporterCell(PlantCellType type, IPlantCell current, IEnumerable <IPlantCell> cells) { float closestDistance = float.MaxValue; IPlantCell closestCell = null; foreach (var cell in cells) { if (cell.CellType != type) { continue; } float distance = Vector3.Distance(cell.Geometry.TopCenter, current.Geometry.TopCenter); if (distance < closestDistance) { closestDistance = distance; closestCell = cell; } } if (closestCell == null) { logger.LogFatal("Could not find closest cell of type {CellType} for cell at {Cell}", type, current.Geometry.TopCenter); } return(closestCell); }
public FluidCarrier(IPlantCell destination, IPlantCell current, IPlantCell closestTransportCell, PlantCellType transportType, TFluid fluid) { Destination = destination; Current = current; ClosestTransportCell = closestTransportCell; this.transportType = transportType; Fluid = fluid; }
public IPlantCell CreateCell(PlantCellType type, Vector3 center, float radius, float height) { var geometry = CreateCellGeometry(center, radius, height); var vacuole = new Vacuole(); var wall = new CellWall(); return(cellFactory.CreateCell(type, geometry, vacuole, wall)); }
public void Add(PlantCellType type, int r, int c) { if (typeGrid.TryGetValue(r, out var g)) { g[c] = type; } else { typeGrid[r] = new Dictionary <int, PlantCellType>(new[] { KeyValuePair.Create(c, type) }); } }
/// <summary> /// Helper method to instantiate a new plant cell type based on the provided type /// </summary> /// <param name="type">The type of cell to new</param> /// <param name="geometry">The new geometry</param> /// <param name="vacuole">The vacuole organ</param> /// <param name="wall">The cell wall</param> /// <param name="neighbors">The neighboring plant cells</param> /// <returns>New cell of type <see cref="type"/> with provided parameters</returns> private IPlantCell InstantiateCell(PlantCellType type, ICellGeometry geometry, IVacuole vacuole, ICellWall wall) { switch (type) { case PlantCellType.Xylem: return(new XylemCell(geometry, vacuole, wall)); case PlantCellType.Phloem: return(new PhloemCell(geometry, vacuole, wall)); case PlantCellType.Sclerenchyma: return(new SclerenchymaCell(geometry, vacuole, wall)); case PlantCellType.Collenchyma: return(new CollenchymaCell(geometry, vacuole, wall)); case PlantCellType.Parenchyma: return(new ParenchymaCell(geometry, vacuole, wall)); default: throw new ArgumentOutOfRangeException(nameof(type), type, "Invalid Plant Cell Type"); } }
private IPlantCell CreatePlantCell(PlantCellType type, ICellGeometry geometry, IVacuole vacuole, ICellWall cellWall) { return(cellFactory.CreateCell(type, geometry, vacuole, cellWall)); }
/// <summary> /// Helper method to instantiate a new plant cell type based on the provided type /// </summary> /// <param name="type">The type of cell to new</param> /// <param name="geometry">The new geometry</param> /// <param name="vacuole">The vacuole organ</param> /// <param name="wall">The cell wall</param> /// <param name="neighbors">The neighboring plant cells</param> /// <returns>New cell of type <see cref="type"/> with provided parameters</returns> public IPlantCell CreateCell(PlantCellType type, ICellGeometry geometry, IVacuole vacuole, ICellWall wall) { return(InstantiateCell(type, geometry, vacuole, wall)); }