public NeedSatisfier GetNearestSatisfier(Employee.SatisfactionStatus key, Vector3 position) { if (!Satisfiers.ContainsKey(key)) { return(null); } List <NeedSatisfier> satisfiers = Satisfiers[key]; // If there's no satisfier available (this is, if they're all being used or there aren't any) return null. NeedSatisfier nearestSatisfier = null; float lastDistance = Mathf.Infinity; foreach (NeedSatisfier satisfier in satisfiers) { if (!satisfier.isAvailable) { // Can't use this guy... next! continue; } float distance = Vector3.Distance(satisfier.transform.position, position); if (distance < lastDistance) { lastDistance = distance; nearestSatisfier = satisfier; } } return(nearestSatisfier); }
public void AddSatisfier(Employee.SatisfactionStatus key, NeedSatisfier satisfier) { if (!Satisfiers.ContainsKey(key)) { Satisfiers[key] = new List <NeedSatisfier>(); } Satisfiers[key].Add(satisfier); }
public void RemoveSatisfier(Employee.SatisfactionStatus key, NeedSatisfier satisfier) { if (!Satisfiers.ContainsKey(key)) { return; } Satisfiers[key].Remove(satisfier); }
public List <NeedSatisfier> GetSatisfierList(Employee.SatisfactionStatus key) { if (Satisfiers.ContainsKey(key)) { return(Satisfiers[key]); } else { return(null); } }