void OnTriggerEnter(Collider col) { WeldableObject obj = col.GetComponent <WeldableObject>(); if (obj && !overlapping.Contains(obj)) { overlapping.Add(obj); print("Enter"); } }
void OnTriggerExit(Collider col) { WeldableObject obj = col.GetComponent <WeldableObject>(); if (obj) { obj.isWeldTarget = false; overlapping.Remove(obj); print("Exit"); } }
void PropagatePickup(int button, bool isHeld) { if (held != isHeld) { held = isHeld; if (held) { CreateTriggers(); } else { DestroyTriggers(); readyForWeld = true; } foreach (WeldableObject obj in GetComponentsInChildren <WeldableObject>()) { if (obj != this) { if (isHeld) { obj.Pickup(button); } else { obj.Drop(button); } } } Controller interactor = transform.root.GetComponent <PhysicsObject>().interactor; foreach (WeldableObject obj in weldedObjects) { WeldableObject obj2 = obj.transform.root.GetComponent <WeldableObject>(); if (obj2 && obj2.canPickup) { obj2.currentButton = button; if (interactor) { obj2.localPickupPosition = interactor.transform.InverseTransformPoint(obj2.transform.position); obj2.localPickupRotation = Quaternion.Inverse(interactor.transform.rotation) * obj2.transform.rotation; } obj2.interactor = interactor; obj2.PropagatePickup(button, isHeld); } } } }
private bool PropagateThroughWelds(WeldableObject obj) { if (obj && !currentInteraction.Contains(obj)) { if (!obj.canPickup) { return(false); } currentInteraction.Add(obj); bool b = obj.canPickup; foreach (WeldableObject other in obj.weldedObjects) { b &= PropagateThroughWelds(other.transform.root.GetComponent <WeldableObject>()); } for (int i = 0; i < obj.transform.childCount; i++) { b &= PropagateThroughWelds(obj.transform.GetChild(i).GetComponent <WeldableObject>()); } if (b) { return(true); } else { currentInteraction.Remove(obj); return(false); } } return(true); }