Game.Prefabs.TerraformingPrefab
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
A prefab class used by the terraforming tool. Holds authorable settings (terraforming type, target, brush material) and registers/initializes the runtime ECS components required for the tool (TerraformingData and PlaceableInfoviewItem). When the prefab is instantiated into an Entity, it writes the prefab's configured type/target into the entity's TerraformingData component.
Fields
-
public TerraformingType m_Type
Specifies the terraforming operation type for this prefab instance (enum). This value is copied into the TerraformingData component during Initialize. -
public TerraformingTarget m_Target
Specifies what the terraforming operation targets (enum, e.g., terrain, water, etc.). This value is copied into the TerraformingData component during Initialize. -
public Material m_BrushMaterial
Material used to render the terraforming brush/visualization in the editor or in-game preview. This is an authoring-time UnityEngine.Material reference and is not written to the ECS component in the provided code.
Properties
- (None)
Constructors
- (No explicit constructors defined; uses the default parameterless constructor)
Methods
public override void GetPrefabComponents(HashSet<ComponentType> components)
Registers the ECS component types that this prefab will require on created Entities. This override adds:- TerraformingData (read/write)
-
PlaceableInfoviewItem (read/write) It also calls base.GetPrefabComponents(components) to include any components registered by the base PrefabBase.
-
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab is instantiated into an Entity. It: - Calls base.Initialize(entityManager, entity).
- Constructs a default TerraformingData struct, sets its m_Type and m_Target fields from the prefab fields m_Type and m_Target.
- Writes that TerraformingData into the entity via entityManager.SetComponentData.
Usage Example
// The class itself already implements Initialize to copy prefab settings to the entity:
public override void Initialize(EntityManager entityManager, Entity entity)
{
base.Initialize(entityManager, entity);
TerraformingData componentData = default(TerraformingData);
componentData.m_Type = m_Type;
componentData.m_Target = m_Target;
entityManager.SetComponentData(entity, componentData);
}
// Typical usage: author the prefab in the editor with m_Type/m_Target and m_BrushMaterial.
// At runtime, when the prefab is converted/instantiated to an Entity, the TerraformingData
// component will contain the configured m_Type and m_Target for systems to consume.
{{ Notes: - This prefab is part of the Unity ECS conversion workflow: GetPrefabComponents declares the components required on the entity and Initialize populates component data. - TerraformingType and TerraformingTarget are project-specific enums/types; consult their definitions for valid values. - m_BrushMaterial is a UnityEngine.Material used for visualization and is not persisted into the ECS component in this class. - If you need to persist additional prefabricated settings into ECS, extend Initialize to create/set the corresponding component data. }}