How are we dealing with hoppers when they are placed between 2 buildings that can use their inv?
Am i right in thinking currently if building 1 grabs the item from the hopper while building 2 has finished its check to see if theres an item there but hasnt grabbed it yet, itll barf.
Consider this:
If 2 buildings were running that in their class and in tick were doing:
Thats gonna barf right? so can we tell buildings to reserve items in hoppers even if its only for a few ticks?
Am i right in thinking currently if building 1 grabs the item from the hopper while building 2 has finished its check to see if theres an item there but hasnt grabbed it yet, itll barf.
Consider this:
Code Select
private Thing StuffInHopper
{
get
{
ThingDef thingDef = ThingDef.Named("Hopper");
Thing result;
foreach (IntVec3 current in GenAdj.AdjacentSquaresCardinal(this))
{
Thing thing = null;
Thing thing2 = null;
foreach (Thing current2 in Find.ThingGrid.ThingsAt(current))
{
if (current2.def == ThingDef.Named("Stuff"))
{
thing = current2;
}
if (current2.def == thingDef)
{
thing2 = current2;
}
}
if (thing != null && thing2 != null)
{
result = thing;
return result;
}
}
result = null;
return result;
}
}
If 2 buildings were running that in their class and in tick were doing:
Code Select
do
{
int num3 = Mathf.Min(StuffInHopper.stackCount, num);
num2 += num3;
list.Add(StuffInHopper.def);
StuffInHopper.SplitOff(num3);
if (num2 >= num)
{
break;
}
StuffInHopper= this.StuffInHopper;
}
while (StuffInHopper!= null);
Thats gonna barf right? so can we tell buildings to reserve items in hoppers even if its only for a few ticks?