Skip to content

Commit

Permalink
Work in Winter and Evenings, fix nre
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkfalcon committed Aug 27, 2018
1 parent 6aaed56 commit e2d608e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions BetterJunimos/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ internal class HutSettings {
public JunimoImprovement JunimoImprovements { get; set; } = new JunimoImprovement();
internal class JunimoImprovement {
public bool CanWorkInRain { get; set; } = true;
public bool CanWorkInWinter { get; set; } = false;
public bool CanWorkInEvenings { get; set; } = false;
public bool WorkFaster { get; set; } = false;
public bool AvoidHarvestingFlowers { get; set; } = true;
}
Expand Down
2 changes: 1 addition & 1 deletion BetterJunimos/Patches/JunimoHarvesterPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class PatchPathfindDoWork {

public static bool Prefix(JunimoHarvester __instance) {
JunimoHut hut = Util.GetHutFromId(Util.GetHutIdFromJunimo(__instance));
if (Game1.timeOfDay > 1900) {
if (Game1.timeOfDay > 1900 && !Util.Config.JunimoImprovements.CanWorkInEvenings) {
if (__instance.controller != null)
return false;
__instance.returnToJunimoHut(__instance.currentLocation);
Expand Down
7 changes: 5 additions & 2 deletions BetterJunimos/Patches/JunimoHutPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public static void Postfix(JunimoHut __instance, GameTime time, int __state) {
// from Update
junimoSendOutTimer.SetValue(sendOutTimer - time.ElapsedGameTime.Milliseconds);
if (sendOutTimer > 0 || __instance.myJunimos.Count() >= Util.Config.JunimoHuts.MaxJunimos ||
Game1.IsWinter || !__instance.areThereMatureCropsWithinRadius() || Game1.farmEvent != null)
!__instance.areThereMatureCropsWithinRadius() || Game1.farmEvent != null)
return;
// Winter
if (Game1.IsWinter && !Util.Config.JunimoImprovements.CanWorkInWinter)
return;
// Rain
if (Game1.isRaining && !Util.Config.JunimoImprovements.CanWorkInRain)
Expand All @@ -85,7 +88,7 @@ public static void Postfix(JunimoHut __instance, GameTime time, int __state) {
internal class ReplaceJunimoHutNumber {
public static bool Prefix(JunimoHut __instance, ref int __result) {
for (int index = 0; index < Util.Config.JunimoHuts.MaxJunimos; ++index) {
if (index >= __instance.myJunimos.Count<JunimoHarvester>()) {
if (index >= __instance.myJunimos.Count()) {
__result = index;
return false;
}
Expand Down
1 change: 1 addition & 0 deletions BetterJunimos/Utils/JunimoAbilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ private bool UseItemAbility(Guid id, Vector2 pos, int itemCategory, Func<Vector2
NetObjectList<Item> chest = hut.output.Value.items;

Item foundItem = chest.FirstOrDefault(item => item.Category == itemCategory);
if (foundItem == null) return false;
bool success = useItem(pos, foundItem.ParentSheetIndex);
if (success) {
Util.ReduceItemCount(chest, foundItem);
Expand Down

0 comments on commit e2d608e

Please sign in to comment.