Beispiel #1
0
        private void MyEntitiesOnOnEntityAdd(MyEntity entity)
        {
            if (!BlockLimiterConfig.Instance.EnableLimits)
            {
                return;
            }

            if (!(entity is MyCubeGrid grid))
            {
                return;
            }

            if (grid.Projector != null || grid.IsPreview)
            {
                return;
            }

            var biggestGrid = Grid.GetBiggestGridInGroup(grid);

            var blocks = grid.CubeBlocks;

            foreach (var block in blocks)
            {
                Block.IncreaseCount(block.BlockDefinition, block.OwnerId, 1, grid.EntityId);
                if (biggestGrid != null && biggestGrid != grid)
                {
                    Block.IncreaseCount(block.BlockDefinition, block.OwnerId, 1, biggestGrid.EntityId);
                }
            }
        }
Beispiel #2
0
        public static bool CheckLimits_future(MyObjectBuilder_CubeGrid[] grids, long id = 0)
        {
            if (grids.Length == 0 || !BlockLimiterConfig.Instance.EnableLimits || Utilities.IsExcepted(id, new List <string>()))
            {
                return(false);
            }


            return(!grids.Any(Grid.IsSizeViolation) && grids.Any(x => !Grid.CanSpawn(x, id)));
        }
Beispiel #3
0
        public static bool CheckLimits_future(MyObjectBuilder_CubeGrid[] grids, long id = 0)
        {
            if (grids.Length == 0 || !BlockLimiterConfig.Instance.EnableLimits || Utilities.IsExcepted(id))
            {
                return(false);
            }

            foreach (var grid in grids)
            {
                if (Grid.CanSpawn(grid, id))
                {
                    continue;
                }
                return(true);
            }

            return(false);
        }