Skip to content

Commit

Permalink
#612 added support for local Trading
Browse files Browse the repository at this point in the history
fixed issue with exposing ThingOwner
  • Loading branch information
Sn1p3rr3c0n committed Sep 13, 2022
1 parent a3c4090 commit 2e0e230
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using ProjectRimFactory.Storage;
using RimWorld;
using Verse;

namespace ProjectRimFactory.Common.HarmonyPatches
{
[HarmonyPatch(typeof(Pawn_TraderTracker), "ColonyThingsWillingToBuy")]
class Patch_Pawn_TraderTracker_ColonyThingsWillingToBuy
{
static void Postfix(Pawn playerNegotiator, ref IEnumerable<Thing> __result)
{
var map = playerNegotiator.Map;
if (map is null) return;

HashSet<Thing> yieldedThings = new HashSet<Thing>();
yieldedThings.AddRange<Thing>(__result);
foreach (ILinkableStorageParent dsu in TradePatchHelper.AllPowered(map))
{
//Only for Cold Storage
if (dsu.AdvancedIOAllowed) continue;

yieldedThings.AddRange<Thing>(dsu.StoredItems);
}
__result = yieldedThings;

}

}
}
2 changes: 1 addition & 1 deletion Source/ProjectRimFactory/Storage/Building_ColdStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public override void ExposeData()
{
base.ExposeData();
Scribe_Collections.Look(ref ports, "ports", LookMode.Reference);
Scribe_Deep.Look(ref this.thingOwner, "thingowner");
Scribe_Deep.Look(ref this.thingOwner, "thingowner",this);
Scribe_Values.Look(ref uniqueName, "uniqueName");
Scribe_Deep.Look(ref settings, "settings", this);
ModExtension_Crate ??= def.GetModExtension<DefModExtension_Crate>();
Expand Down

0 comments on commit 2e0e230

Please sign in to comment.