Skip to content

Game.Prefabs.ResearchFacility

Assembly:
Assembly-CSharp (typical Unity game assembly; actual assembly may vary)
Namespace: Game.Prefabs

Type:
class

Base:
ComponentBase, IServiceUpgrade

Summary:
Prefab component class used by the game's prefab system to describe a Research Facility building. It registers the runtime ECS components required for the prefab (ResearchFacilityData, UpdateFrameData) and contributes archetype/upgrade components for the entity that will be created from the prefab. It also performs minimal initialization by setting an UpdateFrameData with a frame interval of 6. The class implements IServiceUpgrade to provide components needed when this building is used as an upgrade target.


Fields

  • This class declares no explicit fields.
    The behavior is implemented entirely via overridden methods and interface implementation; it relies on ECS component types rather than storing state fields in the prefab component.

Properties

  • This class declares no properties.
    All interaction is done via methods that populate component type collections or initialize created entities.

Constructors

  • public ResearchFacility()
    Implicit default constructor. No custom construction logic is defined.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the ECS component types required on every entity instantiated from this prefab:
  • ResearchFacilityData (read/write)
  • UpdateFrameData (read/write)

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds archetype-level components to the entity type used for this prefab:

  • Game.Buildings.ResearchFacility (read/write) — the domain/building component representing the research facility.
  • Efficiency (read/write) — added conditionally only when the prefab does not have a ServiceUpgrade component but does have a CityServiceBuilding component. This allows city service buildings that are not upgrade prefabs to get an Efficiency component on their archetype.

Note: The method uses GetComponent() and GetComponent() on the prefab class to decide whether to include Efficiency.

  • public void GetUpgradeComponents(HashSet<ComponentType> components)
    Required by IServiceUpgrade. Adds Game.Buildings.ResearchFacility (read/write) to the set of components that should be present when this prefab is used as a service upgrade.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Performs runtime initialization for the entity created from the prefab. Sets UpdateFrameData on the entity to a value of 6 (UpdateFrameData(6)), indicating the update frequency or frame offset used by the updating system.

Usage Example

// Example: extending or customizing initialization for the ResearchFacility prefab
[Preserve]
public class CustomResearchFacility : ResearchFacility
{
    public override void Initialize(EntityManager entityManager, Entity entity)
    {
        base.Initialize(entityManager, entity);
        // Additional initialization: for example, add or modify component data
        // var efficiency = new Efficiency { value = 1.0f };
        // entityManager.SetComponentData(entity, efficiency);
    }
}

Additional notes: - This prefab component works with Unity.Entities (ECS) and relies on types such as ComponentType, EntityManager, and Entity. - Component types referenced here (ResearchFacilityData, UpdateFrameData, Game.Buildings.ResearchFacility, Efficiency) must exist in the runtime code for the entity to function correctly. - The conditional addition of Efficiency ensures that service buildings that are not upgrade prefabs still receive efficiency handling, while upgrade prefabs (with ServiceUpgrade) avoid duplicating that component.