Skip to content

Game.Prefabs.LotPrefab

Assembly:
Assembly-CSharp (typical game assembly; replace with actual assembly if different)

Namespace:
Game.Prefabs

Type:
class

Base:
AreaPrefab

Summary:
LotPrefab is an AreaPrefab used to define lot-specific data and archetype components for the ECS world. It exposes configurable fields such as maximum selection radius, range color, and flags for water placement, overlap allowance, and editing. At initialization it writes a LotData component to the entity and contributes a set of prefab and archetype component types required for lot entities.


Fields

  • public float m_MaxRadius = 200f
    Maximum radius (in world units) used by the lot for selection/interaction ranges. Default value in the class is 200f.

  • public UnityEngine.Color m_RangeColor = UnityEngine.Color.white
    Color used to display the lot's range/area in-editor or in-game overlays. Defaults to white.

  • public bool m_OnWater
    If true, indicates the lot can be placed on water. Used by placement/validation logic.

  • public bool m_AllowOverlap
    If true, allows the lot to overlap other lots or areas. Affects placement validation and collision/overlap checks.

  • public bool m_AllowEditing = true
    If true, the lot supports in-game editing (e.g., resizing/moving). Defaults to true.

Properties

This class does not declare any C# properties. It only exposes public fields and overrides methods from AreaPrefab to add ECS component types.

Constructors

  • public LotPrefab()
    Default parameterless constructor (implicit). The class relies on field initializers for default values; any initialization that requires ECS is done in Initialize.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components) : System.Void
    Adds required component types for the prefab representation. This override calls base.GetPrefabComponents(...) and then adds:
  • ComponentType.ReadWrite()
  • ComponentType.ReadWrite()

These ensure the prefab will create entities with LotData and area geometry data when converted.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components) : System.Void
    Adds component types that should be part of the runtime archetype for lot entities. This override calls base.GetArchetypeComponents(...) and then adds:
  • ComponentType.ReadWrite()
  • ComponentType.ReadWrite()
  • ComponentType.ReadWrite()
  • ComponentType.ReadWrite()

These components represent runtime behavior/state, geometry, and deterministic random seeds for the lot.

  • public override void Initialize(EntityManager entityManager, Entity entity) : System.Void
    Called to initialize an entity instance from this prefab. This override calls base.Initialize(...) and then sets the LotData component data on the entity using the prefab field values:
  • entityManager.SetComponentData(entity, new LotData(m_MaxRadius, m_RangeColor, m_OnWater, m_AllowOverlap));

Note: m_AllowEditing is a prefab-level flag (likely used by editor/UI code) but is not written into LotData by this method.

Usage Example

using Unity.Entities;
using UnityEngine;
using Game.Prefabs;

// Example: manually creating an entity and initializing it using a LotPrefab instance
public class LotPrefabExample : MonoBehaviour
{
    public LotPrefab lotPrefab; // assign in inspector

    void Start()
    {
        var world = World.DefaultGameObjectInjectionWorld;
        var entityManager = world.EntityManager;

        // Create an empty entity and initialize it from the prefab
        var entity = entityManager.CreateEntity();
        lotPrefab.Initialize(entityManager, entity);

        // The entity now has LotData (with m_MaxRadius, m_RangeColor, m_OnWater, m_AllowOverlap)
        // and archetype components added by GetArchetypeComponents/GetPrefabComponents.
    }
}

Notes and tips: - The class is annotated with [ComponentMenu("Areas/", new Type[] { })], placing it in the Areas menu in the Unity editor component menu. - Replace the assumed assembly name if your project uses a different compiled assembly. - m_AllowEditing appears to be editor/tooling related and is not applied to the entity in Initialize; if you need that state at runtime, consider extending LotData or writing a separate component.