コード例 #1
0
        public JointData GetJointData()
        {
            JointData jointData;

            JointBehaviour jointBehaviour = RootGameObject.GetComponent <JointBehaviour>();

            if (jointBehaviour == null)
            {
                return(null);
            }

            jointData = new JointData {
                JointConnetionsData = new Dictionary <int, JointConnetionsData>()
            };

            foreach (JointPoint jointPoint in jointBehaviour.JointPoints)
            {
                if (jointPoint.IsFree)
                {
                    continue;
                }

                var objectId = jointPoint.gameObject.GetComponent <ObjectId>();

                if (objectId == null)
                {
                    LogManager.GetCurrentClassLogger().Error($"Joint point {jointPoint.gameObject} have no object id");

                    continue;
                }

                var connectedJointPointObjectId = jointPoint.ConnectedJointPoint.gameObject.GetComponent <ObjectId>();

                if (connectedJointPointObjectId == null)
                {
                    LogManager.GetCurrentClassLogger()
                    .Error($"Connected joint point {jointPoint.ConnectedJointPoint.gameObject} have no object id");

                    continue;
                }

                int jointPointId = objectId.Id;
                int connectedObjectInstanceId   = jointPoint.ConnectedJointPoint.JointBehaviour.Wrapper.GetInstanceId();
                int connectedObjectJointPointId = connectedJointPointObjectId.Id;

                jointData.JointConnetionsData.Add(jointPointId,
                                                  new JointConnetionsData
                {
                    ConnectedObjectInstanceId   = connectedObjectInstanceId,
                    ConnectedObjectJointPointId = connectedObjectJointPointId,
                    ForceLocked = jointPoint.IsForceLocked
                });
            }

            return(jointData);
        }
コード例 #2
0
        public void Delete()
        {
            List <ObjectBehaviourWrapper> childrens =
                RootGameObject.GetComponentsInChildren <ObjectBehaviourWrapper>().ToList();

            childrens.Reverse();

            JointBehaviour jointBehaviour = RootGameObject.GetComponent <JointBehaviour>();

            if (jointBehaviour != null)
            {
                jointBehaviour.UnLockAndDisconnectPoints();
            }


            foreach (var children in childrens)
            {
                ObjectController type = children.OwdObjectController;
                WrappersCollection.Remove(type.Id);

                foreach (ColliderController colliderController in type._colliderControllers)
                {
                    colliderController.Destroy();
                }

                foreach (InputController inputController in type._inputControllers.Values)
                {
                    inputController.Destroy();
                }

                type.OnDestroy?.Invoke();
                type.Entity?.Destroy();

                if (type.Uiid != null)
                {
                    Object.Destroy(type.Uiid.gameObject);
                }

                if (type.UiObject != null)
                {
                    Object.Destroy(type.UiObject.gameObject);
                }

                if (type.EntityParentLine != null)
                {
                    Object.Destroy(type.EntityParentLine.gameObject.Value);
                    type.EntityParentLine.Destroy();
                }

                type.RootGameObject.DestroyGameObject();
                type.Dispose();
            }

            ProjectData.ObjectsAreChanged = true;
        }
コード例 #3
0
        private void AddJointBehaviour()
        {
            if (RootGameObject.GetComponent <JointBehaviour>() != null)
            {
                return;
            }

            _jointBehaviour = RootGameObject.AddComponent <JointBehaviour>();
            _jointBehaviour.Init();
            LogManager.GetCurrentClassLogger().Info("Added joint behaviour on " + RootGameObject.name);
        }