mirror of
https://github.com/Xevion/RimWorld-Hydroponics-Expanded.git
synced 2025-12-06 09:16:15 -06:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a98d6aa83 | |||
| a8b7ba4496 | |||
| acbc440d10 | |||
| 9cbbc0a823 | |||
| c14d9ad840 | |||
| ff16bd7a08 | |||
| 6774a121ce | |||
| 8cd1ae7caf | |||
| 7f97c26916 | |||
| 8facf38ab2 | |||
| d64e18207e | |||
| 275c524a30 | |||
| bc7308749b | |||
| d53a7f2763 | |||
| 85eeec32e3 | |||
|
|
2486dd2e7c | ||
| d3321ececb | |||
| 9e86262e5d | |||
| 1e6a60b996 | |||
| 7f5c1884fc | |||
| 6cc3d59f8d | |||
| d2a019997c |
|
Before Width: | Height: | Size: 333 KiB After Width: | Height: | Size: 333 KiB |
|
Before Width: | Height: | Size: 718 KiB After Width: | Height: | Size: 718 KiB |
52
.github/workflows/build.yml
vendored
Normal file
52
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
name: Build
|
||||
|
||||
env:
|
||||
SLN_PATH: Source/HydroponicsExpanded/
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Dotnet
|
||||
uses: actions/setup-dotnet@v2
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Install Mod Dependencies
|
||||
run: dotnet restore ${{ env.SLN_PATH }}
|
||||
|
||||
- name: Build Mod
|
||||
run: dotnet build ${{ env.SLN_PATH }} --configuration Release --no-restore
|
||||
|
||||
- name: Setup Go environment
|
||||
uses: actions/setup-go@v5.0.1
|
||||
with:
|
||||
go-version: stable
|
||||
|
||||
- name: Get Version
|
||||
id: get_version
|
||||
run: |
|
||||
go install github.com/sibprogrammer/xq@latest
|
||||
VERSION=$(xq ./About/About.xml -x "/ModMetaData/modVersion")
|
||||
echo "::set-output name=result::$VERSION"
|
||||
|
||||
- name: Move files
|
||||
run: |
|
||||
mkdir -p output/HydroponicsExpanded
|
||||
mv About/ Assemblies/ Defs/ Languages/ Textures/ output/HydroponicsExpanded
|
||||
|
||||
- name: Upload Mod Artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: HydroponicsExpanded-${{ steps.get_version.outputs.result }}
|
||||
path: output/
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.idea
|
||||
/Assemblies/*.dll
|
||||
/Assemblies/*.pdb
|
||||
Assemblies/*.dll
|
||||
Assemblies/*.pdb
|
||||
build/
|
||||
@@ -5,8 +5,8 @@
|
||||
<author>Xevion</author>
|
||||
<description>Provides simple but powerful hydroponics that store plants underground at the cost of expensive components, lots of power, and research.</description>
|
||||
<supportedVersions>
|
||||
<li>1.4</li>
|
||||
<li>1.5</li>
|
||||
</supportedVersions>
|
||||
<modVersion>0.1</modVersion>
|
||||
<modVersion>0.2.1</modVersion>
|
||||
<url>https://github.com/Xevion/RimWorld-Hydroponics-Expanded</url>
|
||||
</ModMetaData>
|
||||
1
About/PublishedFileId.txt
Normal file
1
About/PublishedFileId.txt
Normal file
@@ -0,0 +1 @@
|
||||
3005196131
|
||||
16
README.md
16
README.md
@@ -8,6 +8,9 @@
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
[![badge-workshop-subscribers]][workshop-link] [![badge-workshop-favorites]][workshop-link] [![badge-version]][workshop-link]
|
||||
|
||||
Provides simple but powerful hydroponics that store plants underground at the cost of expensive components, lots of
|
||||
power, and research.
|
||||
@@ -24,7 +27,7 @@ expensive both in resources & power usage.
|
||||
- Compact Hydroponics for growing many plants in a small space.
|
||||
- Balanced recipes with absurd power/recipe requirements for absurd density.
|
||||
- Simple usage with relatively no changes compared to traditional Hydroponics.
|
||||
- Strong compatability with few changes to Vanilla RimWorld.
|
||||
- Strong compatibility with few changes to Vanilla RimWorld.
|
||||
|
||||
## Compatibility
|
||||
|
||||
@@ -32,8 +35,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.
|
||||
|
||||
@@ -65,6 +69,12 @@ preventing the crop from being sown in the hydroponics in the first place (there
|
||||
|
||||
[workshop-link]: https://steamcommunity.com/sharedfiles/filedetails/?id=3005196131
|
||||
|
||||
[badge-version]: https://img.shields.io/badge/built_for-RimWorld_1.5-blue
|
||||
|
||||
[badge-workshop-subscribers]: https://img.shields.io/endpoint.svg?url=https://shieldsio-steam-workshop.jross.me/3005196131/subscriptions-text
|
||||
|
||||
[badge-workshop-favorites]: https://img.shields.io/endpoint.svg?url=https://shieldsio-steam-workshop.jross.me/3005196131/favourites-text
|
||||
|
||||
[hydroponics-basin]: https://rimworldwiki.com/wiki/Hydroponics_basin
|
||||
|
||||
[rimworld]: https://store.steampowered.com/app/294100/RimWorld/
|
||||
@@ -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 =
|
||||
@@ -191,13 +234,13 @@ namespace HydroponicsExpanded {
|
||||
private static readonly Material HydroponicUnfilledMaterial =
|
||||
SolidColorMaterials.SimpleSolidColorMaterial(new Color(0.3f, 0.3f, 0.3f));
|
||||
|
||||
public override void Draw() {
|
||||
base.Draw();
|
||||
protected override void DrawAt(Vector3 drawLoc, bool flip=false) {
|
||||
base.DrawAt(drawLoc, flip);
|
||||
|
||||
// Only draw growth percentage bar during Sowing stage
|
||||
if (_stage == HydroponicsStage.Grow) {
|
||||
var bar = new GenDraw.FillableBarRequest {
|
||||
center = DrawPos + Vector3.up * 0.1f,
|
||||
center = drawLoc + Vector3.up * 0.1f,
|
||||
size = new Vector2(DrawSize.y - 0.4f, DrawSize.x - 0.4f),
|
||||
margin = 0.15f,
|
||||
fillPercent = _highestGrowth,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<!-- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> -->
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@@ -9,8 +9,9 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>HydroponicsExpanded</RootNamespace>
|
||||
<AssemblyName>HydroponicsExpanded</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -31,7 +32,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- <ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -45,15 +46,18 @@
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</ItemGroup> -->
|
||||
<ItemGroup>
|
||||
<Compile Include="Buildings\Building_DenseHydroponicsBasin.cs" />
|
||||
<!-- <Compile Include="Buildings\Building_DenseHydroponicsBasin.cs" />
|
||||
<Compile Include="Enums\HydroponicsStage.cs" />
|
||||
<Compile Include="ModExtension\CapacityExtension.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utility\BetweenExtension.cs" />
|
||||
<Compile Include="Utility\BetweenExtension.cs" /> -->
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4085" />
|
||||
</ItemGroup>
|
||||
<!-- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -->
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
84
build.py
84
build.py
@@ -1,84 +0,0 @@
|
||||
import glob
|
||||
import logging
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from shutil import rmtree
|
||||
from typing import List
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
PROJECT_DIRECTORY: Path = Path(__file__).parent
|
||||
|
||||
|
||||
def main(output_directory: Path) -> None:
|
||||
# Check that output directory exists properly.
|
||||
if not output_directory.exists():
|
||||
# If the parent doesn't exist, we aren't going to create the folder.
|
||||
if not output_directory.parent.exists():
|
||||
raise RuntimeError("Cannot create more than one directory. Please check the output")
|
||||
|
||||
output_directory.mkdir(parents=False, exist_ok=False)
|
||||
|
||||
output_mod_directory: Path = output_directory / "HydroponicsExpanded"
|
||||
|
||||
# Folders that we need to be removed from the output directory if they contain any files.
|
||||
pertinents_folders: List[str] = ["Defs", "Assemblies", "About", "Textures", "Languages"]
|
||||
if output_mod_directory.exists():
|
||||
logger.debug('Checking for folders to clear in destination.')
|
||||
|
||||
for folder in pertinents_folders:
|
||||
destination_folder_path: Path = output_mod_directory / folder
|
||||
|
||||
# Ignore folders that don't exist.
|
||||
if not destination_folder_path.exists():
|
||||
continue
|
||||
|
||||
has_children: bool = any(destination_folder_path.iterdir())
|
||||
logger.debug('Clearing "{}" folder.'.format(folder))
|
||||
if has_children:
|
||||
rmtree(destination_folder_path)
|
||||
# destination_folder_path.rmdir()
|
||||
else:
|
||||
output_mod_directory.mkdir(parents=False)
|
||||
|
||||
patterns: List[str] = [
|
||||
"About/",
|
||||
"About/About.xml",
|
||||
"About/Preview.png",
|
||||
"Assemblies/",
|
||||
"Assemblies/HydroponicsExpanded.dll",
|
||||
"Defs/**",
|
||||
"Languages/**",
|
||||
"Textures/**"
|
||||
]
|
||||
|
||||
for pattern in patterns:
|
||||
paths: List[Path] = list(map(Path, glob.glob(str(PROJECT_DIRECTORY / pattern), recursive=True)))
|
||||
|
||||
for source_path in paths:
|
||||
relative_path: Path = source_path.relative_to(PROJECT_DIRECTORY)
|
||||
destination_path: Path = output_mod_directory / relative_path
|
||||
|
||||
logger.debug("Copying from {} to {}".format(source_path, destination_path))
|
||||
if source_path.is_dir():
|
||||
destination_path.mkdir(exist_ok=True)
|
||||
elif source_path.is_file():
|
||||
shutil.copyfile(source_path, destination_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
output_directory: Path = PROJECT_DIRECTORY / "build"
|
||||
if len(sys.argv) > 1:
|
||||
output_directory = Path(sys.argv[1])
|
||||
else:
|
||||
logger.warning('Output directory automatically chosen.')
|
||||
|
||||
logger.debug('Project Directory: {}'.format(PROJECT_DIRECTORY))
|
||||
logger.debug('Output Directory: {}'.format(output_directory))
|
||||
|
||||
main(output_directory)
|
||||
except BaseException as e:
|
||||
logger.error("Build script failed", exc_info=e)
|
||||
Reference in New Issue
Block a user