Game.Prefabs.IServiceUpgrade
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: interface
Base: (none)
Summary:
IServiceUpgrade is a small interface intended for prefab/service upgrade implementations. Implementers are expected to add the ECS ComponentType entries required for an upgrade into the provided HashSet so the upgrade system can include those components in an entity archetype or otherwise prepare them for use during the upgrade process. This is used with Unity.Entities ComponentType values.
Fields
- (none)
No fields are defined on the interface itself; implementations may hold their own state.
Properties
- (none)
The interface does not declare any properties.
Constructors
- (none)
Interfaces do not define constructors. Implementing classes or structs provide construction as needed.
Methods
void GetUpgradeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Provide the set of ComponentType entries required by this upgrade. The method receives a HashSet to which the implementation should add the ComponentType instances (e.g., ComponentType.ReadWriteor ComponentType.ReadOnly ). Using a HashSet avoids duplicate component types.
Parameters:
- components — a HashSet
Behavior notes: - Implementations should only add ComponentType values and not mutate or replace the HashSet reference. - Keep additions idempotent — calling GetUpgradeComponents multiple times should not produce unintended side effects beyond adding the same ComponentType values. - Ensure the ComponentType values refer to component types that are available/registered in the mod/game context.
Usage Example
using System.Collections.Generic;
using Unity.Entities;
using Game.Prefabs;
public struct ServiceLevelComponent : IComponentData
{
public int level;
}
public class ExampleServiceUpgrade : IServiceUpgrade
{
public void GetUpgradeComponents(HashSet<ComponentType> components)
{
// Add a read/write component required by this upgrade
components.Add(ComponentType.ReadWrite<ServiceLevelComponent>());
// Add other component types as needed
// components.Add(ComponentType.ReadOnly<SomeOtherComponent>());
}
}
Additional integration tips: - Make sure to include the correct using directives: System.Collections.Generic and Unity.Entities. - The upgrade system that consumes IServiceUpgrade implementations will typically merge these ComponentType values into an entity archetype or add them to an existing entity during the upgrade flow. - Test that added component types are compatible with the ECS systems that will operate on upgraded entities.