Skip to content

Game.Prefabs.DestructibleObjectData

Assembly:
Assembly-CSharp

Namespace: Game.Prefabs

Type:
struct

Base:
IComponentData, IQueryTypeParameter

Summary:
Component data used to mark in-game prefabs/entities as destructible. Holds simple float values used by game systems (damage, fire spread, collapse) to determine how the object behaves when it takes damage or is exposed to fire. This is a pure data component (no behavior).


Fields

  • public float m_FireHazard
    Fire-related hazard value for this destructible object. Used by fire/damage systems to compute ignition chance, spread or intensity. The exact meaning and units are game-specific; treat it as a scalar weight where higher values indicate greater susceptibility or contribution to fire behavior.

  • public float m_StructuralIntegrity
    Represents the object's remaining structural integrity or resistance to destruction. Typically used by damage/collapse logic to determine when an object should break or be removed. Usually represented as a non-negative float; higher values mean more durable.

Properties

  • None.
    This type is a simple value type (struct) and exposes two public fields instead of properties.

Constructors

  • public DestructibleObjectData()
    No explicit constructors are defined in the source; the default parameterless struct constructor is available. If desired, you may create instances using an object initializer or by defining your own constructor in a local copy (structs in C# allow custom constructors).

Example of constructing an instance in user code:

var data = new DestructibleObjectData
{
    m_FireHazard = 0.5f,
    m_StructuralIntegrity = 100f
};

Methods

  • None.
    This component contains only data fields and implements IComponentData / IQueryTypeParameter for use with the Unity ECS; it provides no methods.

Usage Example

// Create or get an EntityManager and an Entity representing a destructible prefab/entity
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity prefabEntity = ...; // obtain or create the entity

// Assign DestructibleObjectData to an entity
var destructible = new Game.Prefabs.DestructibleObjectData
{
    m_FireHazard = 0.8f,
    m_StructuralIntegrity = 150f
};

entityManager.AddComponentData(prefabEntity, destructible);

// Querying in a System (example)
public partial class DestructionSystem : SystemBase
{
    protected override void OnUpdate()
    {
        // Example of iterating over entities with DestructibleObjectData
        Entities.ForEach((ref Game.Prefabs.DestructibleObjectData d) =>
        {
            // Use d.m_FireHazard and d.m_StructuralIntegrity in your logic
            // e.g., reduce integrity when exposed to fire
        }).ScheduleParallel();
    }
}

Notes: - Because this type implements IQueryTypeParameter, it is usable directly in queries and job signatures in Unity.Entities code. - Be careful with field ranges/units: the source doesn't document them, so inspect other game code or balance values in testing.