mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-03 13:30:25 +07:00
Better leg unit death explosion
This commit is contained in:
parent
69f59ff803
commit
a138b7b9a8
Binary file not shown.
@ -2360,5 +2360,20 @@ public class Fx{
|
||||
}
|
||||
|
||||
Lines.endLine();
|
||||
}).followParent(false).rotWithParent(false);
|
||||
}).followParent(false).rotWithParent(false),
|
||||
|
||||
legDestroy = new Effect(90f, 100f, e -> {
|
||||
if(!(e.data instanceof LegDestroyData data)) return;
|
||||
rand.setSeed(e.id);
|
||||
|
||||
e.lifetime = rand.random(70f, 130f);
|
||||
|
||||
Tmp.v1.trns(rand.random(360f), rand.random(data.region.width / 8f) * e.finpow());
|
||||
float ox = Tmp.v1.x, oy = Tmp.v1.y;
|
||||
|
||||
alpha(e.foutpowdown());
|
||||
|
||||
stroke(data.region.height * scl);
|
||||
line(data.region, data.a.x + ox, data.a.y + oy, data.b.x + ox, data.b.y + oy, false);
|
||||
}).layer(Layer.groundUnit + 5f);
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ public class Planets{
|
||||
landCloudColor = Color.valueOf("ed6542");
|
||||
atmosphereColor = Color.valueOf("f07218");
|
||||
defaultEnv = Env.scorching | Env.terrestrial;
|
||||
drillOverlay = Blocks.air;
|
||||
startSector = 10;
|
||||
atmosphereRadIn = 0.02f;
|
||||
atmosphereRadOut = 0.3f;
|
||||
|
15
core/src/mindustry/entities/LegDestroyData.java
Normal file
15
core/src/mindustry/entities/LegDestroyData.java
Normal file
@ -0,0 +1,15 @@
|
||||
package mindustry.entities;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.geom.*;
|
||||
|
||||
public class LegDestroyData{
|
||||
public Vec2 a, b;
|
||||
public TextureRegion region;
|
||||
|
||||
public LegDestroyData(Vec2 a, Vec2 b, TextureRegion region){
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.region = region;
|
||||
}
|
||||
}
|
@ -15,6 +15,8 @@ import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@Component
|
||||
abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc{
|
||||
private static final Vec2 straightVec = new Vec2();
|
||||
@ -57,6 +59,31 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc{
|
||||
resetLegs(1f);
|
||||
}
|
||||
|
||||
@MethodPriority(-1)
|
||||
@Override
|
||||
public void destroy(){
|
||||
if(!isAdded() || Vars.headless) return;
|
||||
|
||||
float legExplodeRad = type.legRegion.height / 4f / 1.45f;
|
||||
|
||||
//create effects for legs being destroyed
|
||||
for(int i = 0; i < legs.length; i++){
|
||||
Leg l = legs[i];
|
||||
|
||||
Vec2 base = legOffset(Tmp.v1, i).add(x, y);
|
||||
|
||||
Tmp.v2.set(l.base).sub(l.joint).inv().setLength(type.legExtension);
|
||||
|
||||
for(Vec2 vec : new Vec2[]{base, l.joint, l.base}){
|
||||
Damage.dynamicExplosion(vec.x, vec.y, 0f, 0f, 0f, legExplodeRad, state.rules.damageExplosions, false, team, type.deathExplosionEffect);
|
||||
}
|
||||
|
||||
Fx.legDestroy.at(base.x, base.y, 0f, new LegDestroyData(base.cpy(), l.joint, type.legRegion));
|
||||
Fx.legDestroy.at(l.joint.x, l.joint.y, 0f, new LegDestroyData(l.joint.cpy().add(Tmp.v2), l.base, type.legBaseRegion));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void resetLegs(){
|
||||
resetLegs(type.legLength);
|
||||
}
|
||||
@ -89,7 +116,6 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc{
|
||||
baseRotation = rotation;
|
||||
}
|
||||
|
||||
float rot = baseRotation;
|
||||
float legLength = type.legLength;
|
||||
|
||||
//set up initial leg positions
|
||||
|
@ -506,7 +506,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
float power = item().charge * Mathf.pow(stack().amount, 1.11f) * 160f;
|
||||
|
||||
if(!spawnedByCore){
|
||||
Damage.dynamicExplosion(x, y, flammability, explosiveness, power, bounds() / 2f, state.rules.damageExplosions, item().flammability > 1, team, type.deathExplosionEffect);
|
||||
Damage.dynamicExplosion(x, y, flammability, explosiveness, power, (bounds() + type.legLength/1.7f) / 2f, state.rules.damageExplosions, item().flammability > 1, team, type.deathExplosionEffect);
|
||||
}else{
|
||||
type.deathExplosionEffect.at(x, y, bounds() / 2f / 8f);
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import mindustry.world.blocks.ConstructBlock.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
import mindustry.world.blocks.legacy.*;
|
||||
import mindustry.world.blocks.power.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.sandbox.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||
@ -421,20 +420,20 @@ public class Schematics implements Loadable{
|
||||
|
||||
/** Places the last launch loadout at the coordinates and fills it with the launch resources. */
|
||||
public static void placeLaunchLoadout(int x, int y){
|
||||
placeLoadout(universe.getLastLoadout(), x, y, state.rules.defaultTeam, state.rules.sector == null ? Blocks.air : state.rules.sector.planet.drillOverlay);
|
||||
placeLoadout(universe.getLastLoadout(), x, y, state.rules.defaultTeam);
|
||||
if(world.tile(x, y).build == null) throw new RuntimeException("No core at loadout coordinates!");
|
||||
world.tile(x, y).build.items.add(universe.getLaunchResources());
|
||||
}
|
||||
|
||||
public static void placeLoadout(Schematic schem, int x, int y){
|
||||
placeLoadout(schem, x, y, state.rules.defaultTeam, Blocks.oreCopper);
|
||||
placeLoadout(schem, x, y, state.rules.defaultTeam);
|
||||
}
|
||||
|
||||
public static void placeLoadout(Schematic schem, int x, int y, Team team, Block resource){
|
||||
placeLoadout(schem, x, y, team, resource, true);
|
||||
public static void placeLoadout(Schematic schem, int x, int y, Team team){
|
||||
placeLoadout(schem, x, y, team, true);
|
||||
}
|
||||
|
||||
public static void placeLoadout(Schematic schem, int x, int y, Team team, Block resource, boolean check){
|
||||
public static void placeLoadout(Schematic schem, int x, int y, Team team, boolean check){
|
||||
Stile coreTile = schem.tiles.find(s -> s.block instanceof CoreBlock);
|
||||
Seq<Tile> seq = new Seq<>();
|
||||
if(coreTile == null) throw new IllegalArgumentException("Loadout schematic has no core tile!");
|
||||
@ -465,10 +464,6 @@ public class Schematics implements Loadable{
|
||||
tile.build.configureAny(config);
|
||||
}
|
||||
|
||||
if(st.block instanceof Drill && resource != Blocks.air){
|
||||
tile.getLinkedTiles(t -> t.setOverlay(resource));
|
||||
}
|
||||
|
||||
if(tile.build instanceof CoreBuild cb){
|
||||
state.teams.registerCore(cb);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class BaseGenerator{
|
||||
|
||||
for(Tile tile : cores){
|
||||
tile.clearOverlay();
|
||||
Schematics.placeLoadout(coreschem.schematic, tile.x, tile.y, team, coreschem.required instanceof Item ? bases.ores.get((Item)coreschem.required) : Blocks.oreCopper, false);
|
||||
Schematics.placeLoadout(coreschem.schematic, tile.x, tile.y, team, false);
|
||||
|
||||
//fill core with every type of item (even non-material)
|
||||
Building entity = tile.build;
|
||||
|
@ -9,14 +9,12 @@ import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.noise.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.content.TechTree.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.g3d.*;
|
||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||
import mindustry.maps.generators.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@ -68,8 +66,6 @@ public class Planet extends UnlockableContent{
|
||||
public boolean accessible = true;
|
||||
/** Environment flags for sectors on this planet. */
|
||||
public int defaultEnv = Env.terrestrial | Env.spores | Env.groundOil | Env.groundWater | Env.oxygen;
|
||||
/** Default block placed under drills upon launching. */
|
||||
public Block drillOverlay = Blocks.oreCopper;
|
||||
/** If true, a day/night cycle is simulated. */
|
||||
public boolean updateLighting = true;
|
||||
/** Day/night cycle parameters. */
|
||||
|
Loading…
Reference in New Issue
Block a user