示例#1
0
 static void Player_PlacedBlock(object sender, Events.PlayerPlacedBlockEventArgs e)
 {
     try
     {
         if (e.Player.World.Portals != null && e.Player.World.Portals.Count > 0 && e.Context != BlockChangeContext.Portal)
         {
             lock (e.Player.World.Portals.SyncRoot)
             {
                 foreach (Portal portal in e.Player.World.Portals)
                 {
                     if (portal.IsInRange(e.Coords))
                     {
                         BlockUpdate update = new BlockUpdate(null, e.Coords, e.OldBlock);
                         e.Player.World.Map.QueueUpdate(update);
                         e.Player.Message("You can not place a block inside portal: " + portal.Name);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Log(LogType.Error, "PortalHandler.Player_PlacedBlock: " + ex);
     }
 }
示例#2
0
        public static void towerInit(object sender, Events.PlayerPlacedBlockEventArgs e)
        {
            World world = e.Player.World;

            if (e.Player.towerMode)
            {
                if (world.Map != null && world.IsLoaded)
                {
                    if (e.Context == BlockChangeContext.Manual)
                    {
                        if (e.NewBlock == Block.Iron)
                        {
                            waterThread = new Thread(new ThreadStart(delegate
                            {
                                if (e.Player.TowerCache != null)
                                {
                                    world.Map.QueueUpdate(new BlockUpdate(null, e.Player.towerOrigin, Block.Air));
                                    e.Player.towerOrigin = e.Coords;
                                    foreach (Vector3I block in e.Player.TowerCache.Values)
                                    {
                                        e.Player.Send(PacketWriter.MakeSetBlock(block, Block.Air));
                                    }
                                    e.Player.TowerCache.Clear();
                                }
                                e.Player.towerOrigin = e.Coords;
                                e.Player.TowerCache  = new System.Collections.Concurrent.ConcurrentDictionary <string, Vector3I>();
                                for (int z = e.Coords.Z; z <= world.Map.Height; z++)
                                {
                                    Thread.Sleep(250);
                                    if (world.Map != null && world.IsLoaded)
                                    {
                                        if (world.Map.GetBlock(e.Coords.X, e.Coords.Y, z + 1) != Block.Air ||
                                            world.Map.GetBlock(e.Coords) != Block.Iron ||
                                            e.Player.towerOrigin != e.Coords ||
                                            !e.Player.towerMode)
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            Vector3I tower = new Vector3I(e.Coords.X, e.Coords.Y, z + 1);
                                            e.Player.TowerCache.TryAdd(tower.ToString(), tower);
                                            e.Player.Send(PacketWriter.MakeSetBlock(tower, Block.Water));
                                        }
                                    }
                                }
                            })); waterThread.Start();
                        }
                    }
                }
            }
        }
示例#3
0
        static void Player_PlacedBlock(object sender, Events.PlayerPlacedBlockEventArgs e)
        {
            if (e.Player == Player.Console || e.Context == BlockChangeContext.Portal)
            {
                return;
            }
            try {
                Portal portal = e.Player.World.Portals.Find(e.Coords);
                if (portal == null)
                {
                    return;
                }

                BlockUpdate update = new BlockUpdate(null, e.Coords, e.OldBlock);
                e.Player.World.Map.QueueUpdate(update);
                e.Player.Message("You can not place a block inside portal: " + portal.Name);
            } catch (Exception ex) {
                Logger.Log(LogType.Error, "PortalHandler.Player_PlacedBlock: " + ex);
            }
        }