Game.Prefabs.CompanyNotificationParameterPrefab
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
A prefab that holds configuration for company-related notifications. This prefab references two notification icon prefabs (for "no inputs" and "no customers") and exposes numeric thresholds that control when those notifications should trigger (cost limit for inputs, service limit for customers, and a hotel-specific empty-room limit). It registers the required component data (CompanyNotificationParameterData) on the entity during LateInitialize and converts referenced NotificationIconPrefab instances into entity references via the PrefabSystem.
Fields
-
public NotificationIconPrefab m_NoInputsNotificationPrefab
This is a reference to the NotificationIconPrefab used to show a "no inputs" notification for a company. It is added to the prefab dependencies and converted to an entity reference in LateInitialize. -
public NotificationIconPrefab m_NoCustomersNotificationPrefab
Reference to the NotificationIconPrefab used to show a "no customers" notification. Like the inputs prefab, it's added to dependencies and mapped to an entity in LateInitialize. -
public float m_NoInputCostLimit = 5f
Float threshold representing the input cost limit that helps determine when the "no inputs" notification should trigger. Default value is 5.0. -
public float m_NoCustomersServiceLimit = 0.9f
Float threshold representing the service limit for customers (e.g., if service level drops below this fraction). Default value is 0.9 (90%). -
public float m_NoCustomersHotelLimit = 0.9f
Tooltip: "The limit of empty rooms percentage of total room amount, 0.9 means 90% rooms are empty"
Float threshold specialized for hotels indicating what fraction of empty rooms triggers the "no customers" condition for hotel companies. Default is 0.9 (90%).
Properties
- (none)
This prefab type does not declare its own properties; it exposes configuration via public fields and writes those values into the CompanyNotificationParameterData component on the entity during LateInitialize.
Constructors
public CompanyNotificationParameterPrefab()
Default constructor inherited from PrefabBase. No custom initialization logic in the class constructor; initialization of component data occurs during LateInitialize.
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds referenced NotificationIconPrefab instances (m_NoInputsNotificationPrefab and m_NoCustomersNotificationPrefab) to the provided dependency list so the prefab system knows to load them first. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds CompanyNotificationParameterData to the set of component types that this prefab requires. This ensures the entity archetype includes the component so data can be written in LateInitialize. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Overrides the base method but does not add additional archetype components beyond what PrefabBase provides (keeps default behavior). -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Converts the NotificationIconPrefab references to entities using PrefabSystem.GetEntity and populates a CompanyNotificationParameterData struct with: - m_NoCustomersNotificationPrefab (entity)
- m_NoInputsNotificationPrefab (entity)
- m_NoCustomersServiceLimit
- m_NoInputCostLimit
- m_NoCustomersHotelLimit Then writes that struct to the provided entity via entityManager.SetComponentData(entity, componentData).
Usage Example
// This prefab is typically configured in the editor (assign prefabs and thresholds).
// At runtime, the prefab system will call LateInitialize to map referenced prefabs to entities
// and set CompanyNotificationParameterData on the created entity.
public override void GetDependencies(List<PrefabBase> prefabs)
{
base.GetDependencies(prefabs);
prefabs.Add(m_NoInputsNotificationPrefab);
prefabs.Add(m_NoCustomersNotificationPrefab);
}
public override void LateInitialize(EntityManager entityManager, Entity entity)
{
base.LateInitialize(entityManager, entity);
var prefabSystem = entityManager.World.GetOrCreateSystemManaged<PrefabSystem>();
CompanyNotificationParameterData data = default;
data.m_NoCustomersNotificationPrefab = prefabSystem.GetEntity(m_NoCustomersNotificationPrefab);
data.m_NoInputsNotificationPrefab = prefabSystem.GetEntity(m_NoInputsNotificationPrefab);
data.m_NoCustomersServiceLimit = m_NoCustomersServiceLimit;
data.m_NoInputCostLimit = m_NoInputCostLimit;
data.m_NoCustomersHotelLimit = m_NoCustomersHotelLimit;
entityManager.SetComponentData(entity, data);
}