{"id":18947339,"url":"https://github.com/polinasavelyeva/roominteriorgenerator","last_synced_at":"2025-09-05T12:30:59.955Z","repository":{"id":199106983,"uuid":"692777370","full_name":"PolinaSavelyeva/RoomInteriorGenerator","owner":"PolinaSavelyeva","description":".NET package that helps game developers create unique room interiors","archived":false,"fork":false,"pushed_at":"2024-01-05T17:20:13.000Z","size":1404,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-16T20:46:11.505Z","etag":null,"topics":["csharp","fsharp","game-development","pcg","unity"],"latest_commit_sha":null,"homepage":"https://polinasavelyeva.github.io/RoomInteriorGenerator/","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PolinaSavelyeva.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-09-17T14:55:17.000Z","updated_at":"2024-11-26T00:12:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"7a93acb6-3285-4757-860b-76866e7f1ca4","html_url":"https://github.com/PolinaSavelyeva/RoomInteriorGenerator","commit_stats":null,"previous_names":["polinasavelyeva/roominteriorgenerator"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolinaSavelyeva%2FRoomInteriorGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolinaSavelyeva%2FRoomInteriorGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolinaSavelyeva%2FRoomInteriorGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolinaSavelyeva%2FRoomInteriorGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PolinaSavelyeva","download_url":"https://codeload.github.com/PolinaSavelyeva/RoomInteriorGenerator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232039713,"owners_count":18464029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","fsharp","game-development","pcg","unity"],"created_at":"2024-11-08T13:09:42.925Z","updated_at":"2025-01-01T00:45:33.732Z","avatar_url":"https://github.com/PolinaSavelyeva.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RoomInteriorGenerator\n\n[![NuGet Badge](https://buildstats.info/nuget/RoomInteriorGenerator)](https://www.nuget.org/packages/RoomInteriorGenerator/) \n![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/PolinaSavelyeva/RoomInteriorGenerator/build.yml)\n\nRoomInteriorGenerator is a .NET library that helps developers to create game environments. It allows you to focus only on defining different objects and hierarchical rules between them instead of an arrangement algorithm.\n\n##  Documentation\n\nSee the [GitHub pages](https://polinasavelyeva.github.io/RoomInteriorGenerator/) for the API reference and more information.\n\n## Overview\n\nThe generation process is based on several structures:\n\n- **DataTable**: Lists objects and the rules between them. Consists of several \"columns\": object name, object variants to choose from, rules describing the behaviour of the object and the expected amount of free space around it, and possible child objects that can be placed around the parent.\n- **Cell**: Cell defines the smallest possible unit of a room for arranging furniture. It has several basic states such as Occupied, NonOccupied or AgainstTheWall, which can be extended to give a more accurate furnishing result.\n- **CellGrid**: Describes the available room space using cells and their positions.\n- **Room**: Encapsulates a room using its width, height, floor number as seed for random generator, placement function and data table. \n\nTake a look at a simple code example where we want chairs to stand around the table and couches to stand near the bottom wall. First, we'll create data table rows for all the furniture we want to use, and then create the data table itself:\n\n```fsharp\nlet chairLeftRow =\n    DataTableRow(\"Chair\", [| ObjectVariant(\"WhiteChair\", 1, 1, 1, 1); ObjectVariant(\"BlackChair\", 1, 1, 1, 1); ObjectVariant(\"OrangeChair\", 1, 1, 1, 1) |], Leaf LeftTo, Option.None)\n\nlet couchRow =\n    DataTableRow(\"Couch\", [| ObjectVariant(\"LongCouch\", 3, 3, 0, 0) |], Node AgainstTheBottomWall, Option.None)\n    \nlet tableRow =\n     DataTableRow( \"Table\", [| ObjectVariant(\"DinnerTable\", 2, 2, 2, 2); ObjectVariant(\"OfficeTable\", 2, 2, 3, 3) |],  Node None, Some [| chairLeftRow; chairRightRow; chairBehindRow; chairInFrontOfRow |])\n\nlet table = DataTable([| chairLeftRow; tableRow; couchRow |])\n```\n\nOur placement function will replace the array values with the selected object variant name:\n\n```fsharp\nlet arrayToChange = Array2D.init width length (fun _ _ -\u003e \"None\")\n\nlet placementFunction =\n\n    fun (_: DataTable.DataTableRow\u003c'Value\u003e) (instance: DataTable.ObjectVariant\u003c'Value\u003e) cellRowIndex cellColumnIndex -\u003e\n        for i in cellRowIndex - instance.FreeCellsOnTheTop .. cellRowIndex + instance.FreeCellsOnTheBottom do\n            for j in cellColumnIndex - instance.FreeCellsOnTheLeft .. cellColumnIndex + instance.FreeCellsOnTheRight do\n                arrayToChange[i, j] \u003c- instance.Variant\n\nlet room = Room(length, width, 291, table)    \nroom.GenerateInterior maximumAmountOfObjects placementFunction\n```\n\nAfter the visualising of the array, we have the following result, where tables are green and blue, chairs are black, white and orange and couches are red:\n\n![Plot](https://github.com/PolinaSavelyeva/RoomInteriorGenerator/blob/sample/Samples/withoutcorners.png)\n\n\n##  Unity Example\n\nFirst, add the RoomInteriorGenerator package to your Unity project when you can open it in your desired script. I fill the data table in the inspector and add the current script to the new GameObject. GameObject should be in the top left corner of your room. GameObject will be the coordinate origin for all furniture placement, so make sure you set the x and z axis directions correctly. Also, all the prefabs you want to place should have (0,0,0) position and 0 degrees y-rotation (depending on your GameObject directions this may be different). Be sure to check the object's pivot point, usually it should be in the centre of your object. This will help you to get the most expected result.\n\n![Inspector](https://github.com/PolinaSavelyeva/RoomInteriorGenerator/blob/sample/Samples/Inspector.png)\n\nThe main body of my script looks like this:\n\n```csharp\nprivate void Start()\n{\n    var rows = dataTable.Select(row =\u003e row.ToDataTableRow()).ToArray();\n    var dataTableFs = new DataTable.DataTable\u003cGameObject\u003e(rows);\n    var room = new Room\u003cGameObject\u003e(roomLength, roomWidth, floorNumber, dataTableFs);\n    var tupleFunction =\n        FuncConvert.ToFSharpFunc\u003cTuple\u003cDataTable.DataTableRow\u003cGameObject\u003e, DataTable.ObjectVariant\u003cGameObject\u003e, int, int\u003e\u003e(\n                t =\u003e PlaceObject(t.Item1, t.Item2, t.Item3, t.Item4));\n    var placementFunction = FuncConvert.FuncFromTupled(tupleFunction);\n\n    room.GenerateInterior(maximumAmountOfObjects, placementFunction);\n}\n```\n\nThe final result:\n\n![Room](https://github.com/PolinaSavelyeva/RoomInteriorGenerator/blob/sample/Samples/Room.png)\n\nTake a look at the [Time-Reactor-Game](https://github.com/RuslanBeresnev/Time-Reactor-Game) to see all the steps of package implementation.\n\n## Requirements\n\nMake sure the following requirements are installed on your system:\n\n- [dotnet SDK](https://www.microsoft.com/net/download/core) 3.0 or higher (recommended 6.0+),\n- [Mono](http://www.mono-project.com/) if you're on Linux or macOS\nor\n- [VSCode Dev Container](https://code.visualstudio.com/docs/remote/containers).\n\n### Template\nTo find more building and running options take a look at the [MiniScaffold](https://github.com/TheAngryByrd/MiniScaffold) template.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolinasavelyeva%2Froominteriorgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolinasavelyeva%2Froominteriorgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolinasavelyeva%2Froominteriorgenerator/lists"}