コード例 #1
0
ファイル: CellarAddon.cs プロジェクト: zerodowned/UO-Forever
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.GetVersion();

            switch (version)
            {
            case 1:
            {
                _Placeholder = reader.ReadItem <CellarPlaceholder>();
                _FloorTiles  = reader.ReadStrongItemList <CellarFloor>();
                _WallTiles   = reader.ReadStrongItemList <CellarWall>();
                _Style       = reader.ReadFlag <CellarStyle>();
                House        = reader.ReadItem <BaseHouse>();
                StairsDown   = reader.ReadItem <CellarStairs>();
                StairsUp     = reader.ReadItem <CellarStairs>();
            }
                goto case 0;

            case 0:
            {
                if (version < 1)
                {
                    _FloorTiles = new List <CellarFloor>();
                    _WallTiles  = new List <CellarWall>();
                }
            }
            break;
            }
        }
コード例 #2
0
ファイル: CellarAddon.cs プロジェクト: zerodowned/UO-Forever
        public void LinkWith(CellarStairs other)
        {
            if (Link == other || other == null || other == this)
            {
                return;
            }

            other.Link = this;
            Link       = other;
        }
コード例 #3
0
        private void InvalidateComponents()
        {
            if (Deleted || Map == null || Map == Map.Internal)
            {
                return;
            }

            if (StairsDown == null || StairsUp == null)
            {
                var stairs = Components.OfType <CellarStairs>().OrderByDescending(s => s.Z).ToArray();

                if (stairs.Length > 1)
                {
                    StairsDown = stairs.First();
                    StairsUp   = stairs.Last();

                    StairsDown.Link = StairsUp;
                    StairsUp.Link   = StairsDown;
                }
            }
            else if (StairsDown.Link == null || StairsUp.Link == null)
            {
                StairsDown.Link = StairsUp;
                StairsUp.Link   = StairsDown;
            }

            if (_Style == CellarStyle.None)
            {
                var tiles = new Queue <AddonComponent>(Components);

                while (_Style == CellarStyle.None && tiles.Count > 0)
                {
                    var floor = tiles.Dequeue();

                    if (floor != null)
                    {
                        _Style = CellarStyles.ResolveOldID(floor.ItemID);
                    }
                }

                tiles.Clear();
            }

            if (_Style == CellarStyle.None)
            {
                _Style = CellarStyle.Dirt;
            }

            UpdateComponents();
        }
コード例 #4
0
ファイル: CellarAddon.cs プロジェクト: zerodowned/UO-Forever
        public void GenerateComponents()
        {
            if (Deleted || Map == null || Map == Map.Internal || Location == Point3D.Zero)
            {
                return;
            }

            if (House == null || House.Deleted)
            {
                House = BaseHouse.FindHouseAt(this);
            }

            if (House == null || House.Deleted || House.Area == null || House.Area.Length == 0 || _Placeholder == null ||
                _Placeholder.Deleted)
            {
                House = null;
                return;
            }

            if (_Style == CellarStyle.None)
            {
                _Style = CellarStyle.Dirt;
            }

            Point3D p = _Placeholder.Location;
            Point3D o = _Placeholder.Offset;
            Point3D t = House.Location;

            Components.Remove(_Placeholder);

            _Placeholder.Addon = null;
            _Placeholder.Delete();
            _Placeholder = null;

            var s = Style.GetInfo();

            AddComponent(StairsDown = new CellarStairs(s.StairsDown), o);

            var floorPoints = new List <Point2D>();
            var wallPoints  = new List <Point2D>();

            foreach (var r2d in House.Region.Area.Select(r3d => new Rectangle2D(r3d.Start, r3d.End)))
            {
                floorPoints.AddRange(r2d.EnumeratePoints().Not(floorPoints.Contains));
            }

            floorPoints.ForEach(
                f =>
            {
                var points = new[]
                {
                    f.Clone2D(-1, -1),                        //nw
                    f.Clone2D(0, -1),                         //n
                    f.Clone2D(1, -1),                         //ne
                    f.Clone2D(1),                             //e
                    f.Clone2D(1, 1),                          //se
                    f.Clone2D(0, 1),                          //s
                    f.Clone2D(-1, 1),                         //sw
                    f.Clone2D(-1)                             //w
                };

                wallPoints.AddRange(points.Not(floorPoints.Contains).Not(wallPoints.Contains));
            });

            foreach (var p3d in floorPoints.Select(p2d => p2d.ToPoint3D(t.Z - 40).Clone3D(-p.X, -p.Y, -p.Z)))
            {
                _FloorTiles.Add(AddComponent(new CellarFloor(s.FloorTiles.GetRandom()), p3d));
            }

            foreach (var p3d in wallPoints.Select(p2d => p2d.ToPoint3D(t.Z - 40).Clone3D(-p.X, -p.Y, -p.Z)))
            {
                _WallTiles.Add(AddComponent(new CellarWall(s.WallTiles.GetRandom()), p3d));
            }

            AddComponent(StairsUp = new CellarStairs(s.StairsUp), p.ToPoint3D(t.Z - 40).Clone3D(-p.X, -p.Y, -p.Z));

            StairsDown.LinkWith(StairsUp);

            if (!House.Addons.Contains(this))
            {
                House.Addons.Add(this);
            }
        }