void UpdateResidentsAge() { //iterate backwards to not have any problems with removing residents or children for (int i = Residents.Count - 1; i >= 0; i--) { Prole p = Residents[i]; bool diseased = p.diseased; p.UpdateAge(); if (!p.diseased && diseased) { RemoveDiseasedResident(); //if resident was diseased and is no longer bc time ran out, remove one from the diseased count } //the reason we age children here and not in Prole.UpdateAge() is so we can detect death and coming of age for (int j = p.children.Count - 1; j >= 0; j--) { Child c = p.children[j]; bool diseasedC = c.diseased; c.UpdateAge(); if (!c.diseased && diseasedC) { RemoveDiseasedResident(); //if the child was diseased and is no longer bc time ran out, remove one from the diseased count } //do if c is dead if (c.markedForDeath) { //if c was diseased upon death, remove one from diseased count if (c.diseased) { RemoveDiseasedResident(); } p.children.Remove(c); c.Kill(); Corpses++; } //do if c is grown up else if (c.GrownUp) { ReceiveImmigrant(p.GrowUpChild(c)); p.children.Remove(c); } } //do if p is about to die if (p.markedForDeath) { //if c was diseased upon death, remove one from diseased count if (p.diseased) { RemoveDiseasedResident(); } p.Kill(); population.RemoveProle(p); Corpses++; } } }
void SendOutProspects() { //iterate backwards to avoid problems from removing prospects for (int i = Prospects.Count - 1; i >= 0; i--) { Prole prospect = Prospects[i]; if (prospect.rejected) //send prospect out of it is rejected or now too old to work or has waited for too long (regardless of hire status) { SendAwayProspect(prospect); } else if (prospect.accepted) { HireProspect(prospect); } prospect.UpdateAge(); //here we can have the prospect age and also countdown to leaving if they waited for too long } }