This commit is contained in:
viktorljung
2016-03-03 23:41:08 +01:00
parent 66c8a17b17
commit bebdacabb4
5 changed files with 538 additions and 400 deletions
-373
View File
@@ -4,7 +4,6 @@ AnimationSystem::AnimationSystem(SystemParams params)
: System(params)
{
EVENT_SUBSCRIBE_MEMBER(m_EAutoAnimationBlend, &AnimationSystem::OnAutoAnimationBlend);
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &AnimationSystem::OnInputCommand);
}
void AnimationSystem::Update(double dt)
@@ -16,7 +15,6 @@ void AnimationSystem::Update(double dt)
for(auto& autoBlendQueue : m_AutoBlendQueues) {
autoBlendQueue.second.UpdateTime(dt);
// autoBlendQueue.second.PrintQueue();
}
}
@@ -136,7 +134,6 @@ void AnimationSystem::UpdateWeights(double dt)
if (blendTree != nullptr) {
blendJob.BlendInfo.progress = glm::clamp(blendJob.CurrentTime / blendJob.Duration, 0.0, 1.0);
LOG_INFO("Progress: %f, %s", blendJob.BlendInfo.progress, blendJob.BlendInfo.NodeName.c_str());
blendJob.BlendInfo = blendTree->AutoBlendStep(blendJob.BlendInfo);
}
@@ -215,376 +212,6 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
}
}
}
LOG_INFO("Inserting %s blendJob into %s subtree", e.NodeName.c_str(), subTreeRoot.Name().c_str());
m_AutoBlendQueues[subTreeRoot].Insert(abj);
LOG_INFO("\n");
m_AutoBlendQueues.at(subTreeRoot).PrintQueue();
LOG_INFO("\n");
return true;
}
bool AnimationSystem::OnInputCommand(const Events::InputCommand& e)
{
if (e.Value == 1.f) {
if(e.Command == "DashForward") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.2;
aeb.NodeName = "DashForward";
aeb.RootNode = entity;
aeb.Restart = true;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "StandCrouchBlend";
aeb.RootNode = entity;
aeb.Delay = -0.3;
aeb.Start = true;
aeb.Restart = false;
aeb.AnimationEntity = entity.FirstChildByName("DashForward");
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Command == "DashBackward") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1;
aeb.NodeName = "DashBackward";
aeb.RootNode = entity;
aeb.Restart = true;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "StandCrouchBlend";
aeb.RootNode = entity;
aeb.Start = true;
aeb.Restart = false;
aeb.Delay = -0.3;
aeb.AnimationEntity = entity.FirstChildByName("DashBackward");
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Command == "DashLeft") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1;
aeb.NodeName = "DashLeft";
aeb.RootNode = entity;
aeb.Restart = true;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "StandCrouchBlend";
aeb.RootNode = entity;
aeb.Delay = -0.3;
aeb.Start = true;
aeb.Restart = false;
aeb.AnimationEntity = entity.FirstChildByName("DashLeft");
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Command == "DashRight") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1;
aeb.NodeName = "DashRight";
aeb.RootNode = entity;
aeb.Restart = true;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "StandCrouchBlend";
aeb.RootNode = entity;
aeb.Start = true;
aeb.Restart = false;
aeb.AnimationEntity = entity.FirstChildByName("DashRight");
aeb.Delay = -0.3;
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Command == "Jump") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.25;
aeb.NodeName = "Jump";
aeb.RootNode = entity;
aeb.Start = true;
aeb.Restart = true;
m_EventBroker->Publish(aeb);
}
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "StandCrouchBlend";
aeb.RootNode = entity;
aeb.Start = true;
aeb.Restart = false;
aeb.AnimationEntity = entity.FirstChildByName("Jump");
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Command == "Reload") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.2;
aeb.NodeName = "ReloadSwitch";
aeb.RootNode = entity;
aeb.Start = true;
aeb.Restart = true;
m_EventBroker->Publish(aeb);
}
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.2;
aeb.NodeName = "IdlePrimary";
aeb.RootNode = entity;
aeb.Delay = -0.1;
aeb.Start = true;
aeb.Restart = false;
aeb.AnimationEntity = entity.FirstChildByName("ReloadSwitch");
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Command == "Crouch") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "CrouchMovement";
aeb.RootNode = entity;
aeb.Start = true;
aeb.Restart = true;
aeb.SingleLevelBlend = true;
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Command == "Shoot") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1;
aeb.NodeName = "ShootPrimary";
aeb.RootNode = entity;
aeb.Start = true;
aeb.Restart = true;
m_EventBroker->Publish(aeb);
}
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1;
aeb.NodeName = "IdlePrimary";
aeb.RootNode = entity;
aeb.Delay = 0.0;
aeb.Start = true;
aeb.Restart = false;
aeb.AnimationEntity = entity.FirstChildByName("ShootPrimary");
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Command == "LeftTest") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1;
aeb.NodeName = "Left";
aeb.RootNode = entity;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Command == "RightTest") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1;
aeb.NodeName = "Right";
aeb.RootNode = entity;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Command == "ForwardTest") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1;
aeb.NodeName = "Walk";
aeb.RootNode = entity;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
}
}
}
} else if (e.Command == "BackwardTest") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1;
aeb.NodeName = "Walk";
aeb.RootNode = entity;
aeb.Start = true;
aeb.Reverse = true;
m_EventBroker->Publish(aeb);
}
}
}
} else if (e.Value == 0.f) {
if (e.Command == "Crouch") {
auto blendComponents = m_World->GetComponents("BlendAdditive");
if (blendComponents == nullptr) {
return false;
}
for (auto& bc : *blendComponents) {
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
if (entity.Name() == "Assault") {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "StandMovement";
aeb.RootNode = entity;
aeb.Start = true;
aeb.Restart = true;
aeb.SingleLevelBlend = true;
m_EventBroker->Publish(aeb);
}
}
}
}
}
}