Exemple #1
0
 public void Unload()
 {
     m_static = null;
 }
Exemple #2
0
        private MyCubeGrid CalculateNewRoot(MyGroups <MyCubeGrid, MyGridPhysicalHierarchyData> .Group group)
        {
            if (group.m_members.Count == 1)
            {
                return(group.m_members.FirstElement <MyGroups <MyCubeGrid, MyGridPhysicalHierarchyData> .Node>().NodeData);
            }
            MyGroups <MyCubeGrid, MyGridPhysicalHierarchyData> .Node node = null;
            float num = 0f;
            List <MyGroups <MyCubeGrid, MyGridPhysicalHierarchyData> .Node> list = new List <MyGroups <MyCubeGrid, MyGridPhysicalHierarchyData> .Node>();

            if (group.m_members.Count == 1)
            {
                return(group.m_members.FirstElement <MyGroups <MyCubeGrid, MyGridPhysicalHierarchyData> .Node>().NodeData);
            }
            bool flag = false;

            foreach (MyGroups <MyCubeGrid, MyGridPhysicalHierarchyData> .Node node3 in group.Nodes)
            {
                if (node3.NodeData.IsStatic || MyFixedGrids.IsRooted(node3.NodeData))
                {
                    if (!flag)
                    {
                        list.Clear();
                        node = null;
                        flag = true;
                    }
                    list.Add(node3);
                }
                if (!flag)
                {
                    if (this.IsGridControlled(node3.NodeData))
                    {
                        node = node3;
                    }
                    if (node3.NodeData.Physics != null)
                    {
                        float            mass           = 0f;
                        HkMassProperties?massProperties = node3.NodeData.Physics.Shape.MassProperties;
                        if (massProperties != null)
                        {
                            mass = massProperties.Value.Mass;
                        }
                        if (mass > num)
                        {
                            num = mass;
                            list.Clear();
                            list.Add(node3);
                        }
                        else if (mass == num)
                        {
                            list.Add(node3);
                        }
                    }
                }
            }
            MyGroups <MyCubeGrid, MyGridPhysicalHierarchyData> .Node node2 = null;
            if (list.Count == 1)
            {
                node2 = list[0];
            }
            else if (list.Count > 1)
            {
                long entityId = list[0].NodeData.EntityId;
                MyGroups <MyCubeGrid, MyGridPhysicalHierarchyData> .Node node4 = list[0];
                foreach (MyGroups <MyCubeGrid, MyGridPhysicalHierarchyData> .Node node5 in list)
                {
                    if (!MyWeldingGroups.Static.IsEntityParent(node5.NodeData))
                    {
                        continue;
                    }
                    if (entityId > node5.NodeData.EntityId)
                    {
                        entityId = node5.NodeData.EntityId;
                        node4    = node5;
                    }
                }
                node2 = node4;
            }
            if (node != null)
            {
                if (node2 == null)
                {
                    node2 = node;
                }
                else if ((node.NodeData.Physics == null) || (node2.NodeData.Physics == null))
                {
                    node2 = node;
                }
                else
                {
                    float            mass           = 0f;
                    HkMassProperties?massProperties = node.NodeData.Physics.Shape.MassProperties;
                    if (massProperties != null)
                    {
                        mass = massProperties.Value.Mass;
                    }
                    float mass = 0f;
                    massProperties = node2.NodeData.Physics.Shape.MassProperties;
                    if (massProperties != null)
                    {
                        mass = massProperties.Value.Mass;
                    }
                    if ((mass / mass) < 2f)
                    {
                        node2 = node;
                    }
                }
            }
            return(node2?.NodeData);
        }
Exemple #3
0
 public void Load()
 {
     m_static = this;
 }