Cherry-picked multiple changes from master
This commit is contained in:
@@ -7,7 +7,6 @@ import javafx.beans.property.SimpleObjectProperty;
|
||||
import mock.model.collider.ColliderRegistry;
|
||||
import network.Messages.Enums.RaceStatusEnum;
|
||||
import network.Messages.Enums.RaceTypeEnum;
|
||||
import network.Messages.LatestMessages;
|
||||
import shared.dataInput.BoatDataSource;
|
||||
import shared.dataInput.RaceDataSource;
|
||||
import shared.dataInput.RegattaDataSource;
|
||||
@@ -33,11 +32,6 @@ public abstract class Race {
|
||||
* The source of regatta related data.
|
||||
*/
|
||||
protected RegattaDataSource regattaDataSource;
|
||||
/**
|
||||
* The collection of latest race messages.
|
||||
* Can be either read from or written to.
|
||||
*/
|
||||
protected LatestMessages latestMessages;
|
||||
/**
|
||||
* A list of compound marks in the race.
|
||||
*/
|
||||
@@ -80,7 +74,7 @@ public abstract class Race {
|
||||
protected ColliderRegistry colliderRegistry;
|
||||
/**
|
||||
* The number of frames per second.
|
||||
* We essentially track the number of frames generated per second, over a one second period. When {@link #lastFpsResetTime} reaches 1 second, {@link #currentFps} is reset.
|
||||
* We essentially track the number of frames generated per second, over a one second period. When {@link #lastFpsResetTime} reaches 1 second, currentFps is reset.
|
||||
*/
|
||||
private int currentFps = 0;
|
||||
/**
|
||||
@@ -92,53 +86,38 @@ public abstract class Race {
|
||||
*/
|
||||
private long lastFpsResetTime;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a race object with a given BoatDataSource, RaceDataSource, and RegattaDataSource.
|
||||
* @param boatDataSource Data source for boat related data (yachts and marker boats).
|
||||
* @param raceDataSource Data source for race related data (participating boats, legs, etc...).
|
||||
* @param regattaDataSource Data source for race related data (course name, location, timezone, etc...).
|
||||
* @param latestMessages The collection of latest messages, which can be written to, or read from.
|
||||
*/
|
||||
public Race(BoatDataSource boatDataSource, RaceDataSource raceDataSource, RegattaDataSource regattaDataSource, LatestMessages latestMessages) {
|
||||
public Race(BoatDataSource boatDataSource, RaceDataSource raceDataSource, RegattaDataSource regattaDataSource) {
|
||||
|
||||
//Keep a reference to data sources.
|
||||
this.raceDataSource = raceDataSource;
|
||||
this.boatDataSource = boatDataSource;
|
||||
this.regattaDataSource = regattaDataSource;
|
||||
|
||||
this.latestMessages = latestMessages;
|
||||
|
||||
|
||||
//Marks.
|
||||
this.compoundMarks = raceDataSource.getCompoundMarks();
|
||||
|
||||
//Boundaries.
|
||||
this.boundary = raceDataSource.getBoundary();
|
||||
|
||||
|
||||
//Legs.
|
||||
this.useLegsList(raceDataSource.getLegs());
|
||||
|
||||
|
||||
//Race ID.
|
||||
this.raceId = raceDataSource.getRaceId();
|
||||
|
||||
//Regatta name.
|
||||
this.regattaName = regattaDataSource.getRegattaName();
|
||||
|
||||
//Race clock.
|
||||
this.raceClock = new RaceClock(this.raceDataSource.getStartDateTime());
|
||||
|
||||
//Race status.
|
||||
this.setRaceStatusEnum(RaceStatusEnum.NOT_ACTIVE);
|
||||
//Race type.
|
||||
this.raceType = raceDataSource.getRaceType();
|
||||
|
||||
//Wind.
|
||||
this.setWind(Bearing.fromDegrees(0), 0);
|
||||
|
||||
// Set up colliders
|
||||
this.colliderRegistry = new ColliderRegistry();
|
||||
this.colliderRegistry.addAllColliders(compoundMarks);
|
||||
}
|
||||
@@ -153,7 +132,6 @@ public abstract class Race {
|
||||
*/
|
||||
protected abstract void initialiseBoats();
|
||||
|
||||
|
||||
/**
|
||||
* Updates the race to use a new list of legs, and adds a dummy "Finish" leg at the end.
|
||||
* @param legs The new list of legs to use.
|
||||
@@ -185,10 +163,6 @@ public abstract class Race {
|
||||
return legID == lastLegID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current race status.
|
||||
* @return The current race status.
|
||||
@@ -205,7 +179,6 @@ public abstract class Race {
|
||||
this.raceStatusEnum = raceStatusEnum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type of race this is.
|
||||
* @return The type of race this is.
|
||||
@@ -222,7 +195,6 @@ public abstract class Race {
|
||||
return regattaName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the race to have a specified wind bearing and speed.
|
||||
* @param windBearing New wind bearing.
|
||||
@@ -241,7 +213,6 @@ public abstract class Race {
|
||||
this.raceWind.setValue(wind);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the wind bearing.
|
||||
* @return The wind bearing.
|
||||
@@ -268,7 +239,6 @@ public abstract class Race {
|
||||
return raceClock;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the RaceDataSource used for the race.
|
||||
* @return The RaceDataSource used for the race.
|
||||
@@ -286,7 +256,6 @@ public abstract class Race {
|
||||
return legs.size() - 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the race boundary.
|
||||
* @return The race boundary.
|
||||
@@ -295,12 +264,21 @@ public abstract class Race {
|
||||
return boundary;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of frames generated per second.
|
||||
* @return Frames per second.
|
||||
* Returns the marks of the race.
|
||||
* @return Marks of the race.
|
||||
*/
|
||||
public int getFps() {
|
||||
return lastFps.getValue();
|
||||
public List<CompoundMark> getCompoundMarks() {
|
||||
return compoundMarks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legs of the race.
|
||||
* @return Legs of the race.
|
||||
*/
|
||||
public List<Leg> getLegs() {
|
||||
return legs;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,7 +289,6 @@ public abstract class Race {
|
||||
return lastFps;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increments the FPS counter, and adds timePeriod milliseconds to our FPS reset timer.
|
||||
* @param timePeriod Time, in milliseconds, to add to {@link #lastFpsResetTime}.
|
||||
|
||||
Reference in New Issue
Block a user