From 3bf86cf060fca2db14ed7659ab771d7ae662cee3 Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Fri, 28 Jul 2023 10:40:00 +0200 Subject: [PATCH] #727 combined current status --- Defs/JobDefs/JobDefs_AdvancedPort.xml | 11 + .../Patch_ClosestThing_Global.cs | 479 ++++++++++++++++++ .../Patch_Pawn_JobTracker_StartJob.cs | 50 +- .../Patch_Reachability_CanReach.cs | 15 +- .../JobDriver_GetItemFromAdvancedPort.cs | 49 ++ Source/ProjectRimFactory/Common/PRFDefOf.cs | 3 + .../SAL3/Tools/ReflectionUtility.cs | 3 + .../Storage/Building_StorageUnitIOPort.cs | 1 - 8 files changed, 604 insertions(+), 7 deletions(-) create mode 100644 Defs/JobDefs/JobDefs_AdvancedPort.xml create mode 100644 Source/ProjectRimFactory/Common/HarmonyPatches/Patch_ClosestThing_Global.cs create mode 100644 Source/ProjectRimFactory/Common/JobDriver_GetItemFromAdvancedPort.cs diff --git a/Defs/JobDefs/JobDefs_AdvancedPort.xml b/Defs/JobDefs/JobDefs_AdvancedPort.xml new file mode 100644 index 000000000..c1cdd8655 --- /dev/null +++ b/Defs/JobDefs/JobDefs_AdvancedPort.xml @@ -0,0 +1,11 @@ + + + + PRF_GotoAdvanced + ProjectRimFactory.Common.JobDriver_GetItemFromAdvancedPort + moving. + false + true + false + + \ No newline at end of file diff --git a/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_ClosestThing_Global.cs b/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_ClosestThing_Global.cs new file mode 100644 index 000000000..2281608c9 --- /dev/null +++ b/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_ClosestThing_Global.cs @@ -0,0 +1,479 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Reflection; +using System.Reflection.Emit; +using System.Text; +using System.Threading.Tasks; +using HarmonyLib; +using ProjectRimFactory.Storage; +using RimWorld; +using Verse; + +namespace ProjectRimFactory.Common.HarmonyPatches +{ + [HarmonyPatch] + class Patch_ClosestThing_Global + { + /* + Need to path the internal " void Process(Thing t)" Method to skip the Spawned Check for Items contained in the ASU + That can only be done a Transpiler + + The adding of the Items contained in the ASU can't be done at this point as we might not have access to the current map. + (One could get the map from the spawned Things, but there is the chance that there are no spawned things...) + */ + + //TODO + //Might also need to patch g__Process|6_0 + //Same code should work + public static Type predicateClass; + static MethodBase TargetMethod()//The target method is found using the custom logic defined here + { + predicateClass = typeof(GenClosest); + + var m = predicateClass.GetMethods(AccessTools.all) + .FirstOrDefault(t => t.Name.Contains("g__Process|5_0")); + if (m == null) + { + Log.Error("PRF Harmony Error - m == null for Patch_ClosestThing_Global.TargetMethod()"); + } + return m; + } + + + + static bool Patched = false; + + static IEnumerable Transpiler(IEnumerable instructions) + { + + foreach (var instruction in instructions) + { + if(instruction.opcode == OpCodes.Callvirt && !Patched) + { + Patched = true; + yield return new CodeInstruction(OpCodes.Call, AccessTools.Method( + typeof(Patch_ClosestThing_Global), + nameof(Patch_ClosestThing_Global.SpawnedCheck), new[] { typeof(Thing) })); + continue; + } + + yield return instruction; + + } + + } + + static bool SpawnedCheck(Thing thing) + { + //TODO Might want to add a check if there is a connecting port + if (thing.Spawned) + { + return true; + } + else + { + return thing.ParentHolder is Building_ColdStorage; + } + } + + } + [HarmonyPatch] + class Patch_ClosestThing_Global2 + { + /* + Need to path the internal " void Process(Thing t)" Method to skip the Spawned Check for Items contained in the ASU + That can only be done a Transpiler + + The adding of the Items contained in the ASU can't be done at this point as we might not have access to the current map. + (One could get the map from the spawned Things, but there is the chance that there are no spawned things...) + */ + + public static Type predicateClass; + static MethodBase TargetMethod()//The target method is found using the custom logic defined here + { + predicateClass = typeof(GenClosest); + + var m = predicateClass.GetMethods(AccessTools.all) + .FirstOrDefault(t => t.Name.Contains("g__Process|6_0")); + if (m == null) + { + Log.Error("PRF Harmony Error - m == null for Patch_ClosestThing_Global.TargetMethod()"); + } + return m; + } + + + + static bool Patched = false; + + static IEnumerable Transpiler(IEnumerable instructions) + { + + foreach (var instruction in instructions) + { + if (instruction.opcode == OpCodes.Callvirt && !Patched) + { + Patched = true; + yield return new CodeInstruction(OpCodes.Call, AccessTools.Method( + typeof(Patch_ClosestThing_Global2), + nameof(Patch_ClosestThing_Global2.SpawnedCheck), new[] { typeof(Thing) })); + continue; + } + + yield return instruction; + + } + + } + + static bool SpawnedCheck(Thing thing) + { + //TODO Might want to add a check if there is a connecting port + if (thing.Spawned) + { + return true; + } + else + { + return thing.ParentHolder is Building_ColdStorage; + } + } + + } + + + [HarmonyPatch(typeof(GenClosest), "ClosestThingReachable")] + class Patch_ClosestThingReachable + { + public static void Postfix(Thing __result, ThingRequest thingReq) + { + Log.Message($"ClosestThingReachable returns {__result} for {thingReq} -- region: {thingReq.CanBeFoundInRegion}"); + } + + + static bool Patched = false; + static IEnumerable Transpiler(IEnumerable instructions) + { + foreach (var instruction in instructions) + { + // Log.Message($"{instruction.opcode} - {instruction.operand}"); + if (instruction.opcode == OpCodes.Stloc_S && instruction.operand.ToString() == "System.Collections.Generic.IEnumerable`1[Verse.Thing] (7)" && !Patched) + { + Patched = true; + //Load the Map + yield return new CodeInstruction(OpCodes.Ldarg_1); + yield return new CodeInstruction(OpCodes.Call, AccessTools.Method( + typeof(Patch_ClosestThingReachable), + nameof(Patch_ClosestThingReachable.ThingsWithColdStorage), new[] { typeof(IEnumerable), typeof(Map) })); + + + } + + yield return instruction; + + } + + } + + public static IEnumerable ThingsWithColdStorage(IEnumerable baseList, Map map) + { + List things = baseList.ToList(); + + var mapComp = PatchStorageUtil.GetPRFMapComponent(map); + var storage = mapComp.ColdStorageBuildings; + foreach(var b in storage) + { + things.AddRange((b as Building_ColdStorage).StoredItems); + Log.Message($"added items form {b}"); + } + + return things; + + } + + + } + + + //Works but not enough + [HarmonyPatch(typeof(ItemAvailability), "ThingsAvailableAnywhere")] + class Patch_ItemAvailability_ThingsAvailableAnywhere + { + + public static void Postfix(ref bool __result, ThingDefCountClass need, Pawn pawn, Map ___map) + { + if (__result) return; + + var ColdStorages = PatchStorageUtil.GetPRFMapComponent(___map).ColdStorageBuildings; + foreach(Building_ColdStorage b in ColdStorages) + { + int cnt = need.count; + + var items = b.StoredItems; + for(int i = 0; i < items.Count; i++) + { + var item = items[i]; + + if (item.def == need.thingDef) + { + + cnt -= item.stackCount; + } + if(cnt <= 0) + { + + __result = true; + return; + } + + } + } + } + + + } + + + //Need to Patch RegionwiseBFSWorker + + //Verse.RegionProcessorClosestThingReachable + //override bool RegionProcessor(Region reg) + //Need a Transpiler + /* + List list = reg.ListerThings.ThingsMatching(req); + Add Items Accesible via IO Advanced Ports in that Area + Be aware of duplicates + + Be aware of distance calc + + + + + "//Note that could also enhance the Logic for DSU Access and vs stuff on the floor" + + */ + [HarmonyPatch(typeof(RegionProcessorClosestThingReachable), "RegionProcessor")] + public class Patch_RegionProcessorClosestThingReachable_RegionProcessor + { + + static bool patchedAppend = false; + + + static IEnumerable Transpiler(IEnumerable instructions) + { + bool lastWas_ldloc2 = false; + bool foundThingPos = false; + bool foundThingPosDone = false; + int callCnt = 0; + //req Thing request + //reg region + foreach (var instruction in instructions) + { + + if(!foundThingPosDone && lastWas_ldloc2 && instruction.opcode == OpCodes.Callvirt && instruction.operand.ToString() == "Verse.IntVec3 get_Position()") + { + //Log.Message(); + foundThingPos = true; + } + if(foundThingPos && instruction.opcode != OpCodes.Call) + { + continue; + }else if(foundThingPos) + { + callCnt++; + if(callCnt == 2) + { + yield return new CodeInstruction(OpCodes.Ldarg_0); + yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(RegionProcessorClosestThingReachable), "root")); + yield return new CodeInstruction(OpCodes.Ldarg_1); + yield return new CodeInstruction(OpCodes.Call, AccessTools.Method( + typeof(Patch_RegionProcessorClosestThingReachable_RegionProcessor), + nameof(Patch_RegionProcessorClosestThingReachable_RegionProcessor.CalcDistance), new[] { typeof(Thing), typeof(IntVec3), typeof(Verse.Region) })); + foundThingPosDone = true; + foundThingPos = false; + } + + continue; + } + + + + lastWas_ldloc2 = instruction.opcode == OpCodes.Ldloc_2; + + + if (instruction.opcode == OpCodes.Stloc_0 && !patchedAppend) + { + patchedAppend = true; + yield return new CodeInstruction(OpCodes.Ldarg_1); + yield return new CodeInstruction(OpCodes.Ldarg_0); + yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(RegionProcessorClosestThingReachable),"req")); + yield return new CodeInstruction(OpCodes.Call, AccessTools.Method( + typeof(Patch_RegionProcessorClosestThingReachable_RegionProcessor), + nameof(Patch_RegionProcessorClosestThingReachable_RegionProcessor.AppendIOStuff), new[] { typeof(List), typeof(Verse.Region), typeof(ThingRequest) })); + } + + yield return instruction; + + } + + } + + //maybe use by ref?! + + static List AppendIOStuff(List things, Verse.Region region, ThingRequest req) + { + if(things is null) + { + Log.Warning("things List is Null AppendIOStuff"); + things = new List(); + } + if (region is null) + { + Log.Warning("region is null"); + return things; + } + + + + var AdvancePorts = region.ListerThings.ThingsOfDef(PRFDefOf.PRF_IOPort_II); + if(AdvancePorts is null) + { + Log.Warning("AdvancePorts is null"); + return things; + } + foreach(var thing in AdvancePorts) + { + Storage.Building_AdvancedStorageUnitIOPort port = thing as Storage.Building_AdvancedStorageUnitIOPort; + var Items = port?.boundStorageUnit?.StoredItems; + if (Items == null) continue; + for(int i = 0; i < Items.Count; i++) + { + var item = Items[i]; + if (req.Accepts(item) && !things.Contains(item)) + { + things.Add(item); + } + } + } + return things; + } + + //temp + public static IntVec3 ClosesetPort = new IntVec3(167,0,149); + static float CalcDistance(Thing thing, IntVec3 root, Verse.Region region) + { + + if (thing.ParentHolder is Building_ColdStorage) + { + //Need to fined the closet linked Advance IO Port + //And calc the Position using that + var mapcomp = PatchStorageUtil.GetPRFMapComponent(region.Map); + var Ports = mapcomp.GetadvancedIOLocations; + var port_cnt = Ports.Count(); + float Mindist = float.MaxValue; + for (int i = 0; i< port_cnt; i++) + { + var Port = Ports.ElementAt(i); + if(Port.Value.boundStorageUnit == thing.ParentHolder) { + var dist = (Port.Key - root).LengthHorizontalSquared; + if(dist < Mindist) + { + Mindist = dist; + ClosesetPort = Port.Key; + // Log.Message($"Distance for {Port.Value} is {dist} - getting {thing}"); + } + + + } + } + return Mindist; + + + } + else + { + return (thing.Position - root).LengthHorizontalSquared; + } + } + + + + } + + + [HarmonyPatch(typeof(ReachabilityWithinRegion), "ThingFromRegionListerReachable")] + public class Patch_ReachabilityWithinRegion_ThingFromRegionListerReachable + { + + static IEnumerable Transpiler(IEnumerable instructions) + { + bool done = false; + bool foundThing = false; + + foreach (var instruction in instructions) + { + if(foundThing && !done) + { + yield return new CodeInstruction(OpCodes.Call, AccessTools.Method( + typeof(Patch_ReachabilityWithinRegion_ThingFromRegionListerReachable), + nameof(Patch_ReachabilityWithinRegion_ThingFromRegionListerReachable.GetPosition), new[] { typeof(Thing)})); + done = true; + continue; + } + if(!done && instruction.opcode == OpCodes.Ldarg_0) + { + foundThing = true; + } + + + + yield return instruction; + + } + + } + + + static IntVec3 GetPosition(Thing thing) + { + if (thing.ParentHolder is Building_ColdStorage building_) + { + var pos = Patch_RegionProcessorClosestThingReachable_RegionProcessor.ClosesetPort; + if (!pos.IsValid) + { + Log.Error("PRF GetPosition Post Pos is Invalid"); + pos = building_.Position; + } + + // Log.Message($"PRF GetPosition {pos}"); + return pos; + } + else + { + return thing.Position; + } + } + } + + + + /* + + Katia started 10 jobs in one tick. newJob=HaulToContainer (Job_61312) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429 jobGiver=RimWorld.JobGiver_Work jobList=(Wait_Combat (Job_60887) A=(169, 0, 159)) + (BuildRoof (Job_61106) A=(172, 0, 156) B=(172, 0, 156)) (HaulToContainer (Job_61296) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 + C=Thing_Blueprint_Wall68429) (HaulToContainer (Job_61298) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429) + (HaulToContainer (Job_61300) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429) + (HaulToContainer (Job_61302) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429) + (HaulToContainer (Job_61304) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429) + (HaulToContainer (Job_61306) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429) + (HaulToContainer (Job_61308) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429) + (HaulToContainer (Job_61310) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429) + (HaulToContainer (Job_61312) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429) + + Maybe a job interruption is the issue + + */ +} diff --git a/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_Pawn_JobTracker_StartJob.cs b/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_Pawn_JobTracker_StartJob.cs index 6539907bd..8563a7c16 100644 --- a/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_Pawn_JobTracker_StartJob.cs +++ b/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_Pawn_JobTracker_StartJob.cs @@ -1,6 +1,9 @@ using HarmonyLib; using ProjectRimFactory.Storage; +using RimWorld; using System.Collections.Generic; +using System.ComponentModel; +using UnityEngine; using Verse; using Verse.AI; @@ -55,9 +58,17 @@ private static void GetTargetItems(ref List TargetItems, bool i } + private static bool ShouldGetItem = false; + private static Thing Port = null; + private static LocalTargetInfo _target = null; + public static bool Prefix(Job newJob, ref Pawn ___pawn, JobCondition lastJobEndCondition = JobCondition.None, ThinkNode jobGiver = null, bool resumeCurJobAfterwards = false, bool cancelBusyStances = true , ThinkTreeDef thinkTree = null, JobTag? tag = null, bool fromQueue = false, bool canReturnCurJobToPool = false) { + + // Log.Message($"{newJob} - {jobGiver} - {___pawn}"); + ShouldGetItem = false; + if (newJob.def == PRFDefOf.PRF_GotoAdvanced) return true; //No random moths eating my cloths if (___pawn?.Faction == null || !___pawn.Faction.IsPlayer) return true; var prfmapcomp = PatchStorageUtil.GetPRFMapComponent(___pawn.Map); @@ -95,9 +106,12 @@ public static bool Prefix(Job newJob, ref Pawn ___pawn, JobCondition lastJobEndC { if (AdvancedIO_PatchHelper.CanMoveItem(port.Value, target.Cell)) { - port.Value.AddItemToQueue(target.Thing); - port.Value.updateQueue(); - + // port.Value.AddItemToQueue(target.Thing); + // port.Value.updateQueue(); + _target = target; + Log.Message($"Should have moved {target} x{target.Thing.stackCount} ..."); + ShouldGetItem = true; + Port = port.Value; break; } } @@ -112,5 +126,35 @@ public static bool Prefix(Job newJob, ref Pawn ___pawn, JobCondition lastJobEndC } return true; } + + static bool temp = true; + public static void Postfix(Job newJob, Pawn_JobTracker __instance, ref Pawn ___pawn, JobCondition lastJobEndCondition = JobCondition.None, ThinkNode jobGiver = null, bool resumeCurJobAfterwards = false, bool cancelBusyStances = true + , ThinkTreeDef thinkTree = null, JobTag? tag = null, bool fromQueue = false, bool canReturnCurJobToPool = false) + { + + if (ShouldGetItem && temp) + { + ShouldGetItem = false; + //temp= false; + Log.Message($"Job: {__instance.curJob} Driver: {__instance.curDriver} Targets: {__instance.curJob.targetA}-{__instance.curJob.targetB}-{__instance.curJob.targetC}"); + + + + + __instance.jobQueue.EnqueueFirst(__instance.curJob); + Job job = JobMaker.MakeJob(PRFDefOf.PRF_GotoAdvanced, Port, _target); + job.count = _target.Thing.stackCount; // Mathf.Min(t.stackCount, thingOwner.GetCountCanAccept(t)); + + __instance.StartJob(job); + + + + + + + } + + + } } } diff --git a/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_Reachability_CanReach.cs b/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_Reachability_CanReach.cs index 05f0f800e..2700f379b 100644 --- a/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_Reachability_CanReach.cs +++ b/Source/ProjectRimFactory/Common/HarmonyPatches/Patch_Reachability_CanReach.cs @@ -1,4 +1,6 @@ -using System.Linq; +using ProjectRimFactory.Storage; +using System.Linq; +using System.Security.Cryptography; using Verse; using Verse.AI; @@ -57,9 +59,14 @@ private static bool hasPathToItem(Thing thing, PRFMapComponent mapComp, Reachabi { var ThingPos = thing.Position; + var ParrentHolder = thing.ParentHolder; + + var IsDSU_Link = mapComp.ShouldHideItemsAtPos(ThingPos); + var IsColdLink = ParrentHolder is Building_ColdStorage; + //Quickly Check if the Item is in a Storage Unit //TODO: Rework that -> This includes items in PRF Crates & Excludes items from Cold Storage(Note they currently have bigger issues) - if (!mapComp.ShouldHideItemsAtPos(ThingPos)) return false; + if (! (IsDSU_Link || IsColdLink)) return false; var AdvancedIOLocations = mapComp.GetadvancedIOLocations; var cnt = AdvancedIOLocations.Count; @@ -70,12 +77,14 @@ private static bool hasPathToItem(Thing thing, PRFMapComponent mapComp, Reachabi //Check if that Port has access to the Item //TODO: Rework that -> Is the Use of the Position really best? - if (current.Value.boundStorageUnit?.GetPosition == ThingPos) + var boundStorageUnit = current.Value.boundStorageUnit; + if ( (IsDSU_Link && boundStorageUnit?.GetPosition == ThingPos) || (IsColdLink && ParrentHolder == boundStorageUnit)) { //The Port has access to the Item //Now check if we can reach that Port if (reachability.CanReach(start, current.Key, PathEndMode.Touch, traverseParams)) return true; } + } return false; diff --git a/Source/ProjectRimFactory/Common/JobDriver_GetItemFromAdvancedPort.cs b/Source/ProjectRimFactory/Common/JobDriver_GetItemFromAdvancedPort.cs new file mode 100644 index 000000000..8f88e324a --- /dev/null +++ b/Source/ProjectRimFactory/Common/JobDriver_GetItemFromAdvancedPort.cs @@ -0,0 +1,49 @@ +using RimWorld.Planet; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; +using Verse.AI; +using ProjectRimFactory.Storage; + +namespace ProjectRimFactory.Common +{ + public class JobDriver_GetItemFromAdvancedPort : JobDriver + { + public override bool TryMakePreToilReservations(bool errorOnFailed) + { + return true; + } + + protected override IEnumerable MakeNewToils() + { + LocalTargetInfo lookAtTarget = job.GetTarget(TargetIndex.B); + Toil toil = Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch); + toil.FailOn(() => job.GetTarget(TargetIndex.A).Thing?.Destroyed ?? false); + if (lookAtTarget.IsValid) + { + toil.tickAction = (Action)Delegate.Combine(toil.tickAction, (Action)delegate + { + pawn.rotationTracker.FaceCell(lookAtTarget.Cell); + }); + toil.handlingFacing = true; + } + toil.AddFinishAction(delegate + { + //Give the Items to the Pawn + // pawn.inventory + Log.Message("Made it to the port"); + var port = (Building_AdvancedStorageUnitIOPort)job.GetTarget(TargetIndex.A).Thing; + port.AddItemToQueue(lookAtTarget.Thing); + port.updateQueue(); + + + }); + yield return toil; + //yield return Toils_Haul.StartCarryThing(TargetIndex.B, putRemainderInQueue: false, subtractNumTakenFromJobCount: false); + } + } +} diff --git a/Source/ProjectRimFactory/Common/PRFDefOf.cs b/Source/ProjectRimFactory/Common/PRFDefOf.cs index b627c1ef2..1d6316cf3 100644 --- a/Source/ProjectRimFactory/Common/PRFDefOf.cs +++ b/Source/ProjectRimFactory/Common/PRFDefOf.cs @@ -26,6 +26,8 @@ static PRFDefOf() public static JobDef PRFDrone_ReturnToStation; public static JobDef PRFDrone_SelfTerminate; + public static JobDef PRF_GotoAdvanced; + public static PawnKindDef PRFDroneKind; public static PawnKindDef PRFSlavePawn; @@ -46,6 +48,7 @@ static PRFDefOf() public static ThingDef PRF_DroneModule; public static ThingDef Column; public static ThingDef PRF_MiniDroneColumn; + public static ThingDef PRF_IOPort_II; public static BackstoryDef ChildSpy47; public static BackstoryDef ColonySettler53; diff --git a/Source/ProjectRimFactory/SAL3/Tools/ReflectionUtility.cs b/Source/ProjectRimFactory/SAL3/Tools/ReflectionUtility.cs index 057cc49e8..a8ec1a5e0 100644 --- a/Source/ProjectRimFactory/SAL3/Tools/ReflectionUtility.cs +++ b/Source/ProjectRimFactory/SAL3/Tools/ReflectionUtility.cs @@ -32,5 +32,8 @@ public static class ReflectionUtility //basePowerConsumption public static readonly FieldInfo CompProperties_Power_basePowerConsumption = typeof(CompProperties_Power).GetField("basePowerConsumption", BindingFlags.Instance | BindingFlags.NonPublic); + + //Toils Advanced port + public static readonly FieldInfo JobDriver_toils = typeof(Verse.AI.JobDriver).GetField("toils", BindingFlags.NonPublic | BindingFlags.Instance); } } diff --git a/Source/ProjectRimFactory/Storage/Building_StorageUnitIOPort.cs b/Source/ProjectRimFactory/Storage/Building_StorageUnitIOPort.cs index a53861b74..1e4854e02 100644 --- a/Source/ProjectRimFactory/Storage/Building_StorageUnitIOPort.cs +++ b/Source/ProjectRimFactory/Storage/Building_StorageUnitIOPort.cs @@ -347,7 +347,6 @@ public override IEnumerable GetGizmos() { //ILinkableStorageParent List mylist = Map.listerBuildings.allBuildingsColonist.Where(b => (b as ILinkableStorageParent) != null && (b as ILinkableStorageParent).CanUseIOPort).ToList(); - if (IsAdvancedPort) mylist.RemoveAll(b => !(b as ILinkableStorageParent).AdvancedIOAllowed); List list = new List( mylist.Select(b => new FloatMenuOption(b.LabelCap, () => SelectedPorts().ToList().ForEach(p => p.BoundStorageUnit = (b as ILinkableStorageParent)))) );