Skip to content

Commit

Permalink
#612 added IThingHolder & removed now obsolete Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Sn1p3rr3c0n committed Aug 30, 2022
1 parent f230ea5 commit 794f77c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 119 deletions.

This file was deleted.

25 changes: 17 additions & 8 deletions Source/ProjectRimFactory/Storage/Building_MassStorageUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ public interface ILinkableStorageParent


[StaticConstructorOnStartup]
public abstract class Building_MassStorageUnit : Building, IRenameBuilding, IHaulDestination, IStoreSettingsParent, ILinkableStorageParent
public abstract class Building_MassStorageUnit : Building, IRenameBuilding, IHaulDestination, IStoreSettingsParent, ILinkableStorageParent, IThingHolder
{
private static readonly Texture2D RenameTex = ContentFinder<Texture2D>.Get("UI/Buttons/Rename");

private List<Thing> items = new List<Thing>();
private ThingOwner<Thing> thingOwner = new ThingOwner<Thing>();

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

private List<Building_StorageUnitIOBase> ports = new List<Building_StorageUnitIOBase>();

Expand Down Expand Up @@ -146,7 +148,7 @@ public override void ExposeData()
{
base.ExposeData();
Scribe_Collections.Look(ref ports, "ports", LookMode.Reference);
Scribe_Collections.Look(ref items, "items", LookMode.Deep);
Scribe_Deep.Look(ref this.thingOwner, "thingowner");
Scribe_Values.Look(ref uniqueName, "uniqueName");
Scribe_Deep.Look(ref settings, "settings", this);
ModExtension_Crate ??= def.GetModExtension<DefModExtension_Crate>();
Expand Down Expand Up @@ -289,11 +291,8 @@ public void HandleNewItem(Thing item)

public void HandleMoveItem(Thing item)
{
if (!items.Contains(item))
{
Log.Error($"PRF HandleMoveItem Called for {item} but this {this} does not store that...");
}
else
//With the use of thingOwner this check might be redundent
if (items.Contains(item))
{
items.Remove(item);
}
Expand All @@ -303,5 +302,15 @@ public bool CanReciveThing(Thing item)
{
return settings.AllowedToAccept(item) && CanReceiveIO && CanStoreMoreItems;
}

public void GetChildHolders(List<IThingHolder> outChildren)
{

}

public ThingOwner GetDirectlyHeldThings()
{
return thingOwner;
}
}
}

0 comments on commit 794f77c

Please sign in to comment.