BuildingType
    name = "BLD_SOL_ORB_GEN"
    description = "BLD_SOL_ORB_GEN_DESC"
    buildcost = 75 * [[BUILDING_COST_MULTIPLIER]]
    buildtime = 6
    tags = "ORBITAL"
    location = And [
        Planet
        OwnedBy empire = Source.Owner
        Not Contains Building name = "BLD_SOL_ORB_GEN"
        Not Star type = [Neutron BlackHole NoStar]
    ]
    enqueuelocation = [[ENQUEUE_BUILD_ONE_PER_PLANET]]
    effectsgroups = [
        [[SPECIES_LIKES_OR_DISLIKES_BUILDING_STABILITY_EFFECTS]]
    
        EffectsGroup
            scope = And [
                Planet
                Focus type = "FOCUS_INDUSTRY"
                OwnedBy empire = Source.Owner
                Happiness low = (NamedReal name = "BLD_SOL_ORB_GEN_MIN_STABILITY" value = 10)
                ResourceSupplyConnected empire = Source.Owner condition = Source
            ]
            activation = Star type = [Blue White]
            stackinggroup = "BLD_SOL_ORB_GEN_EFFECT"
            priority = [[TARGET_AFTER_2ND_SCALING_PRIORITY]]
            effects = SetTargetIndustry value = Value + Target.Population
                        * (NamedReal name = "BLD_SOL_ORB_GEN_BRIGHT_TARGET_INDUSTRY_PERPOP"
                                     value = 0.75 * [[INDUSTRY_PER_POP]])

        EffectsGroup
            scope = And [
                Planet
                Focus type = "FOCUS_INDUSTRY"
                OwnedBy empire = Source.Owner
                Happiness low = NamedRealLookup name = "BLD_SOL_ORB_GEN_MIN_STABILITY"
                ResourceSupplyConnected empire = Source.Owner condition = Source
            ]
            activation = And [
                Star type = [Yellow Orange]
                Not ResourceSupplyConnected empire = Source.Owner condition = And [
                    Building name = "BLD_SOL_ORB_GEN"
                    OwnedBy empire = Source.Owner
                    Star type = [Blue White]
                ]
            ]
            stackinggroup = "BLD_SOL_ORB_GEN_EFFECT"
            priority = [[TARGET_AFTER_2ND_SCALING_PRIORITY]]
            effects = SetTargetIndustry value = Value + Target.Population
                        * (NamedReal name = "BLD_SOL_ORB_GEN_NORMAL_TARGET_INDUSTRY_PERPOP"
                                     value = 0.5 * [[INDUSTRY_PER_POP]])

        EffectsGroup
            scope = And [
                Planet
                Focus type = "FOCUS_INDUSTRY"
                OwnedBy empire = Source.Owner
                Happiness low = NamedRealLookup name = "BLD_SOL_ORB_GEN_MIN_STABILITY"
                ResourceSupplyConnected empire = Source.Owner condition = Source
            ]
            activation = And [
                Star type = Red
                Not ResourceSupplyConnected empire = Source.Owner condition = And [
                    Building name = "BLD_SOL_ORB_GEN"
                    OwnedBy empire = Source.Owner
                    Star type = [Yellow Orange Blue White]
                ]
            ]
            stackinggroup = "BLD_SOL_ORB_GEN_EFFECT"
            priority = [[TARGET_AFTER_2ND_SCALING_PRIORITY]]
            effects = SetTargetIndustry value = Value + Target.Population
                        * (NamedReal name = "BLD_SOL_ORB_GEN_DIM_TARGET_INDUSTRY_PERPOP"
                                     value = 0.25 * [[INDUSTRY_PER_POP]])
    ]
    icon = "icons/building/miniature_sun.png"

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