Game.Prefabs.ServiceFeeCollector
Assembly:
Assembly-CSharp (game code / modding assembly). This class lives in the game's runtime assembly that contains game prefabs and component definitions; in a modding project it is typically found in Assembly-CSharp.
Namespace:
Game.Prefabs
Type:
class
Base:
ComponentBase
Summary:
ServiceFeeCollector is a prefab/component wrapper used by the game's prefab-to-entity conversion system. It declares which ECS component(s) should be part of the entity archetype for prefabs that include this Unity component and provides a hook (Initialize) to perform entity initialization when a prefab is instantiated. In this implementation GetArchetypeComponents adds the ECS component Game.City.ServiceFeeCollector to the archetype; the other methods are present but contain no logic and are left for future initialization or extension.
Fields
- None
This MonoBehaviour-derived class defines no instance fields. It only overrides ComponentBase methods to contribute component type information and initialization logic.
Properties
- None
There are no public or private properties defined by this class.
Constructors
public ServiceFeeCollector()
Default parameterless constructor is provided by the runtime (no explicit constructor in source). No special construction logic is required for this component.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
This override is empty in the current implementation. Purpose: allow the component to add components that should be present on the raw prefab (before instantiation) — e.g., author-time data or references. Currently nothing is added. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds the ECS component type used at runtime: -
components.Add(ComponentType.ReadWrite<Game.City.ServiceFeeCollector>());
This ensures entities created from prefabs containing this component include the Game.City.ServiceFeeCollector component in their archetype (read/write access). This ties the prefab representation to the ECS runtime data structure. -
public override void Initialize(EntityManager entityManager, Entity entity)
Empty in the current implementation. Intended for runtime initialization of the created entity (e.g., setting initial ComponentData values, adding additional runtime-only components, or resolving references). If initialization is needed, use entityManager to set component data on the entity here.
Additional notes:
- The class is decorated with the ComponentMenu attribute:
[ComponentMenu("Buildings/", new Type[] { typeof(BuildingPrefab) })]
This places the component in the editor's component menu under Buildings and associates it with the BuildingPrefab type for authoring purposes.
Usage Example
// This example shows the pattern used by ServiceFeeCollector to add an ECS component to
// the prefab's entity archetype and how you might initialize that component during entity creation.
public override void GetArchetypeComponents(HashSet<ComponentType> components)
{
// Ensure the entity will have the runtime component that stores service-fee related data
components.Add(ComponentType.ReadWrite<Game.City.ServiceFeeCollector>());
}
public override void Initialize(EntityManager entityManager, Entity entity)
{
// Example initialization (actual fields depend on Game.City.ServiceFeeCollector struct)
// var data = new Game.City.ServiceFeeCollector { /* set fields here */ };
// entityManager.SetComponentData(entity, data);
}
If you need this prefab to provide author-time (prefab) data, implement GetPrefabComponents. If runtime initialization or setting initial component values is required, implement Initialize to call EntityManager.SetComponentData or add other components.