Skip to content

Custom Databoxes API

Metious edited this page Jan 18, 2021 · 1 revision

for creating Custom Databoxes from a C# mod.

Setting up your project

you will need to add a reference to CustomDataboxes.dll. once that's done, everything you will need from CustomDataboxes will be in the CustomDataboxes.API namespace. just add this line among your using statements.

using CustomDataboxes.API;

CustomDataboxes Properties

after adding the CustomDataboxes.API among your using statements, there are couple Properties you need to setup so it can work properly.

Properties to set Type - Description
DataboxID string Required The ID for the databox that SMLHelper can assign it as a TechType.
PrimaryDescription string Required The big Description that appears in the Databox when you hover on it.
SecondaryDescription string Optional The smaller Description that appears below the PrimaryDescription.
TechTypeToUnlock TechType Required the TechType you assign to get unlocked upon Acquiring the Data.
BiomeToSpawnIn LootDistribution.BiomeData Optional the Biomes you want your Databox to spawn in.

after that, you can call the Patch() method and CustomDataboxes should take care of everything else.

Patching your Databox

  1. Instantiate a new instance of Databox
  2. Populate all required properties (and any optional properies)
  3. Invoke the Patch() method on the instance and that's it, you are good to go.

Example:

#if EXAMPLE
namespace ExampleDatabox
{
    using CustomDataboxes.API;
    using QModManager.API.ModLoading;
    [QModCore]
    public static class ExampleDataboxMod
    {
        [QModPatch]
        public static void MainPatch()
        {
            Databox myDatabox = new Databox()
            {
                DataboxID = "StasisRifleDatabox",
                PrimaryDescription = "StasisRifle Databox",
                SecondaryDescription = "Stasis Rifle Databox",
                BiomesToSpawnIn = new List<LootDistributionData.BiomeData>
                {
                    new LootDistributionData.BiomeData()
                    {
                        biome = BiomeType.GrassyPlateaus_Grass,
                        count = 1,
                        probability = 0.1f
                    },
                    new LootDistributionData.BiomeData()
                    {
                        biome = BiomeType.GrassyPlateaus_TechSite,
                        count = 1,
                        probability = 0.5f
                    },
                    new LootDistributionData.BiomeData()
                    {
                        biome = BiomeType.GrassyPlateaus_TechSite_Scattered,
                        count = 1,
                        probability = 0.1f
                    }
                },
                TechTypeToUnlock = TechType.StasisRifle
            };
            myDatabox.Patch(); // Once patched, you're good to go.
        }
    }
}
#endif
Clone this wiki locally