示例#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();
        }
示例#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();
        }