I am making a Mindustry-type prototype. Some block (reminiscent of miners) can output useful resource (with the IOutput
interface), some block (reminiscent of containers) can enter these useful resource (with IInput
) and a few can do each.
All of them may have the IStorage
interface (for storage) with AddToStorage
and RemoveFromStorage
strategies.
namespace Conveyor
{
[System.Serializable]
public class bulkItem
{
public int itemCount;
public int id;
public bulkItem(int iC, int i)
{
itemCount = iC; id = i;
}
}
interface IBlockStorage
{
public int maxCapacity {get;}
public Record<bulkItem> gadgets {get; set;}
public void InitializeStorage();
public void AddToStorage(bulkItem merchandise);
public void RemoveFromStorage(bulkItem merchandise);
}
}
The problem is, the place ought to the script for transportation (for instance, transporting constructing materials) be connected?
Ought to the output blocks actively searches for enter blocks, then use RemoveFromStorage
on itself, and AddToStorage
on the enter blocks it discovered? Or vice-versa?
Or ought to there be an common InputOutputManager
script someplace and remotely use AddToStorage
and RemoveFromStorage
to these enter/output blocks?
What can be essentially the most code-efficient methodology of doing this?