-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Sub-shapes within Rooms #48
Comments
Hey! Thanks for the suggestion. If I understand your suggestion correctly, these sub-shapes would not change the outline of the rooms, so they would not change the behaviour of the layouting algorithm. If this is the case, it's probably not a good idea to add these sub-shapes to the algorithm itself because it would slow it down. It would be probably better to implement this as a postprocessing step on the output of the algorithm. I added (release 1.0.6, master branch) a simple extension method to the IRoom interface that should help you do this. It could be done as follows:
I also implemented an integration test that should demonstrate how it could be done (here): // Create a rectangular room shape
// Move it away from (0, 0) so that we can properly test the functionality
var rectangleShape = GridPolygon.GetRectangle(10, 4) + new IntVector2(10, 10);
// Create points to be transformed
// These could be for example traps, spawn points, etc.
// We use points of the rectangle here because it is easy to check that the transformation is correct.
var pointsToTransform = rectangleShape.GetPoints();
var mapDescription = new MapDescription<int>();
// Create simple graph with 2 vertices and 1 edge
mapDescription.AddRoom(0);
mapDescription.AddRoom(1);
mapDescription.AddPassage(0, 1);
// Add the rectangle shape
mapDescription.AddRoomShapes(new RoomDescription(rectangleShape, new OverlapMode(1, 0)));
var layoutGenerator = LayoutGeneratorFactory.GetDefaultChainBasedGenerator<int>();
var layout = layoutGenerator.GetLayouts(mapDescription, 1)[0];
foreach (var room in layout.Rooms)
{
// The points were chosen to be the points of the polygon, so after transforming them, they should
// be equal to the room.Shape + room.Position points
var transformedPoints = pointsToTransform.Select(x => room.TransformPointToNewPosition(x));
var expectedPoints = (room.Shape + room.Position).GetPoints();
Assert.That(transformedPoints, Is.EquivalentTo(expectedPoints));
} Is this a solution to your problem/suggestion? |
This is a specific idea that would be useful to my game project - but figured it might be re-usable.
In my game I am working on - each room type will have a specific amount of 'slots' where furniture/devices/interact-able objects can go.
At the moment I don't have anything in place to visualise the slots - but I imagine it would be a case of drawing a series of smaller squares inside a room - ideally adjacent to the walls.
The image would then be visualised with a series of grey outlined boxes inside the room shape.
In my game - players could then choose to put objects / devices / technology into those slots.
Another person might want this feature so they could create table-top dungeon-esq maps that display traps within the room.
Eg: A player who does not have detect trap - gets the original map - minus the trap outlines, but when they 'detect' the trap - the dungeon master reveals the map that has the traps visible.
The text was updated successfully, but these errors were encountered: