Modular Hediffs - SmArtKar/AthenaFramework GitHub Wiki

HediffCompProperties_Modular allows to create "modular" hediffs that can have certain modules installed into them.

    public class HediffCompProperties_Modular : HediffCompProperties
    {
        // List of open slots
        public List<ModuleSlotPackage> slots = new List<ModuleSlotPackage>();
    }

In order to make a certain thing into an implant module it needs two comps: CompUsable_HediffModule would allow the part to be installed

  <li Class="CompProperties_Usable">
    <compClass>AthenaFramework.CompUsable_HediffModule</compClass>
    <useJob>Athena_InstallModule</useJob>
  </li>

While CompProperties_UseEffectHediffModule contains module info

    public class CompProperties_UseEffectHediffModule : CompProperties_Usable
    {
        // List of slot IDs that this module can be installed into
        public List<string> slotIDs;
        // Amount of slot capacity that this module takes
        public float requiredCapacity = 0;
        // List of IDs that this module is incompatible with
        public List<string> excludeIDs;
        // If this module can be ejected
        public bool ejectable = true;
        // Sound that is played when the module is installed
        public SoundDef installSound;
        // Sound that is played when the module is ejected
        public SoundDef ejectSound;
        // List of stage modifiers. Has to either be null, empty, a single element or equal to the parent hediff's amount of stages
        public List<StageOverlay> stageOverlays;
        // List of comps that are applied when this module is attached
        public List<HediffCompProperties> comps;
        // List of hediffs that are applied to the parent part when this module is attached
        public List<HediffDef> hediffs;
        // List of additional graphics that are applied if the parent pawn has an IRenderable that accepts hediff graphic packages linked to it
        public List<HediffGraphicPackage> additionalGraphics;
    }

Installed modules apply their comps to their hediff and can modify stages in order to apply effects. Amount of stages has to either be equal or more than the amount of stages that the hediff contains (1 for cases when the hediff has no stages). Slots can have capacity, limiting the amount of modules that can be installed in them.

    public class ModuleSlotPackage
    {
        public string slotID;
        public string slotName = "Undefined";
        // -1 means unlimited capacity
        public float capacity = -1f;
    }

StageOverlay contain all the fields that a normal stage has and modify the original values by either replacing them(for true/false, string and def valeus) or modify(for factors/offsets)

Modular hediffs require their hediffClass to be set to one of the following values:

public class Hediff_Modular : HediffWithComps { }

public class Hediff_ModularAddedPart : Hediff_AddedPart { }

public class Hediff_ModularImplant : Hediff_Implant { }
⚠️ **GitHub.com Fallback** ⚠️