Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#310 now highlights output stockpile if it can use it entierly #683

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/ProjectRimFactory/AutoMachineTool/Building_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ protected virtual bool PlaceProduct(ref List<Thing> products)
return !this.products.Any();
}

public virtual IntVec3 OutputCell()
public override IntVec3 OutputCell()
{
return FacingCell(this.Position, this.def.Size, this.Rotation.Opposite);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static Room GetRoomOfPawnOrGiver(Pawn pawn, RegionType allowedRegionTypes
{
if (pawn.kindDef == PRFDefOf.PRFSlavePawn && billGiver is Building_SimpleAssembler assembler)
{
return RegionAndRoomQuery.RoomAt(assembler.OutputComp.CurrentCell, billGiver.Map, RegionType.Set_Passable);
return RegionAndRoomQuery.RoomAt(assembler.OutputCell(), billGiver.Map, RegionType.Set_Passable);
}
return pawn.GetRoom(allowedRegionTypes);
}
Expand Down
24 changes: 23 additions & 1 deletion Source/ProjectRimFactory/Common/PRF_Building.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using Verse;

namespace ProjectRimFactory.Common
{
public abstract class PRF_Building : Building, IPRF_Building
Expand All @@ -21,6 +23,11 @@ public virtual void EffectOnAcceptThing(Thing t) { }

public virtual bool ForbidOnPlacing(Thing t) => ForbidOnPlacingDefault;

public virtual IntVec3 OutputCell()
{
return IntVec3.Invalid;
}

public virtual bool ForbidOnPlacingDefault
{
get => forbidOnPlacingDefault;
Expand Down Expand Up @@ -55,6 +62,21 @@ public override void ExposeData()
Scribe_Values.Look(ref obeysStorageFilters, "PRFObeysStorageFilters", true);
Scribe_Values.Look(ref forbidOnPlacingDefault, "PRFForbidOnPlacingDefault", false);
}

public override void DrawExtraSelectionOverlays()
{
base.DrawExtraSelectionOverlays();

//Try highlight Output Area
if (OutputToEntireStockpile && OutputCell() != IntVec3.Invalid)
{
var slotGroup = OutputCell().GetSlotGroup(this.Map);
if (slotGroup != null)
{
GenDraw.DrawFieldEdges(slotGroup.CellsList, CommonColors.outputZone);
}
}
}
}
[Flags] // PRF Building Settinsg
public enum PRFBSetting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public override IEnumerable<Gizmo> GetGizmos()

private void MakeMatchingStockpileZone()
{
var stockpileCells = IngredientStackCells.Where(c => c != OutputComp.CurrentCell && !this.Map.thingGrid.ThingsListAt(c).Any(t => !t.def.CanOverlapZones));
var stockpileCells = IngredientStackCells.Where(c => c != compOutputAdjustable.CurrentCell && !this.Map.thingGrid.ThingsListAt(c).Any(t => !t.def.CanOverlapZones));
if (stockpileCells.Count() > 0)
{
Designator_ZoneAddStockpile_Resources stockpileZone = new Designator_ZoneAddStockpile_Resources();
Expand All @@ -183,14 +183,7 @@ private void MakeMatchingStockpileZone()
}
}


public CompOutputAdjustable OutputComp
{
get
{
return GetComp<CompOutputAdjustable>();
}
}

protected virtual IEnumerable<FloatMenuOption> GetDebugOptions()
{
string StringConverter(Thing t)
Expand All @@ -215,10 +208,13 @@ string StringConverter(Thing t)
protected MapTickManager MapManager => this.mapManager;

private PRFGameComponent prf_gamecomp = Current.Game.GetComponent<PRFGameComponent>();

private CompOutputAdjustable compOutputAdjustable;

public override void SpawnSetup(Map map, bool respawningAfterLoad)
{
base.SpawnSetup(map, respawningAfterLoad);
compOutputAdjustable = GetComp<CompOutputAdjustable>();
this.mapManager = map.GetComponent<MapTickManager>();
if (buildingPawn == null)
DoPawn();
Expand Down Expand Up @@ -316,7 +312,7 @@ public override void Tick()
{
if (thingQueue.Count > 0 &&
PlaceThingUtility.PRFTryPlaceThing(this, thingQueue[0],
OutputComp.CurrentCell, Map))
compOutputAdjustable.CurrentCell, Map))
{
thingQueue.RemoveAt(0);
}
Expand Down Expand Up @@ -640,6 +636,11 @@ public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
prf_gamecomp.DeRegisterAssemblerQueue(this);
}

public override IntVec3 OutputCell()
{
return compOutputAdjustable.CurrentCell;
}

// (Some) Internal variables:
// Logic
protected BillReport currentBillReport;
Expand Down