Merge remote-tracking branch 'origin/master' into Movement
# Conflicts: # include/Game/Systems/Weapon/DefenderWeaponBehaviour.h # resources/Schema/Components.xsd # resources/Schema/Entities/CP_Rocky2.xml # resources/Schema/Entities/MuzzleFlashBlue.xml # resources/Schema/Entities/MuzzleFlashFire.xml # resources/Schema/Entities/MuzzleFlashRed.xml # resources/Schema/Types/Entity.xsd # resources/Shaders/Sprite.frag.glsl # src/Game/Systems/AbilityCooldownHUDSystem.cpp # src/Game/Systems/BoostIconsHUDSystem.cpp # src/Game/Systems/PlayerMovementSystem.cpp # src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp # src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp # src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
void AssaultWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt)
|
||||
{
|
||||
double& fireCooldown = cWeapon["FireCooldown"];
|
||||
Field<double> fireCooldown = cWeapon["FireCooldown"];
|
||||
fireCooldown = glm::max(0.0, fireCooldown - dt);
|
||||
|
||||
WeaponBehaviour::UpdateComponent(entity, cWeapon, dt);
|
||||
@@ -11,30 +11,30 @@ void AssaultWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWra
|
||||
void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt)
|
||||
{
|
||||
// Start reloading automatically if at 0 mag ammo
|
||||
int& magAmmo = cWeapon["MagazineAmmo"];
|
||||
Field<int> magAmmo = cWeapon["MagazineAmmo"];
|
||||
if (m_ConfigAutoReload && magAmmo <= 0) {
|
||||
OnReload(cWeapon, wi);
|
||||
}
|
||||
|
||||
// Only start reloading once we're done firing
|
||||
bool& reloadQueued = cWeapon["ReloadQueued"];
|
||||
double& fireCooldown = cWeapon["FireCooldown"];
|
||||
bool& isReloading = cWeapon["IsReloading"];
|
||||
Field<bool> reloadQueued = cWeapon["ReloadQueued"];
|
||||
Field<double> fireCooldown = cWeapon["FireCooldown"];
|
||||
Field<bool> isReloading = cWeapon["IsReloading"];
|
||||
if (reloadQueued && fireCooldown <= 0) {
|
||||
reloadQueued = fireCooldown;
|
||||
isReloading = true;
|
||||
}
|
||||
|
||||
// Decrement reload timer
|
||||
double& reloadTimer = cWeapon["ReloadTimer"];
|
||||
Field<double> reloadTimer = cWeapon["ReloadTimer"];
|
||||
if (isReloading) {
|
||||
reloadTimer = glm::max(0.0, reloadTimer - dt);
|
||||
}
|
||||
|
||||
// Handle reloading
|
||||
if (isReloading && reloadTimer <= 0.0) {
|
||||
int& magSize = cWeapon["MagazineSize"];
|
||||
int& ammo = cWeapon["Ammo"];
|
||||
Field<int> magSize = cWeapon["MagazineSize"];
|
||||
Field<int> ammo = cWeapon["Ammo"];
|
||||
|
||||
int usedAmmo = glm::max(0, magSize - magAmmo);
|
||||
magAmmo = glm::clamp(ammo + magAmmo, 0, magSize);
|
||||
@@ -56,15 +56,15 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
|
||||
|
||||
// Restore view angle
|
||||
if (IsClient) {
|
||||
float& currentTravel = cWeapon["CurrentTravel"];
|
||||
float& returnSpeed = cWeapon["ViewReturnSpeed"];
|
||||
Field<float> currentTravel = cWeapon["CurrentTravel"];
|
||||
Field<float> returnSpeed = cWeapon["ViewReturnSpeed"];
|
||||
if (currentTravel > 0) {
|
||||
float change = returnSpeed * dt;
|
||||
currentTravel = glm::max(0.f, currentTravel - change);
|
||||
EntityWrapper camera = wi.Player.FirstChildByName("Camera");
|
||||
if (camera.Valid()) {
|
||||
glm::vec3& cameraOrientation = camera["Transform"]["Orientation"];
|
||||
cameraOrientation.x -= change;
|
||||
Field<glm::vec3> cameraOrientation = camera["Transform"]["Orientation"];
|
||||
cameraOrientation.x(cameraOrientation.x() - change);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
|
||||
if (rootNode.Valid()) {
|
||||
EntityWrapper blend = rootNode.FirstChildByName("MovementBlendAssault");
|
||||
if (blend.Valid()) {
|
||||
(double&)blend["Blend"]["Weight"] = animationWeight;
|
||||
(Field<double>)blend["Blend"]["Weight"] = animationWeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,24 +104,24 @@ void AssaultWeaponBehaviour::OnCeasePrimaryFire(ComponentWrapper cWeapon, Weapon
|
||||
|
||||
void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi)
|
||||
{
|
||||
bool& reloadQueued = cWeapon["ReloadQueued"];
|
||||
bool& isReloading = cWeapon["IsReloading"];
|
||||
Field<bool> reloadQueued = cWeapon["ReloadQueued"];
|
||||
Field<bool> isReloading = cWeapon["IsReloading"];
|
||||
if (reloadQueued || isReloading) {
|
||||
return;
|
||||
}
|
||||
|
||||
int& magAmmo = cWeapon["MagazineAmmo"];
|
||||
int& magSize = cWeapon["MagazineSize"];
|
||||
Field<int> magAmmo = cWeapon["MagazineAmmo"];
|
||||
Field<int> magSize = cWeapon["MagazineSize"];
|
||||
if (magAmmo >= magSize) {
|
||||
return;
|
||||
}
|
||||
int& ammo = cWeapon["Ammo"];
|
||||
Field<int> ammo = cWeapon["Ammo"];
|
||||
if (ammo <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
double reloadTime = cWeapon["ReloadTime"];
|
||||
double& reloadTimer = cWeapon["ReloadTimer"];
|
||||
Field<double> reloadTime = cWeapon["ReloadTime"];
|
||||
Field<double> reloadTimer = cWeapon["ReloadTimer"];
|
||||
|
||||
// Start reload
|
||||
reloadQueued = true;
|
||||
@@ -161,7 +161,7 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi)
|
||||
|
||||
// Sound
|
||||
Events::PlaySoundOnEntity e;
|
||||
e.EmitterID = wi.Player.ID;
|
||||
e.Emitter = wi.Player;
|
||||
e.FilePath = "Audio/weapon/Assault/AssaultWeaponReload.wav";
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
@@ -194,13 +194,32 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
cWeapon["FireCooldown"] = 60.0 / (double)cWeapon["RPM"];
|
||||
|
||||
// Ammo
|
||||
int& magAmmo = cWeapon["MagazineAmmo"];
|
||||
Field<int> magAmmo = cWeapon["MagazineAmmo"];
|
||||
if (magAmmo <= 0) {
|
||||
return;
|
||||
} else {
|
||||
magAmmo -= 1;
|
||||
}
|
||||
|
||||
// View punch
|
||||
if (IsClient) {
|
||||
EntityWrapper camera = wi.Player.FirstChildByName("Camera");
|
||||
if (camera.Valid()) {
|
||||
Field<glm::vec3> cameraOrientation = camera["Transform"]["Orientation"];
|
||||
float viewPunch = cWeapon["ViewPunch"];
|
||||
float maxTravelAngle = cWeapon["MaxTravelAngle"];
|
||||
Field<float> currentTravel = cWeapon["CurrentTravel"];
|
||||
if (currentTravel < maxTravelAngle) {
|
||||
float change = viewPunch;
|
||||
if (currentTravel + change > maxTravelAngle) {
|
||||
change = maxTravelAngle - currentTravel;
|
||||
}
|
||||
cameraOrientation.x(cameraOrientation.x() + change);
|
||||
currentTravel += change;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get weapon model based on current person
|
||||
EntityWrapper weaponModelEntity = getRelevantWeaponEntity(wi);
|
||||
if (!weaponModelEntity.Valid()) {
|
||||
@@ -210,12 +229,12 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
// Tracer
|
||||
EntityWrapper tracerSpawner = weaponModelEntity.FirstChildByName("WeaponMuzzleRay");
|
||||
if (tracerSpawner.Valid()) {
|
||||
glm::vec3 origin = Transform::AbsolutePosition(tracerSpawner);
|
||||
glm::vec3 direction = glm::quat(Transform::AbsoluteOrientationEuler(tracerSpawner)) * glm::vec3(0, 0, -1);
|
||||
glm::vec3 origin = TransformSystem::AbsolutePosition(tracerSpawner);
|
||||
glm::vec3 direction = glm::quat(TransformSystem::AbsoluteOrientationEuler(tracerSpawner)) * glm::vec3(0, 0, -1);
|
||||
float distance = traceRayDistance(origin, direction);
|
||||
EntityWrapper ray = SpawnerSystem::Spawn(tracerSpawner, tracerSpawner);
|
||||
if (ray.Valid()) {
|
||||
((glm::vec3&)ray["Transform"]["Scale"]).z = distance;
|
||||
((Field<glm::vec3>)ray["Transform"]["Scale"]).z(distance);
|
||||
}
|
||||
}
|
||||
//MuzzleFlash
|
||||
@@ -235,7 +254,7 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
if (hitMarkerSpawner.Valid()) {
|
||||
SpawnerSystem::Spawn(hitMarkerSpawner, hitMarkerSpawner);
|
||||
Events::PlaySoundOnEntity e;
|
||||
e.EmitterID = wi.Player.ID;
|
||||
e.Emitter = wi.Player;
|
||||
e.FilePath = "Audio/weapon/hitclick.wav";
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
@@ -273,7 +292,7 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
|
||||
// Sound
|
||||
Events::PlaySoundOnEntity e;
|
||||
e.EmitterID = wi.Player.ID;
|
||||
e.Emitter = wi.Player;
|
||||
e.FilePath = "Audio/weapon/Assault/AssaultWeaponFire.wav";
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user