Skip to content

Game.Prefabs.MailBox

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
A prefab component representing a postal mailbox / post transport stop. When the prefab is initialized into an ECS entity it registers the required component types (route connection, transport stop and mailbox data) and writes default RouteConnectionData, TransportStopData and MailBoxData values onto the entity. This prefab configures the mailbox to use pedestrian access and road routing and to act as a cargo/post transport stop rather than a passenger stop.


Fields

  • public int m_MailCapacity = 1000
    Specifies the mailbox storage capacity (number of mail units). The value is copied into the MailBoxData component on the created entity during Initialize.

  • public float m_ComfortFactor
    Comfort factor propagated to the TransportStopData component. Controls how comfortable the stop is considered by the simulation (influences routing/usage/AI decisions depending on game systems).

Properties

  • This class does not declare any properties.

Constructors

  • public MailBox()
    Implicit default constructor. The prefab initializes public fields via inspector/default values; the actual ECS components are created and populated when Initialize is called by the prefab system.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the component types required on the prefab instance: MailBoxData, TransportStopData and RouteConnectionData. This informs the prefab system which component types will be written when the prefab is instantiated.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds the runtime archetype component types expected on the final entity: Game.Objects.Color, Game.Routes.TransportStop, Game.Routes.MailBox, AccessLane, RouteLane and CurrentDistrict. These types describe the ECS archetype the mailbox entity will use.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab is instantiated into an ECS entity. This method:

  • Constructs a RouteConnectionData with:
    • m_AccessConnectionType = RouteConnectionType.Pedestrian
    • m_RouteConnectionType = RouteConnectionType.Road
    • m_AccessTrackType = TrackTypes.None
    • m_RouteTrackType = TrackTypes.None
    • m_AccessRoadType = RoadTypes.None
    • m_RouteRoadType = RoadTypes.Car
    • m_RouteSizeClass = SizeClass.Undefined
    • m_StartLaneOffset = 0f
    • m_EndMargin = 0f
  • Constructs a TransportStopData with:
    • m_ComfortFactor = this.m_ComfortFactor
    • m_LoadingFactor = 0f
    • m_AccessDistance = 0f
    • m_BoardingTime = 0f
    • m_TransportType = TransportType.Post
    • m_PassengerTransport = false
    • m_CargoTransport = true
  • Constructs a MailBoxData with m_MailCapacity = this.m_MailCapacity
  • Writes these three component data instances to the provided entity via EntityManager.SetComponentData.

Usage Example

// Example: typical usage is to configure the prefab in the editor (or via code)
// by setting public fields. When the prefab system instantiates the mailbox
// it will call Initialize and write ECS component data to the entity.

MailBox prefab = /* obtain reference to the MailBox prefab */;
prefab.m_MailCapacity = 1500;
prefab.m_ComfortFactor = 0.9f;

// When the prefab is spawned into the ECS world the engine will call:
entityManager.Instantiate(prefabEntity);
// The prefab system will then call:
prefab.Initialize(entityManager, spawnedEntity);
// After Initialize the entity will have RouteConnectionData, TransportStopData and MailBoxData set.