Skip to content

Game.Prefabs.ToBeRemoved

Assembly:
Assembly-CSharp

Namespace:
Game.Prefabs

Type:
class

Base:
ComponentBase

Summary:
Component used to mark a prefab as "to be removed". The component does not add any runtime components or archetype components (both component-collection methods are empty) and, during initialization, logs a warning indicating that a prefab configured to be removed is being loaded. Optionally holds a reference to a replacement prefab (m_ReplaceWith) which mod code or game logic can consult to substitute the removed prefab.


Fields

  • public PrefabBase m_ReplaceWith
    Reference to an optional replacement prefab. When a prefab is flagged for removal this field can be used by mod/game code to find an alternative PrefabBase to use instead. It is not used by this component internally beyond being a data holder.

Properties

  • None

Constructors

  • public ToBeRemoved()
    No explicit constructor is defined in source; the default parameterless constructor is used.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    This implementation is empty. It intentionally does not add any component types to the provided set, so the prefab will not contribute components via this method.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    This implementation is empty as well. It intentionally does not add any archetype component types.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Calls base.Initialize(entityManager, entity) and then logs a warning via ComponentBase.baseLog.WarnFormat to notify that a prefab configured to be removed is being loaded. The logged message includes the prefab's name: "Loading prefab that is set to be removed ({0})"

This method is the component's active behavior: emit a warning at initialization time so developers/modders can detect unintended usage of removed prefabs.

Usage Example

// Attach this component to a prefab in a prefab definition (or create it by code).
// Optionally assign a replacement prefab to m_ReplaceWith so your mod/system can substitute it.

[ComponentMenu("Prefabs/", new Type[] { })]
public class ToBeRemoved : ComponentBase
{
    public PrefabBase m_ReplaceWith;

    public override void GetPrefabComponents(HashSet<ComponentType> components) { }

    public override void GetArchetypeComponents(HashSet<ComponentType> components) { }

    public override void Initialize(EntityManager entityManager, Entity entity)
    {
        base.Initialize(entityManager, entity);
        ComponentBase.baseLog.WarnFormat(base.prefab, "Loading prefab that is set to be removed ({0})", base.prefab.name);
    }
}

Notes for modders: - Use this component to mark legacy or deprecated prefabs so they can be detected at load time. - The component itself does not perform replacement; your mod/game code should check for ToBeRemoved on prefabs and, if m_ReplaceWith is set, perform the replacement logic (e.g., spawn the replacement prefab or remap references). - Because the two component-collection methods are empty, adding this component will not alter the entity archetype by itself.