diff --git a/source/simulation2/components/ICmpAttack.cpp b/source/simulation2/components/ICmpAttack.cpp index 98ba53f400..f64f877f95 100644 --- a/source/simulation2/components/ICmpAttack.cpp +++ b/source/simulation2/components/ICmpAttack.cpp @@ -31,10 +31,15 @@ class CCmpAttackScripted : public ICmpAttack public: DEFAULT_SCRIPT_WRAPPER(AttackScripted) - virtual float GetRepeatTime(const std::string& type) const - { - return m_Script.Call("GetRepeatTime", type); - } + virtual float GetRepeatTime(const std::string& type) const + { + return m_Script.Call("GetRepeatTime", type); + } + + virtual std::vector GetAttackTypes() const + { + return m_Script.Call>("GetAttackTypes"); + } }; REGISTER_COMPONENT_SCRIPT_WRAPPER(AttackScripted) diff --git a/source/simulation2/components/ICmpAttack.h b/source/simulation2/components/ICmpAttack.h index 37e7a9e5d5..c3e210078e 100644 --- a/source/simulation2/components/ICmpAttack.h +++ b/source/simulation2/components/ICmpAttack.h @@ -18,12 +18,14 @@ #ifndef INCLUDED_ICMPATTACK #define INCLUDED_ICMPATTACK +#include "ps/CStr.h" #include "simulation2/system/Interface.h" class ICmpAttack : public IComponent { public: virtual float GetRepeatTime(const std::string& type) const = 0; + virtual std::vector GetAttackTypes() const = 0; DECLARE_INTERFACE_TYPE(Attack) }; diff --git a/source/tools/atlas/GameInterface/ActorViewer.cpp b/source/tools/atlas/GameInterface/ActorViewer.cpp index 43860df82b..e29c0cf58e 100644 --- a/source/tools/atlas/GameInterface/ActorViewer.cpp +++ b/source/tools/atlas/GameInterface/ActorViewer.cpp @@ -382,7 +382,7 @@ void ActorViewer::SetActor(const CStrW& name, const CStr& animation, player_id_t CStr anim = animation.LowerCase(); float speed = 1.0f; // Speed will be ignored if we have a repeat time. - float repeattime = 0.0f; + float repeatTime = 0.0f; m.CurrentSpeed = 0.0f; if (anim == "walk") { @@ -403,22 +403,25 @@ void ActorViewer::SetActor(const CStrW& name, const CStr& animation, player_id_t m.CurrentSpeed = speed; } - else if (anim == "attack_melee") - repeattime = GetRepeatTimeByAttackType("Melee"); - else if (anim == "attack_ranged") - repeattime = GetRepeatTimeByAttackType("Ranged"); - else if (anim == "attack_slaughter") - repeattime = GetRepeatTimeByAttackType("Slaughter"); - else if (anim == "attack_capture") - repeattime = GetRepeatTimeByAttackType("Capture"); + else if (anim.Find("attack_") == 0) + { + CmpPtr cmpAttack(m.Simulation2, m.Entity); + if (cmpAttack) + for (const CStr& type : cmpAttack->GetAttackTypes()) + if (anim == "attack_" + type.LowerCase()) + { + repeatTime = GetRepeatTimeByAttackType(type); + break; + } + } CmpPtr cmpVisual(m.Simulation2, m.Entity); if (cmpVisual) { // TODO: SetEntitySelection(anim) cmpVisual->SelectAnimation(anim, false, fixed::FromFloat(speed)); - if (repeattime) - cmpVisual->SetAnimationSyncRepeat(fixed::FromFloat(repeattime)); + if (repeatTime > 0.0f) + cmpVisual->SetAnimationSyncRepeat(fixed::FromFloat(repeatTime)); } // update prop list for new entity/animation (relies on needsAnimReload also getting called for entire entity changes)