Exemple #1
0
    protected bool ApplyMod <T>(RoomSpec spec, ProbabilityPool <T> mods)
        where T : RoomModifier
    {
        mods.BeginTaking();
        T mod;

        while (mods.Take(spec.Random, out mod))
        {
            #region DEBUG
            float stepTime = 0;
            if (BigBoss.Debug.logging(Logs.LevelGenMain))
            {
                BigBoss.Debug.w(Logs.LevelGenMain, "   Applying: " + mod);
            }
            if (BigBoss.Debug.logging(Logs.LevelGen))
            {
                stepTime = Time.realtimeSinceStartup;
                BigBoss.Debug.w(Logs.LevelGen, "Applying: " + mod);
            }
            #endregion
            Container2D <GenSpace> backupGrid = new MultiMap <GenSpace>(spec.Grids);
            if (mod.Modify(spec))
            {
                #region DEBUG
                if (BigBoss.Debug.logging(Logs.LevelGen))
                {
                    spec.Grids.ToLog(Logs.LevelGen, "Applying " + mod + " took " + (Time.realtimeSinceStartup - stepTime) + " seconds.");
                }
                #endregion
                mods.EndTaking();
                return(true);
            }
            else
            {
                spec.Grids = backupGrid;
                #region DEBUG
                if (BigBoss.Debug.logging(Logs.LevelGen))
                {
                    spec.Grids.ToLog(Logs.LevelGen, "Couldn't apply mod.  Processing " + mod + " took " + (Time.realtimeSinceStartup - stepTime) + " seconds.");
                }
                #endregion
            }
        }
        mods.EndTaking();
        return(false);
    }
 public override bool Take(System.Random random, out T item)
 {
     return(_pool.Take(random, out item));
 }
Exemple #3
0
 public override bool Take(Random random, out T item)
 {
     return(currentPool.Take(random, out item));
 }