Ejemplo n.º 1
0
    float ComputeEfficiency()                                                                                //nearly similar to InfrastructureBuildings efficiency, the difference is that it isn't clamped to custom min and max value, but straight to 1.0f and 0.0f.
    {
        float budgetEffect = (float)(budget - stats.minBudget) / (float)(stats.maxBudget - stats.minBudget); //linear interpolation

        budgetEffect = budgetEffect * 0.5f + 0.5f;                                                           //This limits the change in budget effect from 50% (at min budget) to 100% (at max budget)

        float manpowerEffect = 0.0f;

        if (workPlace.MaxManpower() == 0) //building does not need manpower
        {
            manpowerEffect = 1.0f;        //TODO this could be removed (unless you're thinking of implementing some futuristic, fully automated industry)
        }
        else if (workPlace.CurrentManpower() >= workPlace.MinManpower())
        {
            manpowerEffect = (float)workPlace.CurrentManpower() / (float)workPlace.MaxManpower();
        }

        float resourceEffect = allocatedResources.CompareToBaseResource(stats.requiredResources);
        float efficiency     = manpowerEffect * budgetEffect * resourceEffect;

        if (manpowerEffect < 0.001f || budgetEffect < 0.001f || resourceEffect < 0.001f)
        {
            efficiency = 0.0f;
        }

        return(efficiency);
    }
Ejemplo n.º 2
0
    protected virtual float ComputeEfficiency()
    {
        float budgetEffect = (float)(budget - stats.minBudget) / (float)(stats.maxBudget - stats.minBudget); //linear interpolation

        budgetEffect = budgetEffect * 0.5f + 0.5f;                                                           //This limits the change in budget effect from 50% (at min budget) to 100% (at max budget)

        float manpowerEffect = 0.0f;

        if (workPlace.MaxManpower() == 0) //building does not need manpower
        {
            manpowerEffect = 1.0f;
        }
        else if (workPlace.CurrentManpower() >= workPlace.MinManpower())
        {
            manpowerEffect = (float)workPlace.CurrentManpower() / (float)workPlace.MaxManpower();
        }

        float resourceEffect = allocatedResources.CompareToBaseResource(stats.requiredResources);
        float efficiency     = manpowerEffect * budgetEffect * resourceEffect * (infraStats.maxEfficiency - infraStats.minEfficiency) + infraStats.minEfficiency;

        if (manpowerEffect < 0.001f || budgetEffect < 0.001f || resourceEffect < 0.001f)
        {
            efficiency = 0.0f;
        }

        return(efficiency);
    }