source: cpp/frams/genetics/geneprops.h @ 759

Last change on this file since 759 was 759, checked in by Maciej Komosinski, 6 years ago

f1 and f4 stick properties unified and moved to a separate structure and file (geneprops.cpp/h)

File size: 3.8 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#ifndef _GENEPROPS_H
6#define _GENEPROPS_H
7
8#include <common/nonstd_math.h>
9#include <frams/model/model.h>
10
11/**
12 * Contains physical, biological and other properties of
13 * stick, except for rotation. The constructor initializes properties of sticks with
14 * default values. In order to change a property of a stick, the executeModifier() method
15 * should be called. Modification of length, curvedness and twist properties
16 * usually affects further sticks, so new sticks should have properties of
17 * parents (prop) modified with the prop.propagateAlong() method.
18 * "Biological" properties (assimilation, stamina, muscle strength and
19 * ingestion) should be normalized after modification with normalizeBiol4().
20 */
21struct GeneProps
22{
23public:
24        double length;            ///<incremented by L, decremented by l. Physical property, length of stick
25        double curvedness;        ///<incremented by C, decremented by c. Curvedness of sticks
26        double weight;            ///<incremented by W, decremented by w. Physical property, weight of stick (in water environment light sticks swim on the surface)
27        double friction;          ///<incremented by F, decremented by f. Physical property, friction of a stick (sticks will slide on the ground or stick to it)
28
29        double muscle_power;      ///<incremented by M, decremented by m. Biological property, muscle strength (muscle speed). Strong muscles act with bigger force, gain higher speed, can resist bigger stress, and use more energy
30        double assimilation;      ///<incremented by A, decremented by a. Biological property, assimilation, photosynthesis (a vertical stick can assimilate twice as much as horizontal one)
31        double stamina;           ///<incremented by S, decremented by s. Biological property, stamina (increases chance of survival during fights)
32        double ingestion;         ///<incremented by I, decremented by i. Biological property, ingestion (ability to gain energy from food)
33
34        double twist;             ///<incremented by Q, decremented by q. Twist of a stick
35        double energy;            ///<incremented by E, decremented by e. Energy of a creature
36
37        double muscle_bend_range; ///<Used only by conv_f1
38        bool muscle_reset_range;  ///<Used only by conv_f1
39
40        double visual_size;       ///<incremented by H, decremented by h. Part's visual size, only affects appearance
41        double cred;              ///<incremented by D, decremented by d. Part's red color proportion
42        double cgreen;            ///<incremented by B, decremented by b. Part's blue color proportion
43        double cblue;             ///<incremented by G, decremented by g. Part's green color proportion
44
45        static GeneProps standard_values;
46
47        /**
48         * Constructor initializing all properties with default values.
49         */
50        GeneProps();
51
52        /**
53         * Normalizes biological properties (muscle_power,
54         * assimilation, stamina, and ingestion). This method is called in
55         * executeModifier() when any of the biological properties is modified. All values
56         * of those properties sum up to 1.
57         */
58        void normalizeBiol4();
59
60        /**
61         * Checks whether the given character is property modifier. If yes, the property
62         * is modified and properties are normalized when needed.
63         * @param modif character that might be a property modifier
64         * @return 0 if the provided character was property modifier, -1 otherwise
65         */
66        int executeModifier(char modif);
67
68        /**
69         * Adjusts current properties for the next stick. In order to set
70         * new properties to the created stick, the copy of the previous stick should be created,
71         * and propagateAlong() should be used for that copy.
72         * @param use_reset_range true if this method should modify muscle_bend_range (used in f1 conversion).
73         */
74        void propagateAlong(bool use_f1_muscle_reset_range);
75};
76
77#endif // _GENEPROPS_H
Note: See TracBrowser for help on using the repository browser.