private static void CheckNeighbourStaticGridsAfterVoxelChanged(MyVoxelBase.OperationType type, MyVoxelBase voxelMap, MyShape shape) { // Check static grids around (possible change to dynamic) if (Sync.IsServer && MyFakes.ENABLE_BLOCK_PLACEMENT_ON_VOXEL && MyFakes.ENABLE_BLOCKS_IN_VOXELS_TEST && MyStructuralIntegrity.Enabled) { BoundingBoxD cutOutBox = shape.GetWorldBoundaries(); cutOutBox.Inflate(0.25); List <MyEntity> boxOverlapList = new List <MyEntity>(); MyEntities.GetElementsInBox(ref cutOutBox, boxOverlapList); foreach (var entity in boxOverlapList) { var grid = entity as MyCubeGrid; if (grid != null && grid.IsStatic) { if (grid.Physics != null && grid.Physics.Shape != null) { grid.Physics.Shape.RecalculateConnectionsToWorld(grid.GetBlocks()); } if (type == MyVoxelBase.OperationType.Cut) { grid.TestDynamic = true; } } } boxOverlapList.Clear(); } }
private static void OnVoxelChanged(MyVoxelBase.OperationType type, MyVoxelBase voxelMap, MyShape shape) { if (Sync.IsServer) { BoundingBoxD cutOutBox = shape.GetWorldBoundaries(); cutOutBox.Inflate(0.25); MyEntities.GetElementsInBox(ref cutOutBox, m_overlapList); // Check static grids around (possible change to dynamic) if (/*MyFakes.ENABLE_BLOCK_PLACEMENT_ON_VOXEL &&*/ MyFakes.ENABLE_BLOCKS_IN_VOXELS_TEST && MyStructuralIntegrity.Enabled) { foreach (var entity in m_overlapList) { var grid = entity as MyCubeGrid; if (grid != null && grid.IsStatic) { if (grid.Physics != null && grid.Physics.Shape != null) { grid.Physics.Shape.RecalculateConnectionsToWorld(grid.GetBlocks()); } if (type == MyVoxelBase.OperationType.Cut) { grid.TestDynamic = true; } } } } } var voxelPhysics = voxelMap as MyVoxelPhysics; MyPlanet planet = voxelPhysics != null ? voxelPhysics.Parent : voxelMap as MyPlanet; if (planet != null) { var planetEnvironment = planet.Components.Get <MyPlanetEnvironmentComponent>(); if (planetEnvironment != null) { var sectors = planetEnvironment.GetSectorsInRange(shape); if (sectors != null) { foreach (var sector in sectors) { sector.DisableItemsInShape(shape); } } } } m_overlapList.Clear(); }
public static void NotifyVoxelChanged(MyVoxelBase.OperationType type, MyVoxelBase voxelMap, ref BoundingBoxD cutOutBox) { cutOutBox.Inflate((double)0.25); MyGamePruningStructure.GetTopmostEntitiesInBox(ref cutOutBox, m_overlapList, MyEntityQueryType.Both); if (MyFakes.ENABLE_BLOCKS_IN_VOXELS_TEST) { foreach (MyEntity entity in m_overlapList) { if (Sync.IsServer) { MyCubeGrid grid = entity as MyCubeGrid; if ((grid != null) && grid.IsStatic) { if ((grid.Physics != null) && (grid.Physics.Shape != null)) { grid.Physics.Shape.RecalculateConnectionsToWorld(grid.GetBlocks()); } if (type == MyVoxelBase.OperationType.Cut) { grid.TestDynamic = MyCubeGrid.MyTestDynamicReason.GridSplit; } } } MyPhysicsBody physics = entity.Physics as MyPhysicsBody; if (((physics != null) && !physics.IsStatic) && (physics.RigidBody != null)) { physics.RigidBody.Activate(); } } } m_overlapList.Clear(); if (Sync.IsServer) { MyPlanetEnvironmentComponent component = voxelMap.Components.Get <MyPlanetEnvironmentComponent>(); if (component != null) { component.GetSectorsInRange(ref cutOutBox, m_overlapList); using (List <MyEntity> .Enumerator enumerator = m_overlapList.GetEnumerator()) { while (enumerator.MoveNext()) { ((MyEnvironmentSector)enumerator.Current).DisableItemsInBox(ref cutOutBox); } } m_overlapList.Clear(); } } }
private static void OnVoxelChanged(MyVoxelBase.OperationType type, MyVoxelBase voxelMap, MyShape shape) { if (!Sync.IsServer) { return; } BoundingBoxD cutOutBox = shape.GetWorldBoundaries(); cutOutBox.Inflate(0.25); MyEntities.GetElementsInBox(ref cutOutBox, m_overlapList); // Check static grids around (possible change to dynamic) if (MyFakes.ENABLE_BLOCK_PLACEMENT_ON_VOXEL && MyFakes.ENABLE_BLOCKS_IN_VOXELS_TEST && MyStructuralIntegrity.Enabled) { foreach (var entity in m_overlapList) { var grid = entity as MyCubeGrid; if (grid != null && grid.IsStatic) { if (grid.Physics != null && grid.Physics.Shape != null) { grid.Physics.Shape.RecalculateConnectionsToWorld(grid.GetBlocks()); } if (type == MyVoxelBase.OperationType.Cut) { grid.TestDynamic = true; } } } } var voxelPhysics = voxelMap as MyVoxelPhysics; MyPlanet planet = voxelPhysics != null ? voxelPhysics.Parent : voxelMap as MyPlanet; if (planet != null) { var center = cutOutBox.Center; foreach (var environment in planet.GetEnvironmentItemsAtPosition(ref center)) { environment.RemoveItemsAroundPoint(cutOutBox.Center, cutOutBox.HalfExtents.Max()); } } m_overlapList.Clear(); }