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