mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
improved offset FX handling
This commit is contained in:
@@ -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
|
||||
}
|
||||
--[[
|
||||
]]--
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+7
-5
@@ -14,13 +14,15 @@ namespace battleship{
|
||||
if(v) ((vb01::Node*)c)->setVisible(false);
|
||||
}
|
||||
|
||||
FxManager::Fx::Fx(std::vector<FxManager::Fx::Component> comps, bool re) : initTime(vb01::getTime()), components(comps), reuse(re){
|
||||
FxManager::Fx::Fx(std::vector<FxManager::Fx::Component> 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);
|
||||
|
||||
@@ -17,7 +17,6 @@ namespace battleship{
|
||||
};
|
||||
|
||||
bool reuse;
|
||||
vb01::s64 initTime;
|
||||
std::vector<Component> components;
|
||||
|
||||
Fx(std::vector<Component>, bool = false);
|
||||
|
||||
@@ -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<sol::table>)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<float>)compTbl["scale"] != sol::nullopt) float sc = compTbl["scale"];
|
||||
|
||||
|
||||
if((sol::optional<string>)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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user