3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef NODETIMER_HEADER
21 #define NODETIMER_HEADER
23 #include "irrlichttypes_bloated.h"
28 NodeTimer provides per-node timed callback functionality.
30 - Furnaces, to keep the fire burnin'
31 - "activated" nodes that snap back to their original state
32 after a fixed amount of time (mesecons buttons, for example)
38 NodeTimer(): timeout(0.), elapsed(0.) {}
39 NodeTimer(f32 timeout_, f32 elapsed_):
40 timeout(timeout_), elapsed(elapsed_) {}
43 void serialize(std::ostream &os) const;
44 void deSerialize(std::istream &is);
51 List of timers of all the nodes of a block
60 void serialize(std::ostream &os, u8 map_format_version) const;
61 void deSerialize(std::istream &is, u8 map_format_version);
64 NodeTimer get(v3s16 p){
65 std::map<v3s16, NodeTimer>::iterator n = m_data.find(p);
74 // Deletes old timer and sets a new one
75 void set(v3s16 p, NodeTimer t){
83 // A step in time. Returns map of elapsed timers.
84 std::map<v3s16, NodeTimer> step(float dtime);
87 std::map<v3s16, NodeTimer> m_data;