From 1e02e04d2ce528df037d1ca37314ea55e8806c52 Mon Sep 17 00:00:00 2001 From: mgueydan Date: Sat, 7 Sep 2013 20:02:50 +0200 Subject: Adding Family for monsters : Hostile/Passive/Water/Ambient --- source/Mobs/Monster.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 5f33d4450..357e540b3 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -55,6 +55,15 @@ public: mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM, mtVillager = E_META_SPAWN_EGG_VILLAGER, } ; + + enum eFamily + { + mfHostile = 0, // Spider, Zombies ... + mfPassive = 1, // Cows, Pigs + mfAmbient = 2, // Bats + mfWater = 3, // Squid + mfMaxplusone = 4, // Nothing + } ; // tolua_end @@ -81,6 +90,7 @@ public: virtual bool ReachedDestination(void); char GetMobType(void) const {return m_MobType; } + virtual eFamily GetMobFamily(void) const = 0; const char * GetState(); void SetState(const AString & str); -- cgit v1.2.3 From e844612503e0d78723c76423e93165164505f7ac Mon Sep 17 00:00:00 2001 From: mgueydan Date: Sat, 7 Sep 2013 20:51:31 +0200 Subject: Adding a getType in Monster that return an enum instead of an int or char --- source/Mobs/Monster.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 357e540b3..594914ca0 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -89,7 +89,8 @@ public: virtual void MoveToPosition(const Vector3f & a_Position); virtual bool ReachedDestination(void); - char GetMobType(void) const {return m_MobType; } + char GetMobType(void) const {return m_MobType; } // MG TODO : see if we can delete this one. + eType GetMobTypeAsEnum(void) const {return (eType)m_MobType; } // MG TODO : see if we should store m_MobType as enum instead of char. virtual eFamily GetMobFamily(void) const = 0; const char * GetState(); -- cgit v1.2.3 From caa54af54640d1c94c57bc84b6b1e4eb2e7a6f3c Mon Sep 17 00:00:00 2001 From: mgueydan Date: Sun, 8 Sep 2013 01:21:43 +0200 Subject: Implementing the MobSpawner (not used yet) that contains spawning rules --- source/Mobs/Monster.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 594914ca0..ef7904e8e 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -54,6 +54,8 @@ public: mtOcelot = E_META_SPAWN_EGG_OCELOT, mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM, mtVillager = E_META_SPAWN_EGG_VILLAGER, + + mtInvalidType, // MG TODO : be sure this is the way we do in this project. (needed inside cMobSpawner::ChooscMonster for instance if nothing can be spawned) } ; enum eFamily @@ -62,7 +64,8 @@ public: mfPassive = 1, // Cows, Pigs mfAmbient = 2, // Bats mfWater = 3, // Squid - mfMaxplusone = 4, // Nothing + + mfMaxplusone, // Nothing. Be sure this is the last and the others are in order } ; // tolua_end -- cgit v1.2.3 From f12ac6b995f46acf76e61e7f83273ebfc18c090f Mon Sep 17 00:00:00 2001 From: mgueydan Date: Tue, 10 Sep 2013 15:09:45 +0200 Subject: Inside cMonster::getMobFamily() : replacing Polymorphism by Map, in order to remove redundancy --- source/Mobs/Monster.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index ef7904e8e..e08fd518a 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -94,7 +94,8 @@ public: char GetMobType(void) const {return m_MobType; } // MG TODO : see if we can delete this one. eType GetMobTypeAsEnum(void) const {return (eType)m_MobType; } // MG TODO : see if we should store m_MobType as enum instead of char. - virtual eFamily GetMobFamily(void) const = 0; + eFamily GetMobFamily(void) const; + const char * GetState(); void SetState(const AString & str); -- cgit v1.2.3