Skip to main content

World Generation Overview

Build Information

Current documentation based on build version: 676042 Last updated: 2025-06-21

System Purpose

The World Generation category provides the core infrastructure for creating, customizing, and managing Don't Starve Together game worlds. These systems handle everything from initial terrain creation to runtime world configuration, enabling diverse and customizable gameplay experiences.

Key Responsibilities

  • Orchestrate complete world creation from terrain to entities
  • Manage world customization presets and player preferences
  • Handle runtime world settings and difficulty adjustments
  • Provide resource regrowth and spatial distribution utilities
  • Support prefab variation systems for world diversity

System Scope

This category includes all systems involved in world creation, configuration, and ongoing world state management, but excludes entity-specific behaviors and player interaction systems.

Architecture Overview

System Components

World generation systems are organized into three main layers: core generation engines, configuration management, and runtime utilities.

Data Flow

World Presets → Generation Pipeline → Terrain Creation → Entity Placement
↓ ↓ ↓ ↓
Settings Config → World Settings → Map Generation → World State
↓ ↓ ↓ ↓
Runtime Overrides → Component Timers → Regrowth Systems → Active World

Integration Points

  • Fundamentals: Basic entity and component systems provide foundation
  • World Systems: Terrain and entity systems use generation data
  • Data Management: Preset and configuration persistence
  • User Interface: World creation and settings interfaces

Recent Changes

BuildDateComponentChange TypeDescription
6760422025-06-21World Generation MainstableCurrent world generation system
6760422025-06-21Custom PresetsstableFile-based preset management
6760422025-06-21World Settings OverridesstableComprehensive configuration system

Core Generation Modules

World Generation Core

Core world creation orchestration and map generation engine.

ModuleStatusDescriptionKey Features
World Generation MainstablePrimary world creation systemTerrain generation, entity placement

Prefab Systems

World diversity and prefab variation systems.

ModuleStatusDescriptionKey Features
Prefab SwapsstableAlternative prefab placement systemResource variations, world diversity

Configuration Management

World preset and settings management systems.

ModuleStatusDescriptionKey Features
Custom PresetsstablePlayer-created world presetsPreset creation, storage, migration
World Settings OverridesstableComprehensive world configurationDifficulty scaling, gameplay tuning

Runtime Utilities

World state management and component integration utilities.

ModuleStatusDescriptionKey Features
World Settings UtilstableComponent timer integrationExternal timer management
Regrowth UtilstableResource regrowth calculationsSpatial distribution, density calculations

Discovery Systems

Player discovery and progression tracking systems.

ModuleStatusDescriptionKey Features
Plant Registry DatastablePlant discovery trackingGrowth stage learning, achievement integration

Common Generation Patterns

World Creation Pipeline

-- Standard world generation pattern
local world_data = {
level_type = "SURVIVAL_TOGETHER",
level_data = level_definition,
show_debug = false
}

-- Generate new world
local savedata = GenerateNew(false, world_data)
if savedata then
print("World generation successful!")
end

Custom Preset Management

-- Create and save custom world preset
local customPresets = CustomPresets()
customPresets:Load()

local success = customPresets:SaveCustomPreset(
LEVELCATEGORY.SETTINGS,
"CUSTOM_SURVIVAL_RELAXED",
"SURVIVAL_TOGETHER",
{ day = "longday", pvp = false },
"Relaxed Survival",
"Extended days with reduced difficulty"
)

World Settings Configuration

-- Apply world difficulty overrides
local worldsettings_overrides = require("worldsettings_overrides")

-- Pre-generation settings
worldsettings_overrides.Pre.deerclops("often")
worldsettings_overrides.Pre.regrowth("fast")

-- Post-generation settings (after TheWorld exists)
worldsettings_overrides.Post.weather("rare")
worldsettings_overrides.Post.autumn("longseason")

Generation System Dependencies

Required Systems

Optional Systems

Performance Considerations

Generation Optimization

  • World generation uses retry mechanisms for failed attempts
  • Memory management includes garbage collection between retries
  • Profiling tools built into generation pipeline for performance analysis
  • Map size limits balanced for different platform capabilities

Runtime Performance

  • External timer systems reduce component overhead
  • Regrowth calculations use optimized spatial algorithms
  • Preset loading implements caching for frequently accessed data
  • Settings overrides minimize runtime computation impact

