Class TravellingVessels
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.sea.TravellingVessels
-
- All Implemented Interfaces:
ITravellingVessels
,java.lang.Iterable<INavigableVessel>
@Component @Lazy public class TravellingVessels extends java.lang.Object implements ITravellingVessels
This iterable collection stores all vessels that are currently travelling. Vessels should be added when they start their travel and be removed when they reach their destination or otherwise stop traveling (e.g. are sunk).- Author:
- Andi Hotz, (c) Sahits GmbH, 2016 Created on Jan 08, 2016
-
-
Field Summary
Fields Modifier and Type Field Description private IMap
map
private java.util.Map<INavigableVessel,TravellingVessel>
vessels
-
Constructor Summary
Constructors Constructor Description TravellingVessels()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addVessel(INavigableVessel vessel, java.util.Optional<javafx.scene.shape.Path> path, java.util.List<javafx.geometry.Point2D> points)
Thevessel
starts it's travel and must be added to this collection together with its data.java.util.Optional<ICity>
findCity(javafx.geometry.Point2D location)
Find the city that is located at the postionlocation
.TravellingVessel
getTravellingVessel(INavigableVessel vessel)
Retrieve the meta date for a travelling vessel.boolean
isTravelling(INavigableVessel vessel)
Check if the vessel is currently travelling.java.util.Iterator<INavigableVessel>
iterator()
void
remove(INavigableVessel vessel)
The vessel is no longer travelling and should no longer be part of this collection.private void
setTravelDestionation(IShip vessel, java.util.Optional<ICity> destCity)
-
-
-
Field Detail
-
vessels
private final java.util.Map<INavigableVessel,TravellingVessel> vessels
-
map
@Autowired private IMap map
-
-
Method Detail
-
addVessel
public void addVessel(INavigableVessel vessel, java.util.Optional<javafx.scene.shape.Path> path, java.util.List<javafx.geometry.Point2D> points)
Thevessel
starts it's travel and must be added to this collection together with its data.- Parameters:
vessel
- that starts the travelpath
- the Bezière path representing the route.points
- the list of points that make up the path along which thevessel
is travelling.
-
setTravelDestionation
private void setTravelDestionation(IShip vessel, java.util.Optional<ICity> destCity)
-
remove
public void remove(INavigableVessel vessel)
The vessel is no longer travelling and should no longer be part of this collection.- Parameters:
vessel
- to be removed
-
iterator
public java.util.Iterator<INavigableVessel> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<INavigableVessel>
- Specified by:
iterator
in interfaceITravellingVessels
-
getTravellingVessel
public TravellingVessel getTravellingVessel(INavigableVessel vessel)
Description copied from interface:ITravellingVessels
Retrieve the meta date for a travelling vessel.- Specified by:
getTravellingVessel
in interfaceITravellingVessels
- Parameters:
vessel
- for which to get the travelling instance- Returns:
- TravellingVessel instance for
vessel
-
isTravelling
public boolean isTravelling(INavigableVessel vessel)
Description copied from interface:ITravellingVessels
Check if the vessel is currently travelling.- Specified by:
isTravelling
in interfaceITravellingVessels
- Parameters:
vessel
- to be checked if it is travelling- Returns:
- true if there is an instance of
TravellingVessel
forvessel
-
findCity
public java.util.Optional<ICity> findCity(javafx.geometry.Point2D location)
Find the city that is located at the postionlocation
.- Parameters:
location
- that should be checked.- Returns:
- Optional of a ICity if there is a city at
location
.
-
-