Пример #1
0
    /// <summary>
    ///   Adds an external population effect to a species
    /// </summary>
    /// <param name="species">Target species</param>
    /// <param name="constant">Change amount (constant part)</param>
    /// <param name="description">What caused the change</param>
    /// <param name="immediate">
    ///   If true applied immediately. Should only be used for the player dying
    /// </param>
    /// <param name="coefficient">Change amount (coefficient part)</param>
    public void AlterSpeciesPopulation(Species species, int constant, string description,
                                       bool immediate = false, float coefficient = 1)
    {
        if (constant == 0 || coefficient == 0)
        {
            return;
        }

        if (species == null)
        {
            throw new ArgumentException("species is null");
        }

        // Immediate is only allowed to use for the player dying
        if (immediate)
        {
            if (!species.PlayerSpecies)
            {
                throw new ArgumentException("immediate effect is only for player dying");
            }

            GD.Print("Applying immediate population effect " +
                     "(should only be used for the player dying)");
            species.ApplyImmediatePopulationChange(constant, coefficient);
        }

        CreateRunIfMissing();

        autoEvo.AddExternalPopulationEffect(species, constant, coefficient, description);
    }