Game.Prefabs.StackProperties
Assembly:
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
StackProperties is a Unity/Colossal framework component used to configure how prefabs should be "stacked" when multiple instances are placed together (for example props or decorative elements that should align along a direction). It exposes configuration fields for stack direction and ordering, control over start/end overlap between stacked instances, and a flag to forbid scaling. The class is annotated with a ComponentMenu attribute so it can be added from the editor under the Rendering menu (for RenderPrefab). The class overrides conversion helper methods GetArchetypeComponents and GetPrefabComponents but in this version they have no implementation — they exist so conversion code can add appropriate ECS components when converting the prefab to entities.
Fields
-
public StackDirection m_Direction
Controls the stacking direction for the prefab instances. Default (in code) is StackDirection.Up. StackDirection is an enum (not defined here) that typically indicates directions such as Up/Down/Left/Right or similar used by the game to orient stacked items. -
public StackOrder m_Order
Controls ordering of stacked elements. Default is StackOrder.Middle. StackOrder is an enum (not defined here) indicating ordering preference (e.g., Front/Back/Middle or similar). -
public float m_StartOverlap
A float value specifying how much overlap should be applied at the start of the stack (units are game units). Used to tune spacing/overlap between the first elements. -
public float m_EndOverlap
A float value specifying overlap at the end of the stack. Used to tune spacing at the end of a stacked sequence. -
public bool m_ForbidScaling
When true, scaling of stacked instances is disallowed. When false, scaling may be permitted (implementation-dependent).
Properties
- None declared in this class.
Constructors
public StackProperties()
Default parameterless constructor (implicitly provided). The class initializes m_Direction and m_Order to default enum values in-field.
Methods
-
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Intended to add required ECS component types to the provided HashSet for the entity archetype. In this implementation the method body is empty. Modders converting this prefab to an ECS entity should add the necessary ComponentType entries here so the entity archetype contains data needed for stacking behavior. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Intended to add required ECS component types to the provided HashSet for the prefab conversion process. Also empty in the provided code. Implement or extend this to ensure prefab->entity conversion adds the appropriate components for runtime stacking.
Usage Example
// Add StackProperties to a GameObject (e.g., in editor script or initialization)
var sp = gameObject.AddComponent<Game.Prefabs.StackProperties>();
sp.m_Direction = StackDirection.Up;
sp.m_Order = StackOrder.Middle;
sp.m_StartOverlap = 0.25f;
sp.m_EndOverlap = 0.25f;
sp.m_ForbidScaling = true;
// If you are converting prefabs to entities, implement the conversion by adding
// appropriate ComponentType entries in GetPrefabComponents/GetArchetypeComponents.
// Example pattern (pseudo-code):
public override void GetPrefabComponents(HashSet<ComponentType> components)
{
// components.Add(ComponentType.ReadWrite<YourStackDataComponent>());
// components.Add(ComponentType.ReadOnly<SomeOtherComponent>());
}
Notes for modders: - The class references StackDirection and StackOrder enums which are part of the game's codebase — check their definitions to see available values and semantics. - GetArchetypeComponents and GetPrefabComponents are the correct extension points to declare ECS components required by your stacking logic. Leaving them empty will not add any ECS data automatically — add ComponentType entries corresponding to your runtime data components so entity conversion produces entities with the expected components.