
zone_planetmega_supercom_extra = {
	icon = "GFX_colony_type_plnmg_brain"
	base_buildtime = @zone_buildtime
	potential = { # planet scope
        owner? = {
            is_hive_empire = no
            has_technology = tech_plnmg_interthought
        }
	}
    unlock = {
        or = {
            has_deposit = d_plnmg_supercom
            hidden_trigger = { has_carrier_flag = planet_has_plnmg_supercom }
        }
    }
    convert_to = { zone_planetmega_brain_extra }
    show_in_tech = tech_plnmg_interthought

    planet_modifier = {
        zone_building_slots_add = @BPV_ZONE_SLOT
        planet_jobs_physics_research_produces_mult = 0.1
        planet_jobs_society_research_produces_mult = 0.05
        planet_jobs_engineering_research_produces_mult = 0.07
    }
    district_planet_modifier = {
        plnmg_sacrifice_supercom_cap_add = @plnmg_sacrifice_cap_per_district
    }
    inline_script = {
        script = jobs/zone_physicists_add
        LARGE_AMOUNT = 100
    }

	resources = {
		category = planet_zones
		cost = { minerals = @zone_cost }
	}
    ai_resource_production = {
        trigger = { always = yes }
        physics_research = 5
        society_research = 1
        engineering_research = 1
    }
    ai_weight_coefficient = 1.1
    ai_priority = 10

	included_building_sets = { research automation urban_automation urban_automation_arcology origin fallen_empire }
    zone_sets = { urban habitat_urban habitat_research ring_world arcology nexus }
}
zone_planetmega_brain_extra = {
    icon = "GFX_colony_type_plnmg_brain"
    base_buildtime = @zone_buildtime
    potential = { # planet scope
        owner? = {
            is_hive_empire = yes
            has_technology = tech_plnmg_interthought
        }
    }
    unlock = {
        or = {
            has_deposit = d_plnmg_fusion_brain
            hidden_trigger = { has_carrier_flag = planet_has_plnmg_fusion_brain }
        }
    }
    convert_to = { zone_planetmega_supercom_extra }

    planet_modifier = { zone_building_slots_add = @BPV_ZONE_SLOT }
    triggered_planet_modifier = {
        potential = { owner? = { is_hive_empire = yes } }
        planet_jobs_physics_research_produces_mult = 0.07
        planet_jobs_society_research_produces_mult = 0.1
        planet_jobs_engineering_research_produces_mult = 0.05
    }
    triggered_district_planet_modifier = {
        potential = { owner? = { is_hive_empire = yes } }
        plnmg_sacrifice_brain_cap_add = @plnmg_sacrifice_cap_per_district
    }
    inline_script = {
        script = jobs/zone_biologists_add
        LARGE_AMOUNT = 100
    }

    resources = {
        category = planet_zones
        cost = { minerals = @zone_cost }
    }
    ai_resource_production = {
        trigger = { always = yes }
        physics_research = 3
        society_research = 5
        engineering_research = 1
    }
    ai_weight_coefficient = 1.1
    ai_priority = 10

    included_building_sets = { research automation urban_automation urban_automation_arcology origin fallen_empire }
    zone_sets = { urban habitat_urban habitat_research ring_world arcology hive }
}

#BPV/BPVR等模组不要修改以下所有区域特化的max_buildings&zone_building_slots_add属性，除非愿意将district_plnmg_expansion_ui也顺便改了

