1 /* Copyright (C) 2013-2014 Michal Brzozowski (rusolis@poczta.fm)
2 
3    This file is part of KeeperRL.
4 
5    KeeperRL is free software; you can redistribute it and/or modify it under the terms of the
6    GNU General Public License as published by the Free Software Foundation; either version 2
7    of the License, or (at your option) any later version.
8 
9    KeeperRL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10    even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11    GNU General Public License for more details.
12 
13    You should have received a copy of the GNU General Public License along with this program.
14    If not, see http://www.gnu.org/licenses/ . */
15 
16 #pragma once
17 
18 #include "util.h"
19 #include "entity_set.h"
20 #include "entity_map.h"
21 
22 class Creature;
23 
24 class TimeQueue {
25   public:
26   TimeQueue();
27   WCreature getNextCreature();
28   vector<WCreature> getAllCreatures() const;
29   void addCreature(PCreature, double time);
30   PCreature removeCreature(WCreature);
31   double getTime(WConstCreature);
32   void increaseTime(WCreature, double diff);
33 
34   template <class Archive>
35   void serialize(Archive& ar, const unsigned int version);
36 
37   private:
38   typedef set<WCreature, function<bool(WConstCreature, WConstCreature)>> Queue;
39   vector<PCreature> SERIAL(creatures);
40   Queue SERIAL(queue);
41   EntityMap<Creature, double> SERIAL(timeMap);
42 };
43 
44