public void RemoveSlot(ZoneSlot gsm) { if (!slotlookup.ContainsKey(gsm.nodename)) { Debug.Log("Tried to remove non-existent slot with nodename:" + gsm.nodename); return; } slotlookup.Remove(gsm.nodename); }
public void AddSlot(ZoneSlot zsm) { if (slotlookup.ContainsKey(zsm.nodename)) { Debug.Log("Tried to add duplicate slot with nodename:" + zsm.nodename); return; } slotlookup[zsm.nodename] = zsm; }
public ZoneSlot GetClosestFreePerson(Vector3 position) { float mindist = 9e10f; ZoneSlot minslot = null; foreach (var zslt in slots.Values) { if (zslt.occupied && !zslt.slotreserved && zslt.connected) { float d = Vector3.Distance(position, zslt.transform.position); if (d <= mindist) { mindist = d; minslot = zslt; } } } return(minslot); }
public ZoneSlot GetClosestAvailableSlot(Vector3 position) { float mindist = 9e10f; ZoneSlot minslot = null; foreach (var zslt in slots.Values) { if (zslt.slotstate == zslotstateE.available && zslt.connected) { float d = Vector3.Distance(position, zslt.transform.position); if (d <= mindist) { mindist = d; minslot = zslt; } } } return(minslot); }
public ZoneSlot GetClosestFreeSlot(Vector3 position, float maxzonedistance = 250) { float mindist = 9e10f; ZoneSlot minslot = null; foreach (var grg in zonelookup.Values) { if (Vector3.Distance(position, grg.GetPosition()) < maxzonedistance) { var sm = grg.GetClosestFreePerson(position); if (sm != null) { float d = Vector3.Distance(position, sm.GetPosition()); if (d < mindist) { mindist = d; minslot = sm; } } } } return(minslot); }
// Use this for initialization public ZoneSlot GetClosestAvailableSlot(Vector3 position, float maxgaragedist = 250) { float mindist = 9e10f; ZoneSlot minslot = null; foreach (var zone in zonelookup.Values) { if (Vector3.Distance(position, zone.GetPosition()) < maxgaragedist) { var sm = zone.GetClosestAvailableSlot(position); if (sm != null) { float d = Vector3.Distance(position, sm.GetPosition()); if (d < mindist) { mindist = d; minslot = sm; } } } } return(minslot); }