OpenMoHAA 0.82.1
Loading...
Searching...
No Matches
worldspawn.h
1/*
2===========================================================================
3Copyright (C) 2015 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// world.h: Global world information (fog and such).
24
25#pragma once
26
27#if defined(CGAME_DLL)
28# include "../cgame_hook/script/centity.h"
29#elif defined(GAME_DLL)
30# include "entity.h"
31#else
32# include "glb_local.h"
33# include "simpleentity.h"
34#endif
35
36#include "gamescript.h"
37
38#define WORLD_CINEMATIC 1
39
40typedef Container<SafePtr<SimpleEntity>> ConSimple;
41
42class TargetList : public Class
43{
44public:
45 CLASS_PROTOTYPE(TargetList);
46
47public:
48 ConSimple list;
49 str targetname;
50
51public:
52 TargetList();
53 TargetList(const str& tname);
54
55 void AddEntity(Listener *ent);
56 void AddEntityAt(Listener *ent, int i);
57 int GetEntityIndex(Listener *ent);
58 void RemoveEntity(Listener *ent);
59 SimpleEntity *GetNextEntity(SimpleEntity *ent);
60};
61
62template<>
63class con_set_Entry<const_str, ConSimple>
64{
67
68private:
69 con_set_Entry *next;
70
71public:
72 const_str key;
73 ConSimple value;
74
75public:
76 void *operator new(size_t size) { return con_set<const_str, ConSimple>::NewEntry(size); }
77
78 void operator delete(void *ptr) { con_set<const_str, ConSimple>::DeleteEntry(ptr); }
79
80 void Archive(Archiver& arc)
81 {
82 int num;
83
84 arc.ArchiveUnsigned(&key);
85 arc.ArchiveObjectPosition((LightClass *)&value);
86
87 if (arc.Loading()) {
88 arc.ArchiveInteger(&num);
89 value.Resize(num);
90 } else {
91 num = value.NumObjects();
92 arc.ArchiveInteger(&num);
93 }
94 }
95
96 const_str& GetKey() { return key; }
97
98 void SetKey(const const_str& newKey) { key = newKey; }
99};
100
101class World : public Entity
102{
103 Container<TargetList *> m_targetListContainer;
104 qboolean world_dying;
105 Vector bounds[2];
106
107public:
108 // farplane variables
109 float farplane_distance;
110 float farplane_bias;
111 Vector farplane_color;
112 qboolean farplane_cull;
113 float skybox_farplane;
114 qboolean render_terrain;
115 float skybox_speed;
116 float farclip_override;
117 Vector farplane_color_override;
118 float animated_farplane_start;
119 float animated_farplane_end;
120 float animated_farplane_start_z;
121 float animated_farplane_end_z;
122 float animated_farplane_bias_start;
123 float animated_farplane_bias_end;
124 float animated_farplane_bias_start_z;
125 float animated_farplane_bias_end_z;
126 Vector animated_farplane_color_start;
127 Vector animated_farplane_color_end;
128 float animated_farplane_color_start_z;
129 float animated_farplane_color_end_z;
130
131 // sky variables
132 float sky_alpha;
133 qboolean sky_portal;
134
135 // orientation variables
136 float m_fAIVisionDistance;
137 float m_fNorth;
138
139 float radius;
140
141public:
142 CLASS_PROTOTYPE(World);
143
144 World();
145 ~World();
146
147 void AddTargetEntity(SimpleEntity *ent);
148 void AddTargetEntityAt(SimpleEntity *ent, int index);
149 void RemoveTargetEntity(SimpleEntity *ent);
150
151 void FreeTargetList();
152
153 SimpleEntity *GetNextEntity(str targetname, SimpleEntity *ent);
154 Listener *GetScriptTarget(str targetname);
155 Listener *GetTarget(str targetname, bool quiet);
156 int GetTargetnameIndex(SimpleEntity *ent);
157
158 TargetList *GetExistingTargetList(const str& targetname);
159 TargetList *GetTargetList(str& targetname);
160
161 void SetFarClipOverride(Event *ev);
162 void SetFarPlaneColorOverride(Event *ev);
163 void SetSoundtrack(Event *ev);
164 void SetGravity(Event *ev);
165 void SetNextMap(Event *ev);
166 void SetMessage(Event *ev);
167 void SetWaterColor(Event *ev);
168 void SetWaterAlpha(Event *ev);
169 void SetLavaColor(Event *ev);
170 void SetLavaAlpha(Event *ev);
171 void GetFarPlane_Color(Event *ev);
172 void SetFarPlane_Color(Event *ev);
173 void GetFarPlaneBias(Event *ev);
174 void SetFarPlaneBias(Event *ev);
175 void SetFarPlane_Cull(Event *ev);
176 void GetSkyboxFarplane(Event *ev);
177 void SetSkyboxFarplane(Event *ev);
178 void SetAnimatedFarplaneColor(Event *ev);
179 void SetAnimatedFarplane(Event *ev);
180 void SetAnimatedFarplaneBias(Event *ev);
181 void UpdateAnimatedFarplane(Event *ev);
182 void GetRenderTerrain(Event *ev);
183 void SetRenderTerrain(Event *ev);
184 void GetSkyboxSpeed(Event *ev);
185 void SetSkyboxSpeed(Event *ev);
186 void GetFarPlane(Event *ev);
187 void SetFarPlane(Event *ev);
188 void SetSkyAlpha(Event *ev);
189 void SetSkyPortal(Event *ev);
190 void SetNumArenas(Event *ev);
191 void SetAIVisionDistance(Event *ev);
192 void SetNorthYaw(Event *ev);
193 void UpdateConfigStrings(void);
194 void UpdateFog(void);
195 void UpdateSky(void);
196
197 void Archive(Archiver& arc) override;
198
199public:
200 const Vector& GetMinBounds() const;
201 const Vector& GetMaxBounds() const;
202 float GetRadius() const;
203};
204
205typedef SafePtr<World> WorldPtr;
206extern WorldPtr world;
207
208bool WithinFarplaneDistance(const Vector& org);
Definition archive.h:86
Definition container.h:85
Definition listener.h:246
Definition lightclass.h:30
Definition listener.h:450
Definition safeptr.h:160
Definition simpleentity.h:42
Definition worldspawn.h:43
Definition vector.h:61
Definition con_set.h:462
Definition con_set.h:119
Definition str.h:77