|
| 1 | +using System.Diagnostics.CodeAnalysis; |
| 2 | +using Microsoft.Xna.Framework; |
| 3 | +using StardewModdingAPI.Framework.ModLoading.Framework; |
| 4 | +using StardewValley; |
| 5 | +using StardewValley.Buildings; |
| 6 | + |
| 7 | +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member: This is internal code to support rewriters and shouldn't be called directly. |
| 8 | + |
| 9 | +namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6 |
| 10 | +{ |
| 11 | + /// <summary>Maps Stardew Valley 1.5.6's <c>BuildableGameLocation</c> methods to their newer form on <see cref="GameLocation"/> to avoid breaking older mods.</summary> |
| 12 | + /// <remarks>This is public to support SMAPI rewriting and should never be referenced directly by mods. See remarks on <see cref="ReplaceReferencesRewriter"/> for more info.</remarks> |
| 13 | + [SuppressMessage("ReSharper", "InconsistentNaming", Justification = SuppressReasons.MatchesOriginal)] |
| 14 | + [SuppressMessage("ReSharper", "ParameterHidesMember", Justification = SuppressReasons.MatchesOriginal)] |
| 15 | + [SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaRewriting)] |
| 16 | + public class BuildableGameLocationFacade : GameLocation, IRewriteFacade |
| 17 | + { |
| 18 | + /********* |
| 19 | + ** Public methods |
| 20 | + *********/ |
| 21 | + public new bool buildStructure(Building b, Vector2 tileLocation, Farmer who, bool skipSafetyChecks = false) |
| 22 | + { |
| 23 | + return base.buildStructure(b, tileLocation, who, skipSafetyChecks); |
| 24 | + } |
| 25 | + |
| 26 | + public new bool destroyStructure(Vector2 tile) |
| 27 | + { |
| 28 | + return base.destroyStructure(tile); |
| 29 | + } |
| 30 | + |
| 31 | + public new bool destroyStructure(Building b) |
| 32 | + { |
| 33 | + return base.destroyStructure(b); |
| 34 | + } |
| 35 | + |
| 36 | + public new Building getBuildingAt(Vector2 tile) |
| 37 | + { |
| 38 | + return base.getBuildingAt(tile); |
| 39 | + } |
| 40 | + |
| 41 | + public new Building getBuildingByName(string name) |
| 42 | + { |
| 43 | + return base.getBuildingByName(name); |
| 44 | + } |
| 45 | + |
| 46 | + public Building? getBuildingUnderConstruction() |
| 47 | + { |
| 48 | + foreach (Building b in this.buildings) |
| 49 | + { |
| 50 | + if (b.daysOfConstructionLeft > 0 || b.daysUntilUpgrade > 0) |
| 51 | + return b; |
| 52 | + } |
| 53 | + |
| 54 | + return null; |
| 55 | + } |
| 56 | + |
| 57 | + public int getNumberBuildingsConstructed(string name) |
| 58 | + { |
| 59 | + return base.getNumberBuildingsConstructed(name); |
| 60 | + } |
| 61 | + |
| 62 | + public bool isBuildable(Vector2 tileLocation) |
| 63 | + { |
| 64 | + return base.isBuildable(tileLocation); |
| 65 | + } |
| 66 | + |
| 67 | + public new bool isPath(Vector2 tileLocation) |
| 68 | + { |
| 69 | + return base.isPath(tileLocation); |
| 70 | + } |
| 71 | + |
| 72 | + public new bool isBuildingConstructed(string name) |
| 73 | + { |
| 74 | + return base.isBuildingConstructed(name); |
| 75 | + } |
| 76 | + |
| 77 | + public new bool isThereABuildingUnderConstruction() |
| 78 | + { |
| 79 | + return base.isThereABuildingUnderConstruction(); |
| 80 | + } |
| 81 | + |
| 82 | + |
| 83 | + /********* |
| 84 | + ** Private methods |
| 85 | + *********/ |
| 86 | + private BuildableGameLocationFacade() |
| 87 | + { |
| 88 | + RewriteHelper.ThrowFakeConstructorCalled(); |
| 89 | + } |
| 90 | + } |
| 91 | +} |
0 commit comments