J. Rogers, SE Ohio
1. Executive Summary
2. Goals & Requirements
Structured Generation: Ensure a "Farm" generates with a house, a barn, and a coop, not just a random cluster of rooms.Verticality: Support for multi-floor buildings and multi-level dungeons.Connectivity: A formal system for "Portals" (stairs, ladders, secret doors) that link different map nodes.Persistence: The generated grid data and room layouts must be saved to the database so they are not re-generated on every visit.Modularity: The system must be extensible, allowing new building or dungeon types to be added simply by creating new JSON blueprint files, without changing Python code.AI Integration: The blueprint should serve as a structural guide for AI content generation, providing context for populating rooms with descriptions, NPCs, and items.
3. Core Concept: The Blueprint File
data/└── blueprints/
├── buildings/
│ ├── tavern_two_story.json
│ ├── farm_small.json
│ └── temple.json
└── dungeons/
└── crypt_standard.json
4. Blueprint JSON Schema
Example: farm_small.json
{ "id": "farm_small",
"name": "Small Farmstead",
"description": "A modest farm with a main house and a few outbuildings.",
"tags": ["rural", "residential"],
"main_building": {
"blueprint_id": "house_rural_two_floor",
"name_template": "{owner}'s Farmhouse"
},
"outbuildings": [
{
"blueprint_id": "barn_small",
"name_template": "Barn",
"count": 1,
"placement_rules": {
"min_dist_from_main": 5,
"max_dist_from_main": 15
}
},
{
"blueprint_id": "coop_simple",
"name_template": "Chicken Coop",
"count": 1,
"placement_rules": {
"min_dist_from_main": 3,
"max_dist_from_main": 8
}
}
]
}
Example: house_rural_two_floor.json (A component used by the farm)
{ "id": "house_rural_two_floor",
"name": "Rural Two-Floor House",
"tags": ["residential"],
"layout": {
"grid_size": {"w": 12, "h": 10},
"floors": 2,
"room_rules": [
{ "tag": "kitchen", "floor": 1, "placement_hint": "rear", "min_size": 12 },
{ "tag": "living_area", "floor": 1, "placement_hint": "front", "min_size": 20 },
{ "tag": "bedroom", "floor": 2, "count": 2, "min_size": 9 }
],
"portals": [
{ "type": "stairs", "link": [1, 2], "placement_hint": "central" }
]
}
}
5. Generation Workflow (Code Logic)
Trigger: The user Shift+Clicks a "Building" marker on the Local Map (e.g., "Miller's Farm"). The marker.metadata contains {"blueprint_id": "farm_small"}.Check Persistence: The TacticalGenerator checks if child nodes (interiors) already exist for this marker. If so, it loads them. If not, it proceeds.Parse Blueprint: The generator loads farm_small.json.Generate Compound Node: It understands this is a compound structure. It will generate a grid layout for the "plot" of land.Place Structures: It recursively calls itself to generate the main_building (house_rural_two_floor.json). It creates a new node in the database for Floor 1 of the house.It runs a partitioning algorithm (e.g., Binary Space Partitioning) on the defined grid_size to create rooms that satisfy the room_rules. It creates another node for Floor 2 .It creates portal markers (type: "stairs") on both nodes, storing the target_node_id in their metadata to link them. It then places the outbuildings (barn_small, coop_simple) on the main plot grid, creating separate nodes for their interiors if defined.
Save Geometry: The final grid data for each floor/building ([[1,1,0], [0,1,0]]) is saved into the geometry_data field of its corresponding node.Return Entry Node: The generator returns the ID of the primary entry point (Floor 1 of the main house). The MapViewer then loads this node.
6. Database Integration
Nodes: Each floor of a building and each level of a dungeon becomes a separate node record.parent_node_id links the interior map back to the local map it's on. type will be building_interior or dungeon_level. geometry_data stores the generated grid map. metadata stores level-specific details (e.g., lighting, theme).
Markers: A marker on the Local Map represents the entire compound (e.g., the Farm). Markers inside an interior map are used for portals (stairs, doors) or interactive objects (chests, levers).Portal markers will have metadata like {"target_node_id": 124, "target_coords": [5, 10]}.
7. User Interaction Flow
Creation: On the Local Map, the user Shift+Clicks. The NativeMarkerEditor appears.The user selects "Building". A new dropdown appears, populated by scanning the data/blueprints/buildings/ directory. The user selects "Small Farmstead". The editor saves a new marker with metadata: {"blueprint_id": "farm_small"}. Entry: The user Shift+Clicks the new "Small Farmstead" marker.The system triggers the TacticalGenerator, which executes the workflow described above. The view changes to a new BattleMapStrategy renderer, showing the grid for Floor 1 of the farmhouse.
No comments:
Post a Comment