Skip to content

Commit

Permalink
#612 Updated to Tick contents
Browse files Browse the repository at this point in the history
resolved some doulble call issues
slightly improved the stacking
  • Loading branch information
Sn1p3rr3c0n committed Sep 1, 2022
1 parent 24b3597 commit c859320
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
14 changes: 8 additions & 6 deletions Source/ProjectRimFactory/Storage/Building_ColdStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public abstract class Building_ColdStorage : Building, IRenameBuilding, IHaulDes
{
private static readonly Texture2D RenameTex = ContentFinder<Texture2D>.Get("UI/Buttons/Rename");

private ThingOwner<Thing> thingOwner = new ThingOwner<Thing>();
protected ThingOwner<Thing> thingOwner = new ThingOwner<Thing>();

private List<Thing> items => thingOwner.InnerListForReading;

Expand Down Expand Up @@ -147,17 +147,19 @@ public virtual string GetITabString(int itemsSelected)

public virtual void RegisterNewItem(Thing newItem)
{

Log.Message($"RegisterNewItem: {newItem}");
if (items.Contains(newItem))
{
Log.Message($"dup: {newItem}");
return;
}
for (var i = 0; i < items.Count; i++)

var items_arr = items.ToArray();
for (var i = 0; i < items_arr.Length; i++)
{
var item = items[i];
if (item.def.category == ThingCategory.Item && item.CanStackWith(newItem))
var item = items_arr[i];
//CanStackWith is already called by TryAbsorbStack...
//Is the Item Check really needed?
if (item.def.category == ThingCategory.Item)
item.TryAbsorbStack(newItem, true);
if (newItem.Destroyed) break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public override void Tick()
{
UpdatePowerConsumption();
}
thingOwner.ThingOwnerTick();
}

public override void PostMapInit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,19 +460,11 @@ public override StorageIOMode IOMode
public override void Notify_ReceivedThing(Thing newItem)
{
base.Notify_ReceivedThing(newItem);
if (mode == StorageIOMode.Input)
{
RefreshInput();
}
}

public override void Notify_LostThing(Thing newItem)
{
base.Notify_LostThing(newItem);
if (mode == StorageIOMode.Output)
{
RefreshOutput();
}
}

public override void RefreshInput()
Expand Down

0 comments on commit c859320

Please sign in to comment.