OpenMoHAA 0.82.0
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 {
43public:
44 CLASS_PROTOTYPE(TargetList);
45
46public:
47 ConSimple list;
48 str targetname;
49
50public:
51 TargetList();
52 TargetList(const str& tname);
53
54 void AddEntity(Listener* ent);
55 void AddEntityAt(Listener* ent, int i);
56 int GetEntityIndex(Listener* ent);
57 void RemoveEntity(Listener* ent);
58 SimpleEntity* GetNextEntity(SimpleEntity* ent);
59};
60
61template<>
62class con_set_Entry<const_str, ConSimple>
63{
66
67private:
68 con_set_Entry *next;
69
70public:
71 const_str key;
72 ConSimple value;
73
74public:
75 void *operator new(size_t size) { return con_set<const_str, ConSimple>::NewEntry(size); }
76
77 void operator delete(void *ptr) { con_set<const_str, ConSimple>::DeleteEntry(ptr); }
78
79 void Archive(Archiver& arc) {
80 int num;
81
82 arc.ArchiveUnsigned(&key);
83 arc.ArchiveObjectPosition((LightClass*)&value);
84
85 if (arc.Loading()) {
86 arc.ArchiveInteger(&num);
87 value.Resize(num);
88 } else {
89 num = value.NumObjects();
90 arc.ArchiveInteger(&num);
91 }
92 }
93 const_str& GetKey() { return key; }
94
95 void SetKey(const const_str& newKey) { key = newKey; }
96};
97
98class World : public Entity
99{
100 Container<TargetList*> m_targetListContainer;
101 qboolean world_dying;
102
103public:
104 // farplane variables
105 float farplane_distance;
106 float farplane_bias;
107 Vector farplane_color;
108 qboolean farplane_cull;
109 float skybox_farplane;
110 qboolean render_terrain;
111 float skybox_speed;
112 float farclip_override;
113 Vector farplane_color_override;
114 float animated_farplane_start;
115 float animated_farplane_end;
116 float animated_farplane_start_z;
117 float animated_farplane_end_z;
118 float animated_farplane_bias_start;
119 float animated_farplane_bias_end;
120 float animated_farplane_bias_start_z;
121 float animated_farplane_bias_end_z;
122 Vector animated_farplane_color_start;
123 Vector animated_farplane_color_end;
124 float animated_farplane_color_start_z;
125 float animated_farplane_color_end_z;
126
127 // sky variables
128 float sky_alpha;
129 qboolean sky_portal;
130
131 // orientation variables
132 float m_fAIVisionDistance;
133 float m_fNorth;
134
135public:
136 CLASS_PROTOTYPE(World);
137
138 World();
139 ~World();
140
141 void AddTargetEntity(SimpleEntity *ent);
142 void AddTargetEntityAt(SimpleEntity *ent, int index);
143 void RemoveTargetEntity(SimpleEntity *ent);
144
145 void FreeTargetList();
146
147 SimpleEntity *GetNextEntity(str targetname, SimpleEntity *ent);
148 Listener *GetScriptTarget(str targetname);
149 Listener *GetTarget(str targetname, bool quiet);
150 int GetTargetnameIndex(SimpleEntity *ent);
151
152 TargetList *GetExistingTargetList(const str& targetname);
153 TargetList *GetTargetList(str& targetname);
154
155 void SetFarClipOverride(Event *ev);
156 void SetFarPlaneColorOverride(Event *ev);
157 void SetSoundtrack(Event *ev);
158 void SetGravity(Event *ev);
159 void SetNextMap(Event *ev);
160 void SetMessage(Event *ev);
161 void SetWaterColor(Event *ev);
162 void SetWaterAlpha(Event *ev);
163 void SetLavaColor(Event *ev);
164 void SetLavaAlpha(Event *ev);
165 void GetFarPlane_Color(Event *ev);
166 void SetFarPlane_Color(Event *ev);
167 void GetFarPlaneBias(Event *ev);
168 void SetFarPlaneBias(Event *ev);
169 void SetFarPlane_Cull(Event *ev);
170 void GetSkyboxFarplane(Event *ev);
171 void SetSkyboxFarplane(Event *ev);
172 void SetAnimatedFarplaneColor(Event *ev);
173 void SetAnimatedFarplane(Event *ev);
174 void SetAnimatedFarplaneBias(Event *ev);
175 void UpdateAnimatedFarplane(Event *ev);
176 void GetRenderTerrain(Event *ev);
177 void SetRenderTerrain(Event *ev);
178 void GetSkyboxSpeed(Event *ev);
179 void SetSkyboxSpeed(Event *ev);
180 void GetFarPlane(Event *ev);
181 void SetFarPlane(Event *ev);
182 void SetSkyAlpha(Event *ev);
183 void SetSkyPortal(Event *ev);
184 void SetNumArenas(Event *ev);
185 void SetAIVisionDistance(Event *ev);
186 void SetNorthYaw(Event *ev);
187 void UpdateConfigStrings(void);
188 void UpdateFog(void);
189 void UpdateSky(void);
190
191 void Archive(Archiver& arc) override;
192};
193
194typedef SafePtr<World> WorldPtr;
195extern WorldPtr world;
196
197bool 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:42
Definition vector.h:61
Definition con_set.h:462
Definition con_set.h:119
Definition str.h:77