public PickupItem OffLoad() { if (_payload == null) { return(null); } _payload.transform.parent = null; var item = _payload; _payload = null; return(item); }
public bool Pickup(PickupItem item) { if (_target != item) { return(false); } _target = null; _payload = item; _payload.transform.parent = this.transform; _payload.transform.localPosition = Vector3.up; _master.PickupComplete(this); return(true); }
public void RegisterItem(PickupItem item) { //The result callback for use with our path request Action <PathResult> callback = (result) => { //If a path was not found, that means the item is inaccessible if (result.status != PathingStatus.Complete) { return; } //Once a result is received, the item is added to the priority queue, with the cost of the path as the priority. //This ensures that the items closest to the master will be at the font of the queue, and hence will be the first to be picked up. //Since this example shows two possible options on how to use a manual request, the item is stored with its path var entry = new ItemEntry { item = item, pathToItem = result.path }; //Since the callback is marshalled onto the main thread, there is no need to synchronize access _itemsForPickup.Enqueue(entry, result.pathCost); }; //The radius should of course be taken off the unit type that is doing the pick-up, but keeping it simple... var req = new CallbackPathRequest(callback) { from = this.transform.position, to = item.transform.position, type = this.requestType, requesterProperties = _workerModel, pathFinderOptions = _workerModel.pathFinderOptions }; GameServices.pathService.QueueRequest(req); }
public void SetTarget(PickupItem item) { _target = item; }