QueueUpdate() публичный Метод

Queues a new block update to be processed. Due to concurrent nature of the server, there is no guarantee that updates will be applied in any specific order.
public QueueUpdate ( BlockUpdate update ) : void
update BlockUpdate
Результат void
Пример #1
0
        public static void playerDisconnected(object sender, PlayerDisconnectedEventArgs e)
        {
            try
            {
                if (e.Player.World != null)
                {
                    if (e.Player.World.IsLoaded)
                    {
                        Map map = e.Player.World.Map;
                        if (e.Player.orangePortal.Count > 0)
                        {
                            int i = 0;
                            foreach (Vector3I block in e.Player.orangePortal)
                            {
                                map.QueueUpdate(new BlockUpdate(null, block, e.Player.orangeOld[i]));
                                i++;
                            }
                            e.Player.orangeOld.Clear();
                            e.Player.orangePortal.Clear();
                        }

                        if (e.Player.bluePortal.Count > 0)
                        {
                            int i = 0;
                            foreach (Vector3I block in e.Player.bluePortal)
                            {
                                map.QueueUpdate(new BlockUpdate(null, block, e.Player.blueOld[i]));
                                i++;
                            }
                            e.Player.blueOld.Clear();
                            e.Player.bluePortal.Clear();
                        }
                    }
                    else
                    {
                        if (e.Player.bluePortal.Count > 0)
                        {
                            e.Player.World.Map.Blocks[e.Player.World.Map.Index(e.Player.bluePortal[0])] =
                                (byte)e.Player.blueOld[0];
                            e.Player.World.Map.Blocks[e.Player.World.Map.Index(e.Player.bluePortal[1])] =
                                (byte)e.Player.blueOld[1];
                        }
                        if (e.Player.orangePortal.Count > 0)
                        {
                            e.Player.WorldMap.Blocks[e.Player.WorldMap.Index(e.Player.orangePortal[0])] =
                                (byte)e.Player.orangeOld[0];
                            e.Player.WorldMap.Blocks[e.Player.WorldMap.Index(e.Player.orangePortal[1])] =
                                (byte)e.Player.orangeOld[1];
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogType.SeriousError, "GunPortalDisconnected: " + ex);
            }
        }
Пример #2
0
 public static void removal(ConcurrentDictionary <String, Vector3I> bullets, Map map)
 {
     foreach (Vector3I bp in bullets.Values)
     {
         map.QueueUpdate(new BlockUpdate(null,
                                         (short)bp.X,
                                         (short)bp.Y,
                                         (short)bp.Z,
                                         Block.Air));
         Vector3I removed;
         bullets.TryRemove(bp.ToString(), out removed);
     }
 }
Пример #3
0
        private static void DrawOneBlock(Player player, Map map, Block drawBlock, Vector3I coord,
                                         BlockChangeContext context, ref int blocks, ref int blocksDenied, fCraft.Drawing.UndoState undoState)
        {
            if (map == null)
            {
                return;
            }
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            if (!map.InBounds(coord))
            {
                return;
            }
            Block block = map.GetBlock(coord);

            if (block == drawBlock)
            {
                return;
            }

            if (player.CanPlace(map, coord, drawBlock, context) != CanPlaceResult.Allowed)
            {
                blocksDenied++;
                return;
            }

            map.QueueUpdate(new BlockUpdate(null, coord, drawBlock));
            Player.RaisePlayerPlacedBlockEvent(player, map, coord, block, drawBlock, context);

            if (!undoState.IsTooLargeToUndo)
            {
                if (!undoState.Add(coord, block))
                {
                    player.Message("NOTE: This draw command is too massive to undo.");
                    player.LastDrawOp = null;
                }
            }
            blocks++;
        }
Пример #4
0
 protected void UpdateMap(BlockUpdate upd)
 {
     _map.SetBlock(upd.X, upd.Y, upd.Z, upd.BlockType);
     _map.QueueUpdate(upd);
 }
Пример #5
0
 public static void removal(ConcurrentDictionary<String, Vector3I> bullets, Map map)
 {
     foreach (Vector3I bp in bullets.Values)
     {
         map.QueueUpdate(new BlockUpdate(null,
             (short)bp.X,
             (short)bp.Y,
             (short)bp.Z,
             Block.Air));
         Vector3I removed;
         bullets.TryRemove(bp.ToString(), out removed);
     }
 }
Пример #6
0
        //stolen from BuildingCommands
        #region DrawOneBlock
        static void DrawOneBlock ( Player player, Map map, Block drawBlock, Vector3I coord,
                                 BlockChangeContext context, ref int blocks, ref int blocksDenied, fCraft.Drawing.UndoState undoState ) {
            if ( map == null ) return;
            if ( player == null ) throw new ArgumentNullException( "player" );

            if ( !map.InBounds( coord ) ) return;
            Block block = map.GetBlock( coord );
            if ( block == drawBlock ) return;

            if ( player.CanPlace( map, coord, drawBlock, context ) != CanPlaceResult.Allowed ) {
                blocksDenied++;
                return;
            }

            map.QueueUpdate( new BlockUpdate( null, coord, drawBlock ) );
            Player.RaisePlayerPlacedBlockEvent( player, map, coord, block, drawBlock, context );

            if ( !undoState.IsTooLargeToUndo ) {
                if ( !undoState.Add( coord, block ) ) {
                    player.Message( "NOTE: This draw command is too massive to undo." );
                    player.LastDrawOp = null;
                }
            }
            blocks++;
        }
Пример #7
0
        public static void ChangedWorld(object sender, PlayerJoinedWorldEventArgs e)
        {
            try {
                if (e.OldWorld != null)
                {
                    if (e.OldWorld.Name == e.NewWorld.Name)
                    {
                        e.Player.orangeOld.Clear();
                        e.Player.orangePortal.Clear();
                        e.Player.blueOld.Clear();
                        e.Player.bluePortal.Clear();
                    }
                    if (e.OldWorld.IsLoaded)
                    {
                        Map map = e.OldWorld.Map;
                        if (e.Player.orangePortal.Count > 0)
                        {
                            int i = 0;
                            foreach (Vector3I block in e.Player.orangePortal)
                            {
                                if (map != null)
                                {
                                    map.QueueUpdate(new BlockUpdate(null, block, e.Player.orangeOld[i]));
                                }
                                i++;
                            }
                            e.Player.orangeOld.Clear();
                            e.Player.orangePortal.Clear();
                        }

                        if (e.Player.bluePortal.Count > 0)
                        {
                            int i = 0;
                            foreach (var block in e.Player.bluePortal)
                            {
                                if (map != null)
                                {
                                    map.QueueUpdate(new BlockUpdate(null, block, e.Player.blueOld[i]));
                                }
                                i++;
                            }
                            e.Player.blueOld.Clear();
                            e.Player.bluePortal.Clear();
                        }
                    }
                    else
                    {
                        if (e.Player.bluePortal.Count > 0)
                        {
                            if (e.OldWorld.Map != null)
                            {
                                e.OldWorld.Map.Blocks[e.OldWorld.Map.Index(e.Player.bluePortal[0])] = ( byte )e.Player.blueOld[0];
                                e.OldWorld.Map.Blocks[e.OldWorld.Map.Index(e.Player.bluePortal[1])] = ( byte )e.Player.blueOld[1];
                            }
                            e.Player.blueOld.Clear();
                            e.Player.bluePortal.Clear();
                        }
                        if (e.Player.orangePortal.Count <= 0)
                        {
                            return;
                        }
                        if (e.OldWorld.Map != null)
                        {
                            e.OldWorld.Map.Blocks[e.OldWorld.Map.Index(e.Player.orangePortal[0])] = ( byte )e.Player.orangeOld[0];
                            e.OldWorld.Map.Blocks[e.OldWorld.Map.Index(e.Player.orangePortal[1])] = ( byte )e.Player.orangeOld[1];
                        }
                        e.Player.orangeOld.Clear();
                        e.Player.orangePortal.Clear();
                    }
                }
            } catch (Exception ex) {
                Logger.Log(LogType.SeriousError, "GunPortalChangeWorld: " + ex);
            }
        }