Skip to content

IStorageSlotObject

Kye edited this page Sep 19, 2022 · 1 revision

IStorageSlotObject

The IStorageSlotObject is an Interface implementation. It allows you to make your Storage Objects Storage Slots Overridable to allow either:

  • Other Modders
  • Server Owners

To customize How Many Storage Slots Are in your Object.

The implementation of the IStorageSlotObject can be used on Any Storage Object.

Below is the Implementation of the IStorageSlotObject:


Implementation


The implementation uses a specific data structure and is setup in a specific way for it to be able to work.

Working with the implementation will be confusing to start with as it is not a normal implementation of the Storage Slot setup. (Okay its pretty close)

private static readonly StorageSlotModel SlotDefaults = new(typeof(RandomObject)) 
{ StorageSlots = 10 };

Here is each component broken down and explained:


typeof(Item)

This is The item you are connecting the Resolver too.


StorageSlots

This is The Total Amount of Storage Slots in the Storage Object


Setting It Up


These are the values that are required when using this on the Your Storage Objects.

Anything Marked with an Asterixis (//*) is Required (Attributes Not Included)

    public partial class RandomObject : WorldObject, IRepresentsItem, IStorageSlotObject
    {
        public override LocString DisplayName => Localizer.DoStr("Random Item");
        public override TableTextureMode TableTexture => TableTextureMode.Metal;
        public Type RepresentedItemType => typeof(RandomItem);

        private static readonly StorageSlotModel SlotDefaults = new(typeof(RandomObject)) { StorageSlots = 10 };

        public RandomObject() { }

        static RandomObject()
        {            
            EMLinkRadiusResolver.AddDefaults(LinkDefaults);
            EMStorageSlotResolver.AddDefaults(SlotDefaults);
        }

And thats it! you can now override the storage objects storage slots with other mods and the EM Configure Plugin (Built In)

Clone this wiki locally