summaryrefslogtreecommitdiff
path: root/src/resources/beinginfo.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-09-30 20:44:00 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-02 09:16:01 +0200
commit127b2620bac315c1b25d3ec752ece7b4df39892d (patch)
tree11a6531b671229398781eb2932d025facfe1168c /src/resources/beinginfo.h
parent5e465c8b260b1c906809fd288a19780581ae54f0 (diff)
downloadmana-127b2620bac315c1b25d3ec752ece7b4df39892d.tar.gz
mana-127b2620bac315c1b25d3ec752ece7b4df39892d.tar.bz2
mana-127b2620bac315c1b25d3ec752ece7b4df39892d.tar.xz
mana-127b2620bac315c1b25d3ec752ece7b4df39892d.zip
Removed getter/setter cruft from BeingInfo
Made the class and the code in general more readable by removing all the needless getters and setters. Also used "enum class" for SoundEvent.
Diffstat (limited to 'src/resources/beinginfo.h')
-rw-r--r--src/resources/beinginfo.h107
1 files changed, 31 insertions, 76 deletions
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 10411848..2eac4237 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -23,6 +23,7 @@
#define BEINGINFO_H
#include "actorsprite.h"
+#include "map.h"
#include "gui/gui.h"
#include "resources/spritedef.h"
@@ -33,19 +34,19 @@
struct Attack
{
- std::string mAction = SpriteAction::ATTACK;
- int mEffectId = 0;
- int mHitEffectId = 0;
- int mCriticalHitEffectId = 0;
- std::string mMissileParticleFilename = std::string();
+ std::string action = SpriteAction::ATTACK;
+ int effectId = 0;
+ int hitEffectId = 0;
+ int criticalHitEffectId = 0;
+ std::string missileParticleFilename;
};
-enum SoundEvent
+enum class SoundEvent
{
- SOUND_EVENT_HIT,
- SOUND_EVENT_MISS,
- SOUND_EVENT_HURT,
- SOUND_EVENT_DIE
+ HIT,
+ MISS,
+ HURT,
+ DIE
};
/**
@@ -57,78 +58,32 @@ enum SoundEvent
*/
class BeingInfo
{
- public:
- static BeingInfo *Unknown;
+public:
+ static BeingInfo *Unknown;
- BeingInfo();
+ BeingInfo();
+ ~BeingInfo();
- ~BeingInfo();
+ std::string name;
+ SpriteDisplay display;
+ ActorSprite::TargetCursorSize targetCursorSize = ActorSprite::TC_MEDIUM;
+ Cursor hoverCursor = Cursor::POINTER;
+ unsigned char walkMask = Map::BLOCKMASK_ALL;
+ Map::BlockType blockType = Map::BLOCKTYPE_CHARACTER;
+ bool targetSelection = true;
- void setName(const std::string &name) { mName = name; }
+ void setTargetCursorSize(const std::string &size);
+ void setHoverCursor(const std::string &cursorName);
- const std::string &getName() const
- { return mName; }
+ void addSound(SoundEvent event, const std::string &filename);
+ const std::string &getSound(SoundEvent event) const;
- void setDisplay(SpriteDisplay display);
+ void addAttack(int id, Attack attack);
+ const Attack &getAttack(int id) const;
- const SpriteDisplay &getDisplay() const
- { return mDisplay; }
-
- void setTargetCursorSize(const std::string &size);
-
- void setTargetCursorSize(ActorSprite::TargetCursorSize targetSize)
- { mTargetCursorSize = targetSize; }
-
- ActorSprite::TargetCursorSize getTargetCursorSize() const
- { return mTargetCursorSize; }
-
- void setHoverCursor(const std::string &cursorName);
-
- void setHoverCursor(Cursor cursor)
- { mHoverCursor = cursor; }
-
- Cursor getHoverCursor() const
- { return mHoverCursor; }
-
- void addSound(SoundEvent event, const std::string &filename);
-
- const std::string &getSound(SoundEvent event) const;
-
- void addAttack(int id, Attack attack);
-
- const Attack &getAttack(int id) const;
-
- void setWalkMask(unsigned char mask)
- { mWalkMask = mask; }
-
- /**
- * Gets the way the being is blocked by other objects
- */
- unsigned char getWalkMask() const
- { return mWalkMask; }
-
- void setBlockType(Map::BlockType blockType)
- { mBlockType = blockType; }
-
- Map::BlockType getBlockType() const
- { return mBlockType; }
-
- void setTargetSelection(bool n)
- { mTargetSelection = n; }
-
- bool isTargetSelection() const
- { return mTargetSelection; }
-
- private:
- SpriteDisplay mDisplay;
- std::string mName;
- ActorSprite::TargetCursorSize mTargetCursorSize = ActorSprite::TC_MEDIUM;
- Cursor mHoverCursor = Cursor::POINTER;
- std::map<SoundEvent, std::vector<std::string>> mSounds;
- std::map<int, Attack> mAttacks;
- unsigned char mWalkMask;
- Map::BlockType mBlockType = Map::BLOCKTYPE_CHARACTER;
- bool mTargetSelection = true;
+private:
+ std::map<SoundEvent, std::vector<std::string>> mSounds;
+ std::map<int, Attack> mAttacks;
};
#endif // BEINGINFO_H