Пример #1
0
        public MovableAddonComponent(int[] itemids, int direction) : base(itemids[direction])
        {
            _DirectionID = itemids;
            _Direction   = (MovableAddonDirection)direction;

            Movable = false;
        }
Пример #2
0
        //this method performs the rotate operation
        public virtual bool Rotate(bool clockwise)
        {
            int newdirection = (int)_Direction + (clockwise ? 1 : -1);

            if (newdirection > 3)
            {
                newdirection = 0;
            }
            if (newdirection < 0)
            {
                newdirection = 3;
            }

            if (!CanRotateTo((MovableAddonDirection)newdirection))
            {
                return(false);
            }


            _Direction = (MovableAddonDirection)newdirection;

            foreach (MovableAddonComponent component in _Components)
            {
                component.Rotate(clockwise);
            }

            RotateContents(clockwise);

            _Extrema = new Rectangle3D(new Point3D(_Extrema.Start.Y, _Extrema.Start.X, _Extrema.Start.Z), new Point3D(_Extrema.End.Y, _Extrema.End.X, _Extrema.End.Z));

            return(true);
        }
Пример #3
0
        public bool CanRotateTo(MovableAddonDirection direction)
        {
            if (OutOfPower)
            {
                return(false);
            }

            Rectangle3D tempextrema = _Extrema;

            int directiondiff = (int)direction - (int)_Direction;

            //clockwise degree rotation
            if (directiondiff == 1 || directiondiff == -3)
            {
                //rotate extrema accordingly
                _Extrema = new Rectangle3D(new Point3D(-_Extrema.End.Y, _Extrema.Start.X, _Extrema.Start.Z), new Point3D(-_Extrema.Start.Y, _Extrema.End.X, _Extrema.End.Z));
            }
            //counterclockwise
            else if (directiondiff == -1 || directiondiff == 3)
            {
                _Extrema = new Rectangle3D(new Point3D(_Extrema.Start.Y, -_Extrema.End.X, _Extrema.Start.Z), new Point3D(_Extrema.End.Y, -_Extrema.Start.X, _Extrema.End.Z));
            }
            //about face
            else if (directiondiff == -2 || directiondiff == 2)
            {
                _Extrema = new Rectangle3D(new Point3D(-_Extrema.End.X, -_Extrema.End.Y, _Extrema.Start.Z), new Point3D(-_Extrema.Start.X, -_Extrema.Start.Y, _Extrema.End.Z));
            }

            bool canrotate = CanMoveTo(Location, Map);

            _Extrema = tempextrema;

            return(canrotate);
        }
Пример #4
0
        public void Rotate(bool clockwise)
        {
            int newdirection = (int)_Direction + (clockwise ? 1 : -1);

            if (newdirection > 3)
            {
                newdirection = 0;
            }
            if (newdirection < 0)
            {
                newdirection = 3;
            }

            //determine x-y rotation based on previous direction
            int temp = _OffsetY;

            _OffsetY = _OffsetX * (clockwise ? 1 : -1);
            _OffsetX = temp * (clockwise ? -1 : 1);

            Direction = (MovableAddonDirection)newdirection;
        }
Пример #5
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            _DirectionID = new int[4];

            int version = reader.ReadInt();

            _Addon = (MovableAddon)reader.ReadItem();

            _OffsetX = reader.ReadInt();
            _OffsetY = reader.ReadInt();
            _OffsetZ = reader.ReadInt();

            _Direction = (MovableAddonDirection)reader.ReadInt();

            for (int i = 0; i < 4; i++)
            {
                _DirectionID[i] = reader.ReadInt();
            }
        }
Пример #6
0
        public override void Deserialize(GenericReader reader)
        {
            _Components = new List <MovableAddonComponent>();

            base.Deserialize(reader);

            int version = reader.ReadInt();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                _Components.Add((MovableAddonComponent)reader.ReadItem());
            }

            _Direction = (MovableAddonDirection)reader.ReadInt();

            _Controller = (MovableAddonControlComponent)reader.ReadItem();
            _Key        = (MovableAddonKey)reader.ReadItem();

                        #if ( RunUORC1 )
            _Extrema = new Rectangle3D(new Point3D(reader.ReadInt(), reader.ReadInt(), reader.ReadInt()), new Point3D(reader.ReadInt(), reader.ReadInt(), reader.ReadInt()));
                        #else
            /*To RunUO 2.0 RC1 users:  if you're getting an error here, then uncomment line 2 of this file to read:
             *
             #define RunUORC1
             *
             */
            _Extrema = reader.ReadRect3D();
                        #endif

            _Delay = TimeSpan.FromSeconds(reader.ReadDouble());

            ExhaustPowerTimeSpan = reader.ReadTimeSpan();

            _Speed = MovableAddonSpeed.Regular;
        }