/// <summary> /// Attempts to place generate a building based on <paramref name="bp"/> in the plot specified /// </summary> /// <param name="bp"></param> /// <param name="plot"></param> private bool GenBuildingInPlot(BuildingPlan bp, Plot plot) { Vec2i entrance = GenerationRandom.RandomFromArray(plot.EntranceSides); BuildingGenerationPlan bpPlan = new BuildingGenerationPlan() { BuildingPlan = bp, EntranceSide = entrance, MaxHeight = plot.Bounds.Height, MaxWidth = plot.Bounds.Width }; if (bp.MinSize > plot.Bounds.Width || bp.MinSize > plot.Bounds.Height) { return(false); } Building b = BuildingGenerator.CreateBuilding(GenerationRandom, out BuildingVoxels vox, bpPlan); Vec2i pos = new Vec2i(plot.Bounds.X, plot.Bounds.Y); if (entrance.x == -1) { pos = new Vec2i(plot.Bounds.X, plot.Bounds.Y + GenerationRandom.RandomIntFromSet(0, plot.Bounds.Height - b.Height)); } else if (entrance.x == 1) { pos = new Vec2i(plot.Bounds.X + (plot.Bounds.Width - b.Width), plot.Bounds.Y + GenerationRandom.RandomIntFromSet(0, plot.Bounds.Height - b.Height)); } else if (entrance.z == -1) { pos = new Vec2i(plot.Bounds.X + GenerationRandom.RandomIntFromSet(0, plot.Bounds.Width - b.Width), plot.Bounds.Y); } else if (entrance.z == 1) { pos = new Vec2i(plot.Bounds.X + GenerationRandom.RandomIntFromSet(0, plot.Bounds.Width - b.Width), plot.Bounds.Y + (plot.Bounds.Height - b.Height)); } Recti r = AddBuilding(b, vox, pos); if (r != null) { BuildingPlots.Add(r); return(true); } return(false); }