Prevent server sound ear destruction / Particle effect rand param
This commit is contained in:
@@ -164,14 +164,14 @@ public class NetClient implements ApplicationListener{
|
|||||||
public static void sound(Sound sound, float volume, float pitch, float pan){
|
public static void sound(Sound sound, float volume, float pitch, float pan){
|
||||||
if(sound == null) return;
|
if(sound == null) return;
|
||||||
|
|
||||||
sound.play(volume * Core.settings.getInt("sfxvol") / 100f, pitch, pan);
|
sound.play(Mathf.clamp(volume, 0, 2f) * Core.settings.getInt("sfxvol") / 100f, pitch, pan);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(variants = Variant.both, unreliable = true)
|
@Remote(variants = Variant.both, unreliable = true)
|
||||||
public static void soundAt(Sound sound, float x, float y, float volume, float pitch){
|
public static void soundAt(Sound sound, float x, float y, float volume, float pitch){
|
||||||
if(sound == null) return;
|
if(sound == null) return;
|
||||||
|
|
||||||
sound.at(x, y, pitch, volume);
|
sound.at(x, y, pitch, Mathf.clamp(volume, 0, 2f));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(variants = Variant.both, unreliable = true)
|
@Remote(variants = Variant.both, unreliable = true)
|
||||||
|
|||||||
@@ -4,14 +4,19 @@ import arc.*;
|
|||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
|
||||||
/** The most essential effect class. Can create particles in various shapes. */
|
/** The most essential effect class. Can create particles in various shapes. */
|
||||||
public class ParticleEffect extends Effect{
|
public class ParticleEffect extends Effect{
|
||||||
|
private static final Rand rand = new Rand();
|
||||||
|
private static final Vec2 rv = new Vec2();
|
||||||
|
|
||||||
public Color colorFrom = Color.white.cpy(), colorTo = Color.white.cpy();
|
public Color colorFrom = Color.white.cpy(), colorTo = Color.white.cpy();
|
||||||
public int particles = 6;
|
public int particles = 6;
|
||||||
|
public boolean randLength = true;
|
||||||
public float cone = 180f, length = 20f, baseLength = 0f;
|
public float cone = 180f, length = 20f, baseLength = 0f;
|
||||||
/** Particle size/length/radius interpolation. */
|
/** Particle size/length/radius interpolation. */
|
||||||
public Interp interp = Interp.linear;
|
public Interp interp = Interp.linear;
|
||||||
@@ -57,15 +62,25 @@ public class ParticleEffect extends Effect{
|
|||||||
Lines.stroke(interp.apply(strokeFrom, strokeTo, rawfin));
|
Lines.stroke(interp.apply(strokeFrom, strokeTo, rawfin));
|
||||||
float len = interp.apply(lenFrom, lenTo, rawfin);
|
float len = interp.apply(lenFrom, lenTo, rawfin);
|
||||||
|
|
||||||
Angles.randLenVectors(e.id, particles, length * fin + baseLength, e.rotation, cone, (x, y) -> {
|
rand.setSeed(e.id);
|
||||||
|
for(int i = 0; i < particles; i++){
|
||||||
|
float l = length * fin + baseLength;
|
||||||
|
rv.trns(e.rotation + rand.range(cone), !randLength ? l : rand.random(l));
|
||||||
|
float x = rv.x, y = rv.y;
|
||||||
|
|
||||||
Lines.lineAngle(ox + x, oy + y, Mathf.angle(x, y), len);
|
Lines.lineAngle(ox + x, oy + y, Mathf.angle(x, y), len);
|
||||||
Drawf.light(ox + x, oy + y, len * lightScl, lightColor, lightOpacity* Draw.getColor().a);
|
Drawf.light(ox + x, oy + y, len * lightScl, lightColor, lightOpacity * Draw.getColor().a);
|
||||||
});
|
}
|
||||||
}else{
|
}else{
|
||||||
Angles.randLenVectors(e.id, particles, length * fin + baseLength, e.rotation, cone, (x, y) -> {
|
rand.setSeed(e.id);
|
||||||
|
for(int i = 0; i < particles; i++){
|
||||||
|
float l = length * fin + baseLength;
|
||||||
|
rv.trns(e.rotation + rand.range(cone), !randLength ? l : rand.random(l));
|
||||||
|
float x = rv.x, y = rv.y;
|
||||||
|
|
||||||
Draw.rect(tex, ox + x, oy + y, rad, rad, e.rotation + offset + e.time * spin);
|
Draw.rect(tex, ox + x, oy + y, rad, rad, e.rotation + offset + e.time * spin);
|
||||||
Drawf.light(ox + x, oy + y, rad * lightScl, lightColor, lightOpacity * Draw.getColor().a);
|
Drawf.light(ox + x, oy + y, rad * lightScl, lightColor, lightOpacity * Draw.getColor().a);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,12 @@
|
|||||||
package mindustry.world.blocks.production;
|
package mindustry.world.blocks.production;
|
||||||
|
|
||||||
import arc.graphics.g2d.*;
|
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
public class Fracker extends SolidPump{
|
public class Fracker extends SolidPump{
|
||||||
public float itemUseTime = 100f;
|
public float itemUseTime = 100f;
|
||||||
|
|
||||||
public @Load("@-liquid") TextureRegion liquidRegion;
|
|
||||||
public @Load("@-rotator") TextureRegion rotatorRegion;
|
|
||||||
public @Load("@-top") TextureRegion topRegion;
|
|
||||||
|
|
||||||
public Fracker(String name){
|
public Fracker(String name){
|
||||||
super(name);
|
super(name);
|
||||||
hasItems = true;
|
hasItems = true;
|
||||||
@@ -30,33 +23,9 @@ public class Fracker extends SolidPump{
|
|||||||
stats.add(Stat.productionTime, itemUseTime / 60f, StatUnit.seconds);
|
stats.add(Stat.productionTime, itemUseTime / 60f, StatUnit.seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean outputsItems(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextureRegion[] icons(){
|
|
||||||
return new TextureRegion[]{region, rotatorRegion, topRegion};
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FrackerBuild extends SolidPumpBuild{
|
public class FrackerBuild extends SolidPumpBuild{
|
||||||
public float accumulator;
|
public float accumulator;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawCracks(){}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(){
|
|
||||||
Draw.rect(region, x, y);
|
|
||||||
super.drawCracks();
|
|
||||||
|
|
||||||
Drawf.liquid(liquidRegion, x, y, liquids.get(result) / liquidCapacity, result.color);
|
|
||||||
|
|
||||||
Drawf.spinSprite(rotatorRegion, x, y, pumpTime);
|
|
||||||
Draw.rect(topRegion, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
if(consValid()){
|
if(consValid()){
|
||||||
@@ -73,10 +42,5 @@ public class Fracker extends SolidPump{
|
|||||||
dumpLiquid(result);
|
dumpLiquid(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float typeLiquid(){
|
|
||||||
return liquids.get(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,11 @@ public class SolidPump extends Pump{
|
|||||||
return sum > 0.00001f;
|
return sum > 0.00001f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean outputsItems(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canPump(Tile tile){
|
protected boolean canPump(Tile tile){
|
||||||
return tile != null && !tile.floor().isLiquid;
|
return tile != null && !tile.floor().isLiquid;
|
||||||
@@ -85,10 +90,16 @@ public class SolidPump extends Pump{
|
|||||||
public float validTiles;
|
public float validTiles;
|
||||||
public float lastPump;
|
public float lastPump;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawCracks(){}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
Draw.rect(region, x, y);
|
Draw.rect(region, x, y);
|
||||||
Drawf.liquid(liquidRegion, x, y, liquids.total() / liquidCapacity, liquids.current().color);
|
super.drawCracks();
|
||||||
|
|
||||||
|
Drawf.liquid(liquidRegion, x, y, liquids.get(result) / liquidCapacity, result.color);
|
||||||
Drawf.spinSprite(rotatorRegion, x, y, pumpTime * rotateSpeed);
|
Drawf.spinSprite(rotatorRegion, x, y, pumpTime * rotateSpeed);
|
||||||
Draw.rect(topRegion, x, y);
|
Draw.rect(topRegion, x, y);
|
||||||
}
|
}
|
||||||
@@ -133,7 +144,7 @@ public class SolidPump extends Pump{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float typeLiquid(){
|
public float typeLiquid(){
|
||||||
return liquids.total();
|
return liquids.get(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user