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(); } } } } }
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) { makeTower(world, e.Player, e.Coords); } } } } }
internal static void RaisePlayerPlacedBlockEvent( Player player, Map map, Vector3I coords, Block oldBlock, Block newBlock, BlockChangeContext context ) { var e = new PlayerPlacedBlockEventArgs( player, map, coords, oldBlock, newBlock, context ); PlacedBlockEvent.Raise( e ); }