1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CL_FLORA_SHEET_H
20 #define CL_FLORA_SHEET_H
22 #include "plant_sheet.h"
24 /** Infos about a .plant contained in a .flora
30 std::string SheetName
;
32 uint64 CumulatedWeight
; // for sorting by weights
34 virtual void build(const NLGEORGES::UFormElm
&item
);
35 virtual void serial(NLMISC::IStream
&f
);
37 inline bool operator < (const CPlantInfo
&lhs
, const CPlantInfo
&rhs
)
39 return lhs
.CumulatedWeight
< rhs
.CumulatedWeight
;
43 /** Info about flora, read from a .flora sheet
46 class CFloraSheet
: public CEntitySheet
49 float MicroLifeThreshold
; // 0 -> every tile has micro-life > 1 -> no tile has micro-life
53 /// Build the sheet from an external script.
54 virtual void build(const NLGEORGES::UFormElm
&item
);
55 /// Serialize plant sheet into binary data file.
56 virtual void serial(NLMISC::IStream
&f
);
57 // Get total weight of plant infos
58 uint64
getPlantInfoTotalWeight() const { return _TotalWeight
; }
59 /** Get plant info from weighted index
61 * e.g : we have 3 .plant in the .flora:
62 * .plant a.plant, weighted 4
63 * .plant b.plant, weighted 2
64 * .plant c.plant, weighted 1
66 * getPlantInfoWeight(0) -> a.plant
67 * getPlantInfoWeight(1) -> a.plant
68 * getPlantInfoWeight(2) -> a.plant
69 * getPlantInfoWeight(3) -> a.plant (4 occurences)
70 * getPlantInfoWeight(4) -> b.plant
71 * getPlantInfoWeight(5) -> b.plant (2 occurences)
72 * getPlantInfoWeight(6) -> c.plant (1 occurences)
75 const CPlantInfo
*getPlantInfoFromWeightedIndex(uint64 index
) const;
77 uint
getNumPlantInfos() const { return (uint
)_Plants
.size(); }
78 const CPlantInfo
&getPlantInfo(uint index
) const { return _Plants
[index
]; }
80 std::vector
<CPlantInfo
> _Plants
;