Game.Companies.CompanyTransportInstance
Assembly:
{{ Likely defined in the game's main Game assembly (e.g. Assembly-CSharp or a Game assembly). If you have the compiled assemblies, check which assembly contains the Game.Companies namespace. }}
Namespace: Game.Companies
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary:
This is a small ECS component that stores a reference to the Entity representing a company. It is intended to be attached to transport-related entities to associate them with their owning company (for example: transport vehicles, depots, or transport instance records). Because it is a plain value type with a single Entity field it is blittable and suitable for use in Unity DOTS ECS component storage and queries. When not explicitly set, its m_Company will be Entity.Null.
Fields
public Unity.Entities.Entity m_Company
This field holds the Entity that represents the company associated with the transport instance. Use Entity.Null to indicate no company. This field is serialized as part of the component and can be read or written via EntityManager / SystemBase accessors (GetComponentData / SetComponentData / AddComponentData).
Properties
- None.
This struct only exposes the public field m_Company and has no properties.
Constructors
- Implicit default constructor (public CompanyTransportInstance())
The struct has the default parameterless constructor provided by C#. You can construct it with an object initializer, e.g. new CompanyTransportInstance { m_Company = myCompanyEntity }.
Methods
- None.
No custom methods are defined on this component type. It serves purely as data storage for ECS systems.
Usage Example
// Example usage inside a SystemBase or other code with access to an EntityManager/EntityCommandBuffer
public void CreateTransportInstance(EntityManager entityManager, Entity transportEntity, Entity companyEntity)
{
// Attach the CompanyTransportInstance component to a transport entity
var comp = new Game.Companies.CompanyTransportInstance
{
m_Company = companyEntity
};
// If the entity already has the component, use SetComponentData; otherwise add it
if (entityManager.HasComponent<Game.Companies.CompanyTransportInstance>(transportEntity))
{
entityManager.SetComponentData(transportEntity, comp);
}
else
{
entityManager.AddComponentData(transportEntity, comp);
}
}
// Query example in a SystemBase
Entities
.WithAll<Game.Companies.CompanyTransportInstance>()
.ForEach((Entity e, in Game.Companies.CompanyTransportInstance c) =>
{
// c.m_Company is the company Entity associated with e
// Do transport-company related logic here
}).Schedule();
{{ Implementation notes: - Use Entity.Null to represent an unset company. - Because the type implements IQueryTypeParameter and IComponentData, it is intended for use in ECS queries and component storage. - Keep component instances small and blittable for performance in DOTS/ECS. }}