//A method for populating the routine
void populateRoutine(){
ps.routine.Clear();
if (ps.occupations.Count >= 1){
foreach (GameObject go in ps.occupations){
OccupationStats os = go.GetComponent<OccupationStats>();
ps.routine.AddRange(copyRoutine(os.schedule));
}
}
ps.routine.AddRange(dynamicRoutine);
dynamicRoutine.Clear();
}
Routines can also be dynamically added to the same day by simply adding a RoutineEntry to the routine list Schedule of an NPC.
I tested this out by scheduling a funeral the next day for every NPC who knew and liked the deceased NPC.
void arrangeFuneral(PersonStats ps){
RelationshipHelper rh = GameObject.Find("Relationships").GetComponent<RelationshipHelper>();
//Foreach person who knew the deceased
foreach(GameObject go in ps.contacts){
//If the strength of the relationship was greater than -20
if(rh.getStrengthValue(ps.gameObject,go) > -20){
//Create a new Routine entry and add it to the dynamic routine of the contact
RoutineEntry re = new RoutineEntry();
re.startHour = 9;
re.startMinute = 0;
re.endHour = 16;
re.endMinute = 0;
re.location = ps.gameObject.transform.FindChild("Body").gameObject;
re.done = false;
re.priority = 10;
if (go != null){
go.transform.FindChild("Body").GetComponent<PersonMovement>().dynamicRoutine.Add(re);
}
}
}
}
While these simple systems work rather nicely, it is still very limited. Ideally events should be scheduled for weeks in advance.
However thinking about it, this could be made possible with a small adaption to the way the dynamicRoutine and routine lists merge. Items from the dynamicRoutine list should only be added to the routine list if a condition is met, for instance the day number.
No comments:
Post a Comment