Example #1
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="growCrops">Whether crops can grow here.</param>
 /// <param name="growCropsOutOfSeason">Whether out-of-season crops grow here too.</param>
 /// <param name="forceTillable">Whether to allow hoeing anywhere.</param>
 public PerLocationConfig(bool growCrops, bool growCropsOutOfSeason, ModConfigForceTillable?forceTillable)
 {
     this.GrowCrops            = growCrops;
     this.GrowCropsOutOfSeason = growCropsOutOfSeason;
     this.ForceTillable        = forceTillable ?? new(
         dirt : true,
         grass : true,
         stone : false,
         other : false
         );
 }
Example #2
0
        /// <summary>Get whether to override tilling for a given tile.</summary>
        /// <param name="location">The game location to check.</param>
        /// <param name="tile">The tile position to check.</param>
        private bool ShouldMakeTillable(GameLocation location, Vector2 tile)
        {
            ModConfigForceTillable config = this.Config.ForceTillable;

            switch (location.doesTileHaveProperty((int)tile.X, (int)tile.Y, "Type", "Back"))
            {
            case "Dirt":
                return(config.Dirt);

            case "Grass":
                return(config.Grass);

            case "Stone":
                return(config.Stone);

            default:
                return(config.Other);
            }
        }
Example #3
0
        /// <summary>Get whether to override tilling for a given tile.</summary>
        /// <param name="location">The game location to check.</param>
        /// <param name="tilePos">The tile position to check.</param>
        private bool ShouldMakeTillable(GameLocation location, Vector2 tilePos)
        {
            ModConfigForceTillable config = this.Config.ForceTillable;

            // get tile
            Tile tile = location.Map.GetLayer("Back")?.Tiles[(int)tilePos.X, (int)tilePos.Y];

            if (tile?.TileSheet == null || this.GetProperty(tile, "Diggable") != null)
            {
                return(false);
            }

            // get config for tile type
            string type = this.GetProperty(tile, "Type") ?? this.GetFallbackTileType(tile.TileSheet.ImageSource, tile.TileIndex);

            return(type switch
            {
                "Dirt" => config.Dirt,
                "Grass" => config.Grass,
                "Stone" => config.Stone,
                _ => config.Other
            });