/// <summary>Returns a DirectedPath composed by extending this DirectedPath by one hex.</summary> public DirectedPathCollection(IDirectedPath pathSoFar, DirectedPathStepHex pathStep, int stepCost) { PathStep = pathStep; PathSoFar = pathSoFar; TotalCost = (pathSoFar?.TotalCost ?? 0) + stepCost; TotalSteps = (pathSoFar?.TotalSteps ?? -1) + 1; }
/// <summary>Returns a DirectedPath composed by extending this DirectedPath by one hex.</summary> internal DirectedPathCollection(IDirectedPathCollection pathSoFar, DirectedPathStepHex pathStep, int totalCost) { PathStep = pathStep; PathSoFar = pathSoFar; TotalCost = totalCost; TotalSteps = pathSoFar == null ? 0 : pathSoFar.TotalSteps + 1; }
/// <summary>Returns a new instance composed by extending this DirectedPath by one hex.</summary> /// <param name="this"></param> /// <param name="stepHex"></param> /// <param name="stepCost"></param> public static IDirectedPath AddStep(this IDirectedPath @this, DirectedPathStepHex stepHex, int stepCost) => new DirectedPathCollection(@this, stepHex, stepCost);
/// <inheritdoc/> public IDirectedPathCollection AddStep(DirectedPathStepHex neighbour, int stepCost) => new DirectedPathCollection(this, neighbour, TotalCost + stepCost);