private unsafe void AddGridVerticesInsideOBB(MyCubeGrid grid, MyOrientedBoundingBoxD obb) { BoundingBoxD aABB = obb.GetAABB(); using (HashSet <MyGroups <MyCubeGrid, MyGridLogicalGroupData> .Node> .Enumerator enumerator = MyCubeGridGroups.Static.Logical.GetGroup(grid).Nodes.GetEnumerator()) { while (enumerator.MoveNext()) { MyCubeGrid nodeData = enumerator.Current.NodeData; this.m_rdPathfinding.AddToTrackedGrids(nodeData); MatrixD worldMatrix = nodeData.WorldMatrix; MatrixD *xdPtr1 = (MatrixD *)ref worldMatrix; xdPtr1.Translation -= this.m_center; MatrixD xd3 = MatrixD.Transform(worldMatrix, this.rdWorldQuaternion); if (MyPerGameSettings.Game == GameEnum.SE_GAME) { BoundingBoxD xd4 = aABB.TransformFast(nodeData.PositionComp.WorldMatrixNormalizedInv); Vector3I vectori = new Vector3I((int)Math.Round(xd4.Min.X), (int)Math.Round(xd4.Min.Y), (int)Math.Round(xd4.Min.Z)); Vector3I vectori2 = new Vector3I((int)Math.Round(xd4.Max.X), (int)Math.Round(xd4.Max.Y), (int)Math.Round(xd4.Max.Z)); vectori = Vector3I.Min(vectori, vectori2); vectori2 = Vector3I.Max(vectori, vectori2); if (nodeData.Physics != null) { using (MyUtils.ReuseCollection <HkShape>(ref m_tmpShapes)) { MyGridShape shape = nodeData.Physics.Shape; using (MyGridShape.NativeShapeLock.AcquireSharedUsing()) { shape.GetShapesInInterval(vectori, vectori2, m_tmpShapes); foreach (HkShape shape2 in m_tmpShapes) { this.AddPhysicalShape(shape2, (Matrix)xd3); } } } } } } } }
public static bool PrefixUpdateMassFromInventories(List <MyCubeBlock> blocks, MyPhysicsBody rb, MyGridShape __instance) { RefTimeSpan time; if (!lastUpdateTimestamp.TryGetValue(__instance, out time)) { lastUpdateTimestamp.Add(__instance, new RefTimeSpan(MySession.Static.ElapsedGameTime)); return(true); } if ((MySession.Static.ElapsedGameTime - time.timespan).TotalMilliseconds < 1000) { return(false); } lastUpdateTimestamp.Remove(__instance); lastUpdateTimestamp.Add(__instance, new RefTimeSpan(MySession.Static.ElapsedGameTime)); return(true); }