]> git.jsancho.org Git - lugaru.git/commitdiff
Moved more animation info to PersonType
authorCôme Chilliet <come@chilliet.eu>
Sun, 5 Feb 2017 21:24:11 +0000 (22:24 +0100)
committerCôme Chilliet <come@chilliet.eu>
Sun, 5 Feb 2017 21:24:11 +0000 (22:24 +0100)
Source/Objects/Person.cpp
Source/Objects/Person.hpp

index c055e57b0f49a5a3e24fdb3af0461415d738e9f2..817ee03734268e777c76543571c2faa279e51c0b 100644 (file)
@@ -75,6 +75,16 @@ extern XYZ windvector;
 std::vector<std::shared_ptr<Person>> Person::players(1, std::shared_ptr<Person>(new Person()));
 std::vector<PersonType> PersonType::types;
 
+PersonType::PersonType()
+{
+    animTalkIdle = tempanim;
+}
+
+bool PersonType::hasAnimTalkIdle()
+{
+    return (animTalkIdle != tempanim);
+}
+
 void PersonType::Load()
 {
     types.resize(2);
@@ -91,6 +101,8 @@ void PersonType::Load()
     types[wolftype].animStop = wolfstopanim;
     types[wolftype].animLanding = wolflandanim;
     types[wolftype].animLandingHard = wolflandhardanim;
+    types[wolftype].animFightIdle = wolfidle;
+    types[wolftype].animBounceIdle = wolfidle;
 
     types[wolftype].soundsAttack[0] = barksound;
     types[wolftype].soundsAttack[1] = bark2sound;
@@ -130,6 +142,8 @@ void PersonType::Load()
     types[rabbittype].animStop = stopanim;
     types[rabbittype].animLanding = landanim;
     types[rabbittype].animLandingHard = landhardanim;
+    types[rabbittype].animFightIdle = fightidleanim;
+    types[rabbittype].animBounceIdle = bounceidleanim;
 
     types[rabbittype].soundsAttack[0] = rabbitattacksound;
     types[rabbittype].soundsAttack[1] = rabbitattack2sound;
@@ -676,20 +690,15 @@ void Person::CatchFire()
  */
 int Person::getIdle()
 {
-    if (Dialog::inDialog() && (howactive == typeactive) && (creature == rabbittype)) {
-        return talkidleanim;
+    if (Dialog::inDialog() && (howactive == typeactive) && PersonType::types[creature].hasAnimTalkIdle()) {
+        return PersonType::types[creature].animTalkIdle;
     }
     if (hasvictim && (victim != this->shared_from_this())) {
         if ((!victim->dead && victim->aitype != passivetype &&
              victim->aitype != searchtype && aitype != passivetype && aitype != searchtype &&
              victim->id < Person::players.size())) {
             if ((aitype == playercontrolled && stunned <= 0 && weaponactive == -1) || pause) {
-                if (creature == rabbittype) {
-                    return fightidleanim;
-                }
-                if (creature == wolftype) {
-                    return wolfidle;
-                }
+                return PersonType::types[creature].animFightIdle;
             }
             if (aitype == playercontrolled && stunned <= 0 && weaponactive != -1) {
                 if (weapons[weaponids[weaponactive]].getType() == knife) {
@@ -734,13 +743,7 @@ int Person::getIdle()
     if (howactive == typedead4) {
         return dead4anim;
     }
-    if (creature == rabbittype) {
-        return bounceidleanim;
-    }
-    if (creature == wolftype) {
-        return wolfidle;
-    }
-    return 0;
+    return PersonType::types[creature].animBounceIdle;
 }
 
 /* FUNCTION
index ba329fe52639255f20c400403fb7b3c2f2198d64..4896cbd2e237c053ca5fec29763d7407c131d977 100644 (file)
@@ -67,6 +67,10 @@ public:
     animation_type animStop;
     animation_type animLanding;
     animation_type animLandingHard;
+    animation_type animFightIdle;
+    animation_type animBounceIdle;
+    animation_type animTalkIdle;
+
     sound_type soundsAttack[4];
     sound_type soundsTalk[2];
 
@@ -81,6 +85,9 @@ public:
 
     GLubyte bloodText[512 * 512 * 3] = { 0 };
 
+    PersonType();
+    bool hasAnimTalkIdle();
+
     static std::vector<PersonType> types;
     static void Load();
 };