상속: IBrushInstance
예제 #1
1
        public FeedData( Block _textType, Vector3I _pos, Bitmap Image, World world, Direction direction_, Player player_ )
        {
            direction = direction_;
            Blocks = new ConcurrentDictionary<string, Vector3I>();
            Init( Image, world );
            Pos = _pos;
            textType = ( byte )_textType;
            bgType = ( byte )Block.Air;
            FeedData.AddMessages();
            MessageCount = 0;
            Sentence = FeedData.Messages[MessageCount];
            Id = System.Threading.Interlocked.Increment( ref feedCounter );
            player = player_;
            NormalBrush brush = new NormalBrush( Block.Wood );
            DrawOperation Operation = new CuboidWireframeDrawOperation( player );
            Operation.AnnounceCompletion = false;
            Operation.Brush = brush;
            Operation.Context = BlockChangeContext.Drawn;

            if ( !Operation.Prepare( new Vector3I[] { StartPos, FinishPos } ) ) {
                throw new Exception( "Unable to cubw frame." );
            }

            Operation.Begin();
            AddFeedToList( this, world );

            Start();
        }
예제 #2
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();
        }
예제 #3
0
        private static void PortalH(Player player, Command command)
        {
            try
            {
                String option = command.Next();

                if (option == null)
                {
                    CdPortal.PrintUsage(player);
                }
                else if (option.ToLower().Equals("create"))
                {
                    if (player.Can(Permission.ManagePortal))
                    {
                        string world = command.Next();

                        if (world != null && WorldManager.FindWorldExact(world) != null)
                        {
                            DrawOperation operation = new CuboidDrawOperation(player);
                            NormalBrush brush = new NormalBrush(Block.Water, Block.Water);

                            string blockTypeOrName = command.Next();

                            if (blockTypeOrName != null && blockTypeOrName.ToLower().Equals("lava"))
                            {
                                brush = new NormalBrush(Block.Lava, Block.Lava);
                            }
                            else if (blockTypeOrName != null && !blockTypeOrName.ToLower().Equals("water"))
                            {
                                player.Message("Invalid block, choose between water or lava.");
                                return;
                            }

                            string portalName = command.Next();

                            if (portalName == null)
                            {
                                player.PortalName = null;
                            }
                            else
                            {
                                if (!Portal.DoesNameExist(player.World, portalName))
                                {
                                    player.PortalName = portalName;
                                }
                                else
                                {
                                    player.Message("A portal with name {0} already exists in this world.", portalName);
                                    return;
                                }
                            }

                            operation.Brush = brush;
                            player.PortalWorld = world;

                            player.SelectionStart(operation.ExpectedMarks, PortalCreateCallback, operation, Permission.Draw);
                            player.Message("Click {0} blocks or use &H/Mark&S to mark the area of the portal.", operation.ExpectedMarks);
                        }
                        else
                        {
                            if (world == null)
                            {
                                player.Message("No world specified.");
                            }
                            else
                            {
                                player.MessageNoWorld(world);
                            }
                        }
                    }
                    else
                    {
                        player.MessageNoAccess(Permission.ManagePortal);
                    }
                }
                else if (option.ToLower().Equals("remove"))
                {
                    if (player.Can(Permission.ManagePortal))
                    {
                        string portalName = command.Next();

                        if (portalName == null)
                        {
                            player.Message("No portal name specified.");
                        }
                        else
                        {
                            if (player.World.Portals != null && player.World.Portals.Count > 0)
                            {
                                bool found = false;
                                Portal portalFound = null;

                                lock (player.World.Portals.SyncRoot)
                                {
                                    foreach (Portal portal in player.World.Portals)
                                    {
                                        if (portal.Name.Equals(portalName))
                                        {
                                            portalFound = portal;
                                            found = true;
                                            break;
                                        }
                                    }

                                    if (!found)
                                    {
                                        player.Message("Could not find portal by name {0}.", portalName);
                                    }
                                    else
                                    {
                                        portalFound.Remove(player);
                                        player.Message("Portal was removed.");
                                    }
                                }
                            }
                            else
                            {
                                player.Message("Could not find portal as this world doesn't contain a portal.");
                            }
                        }
                    }
                    else
                    {
                        player.MessageNoAccess(Permission.ManagePortal);
                    }
                }
                else if (option.ToLower().Equals("info"))
                {
                    string portalName = command.Next();

                    if (portalName == null)
                    {
                        player.Message("No portal name specified.");
                    }
                    else
                    {
                        if (player.World.Portals != null && player.World.Portals.Count > 0)
                        {
                            bool found = false;

                            lock (player.World.Portals.SyncRoot)
                            {
                                foreach (Portal portal in player.World.Portals)
                                {
                                    if (portal.Name.Equals(portalName))
                                    {
                                        World portalWorld = WorldManager.FindWorldExact(portal.World);
                                        player.Message("Portal {0}&S was created by {1}&S at {2} and teleports to world {3}&S.",
                                            portal.Name, PlayerDB.FindPlayerInfoExact(portal.Creator).ClassyName, portal.Created, portalWorld.ClassyName);
                                        found = true;
                                    }
                                }
                            }

                            if (!found)
                            {
                                player.Message("Could not find portal by name {0}.", portalName);
                            }
                        }
                        else
                        {
                            player.Message("Could not find portal as this world doesn't contain a portal.");
                        }
                    }
                }
                else if (option.ToLower().Equals("list"))
                {
                    if (player.World.Portals == null || player.World.Portals.Count == 0)
                    {
                        player.Message("There are no portals in {0}&S.", player.World.ClassyName);
                    }
                    else
                    {
                        String[] portalNames = new String[player.World.Portals.Count];
                        StringBuilder output = new StringBuilder("There are " + player.World.Portals.Count + " portals in " + player.World.ClassyName + "&S: ");

                        for (int i = 0; i < player.World.Portals.Count; i++)
                        {
                            portalNames[i] = ((Portal)player.World.Portals[i]).Name;
                        }

                        output.Append(portalNames.JoinToString(", "));

                        player.Message(output.ToString());
                    }
                }
                else if (option.ToLower().Equals("enable"))
                {
                    player.PortalsEnabled = true;
                    player.Message("You enabled the use of portals.");
                }
                else if (option.ToLower().Equals("disable"))
                {
                    player.PortalsEnabled = false;
                    player.Message("You disabled the use of portals, type /portal enable to re-enable portals.");
                }
                else
                {
                    CdPortal.PrintUsage(player);
                }
            }
            catch (PortalException ex)
            {
                player.Message(ex.Message);
                Logger.Log(LogType.Error, "WorldCommands.PortalH: " + ex);
            }
            catch (Exception ex)
            {
                player.Message("Unexpected error: " + ex);
                Logger.Log(LogType.Error, "WorldCommands.PortalH: " + ex);
            }
        }
