Housing System
Housing System
Section titled “Housing System”Housing Item Framework
Section titled “Housing Item Framework”Consumable Loot Integration
Section titled “Consumable Loot Integration”Extend loot system to support building mechanics through consumable items:
Struct_Loot Enhancement
Section titled “Struct_Loot Enhancement”Add housing functionality to existing loot structure:
- Consumable Boolean: Mark items as usable from inventory
- Housing Integration: Items spawn as placeable housing objects when consumed
Actor_Housing Implementation
Section titled “Actor_Housing Implementation”Create placeable housing objects:
Housing Actor Components
Section titled “Housing Actor Components”- Static Mesh Component: Root component for visual representation
- Struct_Loot Variable: Contains item data including appearance
- Collision Settings: Custom collision for proper world interaction
Construction Script Integration
Section titled “Construction Script Integration”// Housing Item Appearance SetupOnConstruct() {appearance_mesh = Struct_Loot.Appearance_3D;StaticMesh.SetStaticMesh(appearance_mesh);
// Configure collision for placed objectsStaticMesh.SetCollisionEnabled(NoCollision); // Disabled until placement confirmed}
Housing Placement System
Section titled “Housing Placement System”Inventory Item Consumption
Section titled “Inventory Item Consumption”Implement consumable item usage from inventory:
W_Inventory_Item Enhancement
Section titled “W_Inventory_Item Enhancement”Add consumption functionality to inventory items:
// Consumable Item Button SetupOnConsumableButtonPressed() {if (F_Check_Inventory([Loot_Item], [1])) {if (Loot_Item.Consumable) {// Spawn housing item for placementhousing_item = SpawnActor(Actor_Housing, MouseWorldLocation);housing_item.Struct_Loot = Loot_Item;
StartPlacementMode(housing_item);}}}
Mouse Position Placement
Section titled “Mouse Position Placement”Create intuitive mouse-controlled placement system:
World Position Conversion
Section titled “World Position Conversion”Convert screen mouse position to world coordinates:
// Mouse to World PositionOnPlacementUpdate() {mouse_world_location = ConvertMouseLocationToWorldSpace();ground_trace_start = mouse_world_location + Vector(0,0,250);ground_trace_end = mouse_world_location + Vector(0,0,-5000);
LineTraceForObjects(ground_trace_start, ground_trace_end, [WorldStatic]);
final_location = hit_location;housing_item.SetActorLocation(final_location);}
Grid Snapping System
Section titled “Grid Snapping System”Implement grid-based placement for clean building:
Snap to Grid Implementation
Section titled “Snap to Grid Implementation”// Grid Snapping LogicSnapLocationToGrid(Location, GridSize = 50) {snapped_x = (Location.X / GridSize).Round() * GridSize;snapped_y = (Location.Y / GridSize).Round() * GridSize;snapped_z = Location.Z; // Maintain ground height
return Vector(snapped_x, snapped_y, snapped_z);}
Placement Controls
Section titled “Placement Controls”Real-Time Placement Preview
Section titled “Real-Time Placement Preview”Create smooth placement experience:
Placement Timer System
Section titled “Placement Timer System”- Timer_Housing_Item_Placement: High-frequency timer (0.01 seconds) for smooth updates
- Looping Timer: Continuous updates during placement mode
- Mouse Tracking: Real-time position updates following mouse movement
Placement Confirmation
Section titled “Placement Confirmation”Implement placement controls:
Left Click Confirmation
Section titled “Left Click Confirmation”// Confirm PlacementOnLeftClickDuringPlacement() {if (IsTimerActive(Timer_Housing_Item_Placement)) {// Final validation checkif (F_Check_Inventory([Housing_Item.Loot], [1])) {// Confirm placementStopPlacementTimer();housing_item.StaticMesh.SetCollisionEnabled(QueryAndPhysics);
// Remove item from inventoryInterface_Inventory_Remove([Housing_Item.Loot], [1]);
housing_item_reference = nullptr; // Clear reference}}}
Right Click Cancellation
Section titled “Right Click Cancellation”// Cancel PlacementOnRightClickDuringPlacement() {if (IsTimerActive(Timer_Housing_Item_Placement)) {// Cancel placementStopPlacementTimer();DestroyActor(housing_item);housing_item_reference = nullptr;
// Item remains in inventory}}
Housing Item Recovery
Section titled “Housing Item Recovery”Placed Item Interaction
Section titled “Placed Item Interaction”Allow recovery of placed housing items:
Interaction Integration
Section titled “Interaction Integration”Use existing interaction system for housing recovery:
// Housing Item RecoveryOnHousingItemInteract(PlayerCharacter) {// Add item back to inventoryPlayerCharacter.Interface_Inventory_Add(Struct_Loot);
// Remove from worldDestroyActor(Self);}
This allows players to reclaim and reposition housing items as needed.
Housing System Integration
Section titled “Housing System Integration”UI Integration
Section titled “UI Integration”Connect housing system to existing UI:
- Inventory Widget: Consumable button enables housing placement
- Mouse Controls: Left click to place, right click to cancel
- Grid Visualization: Optional grid overlay during placement mode
World Integration
Section titled “World Integration”- Collision Management: Proper collision states for placed vs. unplaced items
- Performance: Efficient placement update system
- Visual Feedback: Clear indication of placement mode vs. normal gameplay
Housing Examples
Section titled “Housing Examples”Basic Building Blocks
Section titled “Basic Building Blocks”Create simple housing items for testing:
- DT_Loot_Cube: Basic building block
- Consumable Setting: Enable consumable flag
- 3D Appearance: Simple cube mesh for building
Placement Testing
Section titled “Placement Testing”Test housing system with multiple items:
- Multiple Cubes: Place several items to test inventory consumption
- Grid Alignment: Verify snapping works correctly
- Recovery System: Test pickup functionality after placement
The housing system provides creative building mechanics while maintaining integration with existing inventory and interaction systems for seamless gameplay experience.