Skip to content

Commit

Permalink
Agents now leave corpses on death.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewanderson committed Oct 13, 2010
1 parent 6eef9ce commit 1ea88de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Cas/Core/SimulationBase.cs
Expand Up @@ -330,9 +330,14 @@ private void ProcessLocation(ILocation location, List<KeyValuePair<IAgent, ILoca
// Deaths (remove from the back first)
for (int i = deathIndecies.Count - 1; i >= 0; i--)
{
// Kill the agent
var condemned = location.Agents[deathIndecies[i]];
location.Agents.RemoveAt(deathIndecies[i]);
this.RegisterDeath(condemned);

// Add a corpse object with the dead agent's genetic material to the location
var corpse = new Corpse(condemned);
location.CurrentResources.Add(corpse);
}

// Age all surviving agents
Expand Down
4 changes: 4 additions & 0 deletions Cas/Core/Species.cs
Expand Up @@ -139,6 +139,10 @@ public void RecordConsumptionOf(IIsUnique prey, int amount)

(prey as ISpecies).RecordPredation(this);
}
else if (prey is Corpse)
{
ResourcesFromAgents += amount;
}
else // IResourceNode
{
ResourcesFromResourceNodes += amount;
Expand Down
8 changes: 4 additions & 4 deletions Cas/WebCritters/WebCrittersForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ea88de

Please sign in to comment.