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