tweak C1-era CARR
[openc2e.git] / World.h
blob1259a180d3f013366db33b8682ed346b97636a27
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 std::list<std::pair<boost::shared_ptr<class AudioSource>, bool> > uncontrolled_sounds; // audio, followingviewport
54 std::map<int, boost::weak_ptr<Agent> > unidmap;
55 std::vector<caosVM *> vmpool;
57 public:
58 bool quitting, saving, paused;
60 Map map;
62 std::multiset<CompoundPart *, partzorder> zorder; // sorted from top to bottom
63 std::multiset<renderable *, renderablezorder> renders; // sorted from bottom to top
64 std::list<boost::shared_ptr<Agent> > agents;
66 std::map<unsigned int, std::map<unsigned int, cainfo> > carates;
67 std::map<std::string, caosVar> variables;
69 std::vector<boost::filesystem::path> data_directories;
70 Scriptorium scriptorium;
71 prayManager praymanager;
72 imageManager gallery;
73 historyManager history;
75 std::string gametype;
76 float pace;
77 unsigned int race;
78 unsigned int ticktime, tickcount;
79 unsigned int worldtickcount;
80 unsigned int timeofday, dayofseason, season, year;
81 MainCamera camera;
82 bool showrooms, autokill, autostop;
84 AgentRef selectedcreature;
85 void selectCreature(boost::shared_ptr<Agent> c);
86 AgentRef focusagent; unsigned int focuspart;
87 void setFocus(class TextEntryPart *p);
89 Agent *agentAt(unsigned int x, unsigned int y, bool obey_all_transparency = true, bool needs_mouseable = false);
90 CompoundPart *partAt(unsigned int x, unsigned int y, bool obey_all_transparency = true, bool needs_mouseable = false);
91 class PointerAgent *hand() { return theHand; }
93 caosVM *getVM(Agent *owner);
94 void freeVM(caosVM *);
95 void queueScript(unsigned short event, AgentRef agent, AgentRef from = AgentRef(), caosVar p0 = caosVar(), caosVar p1 = caosVar());
97 World();
98 ~World();
99 void init();
100 void initCatalogue();
101 void shutdown();
103 void executeInitScript(boost::filesystem::path p);
104 void executeBootstrap(boost::filesystem::path p);
105 void executeBootstrap(bool switcher);
107 std::string getUserDataDir();
108 std::string findFile(std::string path);
109 std::vector<std::string> findFiles(std::string dir, std::string wild);
111 boost::shared_ptr<AudioSource> playAudio(std::string filename, AgentRef agent, bool controlled, bool loop, bool followviewport = false);
113 void newMoniker(shared_ptr<genomeFile> g, std::string genefile, AgentRef agent);
114 shared_ptr<genomeFile> loadGenome(std::string &filename);
115 std::string generateMoniker(std::string basename);
117 int findCategory(unsigned char family, unsigned char genus, unsigned short species);
119 void tick();
120 void drawWorld();
121 void drawWorld(Camera *cam, Surface *surface);
123 int newUNID(Agent *whofor);
124 void setUNID(Agent *whofor, int unid);
125 void freeUNID(int unid);
127 shared_ptr<Agent> lookupUNID(int unid);
130 extern World world;
131 #endif
132 /* vim: set noet: */