public Vector3 RegisterPersonForWaiting(Person person) { List <WaitLocation> freeWaitLocations = waitingPeople.Where(w => w.person == null).ToList(); if (freeWaitLocations.Count == 0) //no more wait locations, calculate some more { CalculateNewWaitLocations(); freeWaitLocations = waitingPeople.Where(w => w.person == null).ToList(); Debug.Log("All wait locations consumed. Generating more wait locations."); } WaitLocation waitLocation = freeWaitLocations [Random.Range(0, freeWaitLocations.Count())]; waitLocation.person = person; return(waitLocation.position); }
public void UnregisterPerson(Person person) { WaitLocation waitLocation = waitingPeople.FirstOrDefault(w => w.person == person); if (waitLocation != null) { waitLocation.person = null; //set person = null for this waitLocation } else { if (!nonWaitingPeople.Remove(person)) { Debug.LogWarning("A person could not be found to unregister."); Debug.DrawRay(person.transform.position, Vector3.up * 5f, Color.red, 5f); } } }