zone_plnmg_expansion_general_res = {
    icon = "GFX_colony_type_urban"
    base_buildtime = @b4_time
    max_buildings = 3
    planet_modifier = { zone_building_slots_add = 3 }

    triggered_district_planet_modifier = {
        potential = {
            or = {
                has_deposit = d_plnmg_singularity_generator
                has_carrier_flag = planet_has_plnmg_singularity_generator
            }
        }
        planet_jobs_sr_dark_matter_produces_mult = 0.01
        plnmg_demodulator_jobs_bonus_workforce_mult = 0.01
    }
    triggered_district_planet_modifier = {
        potential = { has_plnmg_any_farm_t2 = yes }
        bonus_pop_growth_mult = 0.01
        planet_subject_assembly_organic_add = 1
        planet_jobs_food_produces_mult = 0.01
    }
    triggered_district_planet_modifier = {
        potential = {
            has_carrier_flag = plnmg_all_alloys_prod
            or = {
                has_deposit = d_plnmg_nirvana_factory
                has_carrier_flag = planet_has_plnmg_nirvana_factory
            }
        }
        planet_jobs_alloys_produces_mult = 0.02
    }
    triggered_district_planet_modifier = {
        potential = {
            has_carrier_flag = plnmg_all_goods_prod
            or = {
                has_deposit = d_plnmg_nirvana_factory
                has_carrier_flag = planet_has_plnmg_nirvana_factory
            }
        }
        planet_jobs_consumer_goods_produces_mult = 0.02
    }
    triggered_district_planet_modifier = {
        potential = {
            has_carrier_flag = plnmg_all_goods_prod
            or = {
                has_deposit = d_plnmg_nirvana_factory
                has_carrier_flag = planet_has_plnmg_nirvana_factory
            }
        }
        planet_jobs_alloys_produces_mult = 0.01
        planet_jobs_consumer_goods_produces_mult = 0.01
    }

    resources = {
        category = planet_zones
        cost = { minerals = @b4_minerals }
        upkeep = { energy = @b4_upkeep }
    }
    ai_priority = 1
    ai_resource_production = {
        trigger = { always = yes }
        alloys = 10
        consumer_goods = 10
        food = 15
    }

    zone_sets = { planetmega_expansion } # urban ring_world arcology nexus hive polytechnic
    included_building_sets = { generator mining farming industrial factory foundry betharian fallen_empire_generator fallen_empire_farming fallen_empire_mining generator_automation mining_automation farming_automation }
}
zone_plnmg_expansion_general_abs = {
    icon = "GFX_colony_type_urban"
    base_buildtime = @b4_time
    max_buildings = 3
    planet_modifier = { zone_building_slots_add = 3 }

    triggered_planet_modifier = {
        potential = {
            or = {
                has_deposit = d_plnmg_tms_control
                has_carrier_flag = planet_has_plnmg_tms_control
            }
        }
        unity_tag_jobs_empire_size_add = -0.6
    }

    triggered_district_planet_modifier = {
        potential = {
            or = {
                has_deposit = d_plnmg_maginot_nexus
                has_carrier_flag = planet_has_plnmg_maginot_nexus
            }
        }
        armies_upkeep_mult = -0.01
        planet_army_build_speed_mult = 0.01
    }
    triggered_district_planet_modifier = {
        potential = { has_plnmg_any_lab_t2 = yes }
        planet_jobs_physics_research_produces_mult = 0.01
        planet_jobs_society_research_produces_mult = 0.01
        planet_jobs_engineering_research_produces_mult = 0.01
    }
    triggered_district_planet_modifier = {
        potential = {
            has_deposit = d_plnmg_financial_shikara
            has_carrier_flag = planet_has_plnmg_financial_shikara
        }
        planet_jobs_trade_produces_mult = 0.01
    }
    triggered_district_planet_modifier = {
        potential = {
            or = {
                has_deposit = d_plnmg_tms_control
                has_carrier_flag = planet_has_plnmg_tms_control
            }
        }
        pop_government_ethic_attraction = 0.02
        planet_jobs_unity_produces_mult = 0.01
    }

    # triggered_district_country_modifier = {
    #     potential = { has_deposit = d_plnmg_maginot_nexus }
    #     ship_fire_rate_mult = 0.01
    #     ship_weapon_damage = 0.01
    # }

    resources = {
        category = planet_zones
        cost = { minerals = @b4_minerals }
        upkeep = { energy = @b4_upkeep }
    }
    ai_priority = 1
    ai_resource_production = {
        trigger = { always = yes }
        physics_research = 6
        society_research = 6
        engineering_research = 6
        trade = 15
        unity = 15
    }

    zone_sets = { planetmega_expansion } # urban ring_world arcology nexus hive polytechnic
    included_building_sets = { research fortress unity trade knights fallen_empire urban_automation urban_automation_arcology }
}

