Пример #1
0
        public static void CreateMessageBlock( MessageBlock MessageBlock, World source )
        {
            World world = WorldManager.FindWorldExact( MessageBlock.World );

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

            lock ( source.Map.MessageBlocks.SyncRoot ) {
                source.Map.MessageBlocks.Add( MessageBlock );
            }
        }
Пример #2
0
        public static MessageBlockRange CalculateRange(MessageBlock MessageBlock)
        {
            MessageBlockRange range = new MessageBlockRange(0, 0, 0, 0, 0, 0);

            range.Xmin = MessageBlock.AffectedBlock.X;
            range.Xmax = MessageBlock.AffectedBlock.X;
            range.Ymin = MessageBlock.AffectedBlock.Y;
            range.Ymax = MessageBlock.AffectedBlock.Y;
            range.Zmin = MessageBlock.AffectedBlock.Z;
            range.Zmax = MessageBlock.AffectedBlock.Z;
            return(range);
        }
Пример #3
0
        public static MessageBlock GetMessageBlock(World world, Vector3I block)
        {
            MessageBlock MessageBlock = null;

            try {
                if (world.Map.MessageBlocks != null && world.Map.MessageBlocks.Count > 0)
                {
                    lock (world.Map.MessageBlocks.SyncRoot) {
                        foreach (MessageBlock possibleMessageBlock in world.Map.MessageBlocks)
                        {
                            if (possibleMessageBlock.IsInRange(block))
                            {
                                return(possibleMessageBlock);
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.Log(LogType.Error, "MessageBlockHandler.GetMessageBlock: " + ex);
            }

            return(MessageBlock);
        }
Пример #4
0
 public static MessageBlockRange CalculateRange( MessageBlock MessageBlock )
 {
     MessageBlockRange range = new MessageBlockRange( 0, 0, 0, 0, 0, 0 )
     {
         Xmin = MessageBlock.AffectedBlock.X,
         Xmax = MessageBlock.AffectedBlock.X,
         Ymin = MessageBlock.AffectedBlock.Y,
         Ymax = MessageBlock.AffectedBlock.Y,
         Zmin = MessageBlock.AffectedBlock.Z,
         Zmax = MessageBlock.AffectedBlock.Z
     };
     return range;
 }
Пример #5
0
 public void UpdateMessageBlock( MessageBlock MessageBlock )
 {
     MessageBlock.Name = Name;
     MessageBlock.Creator = Creator;
     MessageBlock.Created = Created;
     MessageBlock.World = World;
     MessageBlock.AffectedBlock = new Vector3I( AffectedBlockX, AffectedBlockY, AffectedBlockZ );
     MessageBlock.Range = new MessageBlockRange( XMin, XMax, YMin, YMax, ZMin, ZMax );
     MessageBlock.Message = Message;
 }
Пример #6
0
 public SerializedData( MessageBlock MessageBlock )
 {
     lock ( MessageBlock ) {
         Name = MessageBlock.Name;
         Creator = MessageBlock.Creator;
         Created = MessageBlock.Created;
         World = MessageBlock.World;
         AffectedBlockX = MessageBlock.AffectedBlock.X;
         AffectedBlockY = MessageBlock.AffectedBlock.Y;
         AffectedBlockZ = MessageBlock.AffectedBlock.Z;
         XMin = MessageBlock.Range.Xmin;
         XMax = MessageBlock.Range.Xmax;
         YMin = MessageBlock.Range.Ymin;
         YMax = MessageBlock.Range.Ymax;
         ZMin = MessageBlock.Range.Zmin;
         ZMax = MessageBlock.Range.Zmax;
         Message = MessageBlock.Message;
     }
 }
Пример #7
0
        public static MessageBlock Deserialize( string name, string sdata, Map map )
        {
            byte[] bdata = Convert.FromBase64String( sdata );
            MessageBlock MessageBlock = new MessageBlock();
            DataContractSerializer serializer = new DataContractSerializer( typeof( SerializedData ) );
            System.IO.MemoryStream s = new System.IO.MemoryStream( bdata );
            SerializedData data = ( SerializedData )serializer.ReadObject( s );

            data.UpdateMessageBlock( MessageBlock );
            return MessageBlock;
        }
Пример #8
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 );
        }
Пример #9
0
 public static MessageBlockRange CalculateRange( MessageBlock MessageBlock )
 {
     MessageBlockRange range = new MessageBlockRange( 0, 0, 0, 0, 0, 0 );
     range.Xmin = MessageBlock.AffectedBlock.X;
     range.Xmax = MessageBlock.AffectedBlock.X;
     range.Ymin = MessageBlock.AffectedBlock.Y;
     range.Ymax = MessageBlock.AffectedBlock.Y;
     range.Zmin = MessageBlock.AffectedBlock.Z;
     range.Zmax = MessageBlock.AffectedBlock.Z;
     return range;
 }