BuildingType
    name = "BLD_COLLECTIVE_NET"
    description = "BLD_COLLECTIVE_NET_DESC"
    buildcost = 250 * [[BUILDING_COST_MULTIPLIER]]
    buildtime = 10
    location = And [
        Planet
        Not Contains Building name = "BLD_COLLECTIVE_NET"
        OwnedBy empire = Source.Owner
        TargetPopulation low = 1
    ]
    enqueuelocation = [[ENQUEUE_BUILD_ONE_PER_PLANET]]
    effectsgroups = [
        [[SPECIES_LIKES_OR_DISLIKES_BUILDING_STABILITY_EFFECTS]]
    
        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                Focus type = "FOCUS_INDUSTRY"
                Happiness low = (NamedReal name = "BLD_COLLECTIVE_NET_MIN_STABILITY" value = 15)
            ]
            activation = Not WithinDistance distance = 200 condition = And [
                Ship
                Not Stationary
            ]
            stackinggroup = "BLD_COLLECTIVE_NET_INDUSTRY_EFFECT"
            priority = [[TARGET_AFTER_2ND_SCALING_PRIORITY]]
            effects = SetTargetIndustry value = Value + Target.Population
                        * (NamedReal name = "BLD_COLLECTIVE_NET_TARGET_INDUSTRY_PERPOP"
                                     value = 0.5 * [[INDUSTRY_PER_POP]])

        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                Focus type = "FOCUS_RESEARCH"
                Happiness low = NamedRealLookup name = "BLD_COLLECTIVE_NET_MIN_STABILITY"
            ]
            activation = Not WithinDistance distance = 200 condition = And [
                Ship
                Not Stationary
            ]
            stackinggroup = "BLD_COLLECTIVE_NET_RESEARCH_EFFECT"
            priority = [[TARGET_AFTER_2ND_SCALING_PRIORITY]]
            effects = SetTargetResearch value = Value + Target.Population
                        * (NamedReal name = "BLD_COLLECTIVE_NET_TARGET_RESEARCH_PERPOP"
                                     value = 0.5 * [[RESEARCH_PER_POP]])
    ]
    icon = "icons/building/psi-corps.png"

#include "/scripting/macros/enqueue.macros"
#include "/scripting/macros/priorities.macros"
#include "/scripting/macros/base_prod.macros"
#include "/scripting/buildings/buildings.macros"
