예제 #1
0
    public void UpdateEnergyBalance(EnergyBalanceInfo energyBalance)
    {
        energyBalanceInfo = energyBalance;

        if (energyBalance.FinalBalance > 0)
        {
            atpBalanceLabel.Text = ATP_BALANCE_DEFAULT_TEXT;
            atpBalanceLabel.AddColorOverride("font_color", new Color(1.0f, 1.0f, 1.0f));
        }
        else
        {
            atpBalanceLabel.Text = ATP_BALANCE_DEFAULT_TEXT + " - ATP PRODUCTION TOO LOW!";
            atpBalanceLabel.AddColorOverride("font_color", new Color(1.0f, 0.2f, 0.2f));
        }

        atpProductionLabel.Text  = string.Format(CultureInfo.CurrentCulture, "{0:F1}", energyBalance.TotalProduction);
        atpConsumptionLabel.Text = string.Format(CultureInfo.CurrentCulture, "{0:F1}", energyBalance.TotalConsumption);

        float maxValue = Math.Max(energyBalance.TotalConsumption, energyBalance.TotalProduction);

        atpProductionBar.MaxValue  = maxValue;
        atpConsumptionBar.MaxValue = maxValue;

        atpProductionBar.UpdateAndMoveBars(SortBarData(energyBalance.Production));
        atpConsumptionBar.UpdateAndMoveBars(SortBarData(energyBalance.Consumption));

        // Resets the statistics panel size to fit
        statisticsPanel.RectSize = Vector2.Zero;

        UpdateEnergyBalanceToolTips(energyBalance);
    }
예제 #2
0
    public void UpdateEnergyBalance(EnergyBalanceInfo energyBalance)
    {
        if (energyBalance.FinalBalance > 0)
        {
            atpBalanceLabel.Text = ATP_BALANCE_DEFAULT_TEXT;
            atpBalanceLabel.AddColorOverride("font_color", new Color(1.0f, 1.0f, 1.0f, 1.0f));
        }
        else
        {
            atpBalanceLabel.Text = ATP_BALANCE_DEFAULT_TEXT + " - ATP PRODUCTION TOO LOW!";
            atpBalanceLabel.AddColorOverride("font_color", new Color(1.0f, 0.2f, 0.2f, 1.0f));
        }

        float maxValue = Math.Max(energyBalance.TotalConsumption, energyBalance.TotalProduction);

        atpProductionBar.MaxValue = maxValue;
        atpProductionBar.Value    = energyBalance.TotalProduction;

        atpConsumptionBar.MaxValue = maxValue;
        atpConsumptionBar.Value    = energyBalance.TotalConsumption;

        var atpProductionBarProgressLength = (float)(atpProductionBar.RectSize.x * atpProductionBar.Value /
                                                     atpProductionBar.MaxValue);
        var atpConsumptionBarProgressLength = (float)(atpConsumptionBar.RectSize.x * atpConsumptionBar.Value /
                                                      atpConsumptionBar.MaxValue);

        atpProductionLabel.RectSize  = new Vector2(atpProductionBarProgressLength, 18);
        atpConsumptionLabel.RectSize = new Vector2(atpConsumptionBarProgressLength, 18);

        atpProductionLabel.Text  = string.Format(CultureInfo.CurrentCulture, "{0:F1}", energyBalance.TotalProduction);
        atpConsumptionLabel.Text = string.Format(CultureInfo.CurrentCulture, "{0:F1}", energyBalance.TotalConsumption);
    }
예제 #3
0
    public void UpdateEnergyBalanceToolTips(EnergyBalanceInfo energyBalance)
    {
        // Clear previous callbacks
        processesTooltipCallbacks.Clear();

        foreach (var subBar in atpProductionBar.SubBars)
        {
            var tooltip = ToolTipManager.Instance.GetToolTip(subBar.Name, "processesProduction");

            ToolTipHelper.RegisterToolTipForControl(subBar, processesTooltipCallbacks, tooltip);

            tooltip.Description =
                $"{SimulationParameters.Instance.GetOrganelleType(subBar.Name).Name}: " +
                $"+{energyBalance.Production[subBar.Name]} ATP";
        }

        foreach (var subBar in atpConsumptionBar.SubBars)
        {
            var tooltip = ToolTipManager.Instance.GetToolTip(subBar.Name, "processesConsumption");

            ToolTipHelper.RegisterToolTipForControl(subBar, processesTooltipCallbacks, tooltip);

            string displayName;

            switch (subBar.Name)
            {
            case "osmoregulation":
            {
                displayName = "Osmoregulation";
                break;
            }

            case "baseMovement":
            {
                displayName = "Base Movement";
                break;
            }

            default:
            {
                displayName = SimulationParameters.Instance.GetOrganelleType(subBar.Name).Name;
                break;
            }
            }

            tooltip.Description = $"{displayName}: -{energyBalance.Consumption[subBar.Name]} ATP";
        }
    }
