freg  0.3
Free-Roaming Elementary Game
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Animal.h
Go to the documentation of this file.
1  /* freg, Free-Roaming Elementary Game with open and interactive world
2  * Copyright (C) 2012-2014 Alexander 'mmaulwurff' Kromm
3  * mmaulwurff@gmail.com
4  *
5  * This file is part of FREG.
6  *
7  * FREG is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * FREG 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 General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with FREG. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #ifndef ANIMAL_H
21 #define ANIMAL_H
22 
23 #include "blocks/Active.h"
24 
25 class DeferredAction;
26 
27 class Animal : public Falling {
28  Q_OBJECT
29 public:
30  Animal(int sub, int id);
31  Animal(QDataStream & str, int sub, int id);
32  ~Animal();
33 
34  int DamageKind() const override;
35  int ShouldAct() const override;
36  void ActFrequent() override;
37  void DoRareAction() override;
38  bool Eat(subs);
39  int Breath() const;
40  int Satiation() const;
41  QString FullName() const override = 0;
42  Animal * IsAnimal() override;
43  Block * DropAfterDamage(bool * delete_block) override;
44  inner_actions ActInner() override;
45 
47 
48 protected:
49  void SaveAttributes(QDataStream & out) const override;
50  void EatGrass();
51 
52  bool moved_in_this_turn = false;
53 
54 private:
55  Animal(Animal &) = delete;
56  Animal & operator=(Animal &) = delete;
57  virtual int NutritionalValue(subs) const;
58 
59  quint8 breath;
60  quint16 satiation;
62 }; // class Animal
63 
64 class Predator : public Animal {
65  Q_OBJECT
66 public:
67  using Animal::Animal;
68 
69  int DamageLevel() const override;
70  void ActFrequent() override;
71  QString FullName() const override;
72 
73 protected:
74  void DoRareAction() override;
75  int Attractive(int sub) const override;
76 
77 private:
78  int NutritionalValue(subs) const override;
79 }; // class Predator
80 
81 #endif // ANIMAL_H
int Satiation() const
Definition: Animal.cpp:66
void ActFrequent() override
Definition: Animal.cpp:143
void DoRareAction() override
Definition: Animal.cpp:149
void DoRareAction() override
Definition: Animal.cpp:47
void EatGrass()
Definition: Animal.cpp:92
Block * DropAfterDamage(bool *delete_block) override
Should return dropped block.
Definition: Animal.cpp:105
void SaveAttributes(QDataStream &out) const override
Definition: Animal.cpp:87
Deferred Action is used when some action needs to be done at next physics turn.
QString FullName() const override
Definition: Animal.cpp:137
int DamageKind() const override
Definition: Animal.cpp:68
quint8 breath
Definition: Animal.h:59
DeferredAction * deferredAction
Definition: Animal.h:61
void SetDeferredAction(DeferredAction *)
Definition: Animal.cpp:111
inner_actions
See Shred::PhysEventsRare() for details.
Definition: Active.h:36
bool moved_in_this_turn
Definition: Animal.h:52
int Attractive(int sub) const override
Definition: Animal.cpp:176
Definition: Animal.h:27
inner_actions ActInner() override
Definition: Animal.cpp:27
Animal(int sub, int id)
Definition: Animal.cpp:116
int Breath() const
Definition: Animal.cpp:65
subs
Substance block is made from.
Definition: header.h:157
int ShouldAct() const override
Definition: Animal.cpp:67
Animal * IsAnimal() override
Definition: Animal.cpp:70
const quint8 sub
Definition: Block.h:177
~Animal()
Definition: Animal.cpp:130
QString FullName() const override=0
int NutritionalValue(subs) const override
Definition: Animal.cpp:139
bool Eat(subs)
Definition: Animal.cpp:72
void ActFrequent() override
Definition: Animal.cpp:39
int DamageLevel() const override
Definition: Animal.cpp:136
Block without special physics and attributes.
Definition: Block.h:89
quint16 satiation
Definition: Animal.h:60
Animal & operator=(Animal &)=delete
virtual int NutritionalValue(subs) const
Definition: Animal.cpp:69