Exemple #1
0
        public void Connect(GameObject jointGameObject, JointPoint jointPoint, bool sender = true)
        {
            if (!IsFree || jointPoint == null)
            {
                return;
            }

            IsFree = false;
            _connectedGameObject = jointGameObject;
            IWrapperAware wrapperAware = _connectedGameObject.GetComponentInChildren<IWrapperAware>();

            if (wrapperAware != null)
            {
                _connectedWrapper = wrapperAware.Wrapper();
                JointBehaviour.AddConnectedJoint(_connectedWrapper, jointPoint.JointBehaviour);
            }

            if (sender)
            {
                var jointConnectedBody = _connectedGameObject.GetComponent<Rigidbody>();

                if (jointConnectedBody != null && !jointConnectedBody.isKinematic)
                {
                    _fixedJoint = JointBehaviour.gameObject.AddComponent<FixedJoint>();
                    _fixedJoint.connectedBody = jointConnectedBody;
                    _fixedJoint.breakForce = 600f;
                    _fixedJoint.breakTorque = 600f;
                }
            }

            ConnectedJointPoint = jointPoint;
            ConnectedJointPoint.Connect(JointBehaviour.gameObject, this, false);
        }
Exemple #2
0
        private void Start()
        {
            CreateConnectionPreview();
            RegisterIntractableEvents();

            IWrapperAware wrapperAware = gameObject.GetComponentInChildren <IWrapperAware>();

            Wrapper = wrapperAware != null?wrapperAware.Wrapper() : new NullWrapper(gameObject);

            _rigidbody     = gameObject.GetComponent <Rigidbody>();
            _parentOnStart = transform.parent;
        }
        public void AddWrapper()
        {
            IWrapperAware wrapperAware = RootGameObject.GetComponentInChildren <IWrapperAware>();

            if (wrapperAware != null)
            {
                Wrapper wrapper = wrapperAware.Wrapper();
                WrappersCollection.Add(Id, wrapper);
                Entity.AddWrapper(wrapper);
                wrapper.InitEntity(Entity);
            }
        }
Exemple #4
0
 public static void EnableTouch(this IWrapperAware self, GameObject go) => self.Wrapper().GetInputController(go)?.EnableViewTouch();
Exemple #5
0
 public static void DisableInputGrab(this IWrapperAware self, GameObject go) => self.Wrapper().GetInputController(go)?.DisableViewGrab();
Exemple #6
0
 public static void EnableInputUsing(this IWrapperAware self, GameObject go) => self.Wrapper().GetInputController(go)?.EnableInputUsing();
 private void Create()
 {
     _wrapperAware = GetComponentInChildren <IWrapperAware>();
 }