Game.Prefabs.DestructionData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType (struct); Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
Describes destruction-related data applied to a prefab in the ECS world. This pure data component is intended for use by systems that spawn or process destruction events (for example: breaking pieces, applying damage to parts of a prefab). It contains the target-selection mode for the destruction effect and a probability that controls how often the destruction occurs.
Fields
-
public EventTargetType m_RandomTargetType
Specifies how the destruction system should choose targets for the destruction event. The exact semantics depend on the EventTargetType enum (e.g., Random, Nearest, All). Used by destruction systems to determine which sub-parts or entities are affected. -
public float m_OccurenceProbability
Chance that the destruction event occurs when evaluated. Expected to be a normalized value (commonly in the 0.0 — 1.0 range). Controls frequency/likelihood of applying the destruction action when the system evaluates this component.
Properties
- This type has no properties. It exposes two public fields and is used as an IComponentData struct.
Constructors
public DestructionData()
Structs have an implicit parameterless constructor; fields default to their default values (m_RandomTargetType default enum value, m_OccurenceProbability = 0f). You can also use an object initializer to set fields.
Methods
- This struct defines no methods.
Usage Example
using Unity.Entities;
using Game.Prefabs;
// create component data and add to an entity
var destruction = new DestructionData
{
m_RandomTargetType = EventTargetType.Random, // example enum value
m_OccurenceProbability = 0.25f // 25% chance when evaluated
};
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(targetEntity, destruction);
Notes: - The exact behavior (how and when m_OccurenceProbability is sampled, and how EventTargetType is interpreted) is implemented by the systems that read this component. - Ensure the EventTargetType enum and consuming systems are available in your mod/runtime for the component to have effect.