Added handling to TileEdit event.

This commit is contained in:
high 2011-12-30 19:19:48 -05:00
parent 4864bd94b8
commit bf50a82cbd

View file

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.IO; using System.IO;
using System.IO.Streams; using System.IO.Streams;
using System.Text; using System.Text;
@ -50,14 +51,28 @@ namespace TShockAPI
private static Dictionary<PacketTypes, GetDataHandlerDelegate> GetDataHandlerDelegates; private static Dictionary<PacketTypes, GetDataHandlerDelegate> GetDataHandlerDelegates;
public static int[] WhitelistBuffMaxTime; public static int[] WhitelistBuffMaxTime;
#region Events #region Events
public static event TileEditHandler TileEdit; public class TileEditEventArgs : HandledEventArgs
public delegate void TileEditHandler(float x, float y, float type, float delete);
public static void OnTileEdit(float x, float y, float type, float editType)
{ {
if (TileEdit != null) public float X { get; set; }
{ public float Y { get; set; }
TileEdit(x, y, type, editType); public float Type { get; set; }
public float EditType { get; set; }
} }
public static event EventHandler<TileEditEventArgs> TileEdit;
public static bool OnTileEdit(float x, float y, float type, float editType)
{
if (TileEdit == null)
return false;
var args = new TileEditEventArgs
{
X = x,
Y = y,
Type = type,
EditType = editType
};
TileEdit(null, args);
return args.Handled;
} }
#endregion #endregion
public static void InitGetDataHandler() public static void InitGetDataHandler()
@ -578,7 +593,8 @@ namespace TShockAPI
var tileX = args.Data.ReadInt32(); var tileX = args.Data.ReadInt32();
var tileY = args.Data.ReadInt32(); var tileY = args.Data.ReadInt32();
var tiletype = args.Data.ReadInt8(); var tiletype = args.Data.ReadInt8();
OnTileEdit(tileX, tileY, tiletype, type); if (OnTileEdit(tileX, tileY, tiletype, type))
return true;
if (tileX < 0 || tileX >= Main.maxTilesX || tileY < 0 || tileY >= Main.maxTilesY) if (tileX < 0 || tileX >= Main.maxTilesX || tileY < 0 || tileY >= Main.maxTilesY)
return false; return false;