void OnPickup(PickupPackage pickup) { // Check if we can pick it up if(pickup.WhoCanPickUp != Sides.Any && pickup.WhoCanPickUp != GetComponent<Faction>().Side) return; // Passed tests, log it as current pickup CurrentPickup = pickup; // React to parameters of the pickup if (pickup.MessageText != "") Message(pickup.MessageText); if (pickup.AttachesImmediately) Attach(); }
public void Detach() { CurrentPickup.Body.transform.parent = null; CurrentPickup.Body.GetComponent<Rigidbody>().isKinematic = false; // Launch pickup CurrentPickup.Body.GetComponent<Rigidbody>().velocity = gameObject.transform.forward * 10.0f; // Alignment CurrentPickup.Body.transform.forward = new Vector3(0, 0, 1); // Tell the pickup that it's free now CurrentPickup.Brain.SendMessage("OnDropping", SendMessageOptions.DontRequireReceiver); // Clear reference CurrentPickup = new PickupPackage(); }
// Tell the object that we're a pickup void OnTriggerEnter(Collider col) { var package = new PickupPackage(Body, gameObject, MessageText, AttachesImmediately, WhoCanPickUp); col.gameObject.SendMessage("OnPickup", package, SendMessageOptions.DontRequireReceiver); }
void OnPickupExit() { CurrentPickup = new PickupPackage(); }