Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/GameInterface/ActorViewer.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
#include "simulation2/components/ICmpPosition.h" | #include "simulation2/components/ICmpPosition.h" | ||||
#include "simulation2/components/ICmpRangeManager.h" | #include "simulation2/components/ICmpRangeManager.h" | ||||
#include "simulation2/components/ICmpTerrain.h" | #include "simulation2/components/ICmpTerrain.h" | ||||
#include "simulation2/components/ICmpUnitMotion.h" | #include "simulation2/components/ICmpUnitMotion.h" | ||||
#include "simulation2/components/ICmpVisual.h" | #include "simulation2/components/ICmpVisual.h" | ||||
#include "simulation2/components/ICmpWaterManager.h" | #include "simulation2/components/ICmpWaterManager.h" | ||||
#include "simulation2/helpers/Render.h" | #include "simulation2/helpers/Render.h" | ||||
#include <boost/algorithm/string.hpp> | |||||
struct ActorViewerImpl : public Scene | struct ActorViewerImpl : public Scene | ||||
{ | { | ||||
NONCOPYABLE(ActorViewerImpl); | NONCOPYABLE(ActorViewerImpl); | ||||
public: | public: | ||||
ActorViewerImpl() : | ActorViewerImpl() : | ||||
Entity(INVALID_ENTITY), | Entity(INVALID_ENTITY), | ||||
Terrain(), | Terrain(), | ||||
ColladaManager(g_VFS), | ColladaManager(g_VFS), | ||||
▲ Show 20 Lines • Show All 329 Lines • ▼ Show 20 Lines | else if (anim == "run") | ||||
CmpPtr<ICmpUnitMotion> cmpUnitMotion(m.Simulation2, m.Entity); | CmpPtr<ICmpUnitMotion> cmpUnitMotion(m.Simulation2, m.Entity); | ||||
if (cmpUnitMotion) | if (cmpUnitMotion) | ||||
speed = cmpUnitMotion->GetWalkSpeed().ToFloat() * cmpUnitMotion->GetRunMultiplier().ToFloat(); | speed = cmpUnitMotion->GetWalkSpeed().ToFloat() * cmpUnitMotion->GetRunMultiplier().ToFloat(); | ||||
else | else | ||||
speed = 12.f; // Typical unit run speed. | speed = 12.f; // Typical unit run speed. | ||||
m.CurrentSpeed = speed; | m.CurrentSpeed = speed; | ||||
} | } | ||||
else if (anim == "attack_melee") | else | ||||
repeattime = GetRepeatTimeByAttackType("Melee"); | for (std::string& type : GetAttackTypes()) | ||||
else if (anim == "attack_ranged") | if (anim == "attack_" + boost::algorithm::to_lower_copy(type)) | ||||
repeattime = GetRepeatTimeByAttackType("Ranged"); | repeattime = GetRepeatTimeByAttackType(type); | ||||
else if (anim == "attack_slaughter") | |||||
repeattime = GetRepeatTimeByAttackType("Slaughter"); | |||||
else if (anim == "attack_capture") | |||||
repeattime = GetRepeatTimeByAttackType("Capture"); | |||||
CmpPtr<ICmpVisual> cmpVisual(m.Simulation2, m.Entity); | CmpPtr<ICmpVisual> cmpVisual(m.Simulation2, m.Entity); | ||||
if (cmpVisual) | if (cmpVisual) | ||||
{ | { | ||||
// TODO: SetEntitySelection(anim) | // TODO: SetEntitySelection(anim) | ||||
cmpVisual->SelectAnimation(anim, false, fixed::FromFloat(speed)); | cmpVisual->SelectAnimation(anim, false, fixed::FromFloat(speed)); | ||||
if (repeattime) | if (repeattime) | ||||
cmpVisual->SetAnimationSyncRepeat(fixed::FromFloat(repeattime)); | cmpVisual->SetAnimationSyncRepeat(fixed::FromFloat(repeattime)); | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
void ActorViewer::SetStatsEnabled(bool enabled) | void ActorViewer::SetStatsEnabled(bool enabled) | ||||
{ | { | ||||
if (enabled) | if (enabled) | ||||
g_ProfileViewer.ShowTable("renderer"); | g_ProfileViewer.ShowTable("renderer"); | ||||
else | else | ||||
g_ProfileViewer.ShowTable(""); | g_ProfileViewer.ShowTable(""); | ||||
} | } | ||||
std::vector<std::string> ActorViewer::GetAttackTypes() const | |||||
{ | |||||
CmpPtr<ICmpAttack> cmpAttack(m.Simulation2, m.Entity); | |||||
if (cmpAttack) | |||||
return cmpAttack->GetAttackTypes(); | |||||
return {}; | |||||
} | |||||
float ActorViewer::GetRepeatTimeByAttackType(const std::string& type) const | float ActorViewer::GetRepeatTimeByAttackType(const std::string& type) const | ||||
{ | { | ||||
CmpPtr<ICmpAttack> cmpAttack(m.Simulation2, m.Entity); | CmpPtr<ICmpAttack> cmpAttack(m.Simulation2, m.Entity); | ||||
if (cmpAttack) | if (cmpAttack) | ||||
return cmpAttack->GetRepeatTime(type); | return cmpAttack->GetRepeatTime(type); | ||||
return 0.0f; | return 0.0f; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator