Multi Layered Apparel Graphics - SmArtKar/AthenaFramework GitHub Wiki
By adding CompProperties_AdditionalApparelGraphics
to your apparel, you can make it display additional textures when worn.
public class CompProperties_AdditionalApparelGraphics : CompProperties
{
// Displayed graphic. This graphic is drawn above the pawn at MoteOverhead altitude layer by default
public GraphicData graphicData;
// Altitude for graphic rendering
public AltitudeLayer altitude = AltitudeLayer.MoteOverhead;
// Mote attached to the equipment piece
public ThingDef attachedMoteDef;
// Effecter attached to the equipment piece
public EffecterDef attachedEffecterDef;
// Offset of the attached mote
public Vector3 attachedMoteOffset = new Vector3();
// Scale of the attached mote
public float attachedMoteScale = 1f;
// If graphics should only be rendered when the pawn is drafted
public bool onlyRenderWhenDrafted = false;
// Additional graphic layers with precise controls
public List<ApparelGraphicPackage> additionalGraphics;
// If any packages use primary/secondary color picker fields, these fields determine apparel's initial primary/secondary colors
public ColorPackageGenerator primaryGenerator = ColorPackageGenerator.Default;
public ColorPackageGenerator secondaryGenerator = ColorPackageGenerator.Default;
// Default colors in case generator(s) is set to none
public Color defaultPrimary = Color.white;
public Color defaultSecondary = Color.white;
}
You can precisely control each layer via ApparelGraphicPackage
objects. These layers can be used with normal, transparent or masked graphic classes and shaders. You can also dynamically change the texture's color(in case of graphics without masks) or mask colors by using firstMask
and secondMask
. These can be set to any value of ApparelPackageColor
in order to dynamically change graphics' colors based on the apparel and it's wearer.
// Graphic data for this package.
public GraphicData graphicData;
// List of offsets. Specific for every direction if 4 are specified, else applies to all directions
// Y dimension determines layer offset, use negative values to render the texture below the pawn
public List<Vector3> offsets;
// Coloring for the first and second masks respectively
// In case chosen shader does not support masks, first mask acts as color
public ApparelPackageColor firstMask = ApparelPackageColor.None;
public ApparelPackageColor secondMask = ApparelPackageColor.None;
// Gradient points. Requires firstMask to be set to either SeverityGradient or HealthGradient
public List<GradientPoint> gradient;
// Determines the amount of graphics generated for the gradient. Higher numbers increase RAM usage but provide a smoother transition.
public int gradientVariants = 10;
// If this graphic should be rendered only when the pawn is drafted. Overrides the props field
public bool onlyRenderWhenDrafted = false;
// If this graphic adds owner's bodytype (if such exists) to its path, similarly to apparel
public bool useBodytype = false;
}
public enum ApparelPackageColor
{
None,
ApparelColor, //Apparel's material color
FactionColor,
IdeoColor,
FavoriteColor,
PrimaryColor,
ParentColor,
SecondaryColor,
HealthGradient,
ParentGradient,
}
If at least one package uses PrimaryColor
or SecondaryColor
, the apparel will also have a gizmo that allows the player to choose the desired colors. Use SecondaryColor
only when PrimaryColor
is already in use.
ParentColor
and ParentGradient
only work when the package is used on certain comps (currently only used on advanced equipment shields)
If any packages use primary or secondary colors, primaryGenerator
and secondaryGenerator
can be set to any number of flags from ColorPackageGenerator
(example: <primaryGenerator>Favorite, Faction, Default</primaryGenerator>
) to control which colors are picked when apparel initially spawns.
public enum ColorPackageGenerator
{
// If multiple flags are selected at the same time, pawn generation flags take priority over others
Default = 1, // Default to pre-selected color
Faction = 2, // If generated on a pawn, use their faction color. Also uses faction color if apparel itself is assigned a faction
Ideology = 4, // If generated on a pawn, use their ideology color
Favorite = 8, // If generated on a pawn, default to their favorite color
Random = 16, // Default to a random color
White = 32, // Defaults to white
}