1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
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/>.
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"
51 /** A village in a continent.
52 * This class holds a village instance group, and manage its loading / unloading.
54 class CVillage
: public IStreamableEntity
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
);
75 //\name From IStreamableEntity
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();
90 // The scene in which this object is inserted
91 NL3D::UScene
*getScene() const { return _Scene
; }
93 ///\name ig added observers
95 void registerObserver(IIGObserver
*obs
);
96 void removeObserver(IIGObserver
*obs
);
97 bool isObserver(IIGObserver
*obs
) const;
101 bool enumIGs(IIGEnum
*callback
);
103 const CStreamableIG
&getIG() const { return _IG
; }
105 ///\name Special Outpost
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
113 // remove the outpost from 3D
114 void removeOutpost ();
115 // Is this village an outpost?
116 bool isOutpost() const {return _IsOutpost
;}
119 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
121 // TODO: if slow, make the pos test only once for all IGs...
123 NL3D::UScene
*_Scene
;
132 NLMISC::CSheetId CurrentSheetId
;
133 NLMISC::CVector Position
;
134 NLMISC::CQuat Rotation
;
137 Position
= NLMISC::CVector::Null
;
138 Rotation
= NLMISC::CQuat::Identity
;
142 CBuilding _Buildings
[RZ_MAX_BUILDING_PER_OUTPOST
];
143 void updateBuilding(uint building
, NLMISC::CSheetId newForm
);