5 Commits
v0.1 ... v0.2

4 changed files with 52 additions and 6 deletions

View File

@@ -0,0 +1 @@
3005196131

View File

@@ -32,8 +32,9 @@ This mod does not modify any core vanilla code or Defs, and only builds off of t
Therefore, other mods should have no problem with Hydroponics Expanded.
That said, mods that add custom crops may have issues - especially if they have custom growth mechanics.
A good example is a crop that, when harvested, does not get deleted. Typical hydroponic-grown crops in Vanilla RimWorld
get deleted when harvested, and thus work fine. Trees however, are not, and do not get deleted once harvested.
Harvestable plants (like Ambrosia) have custom interactions setup to allow them to be harvested _once_ instead of
multiple times.
The way the hydroponics are coded is not conducive to multi-harvest plants.
You can expect any crops like this to not work well within the basins added by Hydroponics Expanded.

View File

@@ -7,6 +7,7 @@ using HydroponicsExpanded.Utility;
using RimWorld;
using UnityEngine;
using Verse;
using Verse.AI;
using Verse.Sound;
namespace HydroponicsExpanded {
@@ -78,6 +79,11 @@ namespace HydroponicsExpanded {
plant.Destroy();
SoundDefOf.CryptosleepCasket_Accept.PlayOneShot(new TargetInfo(Position, Map));
Stage = HydroponicsStage.Grow;
// Some active sowing jobs may be in progress for pathing, and thus will sow plants AFTER the stage
// transition is made. This results in some weird looking random plants very rarely.
// In order to fix this, we'll just remove all pending sowing jobs that relate to THIS hydroponics.
CancelActiveJobs();
}
}
@@ -145,6 +151,17 @@ namespace HydroponicsExpanded {
break;
}
// Re-harvestable plants will be destroyed if we think they've been harvested recently.
foreach (Plant plant in PlantsOnMe) {
if (plant.def.plant.HarvestDestroys) continue;
// Only consider re-harvestable plants eligible if they're still within 20% of their harvest growth level,
// up to 90%. This may need tuning if there are harvestable plants that go to 90% growth.
var minGrowth = plant.def.plant.harvestAfterGrowth;
if (plant.Growth.Between(minGrowth, Math.Min(0.9f, minGrowth + 0.2f), inclusive: true))
plant.Destroy();
}
// All plants have been harvested. Switch back to sowing stage.
if (_innerContainer.Count == 0)
Stage = HydroponicsStage.Sowing;
@@ -169,17 +186,43 @@ namespace HydroponicsExpanded {
public override void TickRare() {
// Tick the current stage.
HydroponicsStage initialStage = _stage;
TickStage(_stage);
HydroponicsStage initialStage = Stage;
TickStage(Stage);
// If the stage changed, re-run the next tick. This can allow for instant Grow -> Harvest transition.
if (_stage != initialStage)
TickStage(_stage);
TickStage(Stage);
// Apply rotting damage to all plants while power is cut.
if (!base.CanAcceptSowNow())
if (!base.CanAcceptSowNow()) {
foreach (Thing thing in _innerContainer)
((Plant)thing).TakeDamage(new DamageInfo(DamageDefOf.Rotting, 1f));
foreach (Plant plant in PlantsOnMe)
plant.TakeDamage(new DamageInfo(DamageDefOf.Rotting, 1f));
}
}
/**
* This method cancels all active sowing jobs that interact with this given hydroponics' growing zone.
*/
private void CancelActiveJobs() {
CellRect region = this.OccupiedRect();
foreach (Pawn pawn in Map.mapPawns.AllPawnsSpawned) {
// Prisoners can't do sow jobs (slaves could though)
if (pawn.IsPrisoner) continue;
foreach (Job job in pawn.jobs.AllJobs()) {
// Only worry about sowing jobs
if (job.def != JobDefOf.Sow) continue;
// Only care if it's in our hydroponics region
if (!region.Contains(job.targetA.Cell)) continue;
Log.Message($"Canceled a Sow Job at {job.targetA.Cell} for {pawn.NameFullColored}");
// Cancel the job, make sure it doesn't get regenerated
pawn.jobs.EndCurrentOrQueuedJob(job, JobCondition.Incompletable, false);
}
}
}
private static readonly Material HydroponicPoweredFillMaterial =

View File

@@ -45,6 +45,7 @@ def main(output_directory: Path) -> None:
patterns: List[str] = [
"About/",
"About/PublishedFileId.txt",
"About/About.xml",
"About/Preview.png",
"Assemblies/",