/// <summary> /// Create a new state object to represent an organism. /// </summary> /// <param name="id">The GUID ID representing this organism in the world.</param> /// <param name="species">The species which defines the basic properties of the organism.</param> /// <param name="generation">The familial generation number.</param> /// <param name="initialEnergyState">The initial EnergyState of the organism.</param> /// <param name="initialRadius">The initial Radius of the organism.</param> internal OrganismState(string id, ISpecies species, int generation, EnergyState initialEnergyState, int initialRadius) { DeathReason = PopulationChangeReason.NotDead; ID = id; Species = species; Generation = generation; SetStoredEnergyInternal(OrganismState.UpperBoundaryForEnergyState(species, initialEnergyState, initialRadius)); Radius = initialRadius; _events = new OrganismEventResults(); _currentPosition = new Point(); }
/// <internal/> public override sealed void InternalMain(bool clearOnly) { OrganismEventResults events = State.OrganismEvents; // Call Initialize once if (!IsInitialized) { Initialize(); IsInitialized = true; } if (events != null) { if (events.ReproduceCompleted != null) { if (InProgressActions.ReproduceAction != null && events.ReproduceCompleted.ActionID == InProgressActions.ReproduceAction.ActionID) { InProgressActions.SetReproduceAction(null); } } } if (CanReproduce) { BeginReproduction(null); } if (clearOnly) { InternalTurnsSkipped++; } else { InternalTurnsSkipped = 0; } }