Game.Prefabs.ExtractorCompany
Assembly: Game
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Prefab component used to define an "ExtractorCompany" prefab. It declares which ECS components should be added to the prefab and to the runtime archetype. The class itself contains no custom initialization by default (Initialize is empty), so modders can extend it to set up entity component data when an entity is instantiated from this prefab. The component is exposed in the editor/menu via the ComponentMenu attribute.
Fields
- This class declares no instance fields.
Properties
- This class declares no properties.
Constructors
public ExtractorCompany()
Default constructor (implicit). No special construction logic in the source.
Methods
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds component types that should be present on the prefab itself (components stored/defined on the prefab). In the current implementation it adds:-
ComponentType.ReadWrite<ExtractorCompanyData>()
This ensures the ExtractorCompanyData component is part of the prefab so it will exist on instantiated entities. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds component types that should be part of the entity archetype used at runtime. In the current implementation it adds: -
ComponentType.ReadWrite<Game.Companies.ExtractorCompany>()
This registers the runtime company component type for entities created from this prefab. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when an entity is created/instantiated from this prefab. The method is empty in the provided implementation; override or modify it to set up component data on the newly created entity using EntityManager (e.g., AddComponentData or SetComponentData).
Additional info:
- The class is annotated with [ComponentMenu("Companies/", new Type[] { typeof(CompanyPrefab) })]
, which places it under the Companies menu in the prefab/component browser (editor integration).
- Uses Unity.Entities for ECS types and Game.Companies namespace for runtime company type.
Usage Example
[ComponentMenu("Companies/", new Type[] { typeof(CompanyPrefab) })]
public class ExtractorCompany : ComponentBase
{
public override void GetPrefabComponents(HashSet<ComponentType> components)
{
components.Add(ComponentType.ReadWrite<ExtractorCompanyData>());
}
public override void GetArchetypeComponents(HashSet<ComponentType> components)
{
components.Add(ComponentType.ReadWrite<Game.Companies.ExtractorCompany>());
}
// Called when the prefab is instantiated — set up component data here
public override void Initialize(EntityManager entityManager, Entity entity)
{
// Example placeholders — replace with real fields from your component data types:
// entityManager.AddComponentData(entity, new ExtractorCompanyData { /* ... */ });
// entityManager.AddComponentData(entity, new Game.Companies.ExtractorCompany { /* ... */ });
}
}