* move imageManager code into new imageManager.h/imageManager.cpp
[openc2e.git] / World.h
blobdef9debe1a174b50be9e7f053208f5431db7c990
1 /*
2 * World.h
3 * openc2e
5 * Created by Alyssa Milburn on Tue May 25 2004.
6 * Copyright (c) 2004 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #ifndef _WORLD_H
21 #define _WORLD_H
23 #include "Map.h"
24 #include "Scriptorium.h"
25 #include "Camera.h"
26 #include "Agent.h"
27 #include "CompoundPart.h"
28 #include "prayManager.h"
29 #include "historyManager.h"
30 #include "imageManager.h"
31 #include <set>
32 #include <map>
33 #include <boost/filesystem/path.hpp>
35 struct cainfo {
36 float gain;
37 float loss;
38 float diffusion;
41 struct scriptevent {
42 unsigned short scriptno;
43 AgentRef agent, from;
44 caosVar p[2];
47 class World {
48 protected:
49 class PointerAgent *theHand;
50 std::list<scriptevent> scriptqueue;
52 public:
53 bool quitting, saving, paused;
55 Map map;
57 std::list<boost::shared_ptr<class AudioSource> > uncontrolled_sounds;
58 std::multiset<CompoundPart *, partzorder> zorder; // sorted from top to bottom
59 std::multiset<renderable *, renderablezorder> renders; // sorted from bottom to top
60 std::list<boost::shared_ptr<Agent> > agents;
62 std::map<unsigned int, std::map<unsigned int, cainfo> > carates;
63 std::map<std::string, caosVar> variables;
64 std::vector<caosVM *> vmpool;
65 std::map<int, boost::weak_ptr<Agent> > unidmap;
67 std::vector<boost::filesystem::path> data_directories;
68 Scriptorium scriptorium;
69 prayManager praymanager;
70 imageManager gallery;
71 historyManager history;
73 std::string gametype;
74 float pace;
75 unsigned int race;
76 unsigned int ticktime, tickcount;
77 unsigned int worldtickcount;
78 unsigned int timeofday, dayofseason, season, year;
79 MainCamera camera;
80 bool showrooms, autokill, autostop;
82 AgentRef selectedcreature;
83 void selectCreature(boost::shared_ptr<Agent> c);
84 AgentRef focusagent; unsigned int focuspart;
85 void setFocus(class TextEntryPart *p);
87 Agent *agentAt(unsigned int x, unsigned int y, bool obey_all_transparency = true, bool needs_mouseable = false);
88 CompoundPart *partAt(unsigned int x, unsigned int y, bool obey_all_transparency = true, bool needs_mouseable = false);
89 class PointerAgent *hand() { return theHand; }
91 caosVM *getVM(Agent *owner);
92 void freeVM(caosVM *);
93 void queueScript(unsigned short event, AgentRef agent, AgentRef from = AgentRef(), caosVar p0 = caosVar(), caosVar p1 = caosVar());
95 World();
96 ~World();
97 void init();
98 void initCatalogue();
99 void shutdown();
101 void executeInitScript(boost::filesystem::path p);
102 void executeBootstrap(boost::filesystem::path p);
103 void executeBootstrap(bool switcher);
105 std::string getUserDataDir();
106 std::string findFile(std::string path);
107 std::vector<std::string> findFiles(std::string dir, std::string wild);
109 boost::shared_ptr<AudioSource> playAudio(std::string filename, AgentRef agent, bool controlled, bool loop);
111 void newMoniker(shared_ptr<genomeFile> g, std::string genefile, AgentRef agent);
112 shared_ptr<genomeFile> loadGenome(std::string &filename);
113 std::string generateMoniker(std::string basename);
115 int findCategory(unsigned char family, unsigned char genus, unsigned short species);
117 void tick();
118 void drawWorld();
119 void drawWorld(Camera *cam, Surface *surface);
121 int newUNID(Agent *whofor);
122 void setUNID(Agent *whofor, int unid);
123 void freeUNID(int unid);
125 shared_ptr<Agent> lookupUNID(int unid);
128 extern World world;
129 #endif
130 /* vim: set noet: */