Line data Source code
1 : #ifndef EAE8DB08_087C_4EC5_AF13_54AECCF72615_HPP 2 : #define EAE8DB08_087C_4EC5_AF13_54AECCF72615_HPP 3 : 4 : #include "DiscType.hpp" 5 : #include "PhysicalObject.hpp" 6 : #include "Vector2d.hpp" 7 : 8 : #include <SFML/System/Vector2.hpp> 9 : 10 : namespace cell 11 : { 12 : 13 : /** 14 : * @brief Represents a particle in the simulation that can collide with others and undergo reactions. Physical 15 : * properties are defined by its DiscType 16 : */ 17 : class Disc : public PhysicalObject 18 : { 19 : public: 20 : /** 21 : * @brief Creates a new disc with the given type 22 : */ 23 329 : explicit Disc(DiscTypeID discTypeID) noexcept 24 329 : : discTypeID_(discTypeID) 25 : { 26 329 : } 27 : 28 : /** 29 : * @brief Assigns a new disc type (no checks) 30 : */ 31 4 : void setType(DiscTypeID discTypeID) noexcept 32 : { 33 4 : discTypeID_ = discTypeID; 34 4 : } 35 : 36 : /** 37 : * @brief Sets the internal destroyed flag (used for removing discs in the simulation) 38 : */ 39 14 : void markDestroyed() noexcept 40 : { 41 14 : destroyed_ = true; 42 14 : } 43 : 44 : /** 45 : * @returns DiscType of the disc 46 : */ 47 720 : DiscTypeID getTypeID() const noexcept 48 : { 49 720 : return discTypeID_; 50 : } 51 : 52 : /** 53 : * @returns `true` if `markDestroyed()` has been called 54 : */ 55 62 : bool isMarkedDestroyed() const noexcept 56 : { 57 62 : return destroyed_; 58 : } 59 : 60 : private: 61 : /** 62 : * @brief Reactions of type A + B -> C require B to be removed (A can be changed to C). This flag 63 : * is set during the reaction processing and the world removed flagged discs after the update step 64 : */ 65 : bool destroyed_ = false; 66 : 67 : /** 68 : * @brief The properties of this disc (mass, radius, ...) 69 : */ 70 : DiscTypeID discTypeID_; 71 : }; 72 : 73 : } // namespace cell 74 : 75 : #endif /* EAE8DB08_087C_4EC5_AF13_54AECCF72615_HPP */