Exemplo n.º 1
0
 public static PathEndMode ResolveClosestTouchPathMode(Pawn pawn, MapExtension mapE, IntVec3 target)
 {
     if (GenPathShip.ShouldNotEnterCell(pawn, mapE, target))
     {
         return(PathEndMode.Touch);
     }
     return(PathEndMode.OnCell);
 }
Exemplo n.º 2
0
 public static MapExtension GetExtensionToMap(Map map)
 {
     if (!mapExtensions.ContainsKey(map))
     {
         MapExtension result = new MapExtension(map);
         mapExtensions.Add(map, result);
         mapExtensions[map].ConstructComponents();
     }
     return(mapExtensions[map]);
 }
 public static bool IsCornerTouchAllowed(int cornerX, int cornerZ, int adjCardinal1X, int adjCardinal1Z, int adjCardinal2X, int adjCardinal2Z, Map map)
 {
     Building building = map.edificeGrid[new IntVec3(cornerX, 0, cornerZ)];
     if (!(building is null) && TouchPathEndModeUtilityShips.MakesOccupiedCellsAlwaysReachableDiagonally(building.def))
         return true;
     IntVec3 intVec = new IntVec3(adjCardinal1X, 0, adjCardinal1Z);
     IntVec3 intVec2 = new IntVec3(adjCardinal2X, 0, adjCardinal2Z);
     MapExtension mapE = MapExtensionUtility.GetExtensionToMap(map);
     return (mapE.getShipPathGrid.Walkable(intVec) && intVec.GetDoor(map) is null) || (mapE.getShipPathGrid.Walkable(intVec2) && intVec2.GetDoor(map) is null);
 }
Exemplo n.º 4
0
        public static void RemoveMapExtension(Map map)
        {
            NullListCheck();
            MapExtension extToRemove = mapExtensions.Find(x => map.uniqueID == x.MapExtensionID);

            if (extToRemove is null)
            {
                Log.Warning("Unable to find MapExtension for Map " + map.uniqueID + ". Error with mod RimShips");
                return;
            }
            mapExtensions.Remove(extToRemove);
        }
Exemplo n.º 5
0
        public static MapExtension GetExtensionToMap(Map map)
        {
            NullListCheck();
            MapExtension result = mapExtensions.Find(x => map.uniqueID == x.MapExtensionID);

            if (result is null)
            {
                result = new MapExtension(map);
                result.ConstructComponents();
                result.StoreMapExtension();
            }
            return(result);
        }
Exemplo n.º 6
0
        public static bool Standable(this IntVec3 c, Map map, MapExtension mapE)
        {
            if (!mapE.getShipPathGrid.Walkable(c))
            {
                return(false);
            }
            List <Thing> list = map.thingGrid.ThingsListAt(c);

            foreach (Thing t in list)
            {
                if (t.def.passability != Traversability.Standable)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 7
0
        private static bool ShouldNotEnterCell(Pawn pawn, MapExtension mapE, IntVec3 dest)
        {
            if (mapE.getShipPathGrid.PerceivedPathCostAt(dest) > 30)
            {
                return(true);
            }
            if (!GenGridShips.Walkable(dest, mapE))
            {
                return(true);
            }
            if (!(pawn is null) && !(pawn.GetComp <CompShips>() is null))
            {
                if (dest.IsForbidden(pawn))
                {
                    return(true);
                }
                //Add utility for doors later?
            }

            return(false);
        }
Exemplo n.º 8
0
 public static bool BlocksDiagonalMovement(int index, Map map, MapExtension mapE)
 {
     return(!mapE.getShipPathGrid.WalkableFast(index) || map.edificeGrid[index] is Building_Door);
 }
Exemplo n.º 9
0
 public static bool BlocksDiagonalMovement(int x, int z, Map map, MapExtension mapE)
 {
     return(ShipPathFinder.BlocksDiagonalMovement(map.cellIndices.CellToIndex(x, z), map, mapE));
 }
Exemplo n.º 10
0
 public static bool Walkable(this IntVec3 c, MapExtension mapE)
 {
     return(mapE.getShipPathGrid.Walkable(c));
 }
Exemplo n.º 11
0
 public static TargetInfo ResolvePathMode(Pawn pawn, TargetInfo dest, ref PathEndMode peMode, MapExtension mapE)
 {
     if (dest.HasThing && dest.Thing.Spawned)
     {
         peMode = PathEndMode.Touch;
         return(dest);
     }
     if (peMode == PathEndMode.InteractionCell)
     {
         if (!dest.HasThing)
         {
             Log.Error("Pathed to cell " + dest + " with PathEndMode.InteractionCell.", false);
         }
         peMode = PathEndMode.OnCell;
         return(new TargetInfo(dest.Thing.InteractionCell, dest.Thing.Map, false));
     }
     if (peMode == PathEndMode.ClosestTouch)
     {
         peMode = GenPathShip.ResolveClosestTouchPathMode(pawn, mapE, dest.Cell);
     }
     return(dest);
 }
Exemplo n.º 12
0
 public static void StoreMapExtension(this MapExtension mapE)
 {
     NullListCheck();
     mapExtensions.Add(mapE);
 }