Merge fixes
This commit is contained in:
@@ -21,7 +21,7 @@ struct SpriteJob : RenderJob
|
||||
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted, bool isIndicator)
|
||||
: RenderJob()
|
||||
{
|
||||
Model = ResourceManager::Load<::Model>((std::string)cSprite["Model"]);
|
||||
Model = ResourceManager::Load<::Model>(cSprite["Model"]);
|
||||
::RawModel::MaterialProperties matProp = Model->MaterialGroups().front();
|
||||
TextureID = 0;
|
||||
|
||||
|
||||
@@ -24,28 +24,28 @@ void AbilityCooldownHUDSystem::Update(double dt)
|
||||
if (!abilityEntity.Valid()) {
|
||||
//If we dont have a shield ability, we return, since we cannot do anything.
|
||||
if (entity.HasComponent("Sprite")) {
|
||||
(std::string&)entity["Sprite"]["DiffuseTexture"] = "Textures/Test/aM4ME4GR.png";
|
||||
(Field<std::string>)entity["Sprite"]["DiffuseTexture"] = "Textures/Test/aM4ME4GR.png";
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
//If we have a shield ability, we set the right icon
|
||||
abilityName = "ShieldAbility";
|
||||
if (entity.HasComponent("Sprite")) {
|
||||
(std::string&)entity["Sprite"]["DiffuseTexture"] = "Textures/Icons/Abilities/Long/SheildDots-01.png";
|
||||
(Field<std::string>)entity["Sprite"]["DiffuseTexture"] = "Textures/Icons/Abilities/Long/SheildDots-01.png";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//If we do have a sprint ability, we change the icon
|
||||
abilityName = "SprintAbility";
|
||||
if (entity.HasComponent("Sprite")) {
|
||||
(std::string&)entity["Sprite"]["DiffuseTexture"] = "Textures/Icons/Abilities/Long/Dash-01.png";
|
||||
(Field<std::string>)entity["Sprite"]["DiffuseTexture"] = "Textures/Icons/Abilities/Long/Dash-01.png";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//If we have a dash ability, we set the icon to the correct one.
|
||||
abilityName = "DashAbility";
|
||||
if (entity.HasComponent("Sprite")) {
|
||||
(std::string&)entity["Sprite"]["DiffuseTexture"] = "Textures/Icons/Abilities/Long/Superman-01.png";
|
||||
(Field<std::string>)entity["Sprite"]["DiffuseTexture"] = "Textures/Icons/Abilities/Long/Superman-01.png";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ void AbilityCooldownHUDSystem::Update(double dt)
|
||||
|
||||
if (cooldownTextEntity.Valid()) {
|
||||
if (cooldownTextEntity.HasComponent("Text")) {
|
||||
std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3);
|
||||
(Field<std::string>)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ void AbilityCooldownHUDSystem::Update(double dt)
|
||||
}
|
||||
|
||||
if (entity.HasComponent("Fill")) {
|
||||
entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD;
|
||||
(Field<double>)entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ void BoostIconsHUDSystem::UpdateComponent(EntityWrapper& entity, ComponentWrappe
|
||||
if (assaultEntity.HasComponent("Fill")) {
|
||||
EntityWrapper assaultBoost = player.FirstChildByName("BoostAssault");
|
||||
if (assaultBoost.Valid()) {
|
||||
(double&)assaultEntity["Fill"]["Percentage"] = 1.0;
|
||||
(Field<double>)assaultEntity["Fill"]["Percentage"] = 1.0;
|
||||
} else {
|
||||
(double&)assaultEntity["Fill"]["Percentage"] = 0.0;
|
||||
(Field<double>)assaultEntity["Fill"]["Percentage"] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,9 +23,9 @@ void BoostIconsHUDSystem::UpdateComponent(EntityWrapper& entity, ComponentWrappe
|
||||
if (defenderEntity.HasComponent("Fill")) {
|
||||
EntityWrapper defenderBoost = player.FirstChildByName("BoostDefender");
|
||||
if (defenderBoost.Valid()) {
|
||||
(double&)defenderEntity["Fill"]["Percentage"] = 1.0;
|
||||
(Field<double>)defenderEntity["Fill"]["Percentage"] = 1.0;
|
||||
} else {
|
||||
(double&)defenderEntity["Fill"]["Percentage"] = 0.0;
|
||||
(Field<double>)defenderEntity["Fill"]["Percentage"] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,9 +34,9 @@ void BoostIconsHUDSystem::UpdateComponent(EntityWrapper& entity, ComponentWrappe
|
||||
if (sniperEntity.HasComponent("Fill")) {
|
||||
EntityWrapper sniperBoost = player.FirstChildByName("BoostSniper");
|
||||
if (sniperBoost.Valid()) {
|
||||
(double&)sniperEntity["Fill"]["Percentage"] = 1.0;
|
||||
(Field<double>)sniperEntity["Fill"]["Percentage"] = 1.0;
|
||||
} else {
|
||||
(double&)sniperEntity["Fill"]["Percentage"] = 0.0;
|
||||
(Field<double>)sniperEntity["Fill"]["Percentage"] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +81,10 @@ void BoostSystem::giveAmmo(EntityWrapper giver, EntityWrapper receiver)
|
||||
{
|
||||
if (receiver.HasComponent("AssaultWeapon")) {
|
||||
int magazineSize = receiver["AssaultWeapon"]["MagazineSize"];
|
||||
int& magazineAmmo = receiver["AssaultWeapon"]["MagazineAmmo"];
|
||||
Field<int> magazineAmmo = receiver["AssaultWeapon"]["MagazineAmmo"];
|
||||
int prevMagazineAmmo = receiver["AssaultWeapon"]["MagazineAmmo"];
|
||||
int maxAmmo = receiver["AssaultWeapon"]["MaxAmmo"];
|
||||
int& ammo = receiver["AssaultWeapon"]["Ammo"];
|
||||
Field<int> ammo = receiver["AssaultWeapon"]["Ammo"];
|
||||
|
||||
int givenAmmo = 3;
|
||||
|
||||
@@ -97,10 +97,10 @@ void BoostSystem::giveAmmo(EntityWrapper giver, EntityWrapper receiver)
|
||||
}
|
||||
} else if (receiver.HasComponent("DefenderWeapon")) {
|
||||
int magazineSize = receiver["DefenderWeapon"]["MagazineSize"];
|
||||
int& magazineAmmo = receiver["DefenderWeapon"]["MagazineAmmo"];
|
||||
Field<int> magazineAmmo = receiver["DefenderWeapon"]["MagazineAmmo"];
|
||||
int prevMagazineAmmo = receiver["DefenderWeapon"]["MagazineAmmo"];
|
||||
int maxAmmo = receiver["DefenderWeapon"]["MaxAmmo"];
|
||||
int& ammo = receiver["DefenderWeapon"]["Ammo"];
|
||||
Field<int> ammo = receiver["DefenderWeapon"]["Ammo"];
|
||||
|
||||
int givenAmmo = 1;
|
||||
|
||||
|
||||
@@ -35,37 +35,37 @@ bool EndScreenSystem::OnWin(const Events::Win& e)
|
||||
if (e.TeamThatWon == 2) {
|
||||
//Red team won
|
||||
if(redSprite.HasComponent("Sprite"))
|
||||
(bool&)redSprite["Sprite"]["Visible"] = true;
|
||||
(Field<bool>)redSprite["Sprite"]["Visible"] = true;
|
||||
if (redText.HasComponent("Text"))
|
||||
(bool&)redText["Text"]["Visible"] = true;
|
||||
(Field<bool>)redText["Text"]["Visible"] = true;
|
||||
|
||||
if (blueSprite.HasComponent("Sprite"))
|
||||
(bool&)blueSprite["Sprite"]["Visible"] = false;
|
||||
(Field<bool>)blueSprite["Sprite"]["Visible"] = false;
|
||||
if (blueText.HasComponent("Text"))
|
||||
(bool&)blueText["Text"]["Visible"] = false;
|
||||
(Field<bool>)blueText["Text"]["Visible"] = false;
|
||||
|
||||
}else if (e.TeamThatWon == 3) {
|
||||
//Blue team won
|
||||
if (redSprite.HasComponent("Sprite"))
|
||||
(bool&)redSprite["Sprite"]["Visible"] = false;
|
||||
(Field<bool>)redSprite["Sprite"]["Visible"] = false;
|
||||
if (redText.HasComponent("Text"))
|
||||
(bool&)redText["Text"]["Visible"] = false;
|
||||
(Field<bool>)redText["Text"]["Visible"] = false;
|
||||
|
||||
if (blueSprite.HasComponent("Sprite"))
|
||||
(bool&)blueSprite["Sprite"]["Visible"] = true;
|
||||
(Field<bool>)blueSprite["Sprite"]["Visible"] = true;
|
||||
if (blueText.HasComponent("Text"))
|
||||
(bool&)blueText["Text"]["Visible"] = true;
|
||||
(Field<bool>)blueText["Text"]["Visible"] = true;
|
||||
} else {
|
||||
//No team won?
|
||||
if (redSprite.HasComponent("Sprite"))
|
||||
(bool&)redSprite["Sprite"]["Visible"] = false;
|
||||
(Field<bool>)redSprite["Sprite"]["Visible"] = false;
|
||||
if (blueSprite.HasComponent("Sprite"))
|
||||
(bool&)blueSprite["Sprite"]["Visible"] = false;
|
||||
(Field<bool>)blueSprite["Sprite"]["Visible"] = false;
|
||||
|
||||
if (redText.HasComponent("Text"))
|
||||
(bool&)redText["Text"]["Visible"] = false;
|
||||
(Field<bool>)redText["Text"]["Visible"] = false;
|
||||
if (blueText.HasComponent("Text"))
|
||||
(bool&)blueText["Text"]["Visible"] = false;
|
||||
(Field<bool>)blueText["Text"]["Visible"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,30 +20,30 @@ void FadeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cFade,
|
||||
}
|
||||
|
||||
double fadeTime = cFade["FadeTime"];
|
||||
double& currentTime = cFade["Time"];
|
||||
Field<bool> currentTime = cFade["Time"];
|
||||
currentTime += dTime;
|
||||
|
||||
if(currentTime > fadeTime) {
|
||||
currentTime = 0.0;
|
||||
if ((bool)cFade["Reverse"]) {
|
||||
(bool&)cFade["Out"] = !(bool)cFade["Out"];
|
||||
(Field<bool>)cFade["Out"] = !(bool)cFade["Out"];
|
||||
currentTime = fadeTime;
|
||||
}
|
||||
}
|
||||
if(currentTime < 0.0) {
|
||||
currentTime = fadeTime;
|
||||
if ((bool)cFade["Reverse"]) {
|
||||
(bool&)cFade["Out"] = !(bool)cFade["Out"];
|
||||
(Field<bool>)cFade["Out"] = !(bool)cFade["Out"];
|
||||
currentTime = 0.0;
|
||||
}
|
||||
}
|
||||
double ratio = currentTime/fadeTime;
|
||||
|
||||
if(entity.HasComponent("Model")){
|
||||
((glm::vec4&)entity["Model"]["Color"]).a = ratio;
|
||||
((Field<glm::vec4>)entity["Model"]["Color"]).w(ratio);
|
||||
}
|
||||
if (entity.HasComponent("Sprite")) {
|
||||
((glm::vec4&)entity["Sprite"]["Color"]).a = ratio;
|
||||
((Field<glm::vec4>)entity["Sprite"]["Color"]).w(ratio);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
// Limit camera pitch so we don't break our necks
|
||||
cameraOrientation.x(glm::clamp(cameraOrientation.x(), -glm::half_pi<float>(), glm::half_pi<float>()));
|
||||
|
||||
float pitch = cameraOrientation.x;
|
||||
float pitch = cameraOrientation.x();
|
||||
double time = ((pitch + glm::half_pi<float>()) / glm::pi<float>());
|
||||
|
||||
// Set third person model aim pitch
|
||||
@@ -325,7 +325,7 @@ void PlayerMovementSystem::setAim(EntityWrapper root, std::string weaponNodeName
|
||||
EntityWrapper aim = weapon.FirstChildByName("Aim");
|
||||
if (aim.Valid()) {
|
||||
if (aim.HasComponent("Animation")) {
|
||||
(double&)aim["Animation"]["Time"] = time;
|
||||
(Field<double>)aim["Animation"]["Time"] = time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
|
||||
Field<int> magSize = cWeapon["MagazineSize"];
|
||||
Field<int> ammo = cWeapon["Ammo"];
|
||||
|
||||
int usedAmmo = glm::max(0, magSize - magAmmo);
|
||||
magAmmo = glm::clamp(ammo + magAmmo, 0, magSize);
|
||||
ammo = glm::max(0, ammo - usedAmmo);
|
||||
int usedAmmo = glm::max(0, *magSize - *magAmmo);
|
||||
magAmmo = glm::clamp(*ammo + *magAmmo, 0, *magSize);
|
||||
ammo = glm::max(0, *ammo - usedAmmo);
|
||||
|
||||
|
||||
isReloading = false;
|
||||
@@ -243,7 +243,7 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
std::uniform_real_distribution<float> randomSpreadAngle(0.f, 3.1415f*2);
|
||||
EntityWrapper flash = SpawnerSystem::Spawn(muzzleFlashSpawner, muzzleFlashSpawner);
|
||||
if (flash.Valid()) {
|
||||
((glm::vec3&)flash["Transform"]["Orientation"]).z = randomSpreadAngle(m_RandomEngine);
|
||||
((Field<glm::vec3>)flash["Transform"]["Orientation"]).z(randomSpreadAngle(m_RandomEngine));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,16 +264,16 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
if (IsClient) {
|
||||
EntityWrapper camera = wi.Player.FirstChildByName("Camera");
|
||||
if (camera.Valid()) {
|
||||
glm::vec3& cameraOrientation = camera["Transform"]["Orientation"];
|
||||
Field<glm::vec3> cameraOrientation = camera["Transform"]["Orientation"];
|
||||
float viewPunch = cWeapon["ViewPunch"];
|
||||
float maxTravelAngle = cWeapon["MaxTravelAngle"];
|
||||
float& currentTravel = cWeapon["CurrentTravel"];
|
||||
Field<float> currentTravel = cWeapon["CurrentTravel"];
|
||||
if (currentTravel < maxTravelAngle) {
|
||||
float change = viewPunch;
|
||||
if (currentTravel + change > maxTravelAngle) {
|
||||
change = maxTravelAngle - currentTravel;
|
||||
}
|
||||
cameraOrientation.x += change;
|
||||
cameraOrientation.x(cameraOrientation.x() + change);
|
||||
currentTravel += change;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
void DefenderWeaponBehaviour::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,27 +11,27 @@ void DefenderWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWr
|
||||
void DefenderWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt)
|
||||
{
|
||||
// Decrement reload timer
|
||||
double& reloadTimer = cWeapon["ReloadTimer"];
|
||||
Field<double> reloadTimer = cWeapon["ReloadTimer"];
|
||||
reloadTimer = glm::max(0.0, reloadTimer - 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);
|
||||
}
|
||||
|
||||
// Handle reloading
|
||||
bool& isReloading = cWeapon["IsReloading"];
|
||||
Field<bool> isReloading = cWeapon["IsReloading"];
|
||||
if (isReloading && reloadTimer <= 0.0) {
|
||||
double reloadTime = cWeapon["ReloadTime"];
|
||||
int& magSize = cWeapon["MagazineSize"];
|
||||
int& ammo = cWeapon["Ammo"];
|
||||
Field<int> magSize = cWeapon["MagazineSize"];
|
||||
Field<int> ammo = cWeapon["Ammo"];
|
||||
if (magAmmo < magSize && ammo > 0) {
|
||||
ammo -= 1;
|
||||
magAmmo += 1;
|
||||
reloadTimer = reloadTime;
|
||||
Events::PlaySoundOnEntity e;
|
||||
e.EmitterID = wi.Player.ID;
|
||||
e.Emitter = wi.Player;
|
||||
e.FilePath = "Audio/weapon/Zoom.wav";
|
||||
m_EventBroker->Publish(e);
|
||||
} else {
|
||||
@@ -52,15 +52,15 @@ void DefenderWeaponBehaviour::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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,23 +86,23 @@ void DefenderWeaponBehaviour::OnCeasePrimaryFire(ComponentWrapper cWeapon, Weapo
|
||||
|
||||
void DefenderWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi)
|
||||
{
|
||||
bool& isReloading = cWeapon["IsReloading"];
|
||||
Field<bool> isReloading = cWeapon["IsReloading"];
|
||||
if (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> reloadTimer = cWeapon["ReloadTimer"];
|
||||
|
||||
// Start reload
|
||||
isReloading = true;
|
||||
@@ -155,7 +155,7 @@ bool DefenderWeaponBehaviour::OnInputCommand(ComponentWrapper cWeapon, WeaponInf
|
||||
|
||||
if(wi.Player.Valid()) {
|
||||
if(wi.Player.HasComponent("ShieldAbility")) {
|
||||
(bool&)wi.Player["ShieldAbility"]["Active"] = true;
|
||||
(Field<double>)wi.Player["ShieldAbility"]["Active"] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ bool DefenderWeaponBehaviour::OnInputCommand(ComponentWrapper cWeapon, WeaponInf
|
||||
|
||||
if (wi.Player.Valid()) {
|
||||
if (wi.Player.HasComponent("ShieldAbility")) {
|
||||
(bool&)wi.Player["ShieldAbility"]["Active"] = false;
|
||||
(Field<bool>)wi.Player["ShieldAbility"]["Active"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,11 +285,11 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
cWeapon["FireCooldown"] = 60.0 / (double)cWeapon["RPM"];
|
||||
|
||||
// Stop reloading
|
||||
bool& isReloading = cWeapon["IsReloading"];
|
||||
Field<double> isReloading = cWeapon["IsReloading"];
|
||||
isReloading = false;
|
||||
|
||||
// Ammo
|
||||
int& magAmmo = cWeapon["MagazineAmmo"];
|
||||
Field<int> magAmmo = cWeapon["MagazineAmmo"];
|
||||
if (magAmmo <= 0) {
|
||||
return;
|
||||
} else {
|
||||
@@ -347,7 +347,7 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
|
||||
// Sound
|
||||
Events::PlaySoundOnEntity e;
|
||||
e.EmitterID = wi.Player.ID;
|
||||
e.Emitter = wi.Player;
|
||||
e.FilePath = "Audio/weapon/Blast.wav";
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
@@ -367,8 +367,8 @@ void DefenderWeaponBehaviour::spawnTracers(ComponentWrapper cWeapon, WeaponInfo&
|
||||
float spreadAngle = glm::radians((float)cWeapon["SpreadAngle"]);
|
||||
|
||||
for (auto& pellet : pattern) {
|
||||
glm::quat pelletRotation = glm::quat(Transform::AbsoluteOrientationEuler(camera)) * glm::quat(glm::vec3(pellet.y, pellet.x, 0) * spreadAngle);
|
||||
glm::vec3 cameraPosition = Transform::AbsolutePosition(camera);
|
||||
glm::quat pelletRotation = glm::quat(TransformSystem::AbsoluteOrientationEuler(camera)) * glm::quat(glm::vec3(pellet.y, pellet.x, 0) * spreadAngle);
|
||||
glm::vec3 cameraPosition = TransformSystem::AbsolutePosition(camera);
|
||||
glm::vec3 direction = pelletRotation * glm::vec3(0, 0, -1);
|
||||
|
||||
float distance;
|
||||
@@ -378,12 +378,12 @@ void DefenderWeaponBehaviour::spawnTracers(ComponentWrapper cWeapon, WeaponInfo&
|
||||
EntityWrapper ray = SpawnerSystem::Spawn(muzzle);
|
||||
if (ray.Valid()) {
|
||||
ComponentWrapper cTransform = ray["Transform"];
|
||||
glm::vec3& rayOrigin = cTransform["Position"];
|
||||
glm::vec3& rayOrientation = cTransform["Orientation"];
|
||||
glm::vec3& rayScale = cTransform["Scale"];
|
||||
Field<glm::vec3> rayOrigin = cTransform["Position"];
|
||||
Field<glm::vec3> rayOrientation = cTransform["Orientation"];
|
||||
Field<glm::vec3> rayScale = cTransform["Scale"];
|
||||
|
||||
glm::vec3 muzzlePosition = Transform::AbsolutePosition(muzzle);
|
||||
glm::quat muzzleOrientation = Transform::AbsoluteOrientation(muzzle);
|
||||
glm::vec3 muzzlePosition = TransformSystem::AbsolutePosition(muzzle);
|
||||
glm::quat muzzleOrientation = TransformSystem::AbsoluteOrientation(muzzle);
|
||||
|
||||
rayOrigin = muzzlePosition;
|
||||
|
||||
@@ -393,7 +393,7 @@ void DefenderWeaponBehaviour::spawnTracers(ComponentWrapper cWeapon, WeaponInfo&
|
||||
float yaw = std::atan2(lookVector.x, lookVector.z);
|
||||
glm::quat orientation = glm::quat(glm::vec3(pitch, yaw, 0));
|
||||
rayOrientation = glm::eulerAngles(orientation);
|
||||
rayScale.z = glm::length(muzzleToHit);
|
||||
rayScale.z(glm::length(muzzleToHit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
void SidearmWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt)
|
||||
{
|
||||
double& cooldown = cWeapon["FireCooldown"];
|
||||
Field<double> cooldown = cWeapon["FireCooldown"];
|
||||
if (cooldown > 0) {
|
||||
cooldown -= dt;
|
||||
if (cooldown < 0) {
|
||||
@@ -17,29 +17,29 @@ void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
|
||||
CheckAmmo(cWeapon, wi);
|
||||
|
||||
// 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"];
|
||||
Field<int> magSize = cWeapon["MagazineSize"];
|
||||
|
||||
magAmmo = magSize;
|
||||
isReloading = false;
|
||||
@@ -65,7 +65,7 @@ void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
|
||||
if (rootNode.Valid()) {
|
||||
EntityWrapper blend = rootNode.FirstChildByName("MovementBlendSidearm");
|
||||
if (blend.Valid()) {
|
||||
(double&)blend["Blend"]["Weight"] = animationWeight;
|
||||
(Field<double>)blend["Blend"]["Weight"] = animationWeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,20 +90,20 @@ void SidearmWeaponBehaviour::OnCeasePrimaryFire(ComponentWrapper cWeapon, Weapon
|
||||
|
||||
void SidearmWeaponBehaviour::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;
|
||||
}
|
||||
|
||||
double reloadTime = cWeapon["ReloadTime"];
|
||||
double& reloadTimer = cWeapon["ReloadTimer"];
|
||||
Field<double> reloadTimer = cWeapon["ReloadTimer"];
|
||||
|
||||
// Start reload
|
||||
reloadQueued = true;
|
||||
@@ -143,7 +143,7 @@ void SidearmWeaponBehaviour::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);
|
||||
}
|
||||
@@ -176,7 +176,7 @@ void SidearmWeaponBehaviour::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 {
|
||||
@@ -192,12 +192,12 @@ void SidearmWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
// Tracer
|
||||
EntityWrapper tracerSpawner = weaponModelEntity.FirstChildByName("WeaponMuzzle");
|
||||
if (tracerSpawner.Valid()) {
|
||||
glm::vec3 origin = Transform::AbsolutePosition(tracerSpawner);
|
||||
glm::vec3 direction = Transform::AbsoluteOrientation(tracerSpawner) * glm::vec3(0, 0, -1);
|
||||
glm::vec3 origin = TransformSystem::AbsolutePosition(tracerSpawner);
|
||||
glm::vec3 direction = TransformSystem::AbsoluteOrientation(tracerSpawner) * glm::vec3(0, 0, -1);
|
||||
float distance = traceRayDistance(origin, direction);
|
||||
EntityWrapper ray = SpawnerSystem::Spawn(tracerSpawner);
|
||||
if (ray.Valid()) {
|
||||
((glm::vec3&)ray["Transform"]["Scale"]).z = distance;
|
||||
((Field<glm::vec3>)ray["Transform"]["Scale"]).z(distance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ void SidearmWeaponBehaviour::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);
|
||||
}
|
||||
@@ -345,7 +345,7 @@ void SidearmWeaponBehaviour::spawnTracer(ComponentWrapper cWeapon, WeaponInfo& w
|
||||
return;
|
||||
}
|
||||
|
||||
glm::vec3 cameraPosition = Transform::AbsolutePosition(camera);
|
||||
glm::vec3 cameraPosition = TransformSystem::AbsolutePosition(camera);
|
||||
glm::vec3 direction = glm::vec3(0, 0, -1);
|
||||
|
||||
float distance;
|
||||
@@ -355,12 +355,12 @@ void SidearmWeaponBehaviour::spawnTracer(ComponentWrapper cWeapon, WeaponInfo& w
|
||||
EntityWrapper ray = SpawnerSystem::Spawn(muzzle);
|
||||
if (ray.Valid()) {
|
||||
ComponentWrapper cTransform = ray["Transform"];
|
||||
glm::vec3& rayOrigin = cTransform["Position"];
|
||||
glm::vec3& rayOrientation = cTransform["Orientation"];
|
||||
glm::vec3& rayScale = cTransform["Scale"];
|
||||
Field<glm::vec3> rayOrigin = cTransform["Position"];
|
||||
Field<glm::vec3> rayOrientation = cTransform["Orientation"];
|
||||
Field<glm::vec3> rayScale = cTransform["Scale"];
|
||||
|
||||
glm::vec3 muzzlePosition = Transform::AbsolutePosition(muzzle);
|
||||
glm::quat muzzleOrientation = Transform::AbsoluteOrientation(muzzle);
|
||||
glm::vec3 muzzlePosition = TransformSystem::AbsolutePosition(muzzle);
|
||||
glm::quat muzzleOrientation = TransformSystem::AbsoluteOrientation(muzzle);
|
||||
|
||||
rayOrigin = muzzlePosition;
|
||||
|
||||
@@ -370,7 +370,7 @@ void SidearmWeaponBehaviour::spawnTracer(ComponentWrapper cWeapon, WeaponInfo& w
|
||||
float yaw = std::atan2(lookVector.x, lookVector.z);
|
||||
glm::quat orientation = glm::quat(glm::vec3(pitch, yaw, 0));
|
||||
rayOrientation = glm::eulerAngles(orientation);
|
||||
rayScale.z = glm::length(muzzleToHit);
|
||||
rayScale.z(glm::length(muzzleToHit));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -492,14 +492,14 @@ void SidearmWeaponBehaviour::CheckAmmo(ComponentWrapper cWeapon, WeaponInfo& wi)
|
||||
EntityWrapper textEntity = friendlyAmmoHud.FirstChildByName("MagazineAmmo");
|
||||
if (textEntity.Valid()) {
|
||||
if (textEntity.HasComponent("Text")) {
|
||||
(std::string&)textEntity["Text"]["Content"] = std::to_string(magazineAmmo);
|
||||
(Field<std::string>)textEntity["Text"]["Content"] = std::to_string(magazineAmmo);
|
||||
}
|
||||
}
|
||||
|
||||
EntityWrapper ammoTextEntity = friendlyAmmoHud.FirstChildByName("Ammo");
|
||||
if (ammoTextEntity.Valid()) {
|
||||
if (ammoTextEntity.HasComponent("Text")) {
|
||||
(std::string&)ammoTextEntity["Text"]["Content"] = std::to_string(ammo);
|
||||
(Field<std::string>)ammoTextEntity["Text"]["Content"] = std::to_string(ammo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -508,14 +508,14 @@ void SidearmWeaponBehaviour::CheckAmmo(ComponentWrapper cWeapon, WeaponInfo& wi)
|
||||
EntityWrapper textEntity = friendlyAmmoHudSpawner.FirstChildByName("MagazineAmmo");
|
||||
if (textEntity.Valid()) {
|
||||
if (textEntity.HasComponent("Text")) {
|
||||
(std::string&)textEntity["Text"]["Content"] = std::to_string(magazineAmmo);
|
||||
(Field<std::string>)textEntity["Text"]["Content"] = std::to_string(magazineAmmo);
|
||||
}
|
||||
}
|
||||
|
||||
EntityWrapper ammoTextEntity = friendlyAmmoHudSpawner.FirstChildByName("Ammo");
|
||||
if (ammoTextEntity.Valid()) {
|
||||
if (ammoTextEntity.HasComponent("Text")) {
|
||||
(std::string&)ammoTextEntity["Text"]["Content"] = std::to_string(ammo);
|
||||
(Field<std::string>)ammoTextEntity["Text"]["Content"] = std::to_string(ammo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user