From 09189ec0bb967ed70daf4f97fad2595739ab3540 Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Sat, 24 Feb 2024 12:12:08 +0100 Subject: [PATCH 1/6] #594 Added ITab Ground and Forbidden Settings are functional Removed Obsolet keys and code --- .../Buildings_Logistics.xml | 1 + Languages/English/Keyed/AllKeyed_SAL3.xml | 7 +- .../Common/IPickupSettings.cs | 19 ++++ .../SAL3/Things/Building_SmartHopper.cs | 90 +++++++++++++------ .../SAL3/Things/ITab_SmartHopper.cs | 63 +++++++++++++ 5 files changed, 150 insertions(+), 30 deletions(-) create mode 100644 Source/ProjectRimFactory/Common/IPickupSettings.cs create mode 100644 Source/ProjectRimFactory/SAL3/Things/ITab_SmartHopper.cs diff --git a/Defs/ThingDefs_Buildings/Buildings_Logistics.xml b/Defs/ThingDefs_Buildings/Buildings_Logistics.xml index 576f03cf..93df958c 100644 --- a/Defs/ThingDefs_Buildings/Buildings_Logistics.xml +++ b/Defs/ThingDefs_Buildings/Buildings_Logistics.xml @@ -120,6 +120,7 @@
  • ITab_Storage
  • ProjectRimFactory.Common.ITab_PowerSupply
  • +
  • ProjectRimFactory.SAL3.Things.ITab_SmartHopper
  • true diff --git a/Languages/English/Keyed/AllKeyed_SAL3.xml b/Languages/English/Keyed/AllKeyed_SAL3.xml index 50f64142..f3019452 100644 --- a/Languages/English/Keyed/AllKeyed_SAL3.xml +++ b/Languages/English/Keyed/AllKeyed_SAL3.xml @@ -31,8 +31,13 @@ Current item max limit: {0} When this is enabled, the smart hopper will unforbid its items if the stored item has less than X stack size. It will also only take items if there are enough items around to exceed the minimum. When this is enabled, the smart hopper will stop taking items if either the stack is full, or the stack size exceeds or is equal to X. - Pickup from ground Can't create Stockpile (No free Cells). + Pickup + Pickup Settings: + Ground + Stockpile + Storage Building + Allow forbidden Project RimFactory diff --git a/Source/ProjectRimFactory/Common/IPickupSettings.cs b/Source/ProjectRimFactory/Common/IPickupSettings.cs new file mode 100644 index 00000000..494088cd --- /dev/null +++ b/Source/ProjectRimFactory/Common/IPickupSettings.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRimFactory.Common +{ + internal interface IPickupSettings + { + + bool AllowGroundPickup { get; set; } + bool AllowStockpilePickup { get; set; } + bool AllowStoragePickup { get; set; } + bool AllowForbiddenPickup { get; set; } + + + } +} diff --git a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs index b90ad4b3..988640c2 100644 --- a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs +++ b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs @@ -1,5 +1,4 @@ using ProjectRimFactory.Common; -using ProjectRimFactory.Common.HarmonyPatches; using ProjectRimFactory.SAL3.Tools; using ProjectRimFactory.Storage; using ProjectRimFactory.Storage.UI; @@ -11,11 +10,12 @@ namespace ProjectRimFactory.SAL3.Things { - public class Building_SmartHopper : Building, IStoreSettingsParent, IPowerSupplyMachineHolder + public class Building_SmartHopper : Building, IStoreSettingsParent, IPowerSupplyMachineHolder, IPickupSettings { private OutputSettings outputSettings; - public IEnumerable cachedDetectorCells; + public List cachedDetectorCells = new List(); + private bool cachedDetectorCellsDirty = false; protected virtual bool ShouldRespectStackLimit => true; @@ -23,27 +23,40 @@ public class Building_SmartHopper : Building, IStoreSettingsParent, IPowerSupply public Thing StoredThing => Position.GetFirstItem(Map); - private bool pickupFromGround; + private CompPowerWorkSetting compPowerWorkSetting; - public IPowerSupplyMachine RangePowerSupplyMachine => this.GetComp(); + public IPowerSupplyMachine RangePowerSupplyMachine => compPowerWorkSetting ?? this.GetComp(); - private IEnumerable CellsToTarget => (this.GetComp()?.GetRangeCells() ?? GenRadial.RadialCellsAround(Position, this.def.specialDisplayRadius, false)).Where(c => c.GetFirst(this.Map) == null); + private IEnumerable CellsToTarget + { + get + { + IEnumerable cells = compPowerWorkSetting?.GetRangeCells() ?? GenRadial.RadialCellsAround(Position, this.def.specialDisplayRadius, false); + return cells.Where(c => c.GetFirst(this.Map) == null); //Exclude other Smart Hoppers + } + } - public IEnumerable CellsToSelect + public List CellsToSelect { get { - if (Find.TickManager.TicksGame % 50 != 0 && cachedDetectorCells != null) + if (Find.TickManager.TicksGame % 50 != 0 || cachedDetectorCellsDirty) { return cachedDetectorCells; } - var resultCache = from IntVec3 c - in this.CellsToTarget - where this.pickupFromGround || c.HasSlotGroupParent(Map) - select c; - cachedDetectorCells = resultCache; - return resultCache; + cachedDetectorCellsDirty = false; + cachedDetectorCells.Clear(); + foreach (IntVec3 c in CellsToTarget) + { + if (!c.InBounds(this.Map)) continue; + if (this.allowGroundPickup || (/*allowStockpilePickup && */c.HasSlotGroupParent(Map))) + { + cachedDetectorCells.Add(c); + } + } + + return cachedDetectorCells; } } @@ -53,10 +66,13 @@ public IEnumerable ThingsToSelect { foreach (var c in CellsToSelect) { - if (!c.InBounds(this.Map)) continue; - foreach (Thing t in GatherThingsUtility.AllThingsInCellForUse(c, Map,false)) + foreach (Thing t in GatherThingsUtility.AllThingsInCellForUse(c, Map,AllowStockpilePickup)) { - yield return t; + if ((allowForbiddenPickup || !t.IsForbidden(Faction.OfPlayer))) + { + + yield return t; + } } } } @@ -80,11 +96,31 @@ public OutputSettings OutputSettings } } - public Thing NPDI_Item => StoredThing; + + + private bool allowGroundPickup = false; + private bool allowStockpilePickup = false; + private bool allowStoragePickup = false; + private bool allowForbiddenPickup = false; + + public bool AllowGroundPickup + { + get => allowGroundPickup; + + set + { + if (value != allowGroundPickup) cachedDetectorCellsDirty = true; + allowGroundPickup = value; + } + } + public bool AllowStockpilePickup { get => allowStockpilePickup; set => allowStockpilePickup = value; } + public bool AllowStoragePickup { get => allowStoragePickup; set => allowStoragePickup = value; } + public bool AllowForbiddenPickup { get => allowForbiddenPickup; set => allowForbiddenPickup = value; } public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); + compPowerWorkSetting = this.GetComp(); if (settings == null) { settings = new StorageSettings(); @@ -92,7 +128,7 @@ public override void SpawnSetup(Map map, bool respawningAfterLoad) } if (!respawningAfterLoad) { - this.pickupFromGround = true; + this.allowGroundPickup = true; } } @@ -101,7 +137,10 @@ public override void ExposeData() base.ExposeData(); Scribe_Deep.Look(ref outputSettings, "outputSettings", "SmartHopper_Minimum_UseTooltip", "SmartHopper_Maximum_UseTooltip"); Scribe_Deep.Look(ref settings, "settings", this); - Scribe_Values.Look(ref this.pickupFromGround, "pickupFromGround"); + Scribe_Values.Look(ref this.allowGroundPickup, "allowGroundPickup", false); + Scribe_Values.Look(ref this.allowStockpilePickup, "allowStockpilePickup", false); + Scribe_Values.Look(ref this.allowStoragePickup, "allowStoragePickup", false); + Scribe_Values.Look(ref this.allowForbiddenPickup, "allowForbiddenPickup", false); } public override string GetInspectString() @@ -185,8 +224,8 @@ public virtual void TryStoreThing(Thing element) public override void DrawExtraSelectionOverlays() { base.DrawExtraSelectionOverlays(); - if (!this.pickupFromGround) - GenDraw.DrawFieldEdges(CellsToSelect.ToList(), Color.green); + if (!this.allowGroundPickup) + GenDraw.DrawFieldEdges(CellsToSelect, Color.green); } public override IEnumerable GetGizmos() @@ -201,13 +240,6 @@ public override IEnumerable GetGizmos() defaultLabel = "SmartHopper_SetTargetAmount".Translate(), action = () => Find.WindowStack.Add(new Dialog_OutputMinMax(OutputSettings)), }; - yield return new Command_Toggle - { - icon = ContentFinder.Get("PRFUi/PickupFromGround"), - defaultLabel = "SmartHopper_PickupFromGround".Translate(), - toggleAction = () => this.pickupFromGround = !this.pickupFromGround, - isActive = () => this.pickupFromGround - }; } public StorageSettings GetStoreSettings() diff --git a/Source/ProjectRimFactory/SAL3/Things/ITab_SmartHopper.cs b/Source/ProjectRimFactory/SAL3/Things/ITab_SmartHopper.cs new file mode 100644 index 00000000..e3cd57f0 --- /dev/null +++ b/Source/ProjectRimFactory/SAL3/Things/ITab_SmartHopper.cs @@ -0,0 +1,63 @@ +using ProjectRimFactory.Common; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using Verse; + +namespace ProjectRimFactory.SAL3.Things +{ + public class ITab_SmartHopper : ITab + { + + private static readonly Vector2 WinSize = new Vector2(200f, 200f); + + private IPickupSettings hopper => this.SelThing as IPickupSettings; + + + private bool GroundPickup = false; + private bool Stockpile = false; + private bool BuildingStorage = false; + private bool Allowforbidden = false; + + public ITab_SmartHopper() + { + this.size = WinSize; + this.labelKey = "PRF.SmartHopper.ITab.Name"; + } + + protected override void FillTab() + { + Listing_Standard list = new Listing_Standard(); + Rect rect = new Rect(0f, 0f, WinSize.x-20f, WinSize.y).ContractedBy(10f); + list.Begin(rect); + + GroundPickup = hopper.AllowGroundPickup; + Stockpile = hopper.AllowStockpilePickup; + BuildingStorage = hopper.AllowStoragePickup; + Allowforbidden = hopper.AllowForbiddenPickup; + + + list.Label("PRF.SmartHopper.ITab.Description".Translate()); + rect = list.GetRect(30); + Widgets.CheckboxLabeled(rect, "PRF.SmartHopper.ITab.AllowGround".Translate(), ref GroundPickup); + rect = list.GetRect(30); + Widgets.CheckboxLabeled(rect, "PRF.SmartHopper.ITab.AllowStockpile".Translate(), ref Stockpile); + rect = list.GetRect(30); + Widgets.CheckboxLabeled(rect, "PRF.SmartHopper.ITab.AllowStorage".Translate(), ref BuildingStorage); + rect = list.GetRect(30); + Widgets.CheckboxLabeled(rect, "PRF.SmartHopper.ITab.AllowForbidden".Translate(), ref Allowforbidden); + + hopper.AllowGroundPickup = GroundPickup; + hopper.AllowStockpilePickup = Stockpile; + hopper.AllowStoragePickup = BuildingStorage; + hopper.AllowForbiddenPickup = Allowforbidden; + + list.End(); + + } + } +} From 13fe797c51c3f0547fa983a3a303e7b8846e6a09 Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Sat, 24 Feb 2024 15:45:12 +0100 Subject: [PATCH 2/6] #594 Added Support for the Stockpile and storage Toggle --- .../SAL3/Things/Building_SmartHopper.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs index 988640c2..33f640db 100644 --- a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs +++ b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs @@ -15,7 +15,7 @@ public class Building_SmartHopper : Building, IStoreSettingsParent, IPowerSupply private OutputSettings outputSettings; public List cachedDetectorCells = new List(); - private bool cachedDetectorCellsDirty = false; + private bool cachedDetectorCellsDirty = true; protected virtual bool ShouldRespectStackLimit => true; @@ -40,7 +40,7 @@ public List CellsToSelect { get { - if (Find.TickManager.TicksGame % 50 != 0 || cachedDetectorCellsDirty) + if (Find.TickManager.TicksGame % 50 != 0 && !cachedDetectorCellsDirty) { return cachedDetectorCells; } @@ -50,7 +50,7 @@ public List CellsToSelect foreach (IntVec3 c in CellsToTarget) { if (!c.InBounds(this.Map)) continue; - if (this.allowGroundPickup || (/*allowStockpilePickup && */c.HasSlotGroupParent(Map))) + if (this.allowGroundPickup || c.HasSlotGroupParent(Map)) { cachedDetectorCells.Add(c); } @@ -68,10 +68,16 @@ public IEnumerable ThingsToSelect { foreach (Thing t in GatherThingsUtility.AllThingsInCellForUse(c, Map,AllowStockpilePickup)) { - if ((allowForbiddenPickup || !t.IsForbidden(Faction.OfPlayer))) + var SlotGroupParrent = t.GetSlotGroup()?.parent; + if ((SlotGroupParrent is Zone_Stockpile && allowStockpilePickup) || + (SlotGroupParrent is Building_Storage && allowStoragePickup) || + (SlotGroupParrent == null && allowGroundPickup)) { + if ((allowForbiddenPickup || !t.IsForbidden(Faction.OfPlayer))) + { - yield return t; + yield return t; + } } } } From c47cdf8c5a176660cab53969bec39e6f665d5820 Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Sat, 24 Feb 2024 18:51:44 +0100 Subject: [PATCH 3/6] #594 added belt setting --- Languages/English/Keyed/AllKeyed_SAL3.xml | 1 + .../ProjectRimFactory/Common/IPickupSettings.cs | 1 + .../SAL3/Things/Building_SmartHopper.cs | 16 ++++++++++------ .../SAL3/Things/ITab_SmartHopper.cs | 5 +++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Languages/English/Keyed/AllKeyed_SAL3.xml b/Languages/English/Keyed/AllKeyed_SAL3.xml index f3019452..ceff0684 100644 --- a/Languages/English/Keyed/AllKeyed_SAL3.xml +++ b/Languages/English/Keyed/AllKeyed_SAL3.xml @@ -38,6 +38,7 @@ Stockpile Storage Building Allow forbidden + Allow Belt Project RimFactory diff --git a/Source/ProjectRimFactory/Common/IPickupSettings.cs b/Source/ProjectRimFactory/Common/IPickupSettings.cs index 494088cd..e8270a66 100644 --- a/Source/ProjectRimFactory/Common/IPickupSettings.cs +++ b/Source/ProjectRimFactory/Common/IPickupSettings.cs @@ -13,6 +13,7 @@ internal interface IPickupSettings bool AllowStockpilePickup { get; set; } bool AllowStoragePickup { get; set; } bool AllowForbiddenPickup { get; set; } + bool AllowBeltPickup { get; set; } } diff --git a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs index 33f640db..961d5f95 100644 --- a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs +++ b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs @@ -1,4 +1,5 @@ -using ProjectRimFactory.Common; +using ProjectRimFactory.AutoMachineTool; +using ProjectRimFactory.Common; using ProjectRimFactory.SAL3.Tools; using ProjectRimFactory.Storage; using ProjectRimFactory.Storage.UI; @@ -7,6 +8,7 @@ using System.Linq; using UnityEngine; using Verse; +using Verse.Noise; namespace ProjectRimFactory.SAL3.Things { @@ -50,7 +52,7 @@ public List CellsToSelect foreach (IntVec3 c in CellsToTarget) { if (!c.InBounds(this.Map)) continue; - if (this.allowGroundPickup || c.HasSlotGroupParent(Map)) + if (this.allowGroundPickup || c.HasSlotGroupParent(Map) || (allowBeltPickup && c.GetThingList(Map).Any(t => t is Building_BeltConveyor))) { cachedDetectorCells.Add(c); } @@ -69,13 +71,13 @@ public IEnumerable ThingsToSelect foreach (Thing t in GatherThingsUtility.AllThingsInCellForUse(c, Map,AllowStockpilePickup)) { var SlotGroupParrent = t.GetSlotGroup()?.parent; - if ((SlotGroupParrent is Zone_Stockpile && allowStockpilePickup) || - (SlotGroupParrent is Building_Storage && allowStoragePickup) || - (SlotGroupParrent == null && allowGroundPickup)) + if ((allowGroundPickup && SlotGroupParrent == null && t.ParentHolder is not Building) || + (allowStockpilePickup && SlotGroupParrent is Zone_Stockpile) || + (allowStoragePickup && SlotGroupParrent is Building_Storage) || + (allowBeltPickup && t.ParentHolder is Building_BeltConveyor)) { if ((allowForbiddenPickup || !t.IsForbidden(Faction.OfPlayer))) { - yield return t; } } @@ -108,6 +110,7 @@ public OutputSettings OutputSettings private bool allowStockpilePickup = false; private bool allowStoragePickup = false; private bool allowForbiddenPickup = false; + private bool allowBeltPickup = false; public bool AllowGroundPickup { @@ -122,6 +125,7 @@ public bool AllowGroundPickup public bool AllowStockpilePickup { get => allowStockpilePickup; set => allowStockpilePickup = value; } public bool AllowStoragePickup { get => allowStoragePickup; set => allowStoragePickup = value; } public bool AllowForbiddenPickup { get => allowForbiddenPickup; set => allowForbiddenPickup = value; } + public bool AllowBeltPickup { get => allowBeltPickup; set => allowBeltPickup = value; } public override void SpawnSetup(Map map, bool respawningAfterLoad) { diff --git a/Source/ProjectRimFactory/SAL3/Things/ITab_SmartHopper.cs b/Source/ProjectRimFactory/SAL3/Things/ITab_SmartHopper.cs index e3cd57f0..6f551096 100644 --- a/Source/ProjectRimFactory/SAL3/Things/ITab_SmartHopper.cs +++ b/Source/ProjectRimFactory/SAL3/Things/ITab_SmartHopper.cs @@ -22,6 +22,7 @@ public class ITab_SmartHopper : ITab private bool Stockpile = false; private bool BuildingStorage = false; private bool Allowforbidden = false; + private bool AllowBelt = false; public ITab_SmartHopper() { @@ -39,6 +40,7 @@ protected override void FillTab() Stockpile = hopper.AllowStockpilePickup; BuildingStorage = hopper.AllowStoragePickup; Allowforbidden = hopper.AllowForbiddenPickup; + AllowBelt = hopper.AllowBeltPickup; list.Label("PRF.SmartHopper.ITab.Description".Translate()); @@ -50,11 +52,14 @@ protected override void FillTab() Widgets.CheckboxLabeled(rect, "PRF.SmartHopper.ITab.AllowStorage".Translate(), ref BuildingStorage); rect = list.GetRect(30); Widgets.CheckboxLabeled(rect, "PRF.SmartHopper.ITab.AllowForbidden".Translate(), ref Allowforbidden); + rect = list.GetRect(30); + Widgets.CheckboxLabeled(rect, "PRF.SmartHopper.ITab.AllowBelt".Translate(), ref AllowBelt); hopper.AllowGroundPickup = GroundPickup; hopper.AllowStockpilePickup = Stockpile; hopper.AllowStoragePickup = BuildingStorage; hopper.AllowForbiddenPickup = Allowforbidden; + hopper.AllowBeltPickup = AllowBelt; list.End(); From 3d63def442ad2f8779d1f7ae57cd004c5ee749de Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Sat, 24 Feb 2024 20:52:44 +0100 Subject: [PATCH 4/6] #594 fixed green helper overlay --- .../SAL3/Things/Building_SmartHopper.cs | 53 ++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs index 961d5f95..690aff5a 100644 --- a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs +++ b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs @@ -38,6 +38,20 @@ private IEnumerable CellsToTarget } } + + private bool cellIsZone_Stockpile(IntVec3 cell) + { + return cell.GetZone(Map) is Zone_Stockpile; + } + private bool cellIsBuilding_Storage(IntVec3 cell) + { + return cell.GetThingList(Map).FirstOrDefault(t => t is ISlotGroupParent) is Building_Storage; + } + private bool cellIsBuilding_BeltConveyor(IntVec3 cell) + { + return cell.GetThingList(Map).Any(t => t is Building_BeltConveyor); + } + public List CellsToSelect { get @@ -52,7 +66,11 @@ public List CellsToSelect foreach (IntVec3 c in CellsToTarget) { if (!c.InBounds(this.Map)) continue; - if (this.allowGroundPickup || c.HasSlotGroupParent(Map) || (allowBeltPickup && c.GetThingList(Map).Any(t => t is Building_BeltConveyor))) + if ((allowStockpilePickup && cellIsZone_Stockpile(c)) || + (allowStoragePickup && cellIsBuilding_Storage(c)) || + (allowBeltPickup && cellIsBuilding_BeltConveyor(c)) || + (this.allowGroundPickup && !cellIsZone_Stockpile(c) && !cellIsBuilding_Storage(c) && !cellIsBuilding_BeltConveyor(c)) + ) { cachedDetectorCells.Add(c); } @@ -122,10 +140,34 @@ public bool AllowGroundPickup allowGroundPickup = value; } } - public bool AllowStockpilePickup { get => allowStockpilePickup; set => allowStockpilePickup = value; } - public bool AllowStoragePickup { get => allowStoragePickup; set => allowStoragePickup = value; } + public bool AllowStockpilePickup + { + get => allowStockpilePickup; + set + { + if (value != allowStockpilePickup) cachedDetectorCellsDirty = true; + allowStockpilePickup = value; + } + } + public bool AllowStoragePickup + { + get => allowStoragePickup; + set + { + if (value != allowStoragePickup) cachedDetectorCellsDirty = true; + allowStoragePickup = value; + } + } public bool AllowForbiddenPickup { get => allowForbiddenPickup; set => allowForbiddenPickup = value; } - public bool AllowBeltPickup { get => allowBeltPickup; set => allowBeltPickup = value; } + public bool AllowBeltPickup + { + get => allowBeltPickup; + set + { + if (value != allowBeltPickup) cachedDetectorCellsDirty = true; + allowBeltPickup = value; + } + } public override void SpawnSetup(Map map, bool respawningAfterLoad) { @@ -234,8 +276,7 @@ public virtual void TryStoreThing(Thing element) public override void DrawExtraSelectionOverlays() { base.DrawExtraSelectionOverlays(); - if (!this.allowGroundPickup) - GenDraw.DrawFieldEdges(CellsToSelect, Color.green); + GenDraw.DrawFieldEdges(CellsToSelect, Color.green); } public override IEnumerable GetGizmos() From d957250252df54ac52a0057e5facdf76b45bc19c Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Sun, 25 Feb 2024 07:44:17 +0100 Subject: [PATCH 5/6] #594 now saving the Belt setting --- Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs index 690aff5a..a645f965 100644 --- a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs +++ b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs @@ -193,6 +193,7 @@ public override void ExposeData() Scribe_Values.Look(ref this.allowStockpilePickup, "allowStockpilePickup", false); Scribe_Values.Look(ref this.allowStoragePickup, "allowStoragePickup", false); Scribe_Values.Look(ref this.allowForbiddenPickup, "allowForbiddenPickup", false); + Scribe_Values.Look(ref this.allowBeltPickup, "allowBeltPickup", false); } public override string GetInspectString() From 3b543d18953fedbec4b89370cd30ac4ee4e2e7fb Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Sun, 25 Feb 2024 08:07:10 +0100 Subject: [PATCH 6/6] #594 removed duplicate code --- .../SAL3/Things/Building_SmartHopper.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs index a645f965..c9d2a3f4 100644 --- a/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs +++ b/Source/ProjectRimFactory/SAL3/Things/Building_SmartHopper.cs @@ -89,15 +89,9 @@ public IEnumerable ThingsToSelect foreach (Thing t in GatherThingsUtility.AllThingsInCellForUse(c, Map,AllowStockpilePickup)) { var SlotGroupParrent = t.GetSlotGroup()?.parent; - if ((allowGroundPickup && SlotGroupParrent == null && t.ParentHolder is not Building) || - (allowStockpilePickup && SlotGroupParrent is Zone_Stockpile) || - (allowStoragePickup && SlotGroupParrent is Building_Storage) || - (allowBeltPickup && t.ParentHolder is Building_BeltConveyor)) + if (allowForbiddenPickup || !t.IsForbidden(Faction.OfPlayer)) { - if ((allowForbiddenPickup || !t.IsForbidden(Faction.OfPlayer))) - { - yield return t; - } + yield return t; } } }