예제 #4
0
    public void UpdateEnergyBalance(EnergyBalanceInfo energyBalance)
    {
        if (energyBalance.FinalBalance > 0)
        {
            atpBalanceLabel.Text = ATP_BALANCE_DEFAULT_TEXT;
            atpBalanceLabel.AddColorOverride("font_color", new Color(1.0f, 1.0f, 1.0f));
        }
        else
        {
            atpBalanceLabel.Text = ATP_BALANCE_DEFAULT_TEXT + " - ATP PRODUCTION TOO LOW!";
            atpBalanceLabel.AddColorOverride("font_color", new Color(1.0f, 0.2f, 0.2f));
        }

        float maxValue = Math.Max(energyBalance.TotalConsumption, energyBalance.TotalProduction);

        atpProductionBar.MaxValue  = maxValue;
        atpConsumptionBar.MaxValue = maxValue;

        atpProductionBar.UpdateAndMoveBars(SortBarData(energyBalance.Production));
        atpConsumptionBar.UpdateAndMoveBars(SortBarData(energyBalance.Consumption));
    }
예제 #5
0
    /// <summary>
    ///   Computes the energy balance for the given organelles in biome
    /// </summary>
    public static EnergyBalanceInfo ComputeEnergyBalance(IEnumerable <OrganelleDefinition> organelles,
                                                         BiomeConditions biome, MembraneType membrane)
    {
        var result = new EnergyBalanceInfo();

        float processATPProduction   = 0.0f;
        float processATPConsumption  = 0.0f;
        float movementATPConsumption = 0.0f;

        int hexCount = 0;

        var enumerated = organelles.ToList();

        foreach (var organelle in enumerated)
        {
            foreach (var process in organelle.RunnableProcesses)
            {
                var processData = CalculateProcessMaximumSpeed(process, biome);

                if (processData.WritableInputs.ContainsKey(ATP))
                {
                    var amount = processData.WritableInputs[ATP];

                    processATPConsumption += amount;

                    result.AddConsumption(organelle.InternalName, amount);
                }

                if (processData.WritableOutputs.ContainsKey(ATP))
                {
                    var amount = processData.WritableOutputs[ATP];

                    processATPProduction += amount;

                    result.AddProduction(organelle.InternalName, amount);
                }
            }

            // Take special cell components that take energy into account
            if (organelle.HasComponentFactory <MovementComponentFactory>())
            {
                var amount = Constants.FLAGELLA_ENERGY_COST;

                movementATPConsumption += amount;
                result.Flagella        += amount;

                result.AddConsumption(organelle.InternalName, amount);
            }

            // Store hex count
            hexCount += organelle.HexCount;
        }

        // Add movement consumption together
        result.BaseMovement = Constants.BASE_MOVEMENT_ATP_COST * hexCount;
        result.AddConsumption("baseMovement", result.BaseMovement);
        var totalMovementConsumption = movementATPConsumption + result.BaseMovement;

        // Add osmoregulation
        result.Osmoregulation = Constants.ATP_COST_FOR_OSMOREGULATION * hexCount *
                                membrane.OsmoregulationFactor;

        result.AddConsumption("osmoregulation", result.Osmoregulation);

        // Compute totals
        result.TotalProduction            = processATPProduction;
        result.TotalConsumptionStationary = processATPConsumption + result.Osmoregulation;
        result.TotalConsumption           = result.TotalConsumptionStationary + totalMovementConsumption;

        result.FinalBalance           = result.TotalProduction - result.TotalConsumption;
        result.FinalBalanceStationary = result.TotalProduction - result.TotalConsumptionStationary;

        return(result);
    }
