1 """ Base class for vehicles. """
5 """ Vehicle base class.
7 A vehicle should have the following attributes:
9 * seats -- list of roach seats.
10 * background -- actor representing background for management scene
14 approximate_radius = 200
17 def by_type(cls, vehicle_type):
18 return cls.vehicle_types.get(vehicle_type)()
21 def register(cls, vehicle_cls):
22 cls.vehicle_types[vehicle_cls.__name__.lower()] = vehicle_cls
25 def register_all(cls):
26 from .walking import Walking
31 """ A space in a vehicle for a roach.
33 * pos -- (x, y) position of the seat relative to the centre of the vehicle.
34 x and y may be numbers from approximately -1.0 to 1.0. They will be
35 multiplied by the approximate_radius of the vehicle.
36 * allowed -- f(roach) for checking whether a roach may occupy the
40 def __init__(self, pos, allowed=None):
42 self.allowed = allowed or (lambda roach: True)
45 Vehicle.register_all()