From 61122a635fae9aac4df5c4dafc4443436dbb9c4f Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Sun, 5 Feb 2017 22:31:01 +0100 Subject: [PATCH] Moved PersonType class to its own file --- CMakeLists.txt | 2 + Source/Objects/Person.cpp | 104 ---------------------------- Source/Objects/Person.hpp | 44 +----------- Source/Objects/PersonType.cpp | 125 ++++++++++++++++++++++++++++++++++ Source/Objects/PersonType.hpp | 69 +++++++++++++++++++ 5 files changed, 197 insertions(+), 147 deletions(-) create mode 100644 Source/Objects/PersonType.cpp create mode 100644 Source/Objects/PersonType.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 851df4e..2e6505e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,7 @@ set(LUGARU_SRCS ${SRCDIR}/Menu/Menu.cpp ${SRCDIR}/Objects/Object.cpp ${SRCDIR}/Objects/Person.cpp + ${SRCDIR}/Objects/PersonType.cpp ${SRCDIR}/Objects/Weapons.cpp ${SRCDIR}/Platform/PlatformUnix.cpp ${SRCDIR}/Platform/PlatformWindows.cpp @@ -165,6 +166,7 @@ set(LUGARU_H ${SRCDIR}/Menu/Menu.hpp ${SRCDIR}/Objects/Object.hpp ${SRCDIR}/Objects/Person.hpp + ${SRCDIR}/Objects/PersonType.hpp ${SRCDIR}/Objects/Weapons.hpp ${SRCDIR}/Platform/Platform.hpp ${SRCDIR}/Thirdparty/optionparser.h diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 817ee03..f020f5e 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -73,110 +73,6 @@ extern float envsoundlife[30]; extern XYZ windvector; std::vector> Person::players(1, std::shared_ptr(new Person())); -std::vector PersonType::types; - -PersonType::PersonType() -{ - animTalkIdle = tempanim; -} - -bool PersonType::hasAnimTalkIdle() -{ - return (animTalkIdle != tempanim); -} - -void PersonType::Load() -{ - types.resize(2); - - /* Wolf */ - types[wolftype].proportions[0] = 1.1; - types[wolftype].proportions[1] = 1.1; - types[wolftype].proportions[2] = 1.1; - types[wolftype].proportions[3] = 1.1; - - types[wolftype].animRun = wolfrunanim; - types[wolftype].animRunning = wolfrunninganim; - types[wolftype].animCrouch = wolfcrouchanim; - 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; - types[wolftype].soundsAttack[2] = bark3sound; - types[wolftype].soundsAttack[3] = barkgrowlsound; - types[wolftype].soundsTalk[0] = growlsound; - types[wolftype].soundsTalk[1] = growl2sound; - - types[wolftype].figureFileName = "Skeleton/BasicFigureWolf"; - types[wolftype].lowFigureFileName = "Skeleton/BasicFigureWolfLow"; - types[wolftype].clothesFileName = "Skeleton/RabbitBelt"; - types[wolftype].modelFileNames[0] = "Models/Wolf.solid"; - types[wolftype].modelFileNames[1] = "Models/Wolf2.solid"; - types[wolftype].modelFileNames[2] = "Models/Wolf3.solid"; - types[wolftype].modelFileNames[3] = "Models/Wolf4.solid"; - types[wolftype].modelFileNames[4] = "Models/Wolf5.solid"; - types[wolftype].modelFileNames[5] = "Models/Wolf6.solid"; - types[wolftype].modelFileNames[6] = "Models/Wolf7.solid"; - types[wolftype].lowModelFileName = "Models/WolfLow.solid"; - types[wolftype].modelClothesFileName = "Models/Belt.solid"; - - types[wolftype].skins.resize(3); - types[wolftype].skins[0] = "Textures/Wolf.jpg"; - types[wolftype].skins[1] = "Textures/DarkWolf.jpg"; - types[wolftype].skins[2] = "Textures/SnowWolf.jpg"; - - /* Rabbit */ - types[rabbittype].proportions[0] = 1.2; - types[rabbittype].proportions[1] = 1.05; - types[rabbittype].proportions[2] = 1; - types[rabbittype].proportions[3] = 1.1; - types[rabbittype].proportions[3].y = 1.05; - - types[rabbittype].animRun = runanim; - types[rabbittype].animRunning = rabbitrunninganim; - types[rabbittype].animCrouch = crouchanim; - 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; - types[rabbittype].soundsAttack[2] = rabbitattack3sound; - types[rabbittype].soundsAttack[3] = rabbitattack4sound; - types[rabbittype].soundsTalk[0] = rabbitchitter; - types[rabbittype].soundsTalk[1] = rabbitchitter2; - - types[rabbittype].figureFileName = "Skeleton/BasicFigure"; - types[rabbittype].lowFigureFileName = "Skeleton/BasicFigureLow"; - types[rabbittype].clothesFileName = "Skeleton/RabbitBelt"; - types[rabbittype].modelFileNames[0] = "Models/Body.solid"; - types[rabbittype].modelFileNames[1] = "Models/Body2.solid"; - types[rabbittype].modelFileNames[2] = "Models/Body3.solid"; - types[rabbittype].modelFileNames[3] = "Models/Body4.solid"; - types[rabbittype].modelFileNames[4] = "Models/Body5.solid"; - types[rabbittype].modelFileNames[5] = "Models/Body6.solid"; - types[rabbittype].modelFileNames[6] = "Models/Body7.solid"; - types[rabbittype].lowModelFileName = "Models/BodyLow.solid"; - types[rabbittype].modelClothesFileName = "Models/Belt.solid"; - - types[rabbittype].skins.resize(10); - types[rabbittype].skins[0] = "Textures/Fur3.jpg"; - types[rabbittype].skins[1] = "Textures/Fur.jpg"; - types[rabbittype].skins[2] = "Textures/Fur2.jpg"; - types[rabbittype].skins[3] = "Textures/Lynx.jpg"; - types[rabbittype].skins[4] = "Textures/Otter.jpg"; - types[rabbittype].skins[5] = "Textures/Opal.jpg"; - types[rabbittype].skins[6] = "Textures/Sable.jpg"; - types[rabbittype].skins[7] = "Textures/Chocolate.jpg"; - types[rabbittype].skins[8] = "Textures/BW2.jpg"; - types[rabbittype].skins[9] = "Textures/WB2.jpg"; -} Person::Person() : whichpatchx(0) diff --git a/Source/Objects/Person.hpp b/Source/Objects/Person.hpp index 4896cbd..3f96a26 100644 --- a/Source/Objects/Person.hpp +++ b/Source/Objects/Person.hpp @@ -23,12 +23,12 @@ along with Lugaru. If not, see . #include "Animation/Animation.hpp" #include "Animation/Skeleton.hpp" -#include "Audio/Sounds.hpp" #include "Environment/Terrain.hpp" #include "Graphic/gamegl.hpp" #include "Graphic/Models.hpp" #include "Graphic/Sprite.hpp" #include "Math/XYZ.hpp" +#include "Objects/PersonType.hpp" #include "Objects/Weapons.hpp" #include @@ -44,54 +44,12 @@ along with Lugaru. If not, see . #define getweapontype 7 #define pathfindtype 8 -enum person_type -{ - rabbittype = 0, - wolftype = 1 -}; - struct InvalidPersonException : public exception { const char * what () const throw () { return "Invalid weapon number"; } }; -class PersonType -{ -public: - // head, body, arms, legs - XYZ proportions[4]; - animation_type animRun; - animation_type animRunning; - animation_type animCrouch; - 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]; - - std::string figureFileName; - std::string lowFigureFileName; - std::string clothesFileName; - std::string modelFileNames[7]; - std::string lowModelFileName; - std::string modelClothesFileName; - - std::vector skins; - - GLubyte bloodText[512 * 512 * 3] = { 0 }; - - PersonType(); - bool hasAnimTalkIdle(); - - static std::vector types; - static void Load(); -}; - class Person : public enable_shared_from_this { private: diff --git a/Source/Objects/PersonType.cpp b/Source/Objects/PersonType.cpp new file mode 100644 index 0000000..b22200a --- /dev/null +++ b/Source/Objects/PersonType.cpp @@ -0,0 +1,125 @@ +/* +Copyright (C) 2016-2017 - 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 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. + +You should have received a copy of the GNU General Public License +along with Lugaru. If not, see . +*/ + +#include "Objects/PersonType.hpp" + +std::vector PersonType::types; + +PersonType::PersonType() +{ + animTalkIdle = tempanim; +} + +bool PersonType::hasAnimTalkIdle() +{ + return (animTalkIdle != tempanim); +} + +void PersonType::Load() +{ + types.resize(2); + + /* Wolf */ + types[wolftype].proportions[0] = 1.1; + types[wolftype].proportions[1] = 1.1; + types[wolftype].proportions[2] = 1.1; + types[wolftype].proportions[3] = 1.1; + + types[wolftype].animRun = wolfrunanim; + types[wolftype].animRunning = wolfrunninganim; + types[wolftype].animCrouch = wolfcrouchanim; + 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; + types[wolftype].soundsAttack[2] = bark3sound; + types[wolftype].soundsAttack[3] = barkgrowlsound; + types[wolftype].soundsTalk[0] = growlsound; + types[wolftype].soundsTalk[1] = growl2sound; + + types[wolftype].figureFileName = "Skeleton/BasicFigureWolf"; + types[wolftype].lowFigureFileName = "Skeleton/BasicFigureWolfLow"; + types[wolftype].clothesFileName = "Skeleton/RabbitBelt"; + types[wolftype].modelFileNames[0] = "Models/Wolf.solid"; + types[wolftype].modelFileNames[1] = "Models/Wolf2.solid"; + types[wolftype].modelFileNames[2] = "Models/Wolf3.solid"; + types[wolftype].modelFileNames[3] = "Models/Wolf4.solid"; + types[wolftype].modelFileNames[4] = "Models/Wolf5.solid"; + types[wolftype].modelFileNames[5] = "Models/Wolf6.solid"; + types[wolftype].modelFileNames[6] = "Models/Wolf7.solid"; + types[wolftype].lowModelFileName = "Models/WolfLow.solid"; + types[wolftype].modelClothesFileName = "Models/Belt.solid"; + + types[wolftype].skins.resize(3); + types[wolftype].skins[0] = "Textures/Wolf.jpg"; + types[wolftype].skins[1] = "Textures/DarkWolf.jpg"; + types[wolftype].skins[2] = "Textures/SnowWolf.jpg"; + + /* Rabbit */ + types[rabbittype].proportions[0] = 1.2; + types[rabbittype].proportions[1] = 1.05; + types[rabbittype].proportions[2] = 1; + types[rabbittype].proportions[3] = 1.1; + types[rabbittype].proportions[3].y = 1.05; + + types[rabbittype].animRun = runanim; + types[rabbittype].animRunning = rabbitrunninganim; + types[rabbittype].animCrouch = crouchanim; + 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; + types[rabbittype].soundsAttack[2] = rabbitattack3sound; + types[rabbittype].soundsAttack[3] = rabbitattack4sound; + types[rabbittype].soundsTalk[0] = rabbitchitter; + types[rabbittype].soundsTalk[1] = rabbitchitter2; + + types[rabbittype].figureFileName = "Skeleton/BasicFigure"; + types[rabbittype].lowFigureFileName = "Skeleton/BasicFigureLow"; + types[rabbittype].clothesFileName = "Skeleton/RabbitBelt"; + types[rabbittype].modelFileNames[0] = "Models/Body.solid"; + types[rabbittype].modelFileNames[1] = "Models/Body2.solid"; + types[rabbittype].modelFileNames[2] = "Models/Body3.solid"; + types[rabbittype].modelFileNames[3] = "Models/Body4.solid"; + types[rabbittype].modelFileNames[4] = "Models/Body5.solid"; + types[rabbittype].modelFileNames[5] = "Models/Body6.solid"; + types[rabbittype].modelFileNames[6] = "Models/Body7.solid"; + types[rabbittype].lowModelFileName = "Models/BodyLow.solid"; + types[rabbittype].modelClothesFileName = "Models/Belt.solid"; + + types[rabbittype].skins.resize(10); + types[rabbittype].skins[0] = "Textures/Fur3.jpg"; + types[rabbittype].skins[1] = "Textures/Fur.jpg"; + types[rabbittype].skins[2] = "Textures/Fur2.jpg"; + types[rabbittype].skins[3] = "Textures/Lynx.jpg"; + types[rabbittype].skins[4] = "Textures/Otter.jpg"; + types[rabbittype].skins[5] = "Textures/Opal.jpg"; + types[rabbittype].skins[6] = "Textures/Sable.jpg"; + types[rabbittype].skins[7] = "Textures/Chocolate.jpg"; + types[rabbittype].skins[8] = "Textures/BW2.jpg"; + types[rabbittype].skins[9] = "Textures/WB2.jpg"; +} diff --git a/Source/Objects/PersonType.hpp b/Source/Objects/PersonType.hpp new file mode 100644 index 0000000..1d48a71 --- /dev/null +++ b/Source/Objects/PersonType.hpp @@ -0,0 +1,69 @@ +/* +Copyright (C) 2016-2017 - 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 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. + +You should have received a copy of the GNU General Public License +along with Lugaru. If not, see . +*/ + +#ifndef _PERSONTYPE_HPP_ +#define _PERSONTYPE_HPP_ + +#include "Animation/Animation.hpp" +#include "Audio/Sounds.hpp" +#include "Math/XYZ.hpp" + +enum person_type +{ + rabbittype = 0, + wolftype = 1 +}; + +class PersonType +{ +public: + // head, body, arms, legs + XYZ proportions[4]; + animation_type animRun; + animation_type animRunning; + animation_type animCrouch; + 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]; + + std::string figureFileName; + std::string lowFigureFileName; + std::string clothesFileName; + std::string modelFileNames[7]; + std::string lowModelFileName; + std::string modelClothesFileName; + + std::vector skins; + + GLubyte bloodText[512 * 512 * 3] = { 0 }; + + PersonType(); + bool hasAnimTalkIdle(); + + static std::vector types; + static void Load(); +}; + +#endif -- 2.39.5