Esempio n. 1
0
        public void Remove(Player requester)
        {
            NormalBrush   brush           = new NormalBrush(Block.Air, Block.Air);
            DrawOperation removeOperation = new CuboidDrawOperation(requester);

            removeOperation.AnnounceCompletion = false;
            removeOperation.Brush   = brush;
            removeOperation.Context = BlockChangeContext.Portal;

            if (this.AffectedBlocks == null)
            {
                this.AffectedBlocks    = new Vector3I[2];
                this.AffectedBlocks[0] = new Vector3I(Range.Xmin, Range.Ymin, Range.Zmin);
                this.AffectedBlocks[1] = new Vector3I(Range.Xmax, Range.Ymax, Range.Zmax);
            }

            if (!removeOperation.Prepare(this.AffectedBlocks))
            {
                throw new PortalException("Unable to remove portal.");
            }

            removeOperation.Begin();

            lock (requester.World.Portals.SyncRoot)
            {
                requester.World.Portals.Remove(this);
            }

            PortalDB.Save();
        }
Esempio n. 2
0
        public static void CreatePortal(Portal portal, World source)
        {
            World world = WorldManager.FindWorldExact(portal.World);

            if (source.Portals == null)
            {
                source.Portals = new ArrayList();
            }

            lock (source.Portals.SyncRoot)
            {
                source.Portals.Add(portal);
            }

            PortalDB.Save();
        }
Esempio n. 3
0
        public void Remove(Player requester, World world)
        {
            DrawOperation op = new CuboidDrawOperation(requester);

            op.AnnounceCompletion = false;
            op.Brush   = new NormalBrush(Block.Air, Block.Air);
            op.Context = BlockChangeContext.Portal;

            Vector3I[] bounds =
            {
                new Vector3I(Range.Xmin, Range.Ymin, Range.Zmin),
                new Vector3I(Range.Xmax, Range.Ymax, Range.Zmax),
            };
            if (!op.Prepare(bounds))
            {
                throw new InvalidOperationException("Unable to remove portal.");
            }

            op.Begin();
            world.Portals.Remove(this);
            PortalDB.Save();
        }