11using Microsoft . Xna . Framework ;
2+ using xTile . Dimensions ;
3+ using xTile . Tiles ;
24
35using StardewValley ;
46using StardewValley . Locations ;
57using StardewValley . Buildings ;
6- using StardewModdingAPI ;
78
89namespace Passage
910{
1011 class Utility
1112 {
12- public static Point GetPointAheadPlayer ( StardewValley . Farmer player , int tileSize )
13+ public static Point GetPointAheadPlayer ( )
1314 {
14- int tileAheadPlayerX = player . getTileX ( ) ;
15- int tileAheadPlayerY = player . getTileY ( ) ;
15+ int tileAheadPlayerX = Game1 . player . getTileX ( ) ;
16+ int tileAheadPlayerY = Game1 . player . getTileY ( ) ;
1617
1718 // Get tile directly ahead of player based on facing
18- switch ( player . facingDirection )
19+ switch ( Game1 . player . facingDirection )
1920 {
2021 case 0 :
2122 tileAheadPlayerY -= 1 ;
@@ -38,30 +39,54 @@ public static Point GetPointAheadPlayer(StardewValley.Farmer player, int tileSiz
3839 }
3940
4041 // Transform tile coords into absolute coords prior to returning
41- return new Point ( tileAheadPlayerX * tileSize , tileAheadPlayerY * tileSize ) ;
42+ return new Point ( tileAheadPlayerX * Game1 . tileSize , tileAheadPlayerY * Game1 . tileSize ) ;
4243 }
4344
44- public static int GetDoorType ( Point tile , GameLocation currentLocation )
45+ public static int GetDoorType ( Point tile )
4546 {
46- if ( currentLocation . doors . ContainsKey ( tile ) ) return 1 ;
47- if ( currentLocation . doesTileHaveProperty ( tile . X , tile . Y , "Action" , "Buildings" ) ? . Split ( ' ' ) ? [ 0 ] == "Door" ) return 2 ;
48- if ( currentLocation is BuildableGameLocation )
47+ if ( Game1 . currentLocation . doors . ContainsKey ( tile ) ) return 1 ;
48+ if ( Game1 . currentLocation . doesTileHaveProperty ( tile . X , tile . Y , "Action" , "Buildings" ) ? . Split ( ' ' ) ? [ 0 ] == "Door" ) return 2 ;
49+ if ( Game1 . currentLocation is BuildableGameLocation )
4950 {
50- foreach ( Building building in ( currentLocation as BuildableGameLocation ) . buildings )
51+ foreach ( Building building in ( Game1 . currentLocation as BuildableGameLocation ) . buildings )
5152 {
5253 if ( building . indoors == null ) continue ;
5354 if ( tile != new Point ( building . tileX + building . humanDoor . X , building . tileY + building . humanDoor . Y ) ) continue ;
5455 return 3 ;
5556 }
5657 }
58+ if ( Game1 . currentLocation . doesTileHaveProperty ( tile . X , tile . Y , "Action" , "Buildings" ) == "EnterSewer" ) return 4 ;
59+ // TODO: return 5 for Sewer entrance in the forest maybe?
60+ if ( Game1 . currentLocation . name == "Mine" || Game1 . currentLocation is MineShaft )
61+ {
62+ Tile trueTile = Game1 . currentLocation . map . GetLayer ( "Buildings" ) . PickTile ( new Location ( tile . X * Game1 . tileSize , tile . Y * Game1 . tileSize ) , Game1 . viewport . Size ) ;
63+ if ( trueTile != null )
64+ {
65+ switch ( trueTile . TileIndex )
66+ {
67+ // Elevator
68+ case 112 :
69+ return 6 ;
70+
71+ // Ladder (up)
72+ case 115 :
73+ return 7 ;
74+
75+ // Ladder (down)
76+ case 173 :
77+ return 8 ;
78+ }
79+ }
80+ }
5781
5882 return 0 ;
5983 }
6084 }
6185
6286 class ModConfig
6387 {
64- public bool EnableAutoDoorInteract { get ; set ; } = true ;
88+ public bool EnableAutoTransport { get ; set ; } = true ;
89+ public bool EnableAutoMineDownLadder { get ; set ; } = false ;
6590 public bool EnableAutoFenceGateManagement { get ; set ; } = true ;
6691 public bool OnlyOpenFenceGateWhileRidingHorse { get ; set ; } = false ;
6792 public float MaxDistanceToKeepFenceGateOpen { get ; set ; } = 1.1f ;
0 commit comments