Game.LocalEffects
Assembly: Assembly-CSharp (in-game)
Namespace: Game.Prefabs
Type: class
Base: ComponentBase, IServiceUpgrade
Summary:
Component used by Building and BuildingExtension prefabs to declare local effects provided by the prefab. The component exposes an array of LocalEffectInfo (m_Effects). During initialization it converts each LocalEffectInfo into LocalModifierData entries and writes them into the entity's DynamicBuffer
Fields
public LocalEffectInfo[] m_Effects
Array of LocalEffectInfo objects configured on the prefab. Each entry describes a local effect (type, mode, radius, delta, radius combine mode, etc.). In Initialize(), each element is converted into a LocalModifierData and appended to the entity's DynamicBuffer. The LocalModifierData is constructed with: - effect type and mode from LocalEffectInfo.m_Type / m_Mode
- radius combine mode from LocalEffectInfo.m_RadiusCombineMode
- value bounds for effect delta using new Bounds1(0f, localEffectInfo.m_Delta)
- value bounds for effect radius using new Bounds1(0f, localEffectInfo.m_Radius)
Properties
- None declared on this class. (ECS component types are contributed via the GetPrefabComponents / GetArchetypeComponents methods.)
Constructors
public LocalEffects()
No explicit constructor is defined in the source — the default parameterless constructor is used.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds ComponentType.ReadWrite() to the prefab component set. This ensures the entity will have a DynamicBuffer to store effect modifiers. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
If the prefab does not already contain a ServiceUpgrade component, this method adds ComponentType.ReadWrite() to the archetype. This ensures normal (non-upgrade) building prefabs provide the LocalEffectProvider component. -
public void GetUpgradeComponents(HashSet<ComponentType> components)
Implements IServiceUpgrade. Adds ComponentType.ReadWrite() for the upgrade archetype. Use this to ensure upgraded building entities get the provider too. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab is converted to an entity. If m_Effects is not null, this method fetches the DynamicBufferon the entity and appends a LocalModifierData record for each LocalEffectInfo in m_Effects (mapping fields as described above). Requires that a DynamicBuffer exists on the entity (GetPrefabComponents ensures that).
Usage Example
// The component itself performs buffer population in Initialize().
[ComponentMenu("Buildings/", new Type[]
{
typeof(BuildingPrefab),
typeof(BuildingExtensionPrefab)
})]
public class LocalEffects : ComponentBase, IServiceUpgrade
{
public LocalEffectInfo[] m_Effects;
public override void Initialize(EntityManager entityManager, Entity entity)
{
base.Initialize(entityManager, entity);
// LocalEffects will convert m_Effects into LocalModifierData entries:
// DynamicBuffer<LocalModifierData> buffer = entityManager.GetBuffer<LocalModifierData>(entity);
// buffer.Add(new LocalModifierData(...));
}
}
Additional notes: - Related types: LocalEffectInfo, LocalModifierData, LocalEffectProvider, ServiceUpgrade, Bounds1. - This component is intended for building prefabs and building extension prefabs and is part of the prefab-to-entity conversion flow.