Skip to content

Game.Prefabs.AnimationLayerMask

Assembly:
Assembly-CSharp

Namespace:
Game.Prefabs

Type:
struct

Base:
System.ValueType

Summary:
A lightweight bitmask wrapper used to represent one or more animation layers as a 32-bit mask. The struct stores the mask in a single private field (uint m_Mask) and provides a constructor to create a mask from a single AnimationLayer value. The constructor treats AnimationLayer.None specially (resulting mask = 0); for other layers it sets the corresponding bit using (1 << (layer - 1)). This implies the AnimationLayer enum is expected to have None = 0 and numbered layers starting at 1. The mask can represent up to 32 layers (uint).


Fields

  • public uint m_Mask
    Stores the bitmask representing animation layers. Each bit corresponds to an animation layer; the constructor sets bit (layer - 1) for a given non-None AnimationLayer. When the layer is AnimationLayer.None, m_Mask is set to 0. Because this is a uint, the mask can represent up to 32 distinct layers.

Properties

  • (none)
    This struct exposes no properties; the mask is stored directly in the public field m_Mask.

Constructors

  • public AnimationLayerMask(AnimationLayer layer)
    Creates an AnimationLayerMask for a single layer:
  • If layer == AnimationLayer.None, m_Mask is set to 0.
  • Otherwise, m_Mask is set to (uint)(1 << (int)(layer - 1)), setting the bit corresponding to that layer. Notes:
  • Assumes AnimationLayer.None == 0 and other AnimationLayer values start from 1.
  • Be aware of shift semantics: shifting by a value >= 32 is undefined for a 32-bit integer and will not produce valid results; do not pass layer values that would make (layer - 1) >= 32.

Methods

  • (none)

Usage Example

// Assume AnimationLayer enum:
// enum AnimationLayer { None = 0, Layer1 = 1, Layer2 = 2, Layer3 = 3, ... }

AnimationLayerMask noneMask = new AnimationLayerMask(AnimationLayer.None);
// noneMask.m_Mask == 0

AnimationLayerMask layer1Mask = new AnimationLayerMask(AnimationLayer.Layer1);
// layer1Mask.m_Mask == 1u      // 1 << 0

AnimationLayerMask layer2Mask = new AnimationLayerMask(AnimationLayer.Layer2);
// layer2Mask.m_Mask == 2u      // 1 << 1

// Combining masks manually:
uint combined = layer1Mask.m_Mask | layer2Mask.m_Mask;
// combined == 3 (bits 0 and 1 set)

{{ Additional notes: - This struct is intended as a minimal representation; it does not provide helper methods for combining, testing, or clearing bits. You may extend it in your mod to add convenient methods (HasLayer, AddLayer, RemoveLayer, etc.). - Validate AnimationLayer values before constructing masks if layer values may be out of expected range. }}