/// <summary> /// The connections in the set. /// </summary> /// <param name="index"> /// The index of the connection. [Limits: 0 <= value < <see cref="Count"/>]. /// </param> /// <returns>The connection.</returns> public OffMeshConnection this[int index] { get { // Not using parameterized constructor. Don't need validation cost. OffMeshConnection result = new OffMeshConnection(); result.start = mVerts[index * 2 + 0]; result.end = mVerts[index * 2 + 1]; result.radius = mRadii[index]; result.direction = mDirs[index]; result.flags = mFlags[index]; result.area = mAreas[index]; result.userId = mUserIds[index]; return result; } set { // Must be validated. // Let exceptions be thrown. mRadii[index] = MathUtil.ClampToPositiveNonZero(value.radius); mDirs[index] = (byte)(value.IsBiDirectional ? 1 : 0); mAreas[index] = NMGen.ClampArea(value.area); mFlags[index] = value.flags; mUserIds[index] = value.userId; // Keep verts last. mVerts[index * 2 + 0] = value.start; mVerts[index * 2 + 1] = value.end; } }
/// <summary> /// Add a connection. /// </summary> /// <remarks> /// <para> /// The connection fields are auto-clamped to valid values. /// </para> /// </remarks> /// <param name="connection">The connection to add.</param> public void Add(OffMeshConnection connection) { // Must be validated. mVerts.Add(connection.start); mVerts.Add(connection.end); mRadii.Add(MathUtil.ClampToPositiveNonZero(connection.radius)); mDirs.Add((byte)(connection.IsBiDirectional ? 1 : 0)); mAreas.Add(NMGen.ClampArea(connection.area)); mFlags.Add(connection.flags); mUserIds.Add(connection.userId); }