예제 #1
0
    /// <summary>
    /// Generates a new ZombieCorpsePositioner, that relies on real 7D2D code to perform its function.
    /// </summary>
    /// <returns>A new zombie corpse positioner.</returns>
    public static ZombieCorpsePositioner GenerateNewPositioner()
    {
        GroundFinder.IsMovementRestrictingBlock isMovementRestrictingBlock = location => GetBlockAt(location).IsCollideMovement;
        ZombieCorpsePositioner.Logger           log = msg => Debug.Log("Corpse Disintigration Fix: " + msg);

        ICacheTimer         cacheTimer   = new CacheTimer(CONFIG.CACHE_PERSISTANCE, () => GameTimer.Instance.ticks);
        GroundPositionCache cache        = new GroundPositionCache(cacheTimer);
        IGroundFinder       groundFinder = new GroundFinder(CONFIG, isMovementRestrictingBlock, cache);

        return(new ZombieCorpsePositioner(log, IsStableBlock, IsValidSpawnPointForCorpseBlock, groundFinder, CONFIG));
    }
예제 #2
0
 /// <summary>
 /// Creates a new ground finder, which relies on the supplied delegate and data cache, to find and cache the 'ground level' for various positions.
 /// </summary>
 /// <param name="config">The configuration parameters to use when conducting the search.</param>
 /// <param name="isMovementRestrictingBlock">The delegate to use, to check if a block allows free movement or not.</param>
 /// <param name="cache">The data cache, to use for improving performance.</param>
 /// <exception cref="ArgumentNullException">If any of the supplied parameters are null.</exception>
 public GroundFinder(IConfiguration config, IsMovementRestrictingBlock isMovementRestrictingBlock, GroundPositionCache cache)
 {
     if (config == null)
     {
         throw new ArgumentNullException("config", "The given configuration data must not be null");
     }
     maxHeight = config.MAX_HEIGHT;
     minHeight = config.MIN_HEIGHT;
     if (isMovementRestrictingBlock == null)
     {
         throw new ArgumentNullException("isMovementRestrictingBlock", "The given delegate function must not be null");
     }
     this.isMovementRestrictingBlock = isMovementRestrictingBlock;
     if (cache == null)
     {
         throw new ArgumentNullException("cache", "The given data cache must not be null");
     }
     this.cache = cache;
 }
 public void Init()
 {
     fakeTimer = new FakeCacheTimer();
     cache     = new GroundPositionCache(fakeTimer);
 }