Scaling Considerations

  • Generation system supports various world sizes and complexities
  • Component timer scaling adapts to world settings and difficulty
  • Resource regrowth systems handle large world areas efficiently
  • Preset systems scale with increasing numbers of custom configurations

Development Guidelines

Best Practices

  • Always validate world generation parameters before creation
  • Use custom presets for testing specific world configurations
  • Apply settings overrides consistently between pre and post generation phases
  • Test world generation with various platform constraints and memory limits

Common Pitfalls

  • Not handling world generation failures and retry scenarios gracefully
  • Applying post-generation overrides before TheWorld entity exists
  • Creating world settings that conflict with other game systems
  • Ignoring platform-specific limitations during world generation

Testing Strategies

  • Test world generation with various preset combinations and override settings
  • Verify custom preset migration from legacy profile systems
  • Test external timer integration with different component configurations
  • Validate world generation performance across different platform targets

World Generation Integration

With Game Systems

World generation systems provide foundation data for all game mechanics:

  • Terrain data drives movement and interaction systems
  • Entity placement affects resource availability and gameplay balance
  • Settings overrides influence all time-based game mechanics
  • Preset systems enable consistent multiplayer experiences

With Mod Systems

Generation systems support extensive mod integration:

  • Custom world types and generation algorithms
  • Additional world settings and override categories
  • Modified prefab placement and swap systems
  • Extended preset capabilities and storage formats

With Platform Systems

Generation adapts to different platform requirements:

  • Memory constraints influence world size and entity density
  • Processing power affects generation algorithm complexity
  • Storage limitations impact preset and configuration options
  • Network capabilities determine multiplayer world sharing features

Troubleshooting Generation Issues

Common Generation Problems

IssueSymptomsSolution
World generation failureGeneration retries repeatedlyCheck memory constraints and world settings compatibility
Custom presets not savingPreset creation returns falseVerify preset ID format and storage permissions
Settings overrides ignoredWorld doesn't reflect configured difficultyEnsure overrides applied in correct pre/post generation phase
External timers not workingComponents use internal timingVerify world settings util integration and component setup

Debugging Generation Systems

  • Use world generation profiling tools to identify performance bottlenecks
  • Check generation debug output for entity placement and terrain issues
  • Verify custom preset data structure integrity and migration status
  • Review settings override application order and dependency requirements

Advanced Generation Features

Custom World Types

  • Framework for implementing new world generation algorithms
  • Support for custom terrain types and entity placement rules
  • Integration patterns for mod-added world generation features
  • Extensible preset system for new world configuration options

Dynamic World Configuration

  • Runtime modification of world settings and difficulty parameters
  • Hot-swapping of certain world generation parameters during gameplay
  • Integration with event systems for triggered world state changes
  • Support for time-based or condition-based world configuration updates

Maintenance and Evolution

System Maintenance

  • Regular validation of world generation algorithms with new builds
  • Testing of custom preset migration with various legacy save formats
  • Performance monitoring for generation systems across different platforms
  • Documentation updates for new world settings and override options

Future Development Opportunities

  • Enhanced world generation algorithms for improved diversity and performance
  • Extended custom preset features including sharing and community integration
  • Advanced world settings for fine-tuned gameplay experience customization
  • Improved debugging and development tools for world generation workflows
SystemRelationshipIntegration Points
World SystemsParent categoryProvides world infrastructure for generation systems
EntitiesConsumerUses generated world data for entity placement and behavior
Tiles and TerrainConsumerImplements terrain generated by world generation systems
Game MechanicsConsumerRelies on world settings and configuration for gameplay balance

Contributing to Generation Systems

Adding New Generation Features

  1. Understand existing generation pipeline and integration points
  2. Follow established patterns for world settings and override integration
  3. Implement proper error handling and platform compatibility
  4. Provide comprehensive testing for various world configuration scenarios

Modifying Existing Systems

  1. Maintain backward compatibility with existing presets and save data
  2. Update related documentation and integration examples
  3. Test changes across different platforms and world configurations
  4. Consider impact on mod systems and custom world generation implementations

Performance Monitoring

Key Metrics

  • World generation time across different world sizes and complexities
  • Memory usage during generation and preset management operations
  • Custom preset loading and saving performance with large preset collections
  • Settings override application time and runtime impact on game systems

Optimization Strategies

  • Cache frequently accessed preset and configuration data
  • Optimize world generation algorithms for common world types and settings
  • Minimize memory allocation during generation and configuration operations
  • Batch settings override applications when possible to reduce system overhead