Game.Tools.NetCourse
Assembly:
Game
Namespace:
Game.Tools
Type:
struct (value type), implements IComponentData, IQueryTypeParameter
Base:
System.ValueType
Summary:
Represents a network "course" (segment geometry) used by the game's road/rail/utility systems. It stores start and end positions on a course, the bezier curve describing the centerline, simple elevation values (start/end), the total curve length and a fixed-index field (used by the network construction/lookup logic). This struct is an ECS component (IComponentData) intended to be attached to entities that need to describe or process a network course in jobs or systems.
Fields
-
public CoursePos m_StartPosition
Start position on the course. CoursePos encodes position and orientation information at the beginning of the course segment. -
public CoursePos m_EndPosition
End position on the course. CoursePos encodes position and orientation information at the end of the course segment. -
public Bezier4x3 m_Curve
A Bezier4x3 describing the centerline of the course between start and end. Typically holds the control points for a cubic bezier in 3D used for interpolation and geometry queries. -
public float2 m_Elevation
Two-component vector storing elevation values. Conventionally used as (startElevation, endElevation) for the course. Useful when sampling height along the curve or for slope calculations. -
public float m_Length
Total length of the course (typically the arc length of the bezier curve). Used for distance-based queries and traversal. -
public int m_FixedIndex
Index value used by network logic. Often used to reference a precomputed/fixed point or slot; may be -1 or another sentinel when not applicable.
Properties
- This type does not declare any properties. It exposes plain public fields for use as an ECS component.
Constructors
public NetCourse()
No explicit constructors are declared in source; the default parameterless constructor is provided by C#. Initialize fields directly when creating an instance.
Methods
- This struct does not declare any methods. It is a plain data container suitable for use in ECS, jobified code and queries.
Usage Example
using Unity.Entities;
using Unity.Mathematics;
using Colossal.Mathematics;
using Game.Tools;
// Example: create an entity and add a NetCourse component
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = entityManager.CreateEntity();
// You would obtain or construct CoursePos and Bezier4x3 from your net-building logic:
CoursePos startPos = new CoursePos(/* ... */);
CoursePos endPos = new CoursePos(/* ... */);
Bezier4x3 curve = new Bezier4x3(/* control points ... */);
var course = new NetCourse
{
m_StartPosition = startPos,
m_EndPosition = endPos,
m_Curve = curve,
m_Elevation = new float2(10f, 12f), // start and end elevation
m_Length = 25.4f,
m_FixedIndex = -1
};
entityManager.AddComponentData(entity, course);
// In a System or Job you can read/modify NetCourse just like any other IComponentData.