zone_plnmg_exp_shroud = {
    icon = "GFX_colony_type_research"
    base_buildtime = @zone_buildtime
    unlock = { has_deposit = d_plnmg_bore_of_the_shroud }
    max_buildings = 3

    planet_modifier = {
        zone_building_slots_add = 3
        planet_telepaths_physics_research_produces_add = 0.5
        planet_telepaths_society_research_produces_add = 0.5
    }
    district_planet_modifier = {
        psionic_pop_bonus_workforce_mult = 0.01
        plnmg_shroud_jobs_bonus_workforce_mult = 0.01
    }

    resources = {
        category = planet_zones
        cost = { minerals = @zone_cost }
    }
    ai_priority = 1
    ai_resource_production = {
        trigger = {
            owner? = {
                or = {
                    has_breached_shroud = yes
                    can_access_shroud = yes
                }
            }
        }
        sr_zro = 3
    }

    swap_type = district_planetmega_exp_shroud
    swap_type_weight = 1

    zone_sets = { planetmega_expansion }
    included_building_sets = { government urban knights fortress }
}

zone_plnmg_exp_extra_galaxy = {
    icon = "GFX_colony_type_normal_colony"
    base_buildtime = @zone_buildtime
    unlock = { has_deposit = d_plnmg_extra_galaxy }
    max_buildings = 4
    planet_modifier = { zone_building_slots_add = 4 }
    district_planet_modifier = { plnmg_extra_galaxy_connect_res_mult = 0.01 }
    resources = {
        category = planet_zones
        cost = { minerals = @zone_cost }
    }
    ai_weight_coefficient = 0
    zone_sets = { planetmega_expansion }
    included_building_sets = { government urban knights }
}
zone_plnmg_exp_world_shaper = {
    icon = "GFX_colony_type_workers"
    base_buildtime = @zone_buildtime
    unlock = { has_deposit = d_plnmg_world_shaper }
    max_buildings = 4

    planet_modifier = { zone_building_slots_add = 4 }
    district_planet_modifier = { planetmega_space_need_mult = -0.01 }
    district_country_modifier = {
        planetmega_space_need_mult = -0.002
        planetmega_space_need_artificial_mult = -0.003
        planetmega_space_need_ecu_mult = -0.002
    }

    resources = {
        category = planet_zones
        cost = { minerals = @zone_cost }
    }
    ai_weight_coefficient = 0
    zone_sets = { planetmega_expansion }
    included_building_sets = { mining mining_automation fallen_empire_mining generator generator_automation fallen_empire_generator }
}
zone_plnmg_exp_nano_storm = {
    icon = "GFX_colony_type_refinery"
    base_buildtime = @zone_buildtime
    unlock = { has_deposit = d_plnmg_nano_storm }
    max_buildings = 4
    planet_modifier = { zone_building_slots_add = 4 }
    district_planet_modifier = { planet_jobs_nanites_produces_mult = 0.02 }
    resources = {
        category = planet_zones
        cost = { minerals = @zone_cost }
    }
    ai_weight_coefficient = 0
    zone_sets = { planetmega_expansion }
    included_building_sets = { factory foundry industrial }
}

###test
# zone_planetmega_expansion_test = {
#     icon = "GFX_colony_type_urban"
#     base_buildtime = 1
#
#     #potential, unlock, on_xxx:
#     #this = colony
#
#     #triggered_planet/country_modifier: this = colony
#     #triggered_district_planet/country_modifier: this = colony
#     #triggered_desc: this = colony
#
#     max_buildings = 3
#     planet_modifier = { zone_building_slots_add = 3 }
#     #max_buildings_planet_class = yes #is it to make sure <planet_class>_max_buildings_add apply on this zone?
#     ai_weight_coefficient = 0
#     zone_sets = { urban }
#     included_building_sets = { government urban generator mining farming research fortress foundry knights betharian fallen_empire_generator fallen_empire_farming fallen_empire_mining urban_automation urban_automation_arcology generator_automation mining_automation farming_automation }
# }
