From 88b9a85b5cc019201fae89764a41b0449448bc68 Mon Sep 17 00:00:00 2001 From: Twitchy Date: Mon, 8 Aug 2011 22:11:17 +1200 Subject: [PATCH] Changed Regions to a tile selection by hitting it. Makes everything a ton more accurate. --- TShockAPI/Commands.cs | 22 +++++++++------------- TShockAPI/GetDataHandlers.cs | 31 +++++++++++++++++++++++++++++++ TShockAPI/TSPlayer.cs | 2 ++ 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 4165a37f..74c10023 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1683,25 +1683,19 @@ namespace TShockAPI { if (args.Parameters[1] == "1") { - args.Player.TempArea.X = args.Player.TileX; - args.Player.TempArea.Y = args.Player.TileY; - args.Player.SendMessage("Set Temp Point 1", Color.Yellow); + if (!args.Player.AwaitingTemp2) + args.Player.AwaitingTemp1 = true; + else + args.Player.SendMessage("Awaiting you to Set Point 2", Color.Yellow); } else if (args.Parameters[1] == "2") { if (args.Player.TempArea.X != 0) { - if (args.Player.TileX > args.Player.TempArea.X && args.Player.TileY > args.Player.TempArea.Y) - { - args.Player.TempArea.Width = args.Player.TileX - args.Player.TempArea.X; - args.Player.TempArea.Height = (args.Player.TileY + 3) - args.Player.TempArea.Y; - args.Player.SendMessage("Set Temp Point 2", Color.Yellow); - } + if (!args.Player.AwaitingTemp1) + args.Player.AwaitingTemp2 = true; else - { - args.Player.SendMessage("Point 2 must be below and right of Point 1", Color.Yellow); - args.Player.SendMessage("Use /region clear to start again", Color.Yellow); - } + args.Player.SendMessage("Awaiting you to Set Point 1", Color.Yellow); } else { @@ -1785,6 +1779,8 @@ namespace TShockAPI { args.Player.TempArea = Rectangle.Empty; args.Player.SendMessage("Cleared temp area", Color.Yellow); + args.Player.AwaitingTemp1 = false; + args.Player.AwaitingTemp2 = false; break; } case "allow": diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 2b829071..9128ec70 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -256,6 +256,37 @@ namespace TShockAPI int x = args.Data.ReadInt32(); int y = args.Data.ReadInt32(); byte tiletype = args.Data.ReadInt8(); + + if (args.Player.AwaitingTemp1) + { + args.Player.TempArea.X = x; + args.Player.TempArea.Y = y; + args.Player.SendMessage("Set Temp Point 1", Color.Yellow); + args.Player.SendTileSquare(x, y); + args.Player.AwaitingTemp1 = false; + return true; + } + + if (args.Player.AwaitingTemp2) + { + if (x > args.Player.TempArea.X && y > args.Player.TempArea.Y) + { + args.Player.TempArea.Width = x - args.Player.TempArea.X; + args.Player.TempArea.Height = y - args.Player.TempArea.Y; + args.Player.SendMessage("Set Temp Point 2", Color.Yellow); + args.Player.SendTileSquare(x, y); + args.Player.AwaitingTemp2 = false; + } + else + { + args.Player.SendMessage("Point 2 must be below and right of Point 1", Color.Yellow); + args.Player.SendMessage("Use /region clear to start again", Color.Yellow); + args.Player.SendTileSquare(x, y); + args.Player.AwaitingTemp2 = false; + } + return true; + } + if (!args.Player.Group.HasPermission("canbuild")) { if (!args.Player.HasBeenSpammedWithBuildMessage) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 3ea6197b..077eff5a 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -39,6 +39,8 @@ namespace TShockAPI public int Index { get; protected set; } public DateTime LastPvpChange { get; protected set; } public Rectangle TempArea; + public bool AwaitingTemp1 { get; set; } + public bool AwaitingTemp2 { get; set; } public DateTime LastExplosive { get; set; } public DateTime LastTileChangeNotify { get; set; } public bool InitSpawn;