Skip to content

Commit

Permalink
Merge pull request #798 from zymex22/issue792
Browse files Browse the repository at this point in the history
Resolved Issue where Pullers can't pull from entrances and exits for UG Belts
  • Loading branch information
Sn1p3rr3c0n authored Jul 14, 2024
2 parents 669ba28 + d48f7c7 commit ea3d2bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected override TargetInfo ProgressBarTarget()
protected virtual Thing TargetThing()
{
Thing target = null;
var allThings = (this.Position + this.Rotation.Opposite.FacingCell).AllThingsInCellForUse(this.Map).ToArray();
var allThings = (this.Position + this.Rotation.Opposite.FacingCell).AllThingsInCellForUse(this.Map,true,true).ToArray();

var AllReserved = this.Map.reservationManager.AllReservedThings().ToHashSet();

Expand Down
21 changes: 15 additions & 6 deletions Source/ProjectRimFactory/Common/GatherThingsUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public static IEnumerable<IntVec3> InputCells(this Building building)
/// <returns>The items in cell <paramref name="c"/> for use.</returns>
/// <param name="c">Cell</param>
/// <param name="map">Map</param>
public static IEnumerable<Thing> AllThingsInCellForUse(this IntVec3 c, Map map, bool allowStorageZones = true)
public static IEnumerable<Thing> AllThingsInCellForUse(this IntVec3 c, Map map, bool allowStorageZones = true,
bool allowUGEntranceConnector = false, bool allowUGBelts = false)
{

if (!c.InBounds(map)) yield break;
Expand All @@ -41,12 +42,20 @@ public static IEnumerable<Thing> AllThingsInCellForUse(this IntVec3 c, Map map,
{
if (holder.GetDirectlyHeldThings() is ThingOwner<Thing> owner)
{
switch (t)
if (t is Building_BeltConveyor belt && belt.IsUnderground && !allowUGBelts)
{
// If the belt is underground or it's a connector to send items underground, skip it.
case Building_BeltConveyor belt when belt.IsUnderground:
case Building_BeltConveyorUGConnector _:
continue;
// It the target is an Underground Belt & wen don't Explicitly allow that then don't place anything
continue;
} else if (t is Building_BeltConveyorUGConnector connector)
{
if (connector.ToUnderground)
{
if (!allowUGEntranceConnector) {
continue; // Don't allow Entrance unless specifically allowed
}
}
// Exits should always be allowed

}

for (int j = owner.InnerListForReading.Count - 1; j >= 0; j--)
Expand Down

0 comments on commit ea3d2bb

Please sign in to comment.