]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Person.h
Refactored weapon taking in Person::takeWeapon
[lugaru.git] / Source / Person.h
index 754a046676763e5f138798723124659e11fdad68..235f14d624f335dffa3ef722e2208e8342e5efe9 100644 (file)
@@ -1,22 +1,21 @@
 /*
 Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
 
 This file is part of Lugaru.
 
-Lugaru is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
+Lugaru is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #ifndef _PERSON_H_
@@ -31,6 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "Terrain.h"
 #include "Sprite.h"
 #include <cmath>
+#include <memory>
 #include "Weapons.h"
 #include "Animation.h"
 
@@ -47,9 +47,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define rabbittype 0
 #define wolftype 1
 
-class Person
+class Person : public enable_shared_from_this<Person>
 {
 public:
+    static std::vector<std::shared_ptr<Person>> players;
+
     int whichpatchx;
     int whichpatchz;
 
@@ -153,7 +155,7 @@ public:
 
     float grabdelay;
 
-    Person *victim;
+    std::shared_ptr<Person> victim;
     bool hasvictim;
 
     float updatedelay;
@@ -229,7 +231,7 @@ public:
 
     int creature;
 
-    int id;
+    unsigned id;
 
     Skeleton skeleton;
 
@@ -326,10 +328,11 @@ public:
 
 
 
-    // convenience
-    Joint& joint(int);
-    XYZ& jointPos(int);
-    XYZ& jointVel(int);
+    // convenience functions
+    inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
+    inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
+    inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
+
 
     void CheckKick();
     void CatchFire();
@@ -390,8 +393,10 @@ public:
     void setAnimation(int);
     void DoAnimations();
     void RagDoll(bool checkcollision);
+
+    void takeWeapon (int weaponId);
 };
 
 const int maxplayers = 10;
-extern Person player[maxplayers];
+
 #endif