Reset collision tag on visualiser boat after displaying collision
- Modified View3D to index subjects rather than shapes by source ID - Enforced one collision per boat on server to reduce rendering load - Changed collision radius to less than bounce radius - Fixed game-breaking null command bug #story[1195]
This commit is contained in:
@@ -366,10 +366,8 @@ public class MockRace extends RaceState {
|
||||
//Checks if the current boat has finished the race or not.
|
||||
boolean finish = this.isLastLeg(boat.getCurrentLeg());
|
||||
|
||||
if (!finish && totalElapsedMilliseconds >= updatePeriodMilliseconds) {
|
||||
|
||||
if(boat.isVelocityDefault()) setBoatSpeed(boat);
|
||||
|
||||
if (!finish && totalElapsedMilliseconds >= updatePeriodMilliseconds && boat.isVelocityDefault()) {
|
||||
setBoatSpeed(boat);
|
||||
//Calculates the distance travelled, in meters, in the current timeslice.
|
||||
double distanceTravelledMeters = boat.calculateMetersTravelled(updatePeriodMilliseconds) * this.scaleFactor;
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ public abstract class Collider extends Observable implements Locatable {
|
||||
// Direction of collider from heading
|
||||
Bearing relative = Bearing.fromDegrees(absolute.degrees() - boat.getBearing().degrees());
|
||||
|
||||
if(actualDistance <= distance) {
|
||||
if(!boat.isColliding() && actualDistance <= distance) {
|
||||
boat.setColliding(true);
|
||||
Collision collision = new Collision(boat, relative, distance);
|
||||
// Notify object of collision
|
||||
onCollisionEnter(collision);
|
||||
|
||||
@@ -29,17 +29,18 @@ public class CollisionCommand extends ObserverCommand {
|
||||
public void execute() {
|
||||
this.azimuth = Azimuth.fromDegrees(boat.getBearing().degrees() - 180d);
|
||||
this.startingPosition = boat.getPosition();
|
||||
this.distance = 30;
|
||||
this.distance = 60;
|
||||
boat.setVelocityDefault(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
if(GPSCoordinate.calculateDistanceMeters(boat.getPosition(), startingPosition) < distance) {
|
||||
boat.setPosition(GPSCoordinate.calculateNewPosition(boat.getPosition(), 2, azimuth));
|
||||
boat.setPosition(GPSCoordinate.calculateNewPosition(boat.getPosition(), 3, azimuth));
|
||||
} else {
|
||||
race.deleteObserver(this);
|
||||
boat.setVelocityDefault(true);
|
||||
boat.setColliding(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user