diff options
author | Rogier <rogier777@gmail.com> | 2017-01-12 04:25:25 +0900 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-01-13 21:56:24 +0100 |
commit | e2dd96b432f057cd8a3886314c78a79138a99c5e (patch) | |
tree | 31340648d7d0f49d777887c0ade633bf561fec18 /src/content_sao.h | |
parent | 7ae7f1ea4cbbda7d7849a1240ce30d867e850bfb (diff) | |
download | minetest-e2dd96b432f057cd8a3886314c78a79138a99c5e.tar.gz minetest-e2dd96b432f057cd8a3886314c78a79138a99c5e.tar.bz2 minetest-e2dd96b432f057cd8a3886314c78a79138a99c5e.zip |
Cleanup content_sao by factorizing similar code parts
Signed-off-by: Loic Blot <loic.blot@unix-experience.fr>
Diffstat (limited to 'src/content_sao.h')
-rw-r--r-- | src/content_sao.h | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/src/content_sao.h b/src/content_sao.h index d5e9b2cbf..4d6cf4dcf 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -40,6 +40,21 @@ public: s16 getHP() const { return m_hp; } // Use a function, if isDead can be defined by other conditions bool isDead() const { return m_hp == 0; } + + bool isAttached() const; + void setArmorGroups(const ItemGroupList &armor_groups); + const ItemGroupList &getArmorGroups(); + void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop); + void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop); + void setBonePosition(const std::string &bone, v3f position, v3f rotation); + void getBonePosition(const std::string &bone, v3f *position, v3f *rotation); + void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation); + void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation); + void addAttachmentChild(int child_id); + void removeAttachmentChild(int child_id); + const UNORDERED_SET<int> &getAttachmentChildIds(); + ObjectProperties* accessObjectProperties(); + void notifyObjectPropertiesModified(); protected: s16 m_hp; float m_yaw; @@ -85,10 +100,9 @@ public: virtual void addedToEnvironment(u32 dtime_s); static ServerActiveObject* create(ServerEnvironment *env, v3f pos, const std::string &data); - bool isAttached(); void step(float dtime, bool send_recommended); std::string getClientInitializationData(u16 protocol_version); - std::string getStaticData(); + std::string getStaticData() const; int punch(v3f dir, const ToolCapabilities *toolcap=NULL, ServerActiveObject *puncher=NULL, @@ -100,19 +114,6 @@ public: std::string getDescription(); void setHP(s16 hp); s16 getHP() const; - void setArmorGroups(const ItemGroupList &armor_groups); - const ItemGroupList &getArmorGroups(); - void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop); - void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop); - void setBonePosition(const std::string &bone, v3f position, v3f rotation); - void getBonePosition(const std::string &bone, v3f *position, v3f *rotation); - void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation); - void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation); - void addAttachmentChild(int child_id); - void removeAttachmentChild(int child_id); - const UNORDERED_SET<int> &getAttachmentChildIds(); - ObjectProperties* accessObjectProperties(); - void notifyObjectPropertiesModified(); /* LuaEntitySAO-specific */ void setVelocity(v3f velocity); v3f getVelocity(); @@ -196,10 +197,9 @@ public: void addedToEnvironment(u32 dtime_s); void removingFromEnvironment(); - bool isStaticAllowed() const; + bool isStaticAllowed() const { return false; } std::string getClientInitializationData(u16 protocol_version); - std::string getStaticData(); - bool isAttached(); + std::string getStaticData() const; void step(float dtime, bool send_recommended); void setBasePosition(const v3f &position); void setPos(const v3f &pos); @@ -227,25 +227,12 @@ public: const ToolCapabilities *toolcap, ServerActiveObject *puncher, float time_from_last_punch); - void rightClick(ServerActiveObject *clicker); + void rightClick(ServerActiveObject *clicker) {} void setHP(s16 hp); void setHPRaw(s16 hp) { m_hp = hp; } s16 readDamage(); u16 getBreath() const { return m_breath; } void setBreath(const u16 breath, bool send = true); - void setArmorGroups(const ItemGroupList &armor_groups); - const ItemGroupList &getArmorGroups(); - void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop); - void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop); - void setBonePosition(const std::string &bone, v3f position, v3f rotation); - void getBonePosition(const std::string &bone, v3f *position, v3f *rotation); - void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation); - void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation); - void addAttachmentChild(int child_id); - void removeAttachmentChild(int child_id); - const UNORDERED_SET<int> &getAttachmentChildIds(); - ObjectProperties* accessObjectProperties(); - void notifyObjectPropertiesModified(); /* Inventory interface |