Example #1
0
        public Life2DZone(string name, Map map, Vector3I[] marks, Player creator, string minRankToChange)
        {
            _map    = map;
            _bounds = new BoundingBox(marks[0], marks[1]);
            if (_bounds.Dimensions.X == 1 && _bounds.Dimensions.Y > 1 && _bounds.Dimensions.Z > 1)
            {
                _orientation = Orientation.X;
                _life2d      = new Life2d(_bounds.Dimensions.Y, _bounds.Dimensions.Z);
                _coords.X    = _bounds.XMin;
            }
            else if (_bounds.Dimensions.X > 1 && _bounds.Dimensions.Y == 1 && _bounds.Dimensions.Z > 1)
            {
                _orientation = Orientation.Y;
                _life2d      = new Life2d(_bounds.Dimensions.X, _bounds.Dimensions.Z);
                _coords.Y    = _bounds.YMin;
            }
            else if (_bounds.Dimensions.X > 1 && _bounds.Dimensions.Y > 1 && _bounds.Dimensions.Z == 1)
            {
                _orientation = Orientation.Z;
                _life2d      = new Life2d(_bounds.Dimensions.X, _bounds.Dimensions.Y);
                _coords.Z    = _bounds.ZMin;
            }
            else
            {
                throw new ArgumentException("bounds must be a 2d rectangle");
            }

            if (_bounds.Dimensions.X * _bounds.Dimensions.Y * _bounds.Dimensions.Z > MaxSize)
            {
                throw new ArgumentException("The life if too large. Width*Length must be less or equal than " + MaxSize);
            }

            CheckPermissionsToDraw(creator);

            Name            = name;
            CreatorName     = creator.Name;
            MinRankToChange = minRankToChange;
            _normal         = DefaultBlocks[NormalIdx];
            _empty          = DefaultBlocks[EmptyIdx];
            _dead           = DefaultBlocks[DeadIdx];
            _newborn        = DefaultBlocks[NewbornIdx];

            _halfStepDelay = DefaultHalfStepDelay;
            _delay         = DefaultDelay;
            Torus          = false;
            _autoReset     = AutoResetMethod.ToRandom;
            _initialState  = _life2d.GetArrayCopy();
        }