예제 #6
0
    /// <summary>
    ///   Computes the energy balance for the given organelles in biome
    /// </summary>
    public static EnergyBalanceInfo ComputeEnergyBalance(IEnumerable <OrganelleDefinition> organelles,
                                                         BiomeConditions biome, MembraneType membrane)
    {
        var result = new EnergyBalanceInfo();

        float processATPProduction   = 0.0f;
        float processATPConsumption  = 0.0f;
        float movementATPConsumption = 0.0f;

        int hexCount = 0;

        var enumerated = organelles.ToList();

        // Compute all process efficiencies once
        var efficiencies = ComputeOrganelleProcessEfficiencies(enumerated, biome);

        foreach (var organelle in enumerated)
        {
            foreach (var efficiencyInfo in efficiencies)
            {
                foreach (var processData in efficiencyInfo.Value.Processes)
                {
                    // Find process inputs and outputs that use/produce ATP
                    // and that are performed by this organelle
                    // and add to totals
                    if (!organelle.Processes.ContainsKey(processData.Process.InternalName))
                    {
                        continue;
                    }

                    if (processData.OtherInputs.ContainsKey(ATP))
                    {
                        var amount = processData.OtherInputs[ATP].Amount;

                        processATPConsumption += amount;

                        result.AddConsumption(organelle.Name, amount);
                    }

                    if (processData.Outputs.ContainsKey(ATP))
                    {
                        var amount = processData.Outputs[ATP].Amount;

                        processATPProduction += amount;

                        result.AddProduction(organelle.Name, amount);
                    }
                }
            }

            // Take special cell components that take energy into account
            if (organelle.HasComponentFactory <MovementComponentFactory>())
            {
                var amount = Constants.FLAGELLA_ENERGY_COST;

                movementATPConsumption += amount;
                result.Flagella        += amount;

                result.AddConsumption(organelle.Name, amount);
            }

            // Store hex count
            hexCount += organelle.HexCount;
        }

        // Add movement consumption together
        result.BaseMovement = Constants.BASE_MOVEMENT_ATP_COST * hexCount;
        var totalMovementConsumption = movementATPConsumption + result.BaseMovement;

        // Add osmoregulation
        result.Osmoregulation = Constants.ATP_COST_FOR_OSMOREGULATION * hexCount *
                                membrane.OsmoregulationFactor;

        result.AddConsumption("osmoregulation", result.Osmoregulation);

        // Compute totals
        result.TotalProduction            = processATPProduction;
        result.TotalConsumptionStationary = processATPConsumption + result.Osmoregulation;
        result.TotalConsumption           = result.TotalConsumptionStationary + totalMovementConsumption;

        result.FinalBalance           = result.TotalProduction - result.TotalConsumption;
        result.FinalBalanceStationary = result.TotalProduction - result.TotalConsumptionStationary;

        return(result);
    }
예제 #7
0
    /// <summary>
    ///   Computes the energy balance for the given organelles in biome
    /// </summary>
    public static EnergyBalanceInfo ComputeEnergyBalance(
        IEnumerable <OrganelleDefinition> organelles, Biome biome, MembraneType membrane)
    {
        var result = new EnergyBalanceInfo();

        float totalATPProduction     = 0.0f;
        float processATPConsumption  = 0.0f;
        float movementATPConsumption = 0.0f;

        int hexCount = 0;

        var atp = SimulationParameters.Instance.GetCompound("atp");

        foreach (var organelle in organelles)
        {
            foreach (var efficiencyInfo in
                     ComputeOrganelleProcessEfficiencies(organelles, biome))
            {
                foreach (var processData in efficiencyInfo.Value.Processes)
                {
                    // Find process inputs and outputs that use/produce ATP and add to
                    // totals
                    if (processData.OtherInputs.ContainsKey(atp.InternalName))
                    {
                        var amount = processData.OtherInputs[atp.InternalName].Amount;

                        processATPConsumption += amount;

                        result.AddConsumption(organelle.Name, amount);
                    }

                    if (processData.Outputs.ContainsKey(atp.InternalName))
                    {
                        var amount = processData.Outputs[atp.InternalName].Amount;

                        totalATPProduction += amount;

                        result.AddProduction(organelle.Name, amount);
                    }
                }
            }

            // Take special cell components that take energy into account
            if (organelle.HasComponentFactory <MovementComponentFactory>())
            {
                var amount = Constants.FLAGELLA_ENERGY_COST;

                movementATPConsumption += amount;

                result.AddConsumption(organelle.Name, amount);
            }

            // Store hex count
            hexCount += organelle.HexCount;
        }

        // Add movement consumption together
        result.BaseMovement = Constants.BASE_MOVEMENT_ATP_COST * hexCount;
        var totalMovementConsumption =
            movementATPConsumption + result.BaseMovement;

        // Add osmoregulation
        result.Osmoregulation = Constants.ATP_COST_FOR_OSMOREGULATION * hexCount *
                                membrane.OsmoregulationFactor;

        result.AddConsumption("osmoregulation", result.Osmoregulation);

        // Compute totals
        var totalATPConsumption =
            processATPConsumption + totalMovementConsumption + result.Osmoregulation;

        var totalBalanceStationary =
            totalATPProduction - totalATPConsumption;
        var totalBalance = totalBalanceStationary - totalMovementConsumption;

        // Finish building the result object
        result.TotalProduction        = totalATPProduction;
        result.TotalConsumption       = totalATPConsumption;
        result.FinalBalance           = totalBalance;
        result.FinalBalanceStationary = totalBalanceStationary;

        return(result);
    }