예제 #4
0
        static void MessageBlockAdd( Player player, Vector3I[] marks, object tag )
        {
            string Message = ( string )tag;
            Vector3I mark = marks[0];
            if ( !player.Info.Rank.AllowSecurityCircumvention ) {
                SecurityCheckResult buildCheck = player.World.BuildSecurity.CheckDetailed( player.Info );
                switch ( buildCheck ) {
                    case SecurityCheckResult.BlackListed:
                        player.Message( "Cannot add a MessageBlock to world {0}&S: You are barred from building here.",
                                        player.World.ClassyName );
                        return;
                    case SecurityCheckResult.RankTooLow:
                        player.Message( "Cannot add a MessageBlock to world {0}&S: You are not allowed to build here.",
                                        player.World.ClassyName );
                        return;
                    //case SecurityCheckResult.RankTooHigh:
                }
            }
            if ( player.LastUsedBlockType != Block.Undefined ) {
                Vector3I Pos = mark;

                if ( player.CanPlace( player.World.Map, Pos, player.LastUsedBlockType, BlockChangeContext.Manual ) != CanPlaceResult.Allowed ) {
                    player.Message( "&WYou are not allowed to build here" );
                    return;
                }

                Player.RaisePlayerPlacedBlockEvent( player, player.WorldMap, Pos, player.WorldMap.GetBlock( Pos ), player.LastUsedBlockType, BlockChangeContext.Manual );
                BlockUpdate blockUpdate = new BlockUpdate( null, Pos, player.LastUsedBlockType );
                player.World.Map.QueueUpdate( blockUpdate );
            } else {
                player.Message( "&WError: No last used blocktype was found" );
                return;
            }
            MessageBlock MessageBlock = new MessageBlock( player.World.Name, mark,
                MessageBlock.GenerateName( player.World ),
                player.ClassyName, Message );
            MessageBlock.Range = new MessageBlockRange( mark.X, mark.X, mark.Y, mark.Y, mark.Z, mark.Z );

            MessageBlockHandler.CreateMessageBlock( MessageBlock, player.World );
            NormalBrush brush = new NormalBrush( Block.Air );
            Logger.Log( LogType.UserActivity, "{0} created MessageBlock {1} (on world {2})", player.Name, MessageBlock.Name, player.World.Name );
            player.Message( "MessageBlock created on world {0}&S with name {1}", player.World.ClassyName, MessageBlock.Name );
        }
