Example #1
0
        public PathGraph(CellInfoLayerPool layerPool, Locomotor locomotor, Actor actor, World world, BlockedByActor check)
        {
            this.locomotor = locomotor;

            // As we support a search over the whole map area,
            // use the pool to grab the CellInfos we need to track the graph state.
            // This allows us to avoid the cost of allocating large arrays constantly.
            // PERF: Avoid LINQ
            var cmls = world.GetCustomMovementLayers();

            pooledLayer         = layerPool.Get();
            cellInfoForLayer    = new CellLayer <CellInfo> [cmls.Length];
            cellInfoForLayer[0] = pooledLayer.GetLayer();
            foreach (var cml in cmls)
            {
                if (cml != null && cml.EnabledForLocomotor(locomotor.Info))
                {
                    cellInfoForLayer[cml.Index] = pooledLayer.GetLayer();
                }
            }

            World              = world;
            Actor              = actor;
            LaneBias           = 1;
            checkConditions    = check;
            checkTerrainHeight = world.Map.Grid.MaximumTerrainHeight > 0;
        }
Example #2
0
        public PathGraph(CellInfoLayerPool layerPool, Locomotor locomotor, Actor actor, World world, BlockedByActor check,
                         Func <CPos, int> customCost, Actor ignoreActor, bool inReverse, bool laneBias)
        {
            customMovementLayers = world.GetCustomMovementLayers();
            customMovementLayersEnabledForLocomotor = customMovementLayers.Count(cml => cml != null && cml.EnabledForLocomotor(locomotor.Info));
            this.locomotor     = locomotor;
            this.world         = world;
            this.actor         = actor;
            this.check         = check;
            this.customCost    = customCost;
            this.ignoreActor   = ignoreActor;
            this.inReverse     = inReverse;
            this.laneBias      = laneBias;
            checkTerrainHeight = world.Map.Grid.MaximumTerrainHeight > 0;

            // As we support a search over the whole map area,
            // use the pool to grab the CellInfos we need to track the graph state.
            // This allows us to avoid the cost of allocating large arrays constantly.
            // PERF: Avoid LINQ
            pooledLayer         = layerPool.Get();
            cellInfoForLayer    = new CellLayer <CellInfo> [customMovementLayers.Length];
            cellInfoForLayer[0] = pooledLayer.GetLayer();
            foreach (var cml in customMovementLayers)
            {
                if (cml != null && cml.EnabledForLocomotor(locomotor.Info))
                {
                    cellInfoForLayer[cml.Index] = pooledLayer.GetLayer();
                }
            }
        }
Example #3
0
 public PathGraph(CellInfoLayerPool layerPool, MobileInfo mobileInfo, Actor actor, World world, bool checkForBlocked)
 {
     pooledLayer       = layerPool.Get();
     cellInfo          = pooledLayer.Layer;
     World             = world;
     this.mobileInfo   = mobileInfo;
     worldMovementInfo = mobileInfo.GetWorldMovementInfo(world);
     Actor             = actor;
     LaneBias          = 1;
     checkConditions   = checkForBlocked ? CellConditions.TransientActors : CellConditions.None;
 }
Example #4
0
 public MapPathGraph(CellInfoLayerPool layerPool, Locomotor locomotor, Actor actor, World world, BlockedByActor check,
                     Func <CPos, int> customCost, Actor ignoreActor, bool laneBias, bool inReverse)
     : base(locomotor, actor, world, check, customCost, ignoreActor, laneBias, inReverse)
 {
     // As we support a search over the whole map area,
     // use the pool to grab the CellInfos we need to track the graph state.
     // This allows us to avoid the cost of allocating large arrays constantly.
     // PERF: Avoid LINQ
     pooledLayer         = layerPool.Get();
     cellInfoForLayer    = new CellLayer <CellInfo> [CustomMovementLayers.Length];
     cellInfoForLayer[0] = pooledLayer.GetLayer();
     foreach (var cml in CustomMovementLayers)
     {
         if (cml != null && cml.EnabledForLocomotor(locomotor.Info))
         {
             cellInfoForLayer[cml.Index] = pooledLayer.GetLayer();
         }
     }
 }
        public PathGraph(CellInfoLayerPool layerPool, LocomotorInfo li, Actor actor, World world, bool checkForBlocked)
        {
            pooledLayer   = layerPool.Get();
            groundInfo    = pooledLayer.GetLayer();
            locomotorInfo = li;
            var layers = world.GetCustomMovementLayers().Values
                         .Where(cml => cml.EnabledForActor(actor.Info, locomotorInfo));

            foreach (var cml in layers)
            {
                customLayerInfo[cml.Index] = Pair.New(cml, pooledLayer.GetLayer());
            }

            World              = world;
            worldMovementInfo  = locomotorInfo.GetWorldMovementInfo(world);
            Actor              = actor;
            LaneBias           = 1;
            checkConditions    = checkForBlocked ? CellConditions.TransientActors : CellConditions.None;
            checkTerrainHeight = world.Map.Grid.MaximumTerrainHeight > 0;
        }