public void Toggle() { if (BOUND_OBJECT) { BOUND_OBJECT.Unbind(); _bound_object = null; } DebugLogging.DrawDebugRay( transform.position, Constants.PLAYER_INTERACTION_DISTANCE * transform.forward); RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, Constants.PLAYER_INTERACTION_DISTANCE, Constants.INTERACTABLE_CULLING_MASK)) { InteractableObjectBindable obj_bindable = Lib.GetComponentInTree <InteractableObjectBindable> (hit.collider.gameObject); if (!obj_bindable) { InteractableObject obj = Lib.GetComponentInTree <InteractableObject> (hit.collider.gameObject); obj.Interacted(); return; } else { _bound_object = obj_bindable; BOUND_OBJECT.Bind(this); return; } } else { //Eventually we'll play a sound or something here. Maybe draw a raycast. } }
int GetRoomId() { RaycastHit hit; if (Physics.Raycast(transform.position, Vector3.down, out hit, Constants.ROOM_DETECTION_RAYCAST_DISTANCE, Constants.ROOM_DETECTION_CULLING_MASK)) { return(hit.transform.GetComponentInParent <RoomObject> ().id); } DebugLogging.DrawDebugRay(transform.position, new Vector3(0, -Constants.ROOM_DETECTION_RAYCAST_DISTANCE, 0)); return(-1); }