Feat/build zone check#75
Open
inqus637 wants to merge 3 commits intoIlyaChichkov:developfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builder Check-Zone API Design
Overview
Add a new endpoint to check if a rectangular area can be used for building heavy constructions.
Endpoint
POST /api/v1/builder/check-zoneRequest
{ "mapId": "uuid", "pointA": { "x": 10, "z": 20 }, "pointB": { "x": 50, "z": 60 } }mapId: UUID of the mappointA: First corner of the areapointB: Second corner of the areaResponse
{ "canBuild": false, "issues": { "terrain": [ { "x": 15, "z": 25, "defName": "Soil", "label": "Dirt" } ], "ores": [ { "x": 30, "z": 40, "defName": "MineableChrome", "label": "Chrome" } ], "buildings": [ { "x": 45, "z": 55, "defName": "Table", "label": "Table" } ], "zones": [ { "x": 35, "z": 45, "zoneType": "Growing", "label": "Farm 1" }, { "x": 10, "z": 15, "zoneType": "Stockpile", "label": "Storage" } ] } }canBuild:trueif no issues,falseotherwiseissues: Grouped by categoryterrain: Cells with terrain lacking Heavy affordanceores: Mineable rocks/oresbuildings: Existing buildingszones: Growing or Stockpile zonesImplementation Details
Logic
map.terrainGrid.TerrainAt(cell)- check ifaffordancesdoes NOT contain Heavycell.GetThingList(map)- checkthing.def.building.mineablething.def.category == ThingCategory.Buildingmap.zoneManager.AllZones, filter byZone_GrowingandZone_Stockpile, check if any cell in the zone overlaps with the check areaData Structures
CheckZoneRequestDtotoBuilderDtos.csCheckZoneResultDtotoBuilderDtos.cswith nested DTOs for each issue typeCheckZonemethod toIBuilderServiceandBuilderServiceBuilderControllerRimWorld API References
map.terrainGrid.TerrainAt(IntVec3)- get terrain at cellTerrainDef.affordances- list of affordance defs (check for Heavy)cell.GetThingList(Map)- get all things at cellThingDef.building.mineable- check if mineableThingCategory.Building- category for buildingsmap.zoneManager.AllZones- all zones on mapZone_Growing,Zone_Stockpile- zone types to checkZone.cells- cells belonging to a zone