Esempio n. 1
0
        public Placeable AddPlaceable(IPlaceableTemplate template, Location loc, Size sz = null)
        {
            if (sz == null)
            {
                if (GetPlaceables((int)loc.X, (int)loc.Y).Any())
                {
                    throw new LocationAlreadyInUseException(loc);
                }
            }
            else
            {
                if (GetPlaceables((int)loc.X, (int)loc.Y, sz.Width, sz.Height).Any())
                {
                    throw new LocationAlreadyInUseException(loc);
                }
            }

            var placeable = template.CreatePlaceableInstance(loc, sz);

            Placeables.Add(placeable);
            placeable.OnAdded();
            return(placeable);
        }
Esempio n. 2
0
 public Placeable AddPlaceable(IPlaceableTemplate template, int x, int y, int w = 0, int h = 0) =>
 AddPlaceable(template, new Location(x, y), w == 0 && h == 0 ? null : new Size(w, h));