Exemplo 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();
        }
Exemplo n.º 2
0
 public static void Init()
 {
     Player.Moved       += Player_Moved;
     Player.JoinedWorld += Player_JoinedWorld;
     Player.PlacedBlock += Player_PlacedBlock;
     PortalDB.StartSaveTask();
 }
Exemplo n.º 3
0
        public static PortalHandler GetInstance()
        {
            if (instance == null)
            {
                instance            = new PortalHandler();
                Player.Moved       += new EventHandler <Events.PlayerMovedEventArgs>(Player_Moved);
                Player.JoinedWorld += new EventHandler <Events.PlayerJoinedWorldEventArgs>(Player_JoinedWorld);
                Player.PlacedBlock += new EventHandler <Events.PlayerPlacedBlockEventArgs>(Player_PlacedBlock);
                PortalDB.StartSaveTask();
            }

            return(instance);
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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();
        }