22 Commits
v0.1 ... v0.2.1

Author SHA1 Message Date
4a98d6aa83 Fix improper asset moving, move non-essential About/ assets into .assets 2024-05-07 19:08:46 -05:00
a8b7ba4496 Update README badge 2024-05-07 19:02:34 -05:00
acbc440d10 Stable go version, update version to appropriate 2.1 2024-05-07 19:00:49 -05:00
9cbbc0a823 Try workflow command set-output for artifact 2024-05-07 18:58:53 -05:00
c14d9ad840 Install xq via Go, remove cat pipe 2024-05-07 18:53:02 -05:00
ff16bd7a08 Remove yq 2024-05-07 18:51:59 -05:00
6774a121ce Use Go for xq 2024-05-07 18:51:11 -05:00
8cd1ae7caf Get version before moving files 2024-05-07 18:41:14 -05:00
7f97c26916 Remove build script, try incorporate mod version into artifact name 2024-05-07 18:40:23 -05:00
8facf38ab2 Merge pull request #2 from Xevion/1.5
1.5: GitHub Workflow Build Script, Project SDK Modernization
2024-05-07 14:16:54 -05:00
d64e18207e Merge pull request #1 from mrsebseb/1.5
1.5 Support, Draw to DrawAt
2024-05-07 14:16:38 -05:00
275c524a30 Working dotnet CLI build, add Krafs RimWorld ref pkg 2024-05-07 04:33:13 -05:00
bc7308749b Add build script 2024-05-07 04:13:30 -05:00
d53a7f2763 Update supported version, modVersion 2024-05-07 01:42:01 -05:00
85eeec32e3 Add 'build' folder to .gitignore 2024-05-07 01:41:46 -05:00
Sebastian
2486dd2e7c 1.5 Support, Draw to DrawAt 2024-04-12 23:18:24 +02:00
d3321ececb Add dynamic Shield.io repository badges 2023-07-18 14:01:37 -05:00
9e86262e5d Add PublishedFileId.txt 2023-07-18 11:26:47 -05:00
1e6a60b996 Update README on multi-harvest plant compatibility details 2023-07-18 01:31:53 -05:00
7f5c1884fc Prevent occaisional plants from being sown upton 'Grow' stage hydroponics 2023-07-18 01:29:34 -05:00
6cc3d59f8d Fix uses of private internal stage variable, damage plants sitting atop container while unpowered 2023-07-18 00:31:29 -05:00
d2a019997c Add bodge fix re-harvestable plants not being destroyed properly 2023-07-18 00:30:36 -05:00
11 changed files with 133 additions and 106 deletions

View File

Before

Width:  |  Height:  |  Size: 333 KiB

After

Width:  |  Height:  |  Size: 333 KiB

View File

View File

Before

Width:  |  Height:  |  Size: 718 KiB

After

Width:  |  Height:  |  Size: 718 KiB

52
.github/workflows/build.yml vendored Normal file
View 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
View File

@@ -1,3 +1,4 @@
.idea
/Assemblies/*.dll
/Assemblies/*.pdb
Assemblies/*.dll
Assemblies/*.pdb
build/

View File

@@ -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>

View File

@@ -0,0 +1 @@
3005196131

View File

@@ -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/

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 =
@@ -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,

View File

@@ -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">

View File

@@ -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)