OpenTTD Source: src/disaster_vehicle.h Source File

OpenTTD Source 15.3

disaster_vehicle.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef DISASTER_VEHICLE_H
11#define DISASTER_VEHICLE_H
12
13#include "vehicle_base.h"
14
16 enum DisasterSubType : uint8_t {
17 ST_ZEPPELINER,
18 ST_ZEPPELINER_SHADOW,
19 ST_SMALL_UFO,
20 ST_SMALL_UFO_SHADOW,
21 ST_AIRPLANE,
22 ST_AIRPLANE_SHADOW,
23 ST_HELICOPTER,
24 ST_HELICOPTER_SHADOW,
25 ST_HELICOPTER_ROTORS,
26 ST_BIG_UFO,
27 ST_BIG_UFO_SHADOW,
28 ST_BIG_UFO_DESTROYER,
29 ST_BIG_UFO_DESTROYER_SHADOW,
30 ST_SMALL_SUBMARINE,
31 ST_BIG_SUBMARINE,
32};
33
37 struct DisasterVehicle final : public SpecializedVehicle<DisasterVehicle, VEH_DISASTER> {
38 SpriteID image_override{};
39 VehicleID big_ufo_destroyer_target = VehicleID::Invalid();
40 uint8_t flags = 0;
41 uint16_t state = 0;
42
44 DisasterVehicle() : SpecializedVehicleBase() {}
45 DisasterVehicle(int x, int y, Direction direction, DisasterSubType subtype, VehicleID big_ufo_destroyer_target = VehicleID::Invalid());
47 virtual ~DisasterVehicle() = default;
48
49 void UpdatePosition(int x, int y, int z);
50 void UpdateDeltaXY() override;
51 void UpdateImage();
52 bool Tick() override;
53};
54
55#endif /* DISASTER_VEHICLE_H */
Direction
Direction
Defines the 8 directions on the map.
Definition direction_type.h:24
DisasterSubType
DisasterSubType
Different sub types of disaster vehicles.
Definition disaster_vehicle.h:16
ST_ZEPPELINER_SHADOW
@ ST_ZEPPELINER_SHADOW
Shadow of the zeppelin.
Definition disaster_vehicle.h:18
ST_HELICOPTER_SHADOW
@ ST_HELICOPTER_SHADOW
Shadow of helicopter.
Definition disaster_vehicle.h:24
ST_SMALL_UFO_SHADOW
@ ST_SMALL_UFO_SHADOW
Shadow of small UFO.
Definition disaster_vehicle.h:20
ST_SMALL_UFO
@ ST_SMALL_UFO
Small UFO, tries to find a road vehicle to destroy.
Definition disaster_vehicle.h:19
ST_BIG_UFO
@ ST_BIG_UFO
Big UFO, finds a piece of railroad to "park" on.
Definition disaster_vehicle.h:26
ST_BIG_UFO_SHADOW
@ ST_BIG_UFO_SHADOW
Shadow of the big UFO.
Definition disaster_vehicle.h:27
ST_ZEPPELINER
@ ST_ZEPPELINER
Zeppelin, crashes at airports.
Definition disaster_vehicle.h:17
ST_BIG_UFO_DESTROYER_SHADOW
@ ST_BIG_UFO_DESTROYER_SHADOW
Shadow of the aircraft.
Definition disaster_vehicle.h:29
ST_BIG_UFO_DESTROYER
@ ST_BIG_UFO_DESTROYER
Aircraft the will bomb the big UFO.
Definition disaster_vehicle.h:28
ST_BIG_SUBMARINE
@ ST_BIG_SUBMARINE
Big submarine, pops up in the oceans but doesn't do anything.
Definition disaster_vehicle.h:31
ST_SMALL_SUBMARINE
@ ST_SMALL_SUBMARINE
Small submarine, pops up in the oceans but doesn't do anything.
Definition disaster_vehicle.h:30
ST_HELICOPTER
@ ST_HELICOPTER
Helicopter destroying a factory.
Definition disaster_vehicle.h:23
ST_AIRPLANE
@ ST_AIRPLANE
Airplane destroying an oil refinery.
Definition disaster_vehicle.h:21
ST_HELICOPTER_ROTORS
@ ST_HELICOPTER_ROTORS
Rotors of helicopter.
Definition disaster_vehicle.h:25
ST_AIRPLANE_SHADOW
@ ST_AIRPLANE_SHADOW
Shadow of airplane.
Definition disaster_vehicle.h:22
SpriteID
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
DisasterVehicle
Disasters, like submarines, skyrangers and their shadows, belong to this class.
Definition disaster_vehicle.h:37
DisasterVehicle::UpdateDeltaXY
void UpdateDeltaXY() override
Updates the x and y offsets and the size of the sprite used for this vehicle.
Definition disaster_vehicle.cpp:997
DisasterVehicle::image_override
SpriteID image_override
Override for the default disaster vehicle sprite.
Definition disaster_vehicle.h:38
DisasterVehicle::DisasterVehicle
DisasterVehicle()
For use by saveload.
Definition disaster_vehicle.h:44
DisasterVehicle::~DisasterVehicle
virtual ~DisasterVehicle()=default
We want to 'destruct' the right class.
DisasterVehicle::big_ufo_destroyer_target
VehicleID big_ufo_destroyer_target
The big UFO that this destroyer is supposed to bomb.
Definition disaster_vehicle.h:39
DisasterVehicle::Tick
bool Tick() override
Calls the tick handler of the vehicle.
Definition disaster_vehicle.cpp:720
DisasterVehicle::flags
uint8_t flags
Flags about the state of the vehicle,.
Definition disaster_vehicle.h:40
DisasterVehicle::state
uint16_t state
Action stage of the disaster vehicle.
Definition disaster_vehicle.h:41
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF >
SpecializedVehicle
Class defining several overloaded accessors so we don't have to cast vehicle types that often.
Definition vehicle_base.h:1014
Vehicle::direction
Direction direction
facing
Definition vehicle_base.h:268
Vehicle::subtype
uint8_t subtype
subtype (Filled with values from AircraftSubType/DisasterSubType/EffectVehicleType/GroundVehicleSubty...
Definition vehicle_base.h:310
Vehicle::UpdatePosition
void UpdatePosition()
Update the position of the vehicle.
Definition vehicle.cpp:1662
vehicle_base.h
Base class for all vehicles.