fCraft.Map.QueueUpdate C# (CSharp) Method

QueueUpdate() public method

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
return void
        public void QueueUpdate( BlockUpdate update )
        {
            updates.Enqueue( update );
        }

Usage Example

Example #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);
            }
        }
All Usage Examples Of fCraft.Map::QueueUpdate