Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / village.h
blob0ec4343a692bc2905fc198c5f7020e87fd940a2b
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #ifndef CL_VILLAGE_H
26 #define CL_VILLAGE_H
29 #include "nel/misc/types_nl.h"
30 #include "streamable_ig.h"
31 #include "nel/misc/cdb.h"
32 #include "client_sheets/continent_sheet.h"
33 #include "game_share/misc_const.h"
34 #include <vector>
36 namespace NL3D
38 class UScene;
41 namespace NLGEORGES
43 class UFormElm;
46 struct IIGAdded;
49 struct CVillageSheet;
51 /** A village in a continent.
52 * This class holds a village instance group, and manage its loading / unloading.
54 class CVillage : public IStreamableEntity
56 public:
57 //\name Object
58 //@{
59 // ctor
60 CVillage();
61 // setup the village from a sheet
62 /** Build that village from an external script.
63 * And insert in the given scene
64 * \param scene The scene in which this village is
65 * \param sheet Sheet describing the village
66 * \param loadedIGMap If not NULL, a map that will be filled with ig that are currently loaded
67 * \return true if the build succeed
69 bool setupFromSheet(NL3D::UScene *scene, const CVillageSheet &sheet, CStreamableIG::TString2IG *loadedIGMap = NULL);
71 // dtor
72 ~CVillage();
73 //@}
75 //\name From IStreamableEntity
76 //@{
77 /** Given a pos, test whether the village needs to be loaded now.
78 * It it returns false, it means that the village is too far or that asynchronous loading suffice.
79 * It it returns true, the next call to update will return only when the loading is completed.
81 virtual bool needCompleteLoading(const NLMISC::CVector &pos) const;
82 /** Test that village against the player position, and load / unload it (using synchronous or asynchronous loading)
84 virtual void update(const NLMISC::CVector &pos);
85 // The same, but force synchronous loading
86 virtual void forceUpdate(const NLMISC::CVector &pos, NLMISC::IProgressCallback &progress);
87 virtual void forceUnload();
88 //@}
90 // The scene in which this object is inserted
91 NL3D::UScene *getScene() const { return _Scene; }
93 ///\name ig added observers
94 //@{
95 void registerObserver(IIGObserver *obs);
96 void removeObserver(IIGObserver *obs);
97 bool isObserver(IIGObserver *obs) const;
98 //@}
100 // ig enumeration
101 bool enumIGs(IIGEnum *callback);
103 const CStreamableIG &getIG() const { return _IG; }
105 ///\name Special Outpost
106 //@{
107 // setup the village as an Outpost (similar to setupFromSheet())
108 bool setupOutpost(NL3D::UScene *scene, const CContinentParameters::CZC &zone, sint32 outpost, CStreamableIG::TString2IG *loadedIGMap);
109 // setup a building pos in this village
110 void setBuildingPosition (uint building, const NLMISC::CQuat &rot, const NLMISC::CVector &pos);
111 // after outpost and building position setuped, can init the outpost into 3D
112 void initOutpost ();
113 // remove the outpost from 3D
114 void removeOutpost ();
115 // Is this village an outpost?
116 bool isOutpost() const {return _IsOutpost;}
117 //@}
119 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
120 private:
121 // TODO: if slow, make the pos test only once for all IGs...
122 CStreamableIG _IG;
123 NL3D::UScene *_Scene;
125 ///\name Outpost
126 // @{
127 bool _IsOutpost;
128 class CBuilding
130 public:
131 uint Id;
132 NLMISC::CSheetId CurrentSheetId;
133 NLMISC::CVector Position;
134 NLMISC::CQuat Rotation;
135 CBuilding()
137 Position= NLMISC::CVector::Null;
138 Rotation= NLMISC::CQuat::Identity;
139 Id= -1;
142 CBuilding _Buildings[RZ_MAX_BUILDING_PER_OUTPOST];
143 void updateBuilding(uint building, NLMISC::CSheetId newForm);
144 // @}
149 #endif