
district_planetmega_expansion = {
    overlay_icon = GFX_district_housing
    custom_gui = "district_plnmg_expansion_ui"
    district_width = 3

    exempt_from_ai_planet_specialization = yes
    is_uncapped = {
        or = {
            is_ringworld = yes
            owner? = { has_technology = tech_planetmega_omnipotence_engineering }
        }
    }
    prerequisites = { tech_planetmega_improved }
    show_tech_unlock_if = { always = no }
    potential = {
        or = {
            has_carrier_flag = planet_has_improved_groundmega
            has_carrier_flag = planet_has_advanced_groundmega
            has_carrier_flag = planet_has_ultimate_groundmega
        }
        nor = {
            uses_district_set = cosmogenesis_world
            has_carrier_flag = district_plnmg_exp_disabled
        }
        owner? = { has_policy_flag = district_plnmg_exp_enabled }
    }
    show_on_uncolonized = { always = no }
    zone_slots = { slot_planetmega_expansion }

    base_buildtime = @zone_buildtime
    resources = {
        category = planet_districts_cities
        cost = { minerals = 750 }
        upkeep = { energy = 2.5 }
    }

    conversion_ratio = 1
    convert_to = {
        district_city
        district_crashed_slaver_ship
        district_arcology_housing
        district_rw_city
        district_nexus
        district_hive
        district_prison
        district_craglands
        district_mindlink
        district_crashed_slaver_ship
        district_resort
        district_slave
    }

    planet_modifier = { planet_housing_add = 1300 }
    triggered_planet_modifier = {
        potential = { owner? = { has_valid_civic = civic_agrarian_idyll } }
        planet_housing_add = -200
    }
    triggered_planet_modifier = {
        potential = { owner? = { has_active_tradition = tr_prosperity_public_works } }
        planet_housing_add = 100
    }

    triggered_name = {
        trigger = { has_zone = { zone = zone_plnmg_expansion_general_res } }
        text = district_planetmega_expansion_res
    }
    triggered_name = {
        trigger = { has_zone = { zone = zone_plnmg_expansion_general_abs } }
        text = district_planetmega_expansion_abs
    }

    triggered_flavor_desc = {
        trigger = { has_zone = { zone = zone_plnmg_expansion_general_res } }
        text = district_planetmega_expansion_res_desc
    }
    triggered_flavor_desc = {
        trigger = { has_zone = { zone = zone_plnmg_expansion_general_abs } }
        text = district_planetmega_expansion_abs_desc
    }
}

###swaps

district_planetmega_exp_shroud = {
    overlay_icon = GFX_district_society
    zone_slots = { slot_empty }
    show_on_uncolonized = { always = no }
    potential = { always = no }
    triggered_name = { text = district_plnmg_exp_shroud_name }
}
district_plnmg_exp_extra_galaxy = {
    icon = district_generator
    overlay_icon = GFX_district_volatile_motes
    #gridbox = district_industrial

    zone_slots = { slot_empty }
    show_on_uncolonized = { always = no }
    potential = { always = no }
}
district_plnmg_exp_world_shaper = {
    icon = district_generator
    overlay_icon = GFX_district_volatile_motes
    gridbox = district_mining

    zone_slots = { slot_empty }
    show_on_uncolonized = { always = no }
    potential = { always = no }
}
district_plnmg_exp_nano_storm = {
    icon = district_generator
    overlay_icon = GFX_district_volatile_motes
    gridbox = district_ring_world_industrial

    zone_slots = { slot_empty }
    show_on_uncolonized = { always = no }
    potential = { always = no }
}

### test ###

# district_plnmg_test = {
#     icon = district_generator
#     overlay_icon = GFX_district_volatile_motes
#     #gridbox = district_industrial
#
#     zone_slots = { slot_empty }
#     show_on_uncolonized = {
#         # this = carrier (planet/ship), from = country (somebody could use that)
#     }
#     potential = {
#         # this = carrier, same as allow, destroy_trigger and all on_xx
#     }
#
#     triggered_planet_modifier = {
#         # this = colony or carrier, WTF PDX can't you make it stable?
#         planet_max_districts_add = 1
#     }
#     triggered_name = {
#         # all other triggered_xx: this = carrier
#         text = agenda_skill_development
#     }
# }
