Exemplo n.º 1
0
        private static void SetAutoReset(Player p, Life2DZone life, string val)
        {
            AutoResetMethod method = AutoResetMethod.None;

            val = val.ToLower();

            if (val == "no" || val == "none")
            {
                method = AutoResetMethod.None;
            }
            else if (val == "toinitial" || val == "i")
            {
                method = AutoResetMethod.ToInitial;
            }
            else if (val == "torandom" || val == "r" || val == "rnd")
            {
                method = AutoResetMethod.ToRandom;
            }
            else
            {
                p.Message("&WUnrecognized auto reset method " + val + ".\n" +
                          "&hType '/life help AutoReset' to see all the possible values.");

                return;
            }

            life.AutoReset = method;

            p.Message("&yAutoReset param set to " + Enum.GetName(typeof(AutoResetMethod), method));
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
            public SerializedData(Life2DZone life)
            {
                lock (life._life2d) {
                    Bounds = life._bounds;
                    Orient = life._orientation;

                    Normal  = life._normal;
                    Empty   = life._empty;
                    Dead    = life._dead;
                    Newborn = life._newborn;

                    RuntimeState  = life._state;
                    HalfStepDelay = life._halfStepDelay;
                    Delay         = life._delay;
                    AutoReset     = life._autoReset;

                    CreatorName     = life.CreatorName;
                    MinRankToChange = life.MinRankToChange;

                    CurrentState = To1DArray(life._life2d.GetArrayCopy(), out Dim0, out Dim1);
                    InitialState = To1DArray((byte[, ])life._initialState.Clone(), out Dim0, out Dim1);
                }
            }