Game.ObjectGeometryPrefab
Assembly: Game
Namespace: Game.Prefabs
Type: abstract class
Base: ObjectPrefab
Summary:
ObjectGeometryPrefab is an abstract prefab base class used to describe the renderable geometry of an object in the game. It holds references to one or more ObjectMeshInfo entries that describe meshes (RenderPrefabs) that make up the object. During prefab processing it contributes dependencies and populates required ECS component lists and archetype component sets depending on the properties present on the referenced mesh prefabs (e.g., color, stack, animation, procedural bone-driven animation, emissive/light, characters/groups). It also exposes a boolean m_Circular flag used to indicate circular geometry behavior (usage depends on rendering / placement systems).
Fields
public ObjectMeshInfo[] m_Meshes
Array of mesh infos describing the visual meshes for this object. Each ObjectMeshInfo references a RenderPrefabBase (m_Mesh). The class inspects these mesh prefabs to:- Add mesh prefabs to the prefab dependency list (GetDependencies),
- Detect which runtime components are required (color, stack, animation, skeleton, emissive, character groups, etc.),
-
Decide which archetype components must be present on spawned entities.
-
public bool m_Circular
A flag indicating whether this object's geometry should be considered circular. This is a simple data flag stored on the prefab and can affect placement/visual logic elsewhere in the engine. The prefab itself does not use m_Circular internally beyond storing it — other systems reading the prefab may query it.
Properties
- This type does not declare any public properties.
Constructors
public ObjectGeometryPrefab()
Default constructor (inherited implicit behavior). Prefab initialization is usually performed by the prefab loading system; derived classes or data-driven loaders populate m_Meshes and m_Circular from prefab data.
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds dependencies for all meshes referenced by m_Meshes into the provided prefabs list. Calls base.GetDependencies(prefabs) first. This ensures that referenced RenderPrefabBase instances are loaded/ordered as needed by the prefab system. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds component "requirements" inferred from the meshes to the provided components set. Always adds ObjectGeometryData and SubMesh. Then scans m_Meshes and: - If any mesh has StackProperties, adds StackData.
-
If any mesh is a CharacterGroup, adds SubMeshGroup and CharacterElement. This list expresses which runtime data components are necessary on entities instantiated from the prefab (prefab-level component requirements).
-
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds archetype ECS components required by this prefab to the provided set. Always adds ObjectGeometry, CullingInfo, MeshBatch, and PseudoRandomSeed. Then inspects the meshes to detect and add optional components: - If any mesh has ColorProperties or is a character group, adds MeshColor.
- If any mesh has StackProperties, adds Stack.
- If any mesh has AnimationProperties, adds Animated.
- If any mesh has ProceduralAnimationProperties, adds Skeleton, Bone, and BoneHistory; additionally, if any procedural bone uses certain BoneType values (see list below), adds Momentum.
- The bone types that trigger Momentum are:
- LookAtDirection
- WindTurbineRotation
- WindSpeedRotation
- PoweredRotation
- TrafficBarrierDirection
- LookAtRotation
- LookAtAim
- LengthwiseLookAtRotation
- WorkingRotation
- OperatingRotation
- LookAtMovementX
- LookAtMovementY
- LookAtMovementZ
- LookAtRotationSide
- LookAtAimForward
- If any mesh has EmissiveProperties, adds Emissive and LightState.
- If any mesh is a CharacterGroup, adds MeshGroup and Animated. This method determines the concrete ECS components that will be included in the archetype used to instantiate object entities.
Usage Example
// Simple derived prefab that assigns meshes and marks circular.
// In real mods these fields are typically filled by prefab loading from asset files.
public class MyCustomObjectPrefab : ObjectGeometryPrefab
{
public MyCustomObjectPrefab()
{
// Example: populate m_Meshes with one or more ObjectMeshInfo entries.
// ObjectMeshInfo is typically a small data-holder that references a RenderPrefabBase (m_Mesh).
m_Meshes = new ObjectMeshInfo[]
{
new ObjectMeshInfo { m_Mesh = /* reference to a RenderPrefabBase instance */ null },
};
// Mark the object as circular if required by your placement/rendering logic.
m_Circular = true;
}
// Optionally override other prefab lifecycle methods if needed.
}
Notes for modders: - The prefab scanning logic is defensive: it skips null mesh references and only adds components when needed. - Many mesh capabilities are determined by the components attached to the referenced RenderPrefabBase (e.g., ColorProperties, StackProperties, AnimationProperties, ProceduralAnimationProperties, EmissiveProperties). - If you add procedural bones to meshes, review BoneType usage — some bone types imply momentum/physics support and will cause Momentum to be added to the archetype automatically.