예제 #5
0
        private static void PortalH(Player player, CommandReader cmd) {
            try {
                string option = cmd.Next();
                if (string.IsNullOrEmpty(option)) {
                    CdPortal.PrintUsage(player);
                    return;
                }
                switch (option.ToLower()) {
                    case "create":
                    case "add":
                        if (player.Can(Permission.CreatePortals)) {
                            string addWorld = cmd.Next();
                            if (!string.IsNullOrEmpty(addWorld) && WorldManager.FindWorldExact(addWorld) != null) {
                                DrawOperation operation = new CuboidDrawOperation(player);
                                NormalBrush brush = new NormalBrush(Block.Water, Block.Water);

                                string blockTypeOrName = cmd.Next();
                                Block pblock;
                                if (blockTypeOrName != null && Map.GetBlockByName(blockTypeOrName, false, out pblock)) {
                                    if ((!validPBlocks.Contains(pblock) && pblock <= Block.StoneBrick) || (pblock == Block.Air && player.Info.Rank != RankManager.HighestRank)) {
                                        player.Message("Invalid block, choose a non-solid block");
                                        return;
                                    } else {
                                        brush = new NormalBrush(pblock, pblock);
                                    }
                                }
                                string addPortalName = cmd.Next();
                                if (string.IsNullOrEmpty(addPortalName)) {
                                    player.PortalName = null;
                                } else {
                                    if (!Portal.DoesNameExist(player.World, addPortalName)) {
                                        player.PortalName = addPortalName;
                                    } else {
                                        player.Message("A portal with name {0} already exists in this world.", addPortalName);
                                        return;
                                    }
                                }
                                World tpWorld = WorldManager.FindWorldExact(addWorld);
                                if (cmd.HasNext) {
                                    int x, y, z, rot = player.Position.R, lot = player.Position.L;
                                    if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z)) {
                                        if (cmd.HasNext && cmd.HasNext) {
                                            if (cmd.NextInt(out rot) && cmd.NextInt(out lot)) {
                                                if (rot > 255 || rot < 0) {
                                                    player.Message("R must be inbetween 0 and 255. Set to player R");
                                                    rot = player.Position.R;
                                                }
                                                if (lot > 255 || lot < 0) {
                                                    player.Message("L must be inbetween 0 and 255. Set to player L");
                                                    lot = player.Position.L;
                                                }
                                            }
                                        }
                                        if (x < 1 || x >= 1024 || y < 1 || y >= 1024 || z < 1 || z >= 1024) {
                                            player.Message("Coordinates are outside the valid range!");
                                            return;
                                        } else {
                                            player.PortalTPPos = new Position((short)(x * 32), (short)(y * 32), (short)(z * 32), (byte)rot, (byte)lot);
                                        }
                                    } else {
                                        player.PortalTPPos = tpWorld.map == null ? new Position(0, 0, 0) : tpWorld.map.Spawn;
                                    }
                                } else {
                                    player.PortalTPPos = tpWorld.map == null ? new Position(0, 0, 0) : tpWorld.map.Spawn;
                                }
                                operation.Brush = brush;
                                player.PortalWorld = addWorld;
                                player.SelectionStart(operation.ExpectedMarks, PortalCreateCallback, operation, Permission.CreatePortals);
                                player.Message("Click {0} blocks or use &H/Mark&S to mark the area of the portal.", operation.ExpectedMarks);
                            } else {
                                if (string.IsNullOrEmpty(addWorld)) {
                                    player.Message("No world specified.");
                                } else {
                                    player.MessageNoWorld(addWorld);
                                }
                            }
                        } else {
                            player.MessageNoAccess(Permission.CreatePortals);
                        }
                        break;
                    case "remove":
                    case "delete":
                        if (player.Can(Permission.CreatePortals)) {
                            string remPortalName = cmd.Next();
                            string remWString = cmd.Next();
                            World remWorld = player.World;
                            if (!string.IsNullOrEmpty(remWString)) {
                                remWorld = WorldManager.FindWorldOrPrintMatches(player, remWString);
                            }
                            if (remWorld == null) {
                                return;
                            }
                            if (string.IsNullOrEmpty(remPortalName)) {
                                player.Message("No portal name specified.");
                            } else {
                                if (remWorld.Portals != null && remWorld.Portals.Count > 0) {
                                    bool found = false;
                                    Portal portalFound = null;
                                    lock (remWorld.Portals.SyncRoot) {
                                        foreach (Portal portal in remWorld.Portals) {
                                            if (portal.Name.ToLower().Equals(remPortalName.ToLower())) {
                                                portalFound = portal;
                                                found = true;
                                                break;
                                            }
                                        }
                                        if (!found) {
                                            player.Message("Could not find portal by name {0}.", remPortalName);
                                        } else {
                                            portalFound.Remove(player, remWorld);
                                            player.Message("Portal was removed.");
                                        }
                                    }
                                } else {
                                    player.Message("Could not find portal as this world doesn't contain a portal.");
                                }
                            }
                        } else {
                            player.MessageNoAccess(Permission.CreatePortals);
                        }
                        break;
                    case "info":
                    case "i":
                        string iPortalName = cmd.Next();
                        string iWString = cmd.Next();
                        World iWorld = player.World;
                        if (!string.IsNullOrEmpty(iWString)) {
                            iWorld = WorldManager.FindWorldOrPrintMatches(player, iWString);
                        }
                        if (iWorld == null) {
                            return;
                        }
                        if (string.IsNullOrEmpty(iPortalName)) {
                            player.Message("No portal name specified.");
                        } else {
                            if (iWorld.Portals != null && iWorld.Portals.Count > 0) {
                                bool found = false;

                                lock (iWorld.Portals.SyncRoot) {
                                    foreach (Portal portal in iWorld.Portals) {
                                        if (portal.Name.ToLower().Equals(iPortalName.ToLower())) {
                                            World portalWorld = WorldManager.FindWorldExact(portal.World);
                                            player.Message("Portal {0}&S was created by {1}&S at {2} and teleports to world {3} at {4}&S.",
                                                portal.Name, PlayerDB.FindPlayerInfoExact(portal.Creator).ClassyName, portal.Created, portalWorld.ClassyName, portal.position().ToString());
                                            found = true;
                                        }
                                    }
                                }
                                if (!found) {
                                    player.Message("Could not find portal by name {0}.", iPortalName);
                                }
                            } else {
                                player.Message("Could not find portal as this world doesn't contain a portal.");
                            }
                        }
                        break;
                    case "list":
                    case "l":
                        string lWString = cmd.Next();
                        World lWorld = player.World;
                        if (!string.IsNullOrEmpty(lWString)) {
                            lWorld = WorldManager.FindWorldOrPrintMatches(player, lWString);
                        }
                        if (lWorld == null) {
                            return;
                        }
                        if (lWorld.Portals == null || lWorld.Portals.Count == 0) {
                            player.Message("There are no portals in {0}&S.", lWorld.ClassyName);
                        } else {
                            string[] portalNames = new string[lWorld.Portals.Count];
                            StringBuilder output = new StringBuilder("There are " + lWorld.Portals.Count + " portals in " + lWorld.ClassyName + "&S: ");
                            for (int i = 0; i < lWorld.Portals.Count; i++) {
                                portalNames[i] = ((Portal)lWorld.Portals[i]).Name;
                            }
                            output.Append(portalNames.JoinToString(", "));
                            player.Message(output.ToString());
                        }
                        break;
                    case "enable":
                    case "on":
                        player.PortalsEnabled = true;
                        player.Message("You enabled the use of portals.");
                        break;
                    case "disable":
                    case "off":
                        player.PortalsEnabled = false;
                        player.Message("You disabled the use of portals, type /portal enable to re-enable portals.");
                        break;
                    default:
                        CdPortal.PrintUsage(player);
                        break;
                }
            } catch (PortalException ex) {
                player.Message(ex.Message);
                Logger.Log(LogType.Error, "WorldCommands.PortalH: " + ex);
            } catch (Exception ex) {
                player.Message("Unexpected error: " + ex);
                Logger.Log(LogType.Error, "WorldCommands.PortalH: " + ex);
            }
        }