diff --git a/Assets/Scripts/GameObjects/Units/unitData.lua b/Assets/Scripts/GameObjects/Units/unitData.lua index cf5accf..b810a39 100644 --- a/Assets/Scripts/GameObjects/Units/unitData.lua +++ b/Assets/Scripts/GameObjects/Units/unitData.lua @@ -126,7 +126,7 @@ units = { weapons = { { type = WeaponClass.HITSCAN, - rateOfFire = 500, + rateOfFire = 1000, damage = 200, maxRange = 25, fireFx = { @@ -151,7 +151,8 @@ units = { landHitFx = { { vfx = true, - duration = 50, + duration = 1, + offset = 100, mesh = { numParticles = 1, texture = PATH .. 'Textures/Explosion/explosion07.png', @@ -162,11 +163,10 @@ units = { }, { vfx = false, + offset = 100, path = PATH .. 'Sounds/SFX/Explosions/explosion00.ogg', duration = 2500 } - --[[ - ]]-- } } }, diff --git a/fxManager.cpp b/fxManager.cpp index cec3399..b44577d 100644 --- a/fxManager.cpp +++ b/fxManager.cpp @@ -14,13 +14,15 @@ namespace battleship{ if(v) ((vb01::Node*)c)->setVisible(false); } - FxManager::Fx::Fx(std::vector comps, bool re) : initTime(vb01::getTime()), components(comps), reuse(re){ + FxManager::Fx::Fx(std::vector comps, bool re) : components(comps), reuse(re){ toggleComponents(!re); } void FxManager::Fx::toggleComponents(bool active){ - for(Component &component : components) + for(Component &component : components){ component.active = active; + component.initTime = getTime(); + } } static FxManager *fxManager = nullptr; @@ -39,8 +41,9 @@ namespace battleship{ for(int j = 0; j < fx->components.size(); j++){ Fx::Component &comp = fx->components[j]; + s64 currTime = getTime(); - if(comp.comp && getTime() - comp.initTime > comp.offsetTime){ + if(comp.comp && currTime - comp.initTime > comp.offsetTime){ if(comp.active){ if(comp.vfx) ((Node*)comp.comp)->setVisible(true); @@ -50,8 +53,7 @@ namespace battleship{ comp.active = false; comp.initTime = getTime(); } - - if(!comp.active && getTime() - comp.initTime > comp.offsetTime + comp.duration){ + else if(!comp.active && currTime - comp.initTime > comp.duration){ if(fx->reuse){ if(comp.vfx) ((Node*)comp.comp)->setVisible(false); diff --git a/fxManager.h b/fxManager.h index 95a20f6..027e8ac 100644 --- a/fxManager.h +++ b/fxManager.h @@ -17,7 +17,6 @@ namespace battleship{ }; bool reuse; - vb01::s64 initTime; std::vector components; Fx(std::vector, bool = false); diff --git a/unit.cpp b/unit.cpp index b8b27ea..83b002b 100755 --- a/unit.cpp +++ b/unit.cpp @@ -93,7 +93,7 @@ namespace battleship{ sol::table compTbl = fxTbl[i + 1]; bool vfx = compTbl["vfx"]; - s64 duration = compTbl["duration"]; + s64 duration = compTbl["duration"], offset = compTbl["offset"].get_or(0); if(vfx){ sol::table meshTbl = compTbl["mesh"]; @@ -104,7 +104,7 @@ namespace battleship{ Vector3 compPos = Vector3::VEC_ZERO; Quaternion compRot = Quaternion::QUAT_W; - float sc = 1; + float sc = compTbl["scale"].get_or(1); if((sol::optional)compTbl["pos"] != sol::nullopt){ sol::table posTable = compTbl["pos"]; @@ -116,9 +116,6 @@ namespace battleship{ compRot = Quaternion(rotTable["w"], rotTable["x"], rotTable["y"], rotTable["z"]); } - if((sol::optional)compTbl["scale"] != sol::nullopt) float sc = compTbl["scale"]; - - if((sol::optional)meshTbl["path"] != sol::nullopt){ mat = new Material(Root::getSingleton()->getLibPath() + "texture"); @@ -187,12 +184,12 @@ namespace battleship{ parNode->attachChild(flashNode); - fxComponents.push_back(FxManager::Fx::Component((void*)flashNode, vfx, duration, compPos)); + fxComponents.push_back(FxManager::Fx::Component((void*)flashNode, vfx, duration, compPos, offset)); } else{ sf::SoundBuffer *sfxBuffer = new sf::SoundBuffer(); sf::Sound *sfx = GameObject::prepareSfx(sfxBuffer, compTbl["path"]); - fxComponents.push_back(FxManager::Fx::Component((void*)sfx, vfx, duration)); + fxComponents.push_back(FxManager::Fx::Component((void*)sfx, vfx, duration, Vector3::VEC_ZERO, offset)); } }