Merge branch 'Movement' of github.com:teamfisk/TacticalZ into Movement

This commit is contained in:
Tleety
2016-03-12 17:04:00 +01:00
12 changed files with 182 additions and 209 deletions
+9 -3
View File
@@ -127,8 +127,8 @@ void AnimationSystem::UpdateAnimations(double dt)
void AnimationSystem::UpdateWeights(double dt)
{
for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) {
/* LOG_INFO("%s", it->first.Name().c_str());
it->second.PrintQueue();*/
//LOG_INFO("%s", it->first.Name().c_str());
//it->second.PrintQueue();
if(it->second.HasActiveBlendJob()) {
AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob();
@@ -158,12 +158,13 @@ void AnimationSystem::UpdateWeights(double dt)
bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
{
if (!e.RootNode.Valid()) {
LOG_ERROR("%s, RootNode invalid %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
if (!e.RootNode.HasComponent("Model")) {
LOG_ERROR("%s, RootNode has no model %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
@@ -171,11 +172,13 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
try {
model = ResourceManager::Load<::Model, true>((std::string)e.RootNode["Model"]["Resource"]);
} catch (const std::exception&) {
LOG_ERROR("%s, RootNode model not finished loading %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
if (skeleton == nullptr) {
LOG_ERROR("%s, RootNode skeleton invalid %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
@@ -183,6 +186,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
if (skeleton->BlendTrees.find(e.RootNode) != skeleton->BlendTrees.end()) {
blendTree = skeleton->BlendTrees.at(e.RootNode);
} else {
LOG_ERROR("%s, No blendtree was found invalid %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
@@ -193,6 +197,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
subTreeRoot = blendTree->GetSubTreeRoot(e.NodeName);
if (!subTreeRoot.Valid()) {
LOG_ERROR("%s, subTreeRoot invalid", e.NodeName);
return false;
}
@@ -237,6 +242,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
subTreeRoot = entity;
if (!subTreeRoot.Valid()) {
LOG_ERROR("%s, subTreeRoot invalid", e.NodeName);
return false;
}
+75 -19
View File
@@ -35,19 +35,25 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
return false;
}
//get the XML file, example: "Schema/Entities/BoostclassName.xml"
std::string classXML = "Schema/Entities/" + className + ".xml";
//check if player already has a child with the component, if so delete that child
auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className);
if (playerBoostAssaultEntity.Valid()) {
m_World->DeleteEntity(playerBoostAssaultEntity.ID);
LOG_INFO("intflictor: %s, vicitm: %s", e.Inflictor.Name().c_str(), e.Victim.Name().c_str());
if(className == "SidearmWeapon") { // give ammo
giveAmmo(e.Inflictor, e.Victim);
} else { //give boost
//get the XML file, example: "Schema/Entities/BoostclassName.xml"
std::string classXML = "Schema/Entities/" + className + ".xml";
//check if player already has a child with the component, if so delete that child
auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className);
if (playerBoostAssaultEntity.Valid()) {
m_World->DeleteEntity(playerBoostAssaultEntity.ID);
}
//load boost XML file, set it entity parented with the victim player
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World);
m_World->SetName(boostAssaultEntity.ID, className);
m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID);
}
//load boost XML file, set it entity parented with the victim player
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World);
m_World->SetName(boostAssaultEntity.ID, className);
m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID);
return true;
}
@@ -55,14 +61,64 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
std::string BoostSystem::DetermineClass(EntityWrapper inflictorPlayer)
{
//determine the class based on what component the inflictor-player has
if (m_World->HasComponent(inflictorPlayer.ID, "DashAbility")) {
return "BoostAssault";
}
if (m_World->HasComponent(inflictorPlayer.ID, "ShieldAbility")) {
return "BoostDefender";
}
if (m_World->HasComponent(inflictorPlayer.ID, "SprintAbility")) {
return "BoostSniper";
if (inflictorPlayer.HasComponent("Player")) {
if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "AssaultWeapon") {
return "BoostAssault";
}
if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "DefenderWeapon") {
return "BoostDefender";
}
if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "SniperWeapon") {
return "BoostSniper";
}
if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "SidearmWeapon") {
return "SidearmWeapon";
}
}
return "";
}
void BoostSystem::giveAmmo(EntityWrapper giver, EntityWrapper receiver)
{
bool gaveAmmo = false;
if (receiver.HasComponent("AssaultWeapon")) {
int magazineSize = receiver["AssaultWeapon"]["MagazineSize"];
int& magazineAmmo = receiver["AssaultWeapon"]["MagazineAmmo"];
int maxAmmo = receiver["AssaultWeapon"]["MaxAmmo"];
int& ammo = receiver["AssaultWeapon"]["Ammo"];
if (magazineAmmo < magazineSize) {
magazineAmmo += 1;
gaveAmmo = true;
} else if (ammo < maxAmmo) {
ammo += 1;
gaveAmmo = true;
}
} else if (receiver.HasComponent("DefenderWeapon")) {
int magazineSize = receiver["DefenderWeapon"]["MagazineSize"];
int& magazineAmmo = receiver["DefenderWeapon"]["MagazineAmmo"];
int maxAmmo = receiver["DefenderWeapon"]["MaxAmmo"];
int& ammo = receiver["DefenderWeapon"]["Ammo"];
if (magazineAmmo < magazineSize) {
magazineAmmo += 1;
gaveAmmo = true;
} else if (ammo < maxAmmo) {
ammo += 1;
gaveAmmo = true;
}
}
if (gaveAmmo) {
EntityWrapper effectSpawner = giver.FirstChildByName("AmmoShareEffectSpawner");
if (effectSpawner.Valid()) {
if (effectSpawner.HasComponent("Spawner")) {
SpawnerSystem::Spawn(effectSpawner, effectSpawner);
}
}
}
}
@@ -24,6 +24,8 @@ void PlayerMovementSystem::Update(double dt)
if (LocalPlayer.Valid()){
updateVelocity(LocalPlayer, dt);
}
m_SprintEffectTimer += dt;
if (m_SprintEffectTimer < 0.016f) {
return;
@@ -74,7 +74,7 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
float animationWeight = glm::min(speed, movementSpeed) / movementSpeed;
EntityWrapper rootNode = wi.FirstPersonEntity;
if (rootNode.Valid()) {
EntityWrapper blend = rootNode.FirstChildByName("MovementBlend");
EntityWrapper blend = rootNode.FirstChildByName("MovementBlendAssault");
if (blend.Valid()) {
(double&)blend["Blend"]["Weight"] = animationWeight;
}
@@ -14,7 +14,6 @@ void SidearmWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWra
void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt)
{
CheckAmmo(cWeapon, wi);
// Start reloading automatically if at 0 mag ammo
@@ -64,7 +63,7 @@ void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
float animationWeight = glm::min(speed, movementSpeed) / movementSpeed;
EntityWrapper rootNode = wi.FirstPersonEntity;
if (rootNode.Valid()) {
EntityWrapper blend = rootNode.FirstChildByName("MovementBlend");
EntityWrapper blend = rootNode.FirstChildByName("MovementBlendSidearm");
if (blend.Valid()) {
(double&)blend["Blend"]["Weight"] = animationWeight;
}
@@ -282,7 +281,7 @@ bool SidearmWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi
// If friendly fire, reduce damage to 0 (needed to make Boosts, Ammosharing work)
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) {
damage = 0;
giveAmmo(cWeapon, wi, victim);
//giveAmmo(cWeapon, wi, victim);
}
// Deal damage!
@@ -294,6 +293,7 @@ bool SidearmWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi
return damage > 0;
}
/*
void SidearmWeaponBehaviour::giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, EntityWrapper receiver)
{
@@ -338,7 +338,7 @@ void SidearmWeaponBehaviour::giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi,
}
}
}
}
}*/
void SidearmWeaponBehaviour::CheckAmmo(ComponentWrapper cWeapon, WeaponInfo& wi)
{