public void AddCell(Cell cell) { // add event handler for logging event of the cell cell.LogEvent += new EventHandler<LogEventArgs>(Cell_LogEvent); AddChild(cell); cell.Parent = this; Log(cell.Type + " added to me.", LogLevel.Minor); }
public void RemoveCell(Cell cell) { cell.Parent = null; cell.LogEvent -= Cell_LogEvent; if (RemoveChild(cell)) { Log(cell.Type + " cell removed from me.", LogLevel.Minor); } }
/// <summary> /// Sends a cell to a randomly-selected type-specific tissue. /// </summary> /// <param name="cell">The cell to be sent to another tissue.</param> /// <param name="tissueType">The type of destination tissue.</param> protected void SendCellToRandomTissue(Cell cell, TissueType tissueType) { var typeAddresses = from address in addressList where (address.Value == tissueType) select address.Key; var typeCount = typeAddresses.Count(); if (typeCount > 0) { int randIx = RandGen.Next(0, typeCount); SendCell(cell, typeAddresses.ElementAt(randIx)); } }
/// <summary> /// Sends a cell to the tissue with the specified address. /// </summary> /// <param name="cell"></param> /// <param name="toAddress"></param> protected void SendCell(Cell cell, Address toAddress) { if (Agents.Contains(cell)) { RemoveCell(cell); } // TODO: the send delay is dummy Mediator.Send(AddCell, toAddress, 0.01, cell); Log(cell.Type + " was sent to tissue " + toAddress, LogLevel.Minor); }