1 // 2 // Copyright (C) 2009-2010 Nick Gasson 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 // 17 18 #ifndef INC_IROLLING_STOCK_HPP 19 #define INC_IROLLING_STOCK_HPP 20 21 #include "Platform.hpp" 22 #include "IController.hpp" 23 #include "Maths.hpp" 24 #include "ICargo.hpp" 25 26 // Interface for various powered and unpowered parts of the train 27 struct IRollingStock { ~IRollingStockIRollingStock28 virtual ~IRollingStock() {} 29 30 // Update speed, fuel, etc. 31 virtual void update(int delta, double gravity) = 0; 32 33 // Display the model 34 virtual void render() const = 0; 35 36 // Return the controller for this vehicle (if it has one) 37 virtual IControllerPtr controller() = 0; 38 39 // Return the speed of the vehicle 40 virtual double speed() const = 0; 41 42 // Return the length of the vehicle in game units 43 virtual float length() const = 0; 44 45 // Return the mass of the vehicle in tons 46 virtual double mass() const = 0; 47 48 // The cargo currently carried, if any 49 virtual ICargoPtr cargo() const = 0; 50 }; 51 52 typedef shared_ptr<IRollingStock> IRollingStockPtr; 53 54 // Make various waggons and engines 55 IRollingStockPtr load_engine(const string& a_res_id); 56 IRollingStockPtr load_waggon(const string& a_res_id); 57 58 #endif 59