Пример #1
0
    /// <summary>
    ///   Blank world creation, only for loading saves
    /// </summary>
    public GameWorld()
    {
        // TODO: save timed effects to json as well
        TimedEffects = new TimedWorldOperations();

        // Register glucose reduction
        TimedEffects.RegisterEffect("reduce_glucose", new WorldEffectLambda((elapsed, total) =>
        {
            foreach (var key in Map.Patches.Keys)
            {
                var patch = Map.Patches[key];

                foreach (var compound in patch.Biome.Compounds.Keys)
                {
                    if (compound.InternalName == "glucose")
                    {
                        var data = patch.Biome.Compounds[compound];

                        // TODO: verify that this change is picked up by the patch manager
                        data.Density *= Constants.GLUCOSE_REDUCTION_RATE;
                    }
                }
            }
        }));
    }
Пример #2
0
    /// <summary>
    ///   Blank world creation, only for loading saves
    /// </summary>
    public GameWorld()
    {
        // TODO: when loading a save this shouldn't be recreated as otherwise that happens all the time
        // Note that as the properties are applied from a save after the constructor, the save is correctly loaded
        // but these extra objects get created and garbage collected
        TimedEffects = new TimedWorldOperations();

        // Register glucose reduction
        TimedEffects.RegisterEffect("reduce_glucose", new GlucoseReductionEffect(this));
    }
Пример #3
0
    public GameWorld(WorldGenerationSettings settings)
    {
        mutator       = new Mutations();
        PlayerSpecies = CreatePlayerSpecies();

        Map = PatchMapGenerator.Generate(settings, PlayerSpecies);

        if (!Map.Verify())
        {
            throw new ArgumentException("generated patch map with settings is not valid");
        }

        // Apply initial populations
        Map.UpdateGlobalPopulations();

        TimedEffects = new TimedWorldOperations();

        // Register glucose reduction
        TimedEffects.RegisterEffect("reduce_glucose", new WorldEffectLambda((elapsed, total) =>
        {
            foreach (var key in Map.Patches.Keys)
            {
                var patch = Map.Patches[key];

                foreach (var compound in patch.Biome.Compounds.Keys)
                {
                    if (compound == "glucose")
                    {
                        var data = patch.Biome.Compounds[compound];

                        // TODO: verify that this change is picked up by the patch manager
                        data.Density *= Constants.GLUCOSE_REDUCTION_RATE;
                    }
                }
            }
        }));
    }