private void PutDownGrabbable(Grabbable grabbable, Map map) { Check.NullArgument<Grabbable>(grabbable, "grabbable"); Check.NullArgument<Map>(map, "map"); var startpoint = grabbable.GetStartPoint(); ActionBatchAction<PlaceTileAction> batchaction = new ActionBatchAction<PlaceTileAction>(); foreach (var tile in grabbable.Tiles) { var mappoint = new MapPoint(startpoint.X + tile.Offset.X, startpoint.Y + tile.Offset.Y); if (!ComponentHelpers.PointInMap(map, mappoint)) continue; batchaction.Add(new PlaceTileAction(mappoint.IntX, mappoint.IntY, MapLayers.UnderLayer, tile.Layer1)); batchaction.Add(new PlaceTileAction(mappoint.IntX, mappoint.IntY, MapLayers.BaseLayer, tile.Layer2)); batchaction.Add(new PlaceTileAction(mappoint.IntX, mappoint.IntY, MapLayers.MiddleLayer, tile.Layer3)); batchaction.Add(new PlaceTileAction(mappoint.IntX, mappoint.IntY, MapLayers.TopLayer, tile.Layer4)); } if (grabbable.CreatePoint != grabbable.GetStartPoint()) { MapEditorManager.ActionManager.PerformAction(batchaction); batchaction.AddRange(grabbable.MoveClearActions.Actions); } else batchaction.Do(context); }
private void GrabbableMoveClearAction(Grabbable g, MapPoint point, Map map) { // We moved, we haven't cleared, and we should clear tiles under our starting point if (point != g.CreatePoint && g.ClearOnMove && !g.Cleared) { ActionBatchAction<PlaceTileAction> batchaction = new ActionBatchAction<PlaceTileAction>(); foreach (var tile in g.Tiles) { var original = new MapPoint(g.CreatePoint.X + tile.Offset.X, g.CreatePoint.Y + tile.Offset.Y); batchaction.Add(new PlaceTileAction(original.IntX, original.IntY, MapLayers.UnderLayer, -1)); batchaction.Add(new PlaceTileAction(original.IntX, original.IntY, MapLayers.BaseLayer, -1)); batchaction.Add(new PlaceTileAction(original.IntX, original.IntY, MapLayers.MiddleLayer, -1)); batchaction.Add(new PlaceTileAction(original.IntX, original.IntY, MapLayers.TopLayer, -1)); } batchaction.Do(context); g.MoveClearActions = batchaction; g.Cleared = true; } }