Add snap to grid for field items, upgrade handle extensions: delete tile

Setting a field item with the snap active will align it to the major gridlines. This will prevent the user from setting un-interactable objects (rocks, trees) unintentionally.

Having the auto-handle extension tiles will now delete all associated tiles when issuing a delete command on an extension tile, rather than just deleting the extension tile.
This commit is contained in:
Kurt
2020-05-16 12:03:21 -07:00
parent 5f46a5c247
commit 6b678ac704
14 changed files with 78 additions and 26 deletions

View File

@@ -320,6 +320,15 @@ private void SetTile(Item tile, int x, int y)
var l = Map.CurrentLayer;
var pgt = new Item();
ItemEdit.SetItem(pgt);
if (pgt.IsFieldItem && CHK_FieldItemSnap.Checked)
{
// coordinates must be even (not odd-half)
x &= 0xFFFE;
y &= 0xFFFE;
tile = l.GetTile(x, y);
}
var permission = l.IsOccupied(pgt, x, y);
switch (permission)
{
@@ -351,8 +360,17 @@ private void SetTile(TerrainTile tile)
private void DeleteTile(Item tile, int x, int y)
{
if (tile.IsRoot && CHK_AutoExtension.Checked)
if (CHK_AutoExtension.Checked)
{
if (!tile.IsRoot)
{
x -= tile.ExtensionX;
y -= tile.ExtensionY;
tile = Map.CurrentLayer.GetTile(x, y);
}
Map.CurrentLayer.DeleteExtensionTiles(tile, x, y);
}
tile.Delete();
ReloadItems();
}