From 3211f850c31bf1047d716627be2536f1e3417b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20=27silibum=27=20B=C3=B6hme?= Date: Sun, 23 Feb 2025 19:25:09 +0100 Subject: [PATCH 1/3] New feature: Ignore tags for TurnOnMachines It's possible to ignore tags for the TurnOnMachines-Action by adding them to the configuration. This new option defaults to the "LargeDoor"-tag which is the cause for this new option. Added as option to ignore more tags if needed as the worldobjects could have an OnOffComponent and need to be ignored also -> Used tags as those are the most global filter that could be applied (and the mod itself is done by a component which can be included by many worldobjects) --- .github/workflows/release.yml | 11 +------- .github/workflows/staging.yml | 11 +------- .../EcoLawExtensionsMod.csproj | 28 ++----------------- EcoLawExtensionsMod/LawExtensionsPlugin.cs | 3 ++ .../LegalActions/TurnOnMachines.cs | 3 +- fetch-eco-reference-assemblies.sh | 15 ---------- 6 files changed, 9 insertions(+), 62 deletions(-) delete mode 100644 fetch-eco-reference-assemblies.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f0e18a..6f9a3fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: name: Build Mod runs-on: ubuntu-latest env: - MODKIT_VERSION: 0.11.1.3-beta-release-795 + MODKIT_VERSION: 0.11.1.9-beta-release-842 ECO_BRANCH: staging steps: - uses: actions/checkout@v4 @@ -21,15 +21,6 @@ jobs: run: dotnet restore ./EcoLawExtensionsMod/EcoLawExtensionsMod.csproj env: DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1 - - name: Cache Eco dlls - id: cache-eco-dlls - uses: actions/cache@v4 - with: - path: ./eco-dlls - key: ${{ env.MODKIT_VERSION }}-ref-dlls - - name: Download Eco dlls - if: steps.cache-eco-dlls.outputs.cache-hit != 'true' - run: sh fetch-eco-reference-assemblies.sh - name: Build run: dotnet build ./EcoLawExtensionsMod/EcoLawExtensionsMod.csproj --configuration Release --no-restore /p:AssemblyVersion=${{github.event.release.tag_name}} env: diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index e7f667d..a1d78ce 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -10,7 +10,7 @@ jobs: name: Build Mod runs-on: ubuntu-latest env: - MODKIT_VERSION: 0.11.1.3-beta-release-795 + MODKIT_VERSION: 0.11.1.6-beta-release-842 ECO_BRANCH: staging steps: - uses: actions/checkout@v4 @@ -22,15 +22,6 @@ jobs: run: dotnet restore ./EcoLawExtensionsMod/EcoLawExtensionsMod.csproj env: DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1 - - name: Cache Eco dlls - id: cache-eco-dlls - uses: actions/cache@v4 - with: - path: ./eco-dlls - key: ${{ env.MODKIT_VERSION }}-ref-dlls - - name: Download Eco dlls - if: steps.cache-eco-dlls.outputs.cache-hit != 'true' - run: sh fetch-eco-reference-assemblies.sh - name: Build run: dotnet build ./EcoLawExtensionsMod/EcoLawExtensionsMod.csproj --configuration Release --no-restore env: diff --git a/EcoLawExtensionsMod/EcoLawExtensionsMod.csproj b/EcoLawExtensionsMod/EcoLawExtensionsMod.csproj index 50108d8..82ba2bc 100644 --- a/EcoLawExtensionsMod/EcoLawExtensionsMod.csproj +++ b/EcoLawExtensionsMod/EcoLawExtensionsMod.csproj @@ -12,32 +12,8 @@ - - - - ..\eco-dlls\Eco.Core.dll - - - ..\eco-dlls\Eco.Gameplay.dll - - - ..\eco-dlls\Eco.ModKit.dll - - - ..\eco-dlls\Eco.Plugins.dll - - - ..\eco-dlls\Eco.Shared.dll - - - ..\eco-dlls\Eco.Simulation.dll - - - ..\eco-dlls\Eco.Stats.dll - - - - + + diff --git a/EcoLawExtensionsMod/LawExtensionsPlugin.cs b/EcoLawExtensionsMod/LawExtensionsPlugin.cs index 18e365a..fb5f811 100644 --- a/EcoLawExtensionsMod/LawExtensionsPlugin.cs +++ b/EcoLawExtensionsMod/LawExtensionsPlugin.cs @@ -48,6 +48,9 @@ public class LawExtensionsConfig { [LocDescription("Seconds between each power grid law tick. Set to 0 to disable.")] public int TickInterval { get; set; } = 30; + + [LocDescription("List of tags to be ignored by the TurnOnMachines-Action")] + public List TurnOnIgnoreTags { get; set; } = ["LargeDoor"]; } [Localized, LocDisplayName(nameof(LawExtensionsPlugin)), Priority(PriorityAttribute.High)] diff --git a/EcoLawExtensionsMod/LegalActions/TurnOnMachines.cs b/EcoLawExtensionsMod/LegalActions/TurnOnMachines.cs index 8941917..3d367d7 100644 --- a/EcoLawExtensionsMod/LegalActions/TurnOnMachines.cs +++ b/EcoLawExtensionsMod/LegalActions/TurnOnMachines.cs @@ -21,6 +21,7 @@ namespace Eco.Mods.LawExtensions using Gameplay.Components; using Gameplay.Settlements; using Gameplay.Economy.Transfer; + using Gameplay.Items; [Eco, LocCategory("Misc"), CreateComponentTabLoc("Eco Law Extensions", IconName = "Law"), LocDisplayName("Turn On Machines"), LocDescription("Tries to turn on all inactive machines that match a set of conditions.")] public class TurnOnMachines_LegalAction : LegalAction @@ -66,7 +67,7 @@ private PostResult Do(LocString description, IContextObject context, Settlement { int cnt = 0; var allRelevantObjects = WorldObjectUtil.AllObjsWithComponent() - .Where(x => x != null && !x.On && (jurisdictionSettlement?.Influences(x.Parent.WorldPosXZi()) ?? true)); + .Where(x => x != null && !x.On && (jurisdictionSettlement?.Influences(x.Parent.WorldPosXZi()) ?? true) && !x.Parent.TagNames().Intersect(LawExtensionsPlugin.Obj.Config.TurnOnIgnoreTags).Any()); foreach (var onOffComponent in allRelevantObjects) { var worldObject = onOffComponent.Parent; diff --git a/fetch-eco-reference-assemblies.sh b/fetch-eco-reference-assemblies.sh deleted file mode 100644 index 3eaf257..0000000 --- a/fetch-eco-reference-assemblies.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -MODKIT_FILENAME="EcoModKit_v$MODKIT_VERSION.zip" - -mkdir -p ./eco-dlls -if [ $ECO_BRANCH = "release" ] -then - wget "https://play.eco/s3/$ECO_BRANCH/$MODKIT_FILENAME" -else - wget "https://eco-releases-$ECO_BRANCH-eu.s3.eu-central-1.amazonaws.com/$MODKIT_FILENAME" -fi -unzip -o $MODKIT_FILENAME -d ./tmp -cp ./tmp/ReferenceAssemblies/*.dll ./eco-dlls -rm -r ./tmp -rm $MODKIT_FILENAME \ No newline at end of file From d36e311dc379dd3d5dc6c335d051ceb2ddf4851b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20=27silibum=27=20B=C3=B6hme?= Date: Sun, 23 Feb 2025 19:26:48 +0100 Subject: [PATCH 2/3] Cleanup - made the filter/where more readable in code --- EcoLawExtensionsMod/LegalActions/TurnOnMachines.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/EcoLawExtensionsMod/LegalActions/TurnOnMachines.cs b/EcoLawExtensionsMod/LegalActions/TurnOnMachines.cs index 3d367d7..5966354 100644 --- a/EcoLawExtensionsMod/LegalActions/TurnOnMachines.cs +++ b/EcoLawExtensionsMod/LegalActions/TurnOnMachines.cs @@ -67,7 +67,9 @@ private PostResult Do(LocString description, IContextObject context, Settlement { int cnt = 0; var allRelevantObjects = WorldObjectUtil.AllObjsWithComponent() - .Where(x => x != null && !x.On && (jurisdictionSettlement?.Influences(x.Parent.WorldPosXZi()) ?? true) && !x.Parent.TagNames().Intersect(LawExtensionsPlugin.Obj.Config.TurnOnIgnoreTags).Any()); + .Where(x => x != null && + !x.On && (jurisdictionSettlement?.Influences(x.Parent.WorldPosXZi()) ?? true) && + !x.Parent.TagNames().Intersect(LawExtensionsPlugin.Obj.Config.TurnOnIgnoreTags).Any()); foreach (var onOffComponent in allRelevantObjects) { var worldObject = onOffComponent.Parent; From 63f7d3cd36a339b8aafdffd2409f6475cae4e25e Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Thu, 29 May 2025 16:45:40 +0100 Subject: [PATCH 3/3] Updated to Eco 0.11.1.12 release build. Updated readme with note about TurnOnIgnoreTags setting. --- EcoLawExtensionsMod/EcoLawExtensionsMod.csproj | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/EcoLawExtensionsMod/EcoLawExtensionsMod.csproj b/EcoLawExtensionsMod/EcoLawExtensionsMod.csproj index 82ba2bc..286b2ef 100644 --- a/EcoLawExtensionsMod/EcoLawExtensionsMod.csproj +++ b/EcoLawExtensionsMod/EcoLawExtensionsMod.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/README.md b/README.md index f509719..438676f 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ Extracts the X/Z coordinate from a location. This will be an integer in whole bl #### Turn On Machines -Tries to turn on machines belonging to a citizen or group that are currently turned off. The filter can specify how the machines were turned off - for example, only try to turn on machines that were turned off legally (e.g. via prevent on Pollute Air). +Tries to turn on machines belonging to a citizen or group that are currently turned off. The filter can specify how the machines were turned off - for example, only try to turn on machines that were turned off legally (e.g. via prevent on Pollute Air). Note that anything configured by the server in the mod's 'TurnOnIgnoreTags' setting will be ignored by this action. | Property Name | Type | Description | | - | - | - |