Jump to content

[Modding] MinionConfig class static initializers reference the Db


Peter Han
  • Branch: Preview Branch Version: Windows Fixed

The changes to the MinionConfig and BaseMinionConfig class contain static initializers that reference the Db:

public static string[] ATTRIBUTES = BaseMinionConfig.BaseMinionAttributes().Append(new string[]
{
    Db.Get().Attributes.FoodExpectation.Id,
    Db.Get().Attributes.ToiletEfficiency.Id
});

public static string[] AMOUNTS = BaseMinionConfig.BaseMinionAmounts().Append(new string[]
{
    Db.Get().Amounts.Bladder.Id,
    Db.Get().Amounts.Stamina.Id,
    Db.Get().Amounts.Calories.Id
});

public static AttributeModifier[] TRAITS = BaseMinionConfig.BaseMinionTraits(MinionConfig.MODEL).Append(new AttributeModifier[]
{
    new AttributeModifier(Db.Get().Attributes.FoodExpectation.Id, DUPLICANTSTATS.GetStatsFor(MinionConfig.MODEL).BaseStats.FOOD_QUALITY_EXPECTATION, MinionConfig.NAME, false, false, true),
    new AttributeModifier(Db.Get().Amounts.Calories.maxAttribute.Id, DUPLICANTSTATS.GetStatsFor(MinionConfig.MODEL).BaseStats.MAX_CALORIES, MinionConfig.NAME, false, false, true),
    new AttributeModifier(Db.Get().Amounts.Calories.deltaAttribute.Id, DUPLICANTSTATS.GetStatsFor(MinionConfig.MODEL).BaseStats.CALORIES_BURNED_PER_SECOND, MinionConfig.NAME, false, false, true),
    new AttributeModifier(Db.Get().Amounts.Stamina.deltaAttribute.Id, DUPLICANTSTATS.GetStatsFor(MinionConfig.MODEL).BaseStats.STAMINA_USED_PER_SECOND, MinionConfig.NAME, false, false, true),
    new AttributeModifier(Db.Get().Amounts.Bladder.deltaAttribute.Id, DUPLICANTSTATS.GetStatsFor(MinionConfig.MODEL).BaseStats.BLADDER_INCREASE_PER_SECOND, MinionConfig.NAME, false, false, true),
    new AttributeModifier(Db.Get().Attributes.ToiletEfficiency.Id, DUPLICANTSTATS.GetStatsFor(MinionConfig.MODEL).BaseStats.TOILET_EFFICIENCY, MinionConfig.NAME, false, false, true)
});

Any attempts to use these classes from a mod will thus crash, as all mod classes are indiscriminately loaded before the Db is initialized. MinionConfig is a popular entry point for many mods, and none of these mods will be possible without removing these references. Can this code be refactored to initialize these arrays later, only after the Db is initialized?


Steps to Reproduce
  1. Make any mod that tries to use MinionConfig
  2. Mod will fail to load with

image.png.59472468c3e1f055bacfa198534915cc.png

  • Sad Dupe 2



User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.

this breaks patching ALL methods that contain any reference to the BaseMinionConfig class or one of its child classes somewhere in their code

Edited by SGT_Imalas
  • Haha 1

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...