Skip to content

Commit

Permalink
Added planter fertility check patch
Browse files Browse the repository at this point in the history
  • Loading branch information
juanosarg committed Apr 27, 2023
1 parent 94b5ce5 commit a2fcee8
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 7 deletions.
Binary file modified 1.4/Assemblies/VFEF.dll
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions Source/VFEF/DefOfs/InternalDefOf.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

using RimWorld;
using Verse;


namespace VFEF
{
[DefOf]
public static class InternalDefOf
{
public static ThingDef VFE_PlanterBox;
public static ThingDef VFE_PlanterBox_Tilable;


static InternalDefOf()
{
DefOfHelper.EnsureInitializedInCtor(typeof(InternalDefOf));
}
}
}
43 changes: 43 additions & 0 deletions Source/VFEF/Harmony/HarmonyInstance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using HarmonyLib;
using RimWorld;
using System.Reflection;
using Verse;
using System.Reflection.Emit;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using System;
using Verse.AI;
using RimWorld.Planet;



namespace VFEF
{

public class VFEF : Mod
{
public VFEF(ModContentPack content) : base(content)
{
var harmony = new Harmony("com.vanillafarmingexpanded");
harmony.PatchAll(Assembly.GetExecutingAssembly());
}
}

}
















27 changes: 27 additions & 0 deletions Source/VFEF/Harmony/PlantUtility_CanSowOnGrower.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using HarmonyLib;
using RimWorld;
using Verse;
using System.Collections.Generic;

namespace VFEF
{
[HarmonyPatch(typeof(PlantUtility), nameof(PlantUtility.CanSowOnGrower))]
static class VFEF_PlantUtility_CanSowOnGrower_Patch
{

public static List<ThingDef> plantersList = new List<ThingDef>() { InternalDefOf.VFE_PlanterBox, InternalDefOf.VFE_PlanterBox_Tilable };

public static bool Postfix(bool __result, ThingDef plantDef, object obj)
{
if ((obj is Building_PlantGrower planter) && plantersList.Contains(planter.def))
{
if (planter.def.fertility >= 0f && planter.def.fertility < plantDef.plant.fertilityMin)
{
return false;
}
}

return __result;
}
}
}
File renamed without changes.
25 changes: 18 additions & 7 deletions Source/VFEF/VFEF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.2.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.2.2.2\lib\net472\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
Expand All @@ -48,15 +52,22 @@
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Building_PlantGrower_NoEmptyLines.cs" />
<Compile Include="Building_Scarecrow.cs" />
<Compile Include="CompProperties_ScaresAnimals.cs" />
<Compile Include="CompProperties_Sprinkler.cs" />
<Compile Include="CompScaresAnimals.cs" />
<Compile Include="CompSprinkler.cs" />
<Compile Include="Building\Building_PlantGrower_NoEmptyLines.cs" />
<Compile Include="Building\Building_Scarecrow.cs" />
<Compile Include="Comps\Properties\CompProperties_ScaresAnimals.cs" />
<Compile Include="Comps\Properties\CompProperties_Sprinkler.cs" />
<Compile Include="Comps\CompScaresAnimals.cs" />
<Compile Include="Comps\CompSprinkler.cs" />
<Compile Include="DefOfs\InternalDefOf.cs" />
<Compile Include="Harmony\HarmonyInstance.cs" />
<Compile Include="Harmony\PlantUtility_CanSowOnGrower.cs" />
<Compile Include="MoteSprinkler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VFEF_SprinklersManager.cs" />
<Compile Include="MapComponents\VFEF_SprinklersManager.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4 changes: 4 additions & 0 deletions Source/VFEF/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Lib.Harmony" version="2.2.2" targetFramework="net472" />
</packages>

0 comments on commit a2fcee8

Please sign in to comment.