chargeShootEffect / Effect startDelay

This commit is contained in:
Anuken
2021-09-29 22:39:33 -04:00
parent efb9df7b1b
commit 6f6590d5bb
6 changed files with 33 additions and 15 deletions

View File

@@ -120,7 +120,7 @@ public interface Platform{
}else{ }else{
ui.loadAnd(() -> { ui.loadAnd(() -> {
try{ try{
Fi result = Core.files.local(name+ "." + extension); Fi result = Core.files.local(name + "." + extension);
writer.write(result); writer.write(result);
platform.shareFile(result); platform.shareFile(result);
}catch(Throwable e){ }catch(Throwable e){

View File

@@ -30,6 +30,8 @@ public class Effect{
public float lifetime = 50f; public float lifetime = 50f;
/** Clip size. */ /** Clip size. */
public float clip; public float clip;
/** Time delay before the effect starts */
public float startDelay;
/** Amount added to rotation */ /** Amount added to rotation */
public float baseRotation; public float baseRotation;
/** If true, parent unit is data are followed. */ /** If true, parent unit is data are followed. */
@@ -58,6 +60,11 @@ public class Effect{
all.add(this); all.add(this);
} }
public Effect startDelay(float d){
startDelay = d;
return this;
}
public void init(){} public void init(){}
public Effect followParent(boolean follow){ public Effect followParent(boolean follow){
@@ -168,21 +175,29 @@ public class Effect{
effect.init(); effect.init();
} }
EffectState entity = EffectState.create(); if(effect.startDelay <= 0f){
entity.effect = effect; inst(effect, x, y, rotation, color, data);
entity.rotation = effect.baseRotation + rotation; }else{
entity.data = data; Time.runTask(effect.startDelay, () -> inst(effect, x, y, rotation, color, data));
entity.lifetime = effect.lifetime;
entity.set(x, y);
entity.color.set(color);
if(effect.followParent && data instanceof Posc p){
entity.parent = p;
entity.rotWithParent = effect.rotWithParent;
} }
entity.add();
} }
} }
private static void inst(Effect effect, float x, float y, float rotation, Color color, Object data){
EffectState entity = EffectState.create();
entity.effect = effect;
entity.rotation = effect.baseRotation + rotation;
entity.data = data;
entity.lifetime = effect.lifetime;
entity.set(x, y);
entity.color.set(color);
if(effect.followParent && data instanceof Posc p){
entity.parent = p;
entity.rotWithParent = effect.rotWithParent;
}
entity.add();
}
public static void decal(TextureRegion region, float x, float y, float rotation){ public static void decal(TextureRegion region, float x, float y, float rotation){
decal(region, x, y, rotation, 3600f, Pal.rubble); decal(region, x, y, rotation, 3600f, Pal.rubble);
} }

View File

@@ -49,6 +49,8 @@ public class BulletType extends Content implements Cloneable{
public Effect despawnEffect = Fx.hitBulletSmall; public Effect despawnEffect = Fx.hitBulletSmall;
/** Effect created when shooting. */ /** Effect created when shooting. */
public Effect shootEffect = Fx.shootSmall; public Effect shootEffect = Fx.shootSmall;
/** Effect created when charging completes; only usable in single-shot weapons with a firstShotDelay / shotDelay. */
public Effect chargeShootEffect = Fx.none;
/** Extra smoke effect created when shooting. */ /** Extra smoke effect created when shooting. */
public Effect smokeEffect = Fx.shootSmallSmoke; public Effect smokeEffect = Fx.shootSmallSmoke;
/** Sound made when hitting something or getting removed.*/ /** Sound made when hitting something or getting removed.*/

View File

@@ -76,7 +76,7 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
//sort counts in descending order //sort counts in descending order
Seq<Entry<Block>> entries = floorc.entries().toArray(); Seq<Entry<Block>> entries = floorc.entries().toArray();
entries.sort(e -> -e.value); entries.sort(e -> -e.value);
//remove all blocks occuring < 30 times - unimportant //remove all blocks occurring < 30 times - unimportant
entries.removeAll(e -> e.value < 30); entries.removeAll(e -> e.value < 30);
Block[] floors = new Block[entries.size]; Block[] floors = new Block[entries.size];
@@ -84,7 +84,7 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
floors[i] = entries.get(i).key; floors[i] = entries.get(i).key;
} }
//TODO bad code //bad contains() code, but will likely never be fixed
boolean hasSnow = floors.length > 0 && (floors[0].name.contains("ice") || floors[0].name.contains("snow")); boolean hasSnow = floors.length > 0 && (floors[0].name.contains("ice") || floors[0].name.contains("snow"));
boolean hasRain = floors.length > 0 && !hasSnow && content.contains(Liquids.water) && !floors[0].name.contains("sand"); boolean hasRain = floors.length > 0 && !hasSnow && content.contains(Liquids.water) && !floors[0].name.contains("sand");
boolean hasDesert = floors.length > 0 && !hasSnow && !hasRain && floors[0] == Blocks.sand; boolean hasDesert = floors.length > 0 && !hasSnow && !hasRain && floors[0] == Blocks.sand;

View File

@@ -350,6 +350,7 @@ public class Weapon implements Cloneable{
if(!continuous){ if(!continuous){
shootSound.at(shootX, shootY, Mathf.random(soundPitchMin, soundPitchMax)); shootSound.at(shootX, shootY, Mathf.random(soundPitchMin, soundPitchMax));
} }
ammo.chargeShootEffect.at(shootX + unit.x - baseX, shootY + unit.y - baseY, rotation, parentize ? unit : null);
}); });
}else{ }else{
unit.vel.add(Tmp.v1.trns(rotation + 180f, ammo.recoil)); unit.vel.add(Tmp.v1.trns(rotation + 180f, ammo.recoil));

View File

@@ -24,4 +24,4 @@ android.useAndroidX=true
#used for slow jitpack builds; TODO see if this actually works #used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000 org.gradle.internal.http.connectionTimeout=100000
archash=57b15a1b73cf0d6f19a50d2111f43d993e57c7f1 archash=6a2c848995763acaaf4e5ee2d589f53f49c7c4c1