Skip to content

Commit

Permalink
Remove starter gift and renovate cabins
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoked-Fish committed Jun 11, 2024
1 parent 3b33fc9 commit 45095f6
Showing 1 changed file with 39 additions and 14 deletions.
53 changes: 39 additions & 14 deletions Framework/Patches/CabinAndHousePatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AnythingAnywhere.Framework.Helpers;
using AnythingAnywhere.Framework.Utilities;
using Common.Helpers;
using HarmonyLib;
using Microsoft.Xna.Framework;
Expand Down Expand Up @@ -28,6 +29,8 @@ public void Apply()
Patch<GameLocation>(PatchType.Prefix, "houseUpgradeAccept", nameof(HouseUpgradeAcceptPrefix));
Patch<GameLocation>(PatchType.Prefix, nameof(GameLocation.carpenters), nameof(CarpentersPrefix), [typeof(Location)]);

Patch<Chest>(PatchType.Prefix, nameof(Chest.checkForAction), nameof(CheckForActionPrefix), [typeof(Farmer), typeof(bool)]);

Patch<BedFurniture>(PatchType.Postfix, nameof(BedFurniture.CanModifyBed), nameof(CanModifyBedPostfix), [typeof(Farmer)]);
Patch<BedFurniture>(PatchType.Transpiler, nameof(BedFurniture.placementAction), nameof(PlacementActionTranspiler));
}
Expand Down Expand Up @@ -72,19 +75,21 @@ private static bool HouseUpgradeAcceptPrefix(GameLocation __instance)
Game1.RequireCharacter("Robin").setNewDialogue("Data\\ExtraDialogue:Robin_HouseUpgrade_Accepted");
Game1.drawDialogue(Game1.getCharacterFromName("Robin"));
ModEntry.Multiplayer?.globalChatInfoMessage("HouseUpgrade", Game1.player.Name, Lexicon.getTokenizedPossessivePronoun(Game1.player.IsMale));
HouseUpgradeHelper.CompleteHouseUpgrade(Game1.player);
UpgradeHelper.CompleteHouseUpgrade(Game1.player);

return false;
}

private static bool CarpentersPrefix(GameLocation __instance, Location tileLocation, ref bool __result)
{
if (!ModEntry.Config.UpgradeCabins && !ModEntry.Config.RenovateCabins)
return true;

foreach (var i in __instance.characters.Where(i => i.Name.Equals("Robin")))
{
if (Vector2.Distance(i.Tile, new Vector2(tileLocation.X, tileLocation.Y)) > 3f)
{
return false;
}

i.faceDirection(2);
if (Game1.player.daysUntilHouseUpgrade.Value < 0 && !Game1.IsThereABuildingUnderConstruction())
{
Expand All @@ -97,10 +102,7 @@ private static bool CarpentersPrefix(GameLocation __instance, Location tileLocat
{
options.Add(new Response("Upgrade", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_UpgradeHouse")));
}
else if ((Game1.MasterPlayer.mailReceived.Contains("ccIsComplete")
|| Game1.MasterPlayer.mailReceived.Contains("JojaMember")
|| Game1.MasterPlayer.hasCompletedCommunityCenter())
&& Game1.RequireLocation<Town>("Town").daysUntilCommunityUpgrade.Value <= 0)
else if ((Game1.MasterPlayer.mailReceived.Contains("ccIsComplete") || Game1.MasterPlayer.mailReceived.Contains("JojaMember") || Game1.MasterPlayer.hasCompletedCommunityCenter()) && Game1.RequireLocation<Town>("Town").daysUntilCommunityUpgrade.Value <= 0)
{
if (!Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade"))
options.Add(new Response("CommunityUpgrade", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_CommunityUpgrade")));
Expand All @@ -113,31 +115,43 @@ private static bool CarpentersPrefix(GameLocation __instance, Location tileLocat
options.Add(new Response("Upgrade", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_UpgradeCabin")));
}

if (Game1.IsMasterGame)
if (Game1.IsMasterGame && CabinUtility.HasCabinsToUpgrade())
{
options.Add(new Response("AA_Upgrade", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_UpgradeCabin")));
}

if (Game1.player.HouseUpgradeLevel >= 2)
{
if (Game1.IsMasterGame)
{
options.Add(new Response("Renovate", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_RenovateHouse")));
}
else
{
options.Add(new Response("Renovate", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_RenovateCabin")));
}
}

if (Game1.IsMasterGame && CabinUtility.HasCabinsToUpgrade(true))
{
options.Add(new Response("AA_Renovate", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_RenovateCabin")));
}
options.Add(new Response("Construct", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_Construct")));
options.Add(new Response("Leave", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_Leave")));

__instance.createQuestionDialogue(Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu"), options.ToArray(), (_, answer) =>
{
if (answer != "AA_Upgrade")
{
__instance.answerDialogueAction("carpenter_" + answer, null);
}
else
switch (answer)
{
HouseUpgradeHelper.UpgradeCabinsResponses();
case "AA_Upgrade":
UpgradeHelper.UpgradeCabinsResponses();
break;
case "AA_Renovate":
RenovationHelper.RenovateCabinsResponses();
break;
default:
__instance.answerDialogueAction("carpenter_" + answer, null);
break;
}
});
}
Expand Down Expand Up @@ -166,6 +180,17 @@ private static bool CarpentersPrefix(GameLocation __instance, Location tileLocat
return false;
}

// Remove starter gift
private static bool CheckForActionPrefix(Chest __instance, Farmer who, ref bool __result, bool justCheckingForActivity = false)
{
if (!__instance.giftboxIsStarterGift.Value || !Game1.IsMasterGame || Game1.currentLocation.Equals(Game1.getLocationFromName(Game1.player.homeLocation.Value)) || justCheckingForActivity)
return true;

__instance.Location.removeObject(__instance.TileLocation, showDestroyedObject: false);
return false;
}


// Enable modifying other players beds/placing inside of other players homes
private static void CanModifyBedPostfix(BedFurniture __instance, Farmer who, ref bool __result)
{
Expand Down

0 comments on commit 45095f6

Please sign in to comment.