Game.Routes.PathSource
Assembly: Assembly-CSharp (game runtime assembly)
Namespace: Game.Routes
Type: struct (value type)
Base: IComponentData, IQueryTypeParameter
Summary:
A small ECS component used to mark or store the source information for a path within the routing system. Designed for Unity's DOTS/ECS, this blittable struct contains a reference to an Entity that represents the source/origin and an integer frame counter used to track when the path/source was last updated. Typically used in queries or systems that process routing updates and to prevent redundant recalculation within the same frame.
Fields
-
public Entity m_Entity
Holds the Entity that acts as the source or origin for a path. This is an Entity handle (Unity.Entities.Entity) and is safe to use in jobs and component data because it is a blittable value. -
public int m_UpdateFrame
An integer used to record the frame index (or update tick) when this PathSource was last processed/updated. Systems can compare this value with the current frame to decide whether to recompute or skip work for this source during the same frame.
Properties
- This type declares no properties; it exposes data via public fields to remain blittable and efficient for DOTS usage.
Constructors
public PathSource()
Structs in C# have an implicit parameterless constructor which initializes m_Entity to Entity.Null and m_UpdateFrame to 0. There is no explicitly declared constructor in the source.
Methods
- This struct has no methods. It is a plain data container intended for use as an IComponentData / query parameter type.
Usage Example
// Adding PathSource to an entity:
var pathSource = new PathSource {
m_Entity = sourceEntity, // an Entity that represents the route origin
m_UpdateFrame = UnityEngine.Time.frameCount
};
entityManager.AddComponentData(targetEntity, pathSource);
// In a SystemBase / job, reading/updating m_UpdateFrame:
public partial class PathProcessingSystem : SystemBase
{
protected override void OnUpdate()
{
int currentFrame = UnityEngine.Time.frameCount;
Entities
.WithName("ProcessPathSources")
.ForEach((ref PathSource ps) =>
{
if (ps.m_UpdateFrame != currentFrame)
{
// perform update work for this path source...
ps.m_UpdateFrame = currentFrame;
}
})
.ScheduleParallel();
}
}
Notes: - The struct is intentionally simple and blittable for efficient use in jobs and parallel queries. - Use m_UpdateFrame to avoid duplicate work within the same frame; treat m_Entity as the canonical reference to the origin entity.