1 #ifndef BLOBLS_CREATURE_COMPOSITION_HPP_
2 #define BLOBLS_CREATURE_COMPOSITION_HPP_
4 #include "../world/Set.hpp"
21 Component(int r, double v)
22 : resource(r), value(v) { }
29 Composition(const Composition &) = default;
30 Composition &operator =(const Composition &) = default;
32 Composition(Composition &&) = default;
33 Composition &operator =(Composition &&) = default;
36 void Add(int res, double amount);
37 bool Has(int res) const noexcept;
38 double Get(int res) const noexcept;
39 double Proportion(int res) const noexcept;
40 double Compatibility(const world::Set<world::Resource> &, int res) const noexcept;
41 double TotalMass() const noexcept { return total_mass; }
44 std::vector<Component>::size_type size() const noexcept { return components.size(); }
45 std::vector<Component>::iterator begin() noexcept { return components.begin(); }
46 std::vector<Component>::iterator end() noexcept { return components.end(); }
47 std::vector<Component>::const_iterator begin() const noexcept { return components.begin(); }
48 std::vector<Component>::const_iterator end() const noexcept { return components.end(); }
49 std::vector<Component>::const_iterator cbegin() noexcept { return components.cbegin(); }
50 std::vector<Component>::const_iterator cend() noexcept { return components.cend(); }
53 std::vector<Component> components;