public Waypoint GetRandomWeightedWaypoint() { float weightsSum = WeightsSum; float randomWeight = Random.Range(0f, weightsSum); float currentWeightsSum = 0f; WaypointRecord randomWeightedRecord = weightedWaypointsRecords.List.Find(record => { currentWeightsSum += record.weight; return(currentWeightsSum >= randomWeight); }); return(randomWeightedRecord?.waypoint); }
public void Remove(Waypoint waypoint) { WaypointRecord recordToRemove = weightedWaypointsRecords.List.Find(record => record.waypoint == waypoint); weightedWaypointsRecords.List.Remove(recordToRemove); }