Skip to content

Game.EndFrameBarrier

Assembly:
Assembly-CSharp (typical Unity game assembly; this file lives in the game's main assembly)

Namespace: Game.Prefabs

Type:
class DistrictModifiers

Base:
ComponentBase

Summary:
This file actually defines the Game.Prefabs.DistrictModifiers component used by the game's prefab system (marked with a ComponentMenu attribute "Policies/" and associated with PolicyPrefab). DistrictModifiers exposes an array of DistrictModifierInfo (m_Modifiers) that, during prefab initialization, are converted into runtime DistrictModifierData entries and written into the Entity's DynamicBuffer. The component registers the DistrictModifierData component type for the prefab so the ECS entity will have a buffer for district modifiers at runtime.


Fields

  • private System.Diagnostics.Stopwatch m_Stopwatch
    This field does not appear in DistrictModifiers.cs. The DistrictModifiers class does not use a Stopwatch; this template field is unrelated to the actual source file. The real class declares a public array of modifier infos (see below).

  • private Unity.Jobs.JobHandle <producerHandle>k__BackingField
    This backing field is not present in DistrictModifiers.cs. DistrictModifiers does not define or use a producerHandle property or any JobHandle fields.

  • public DistrictModifierInfo[] m_Modifiers
    This is the main field declared by the class. It holds the list of modifiers defined on the prefab (presumably set in the editor). During Initialize, each DistrictModifierInfo entry is converted into a DistrictModifierData and added to the entity's DynamicBuffer. If m_Modifiers is null, no entries are added.

Properties

  • public Unity.Jobs.JobHandle producerHandle { get; private set }
    Not present in DistrictModifiers.cs. The DistrictModifiers component does not expose a producerHandle property. The class focuses on registering component types and populating the district modifier buffer during initialization.

Constructors

  • public EndFrameBarrier()
    DistrictModifiers.cs does not define any explicit constructors. It relies on the default parameterless constructor inherited from ComponentBase / Unity's serialization system. Initialization behavior is implemented in the overridden Initialize method rather than a custom constructor.

Methods

  • protected virtual OnCreate() : System.Void
    DistrictModifiers.cs does not implement OnCreate. Instead it overrides the prefab/component lifecycle methods relevant to the prefab-to-entity conversion:

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds ComponentType.ReadWrite() to the provided set. This ensures that entities created from the prefab include a DynamicBuffer (or the component type that represents district modifiers) so the Initialize method can obtain that buffer.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Present but empty in this class; no additional archetype components are added here.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called to initialize the created entity from the prefab. Implementation:

    • Calls base.Initialize(entityManager, entity).
    • If m_Modifiers is non-null, obtains the DynamicBuffer for the entity via entityManager.GetBuffer(entity).
    • Iterates the m_Modifiers array and adds a new DistrictModifierData constructed from each DistrictModifierInfo's m_Type, m_Mode, and m_Range: buffer.Add(new DistrictModifierData(districtModifierInfo.m_Type, districtModifierInfo.m_Mode, districtModifierInfo.m_Range)); This copies authoring data from the prefab component into the runtime ECS buffer.

Usage Example

// Example inspector-assigned authoring component on a prefab:
// - Set m_Modifiers in the editor (an array of DistrictModifierInfo).
// At runtime, the prefab system will call Initialize(...) and populate the entity buffer.

public class ExampleUsage
{
    // Suppose we construct a prefab authoring object in editor code:
    DistrictModifiers authoring = new DistrictModifiers();
    authoring.m_Modifiers = new DistrictModifierInfo[]
    {
        new DistrictModifierInfo { m_Type = DistrictModifierType.SomeType, m_Mode = ModifierMode.Add, m_Range = 10 },
        new DistrictModifierInfo { m_Type = DistrictModifierType.AnotherType, m_Mode = ModifierMode.Multiply, m_Range = 5 }
    };

    // When the prefab is converted to an Entity, DistrictModifiers.Initialize(...)
    // will run and append corresponding DistrictModifierData entries into the entity's buffer.
}

Notes and cautions: - DistrictModifierInfo and DistrictModifierData types are referenced but not defined in this file; consult their definitions for field meanings and valid enum values (m_Type, m_Mode, m_Range). - The component uses the ECS DynamicBuffer pattern; ensure the corresponding buffer element type (DistrictModifierData) is declared as an IBufferElementData in the ECS codebase.