many things
@ -77,7 +77,11 @@ public class EntityProcess extends BaseProcessor{
|
||||
for(Smethod elem : component.methods()){
|
||||
if(elem.is(Modifier.ABSTRACT) || elem.is(Modifier.NATIVE)) continue;
|
||||
//get all statements in the method, store them
|
||||
methodBlocks.put(elem.descString(), elem.tree().getBody().toString());
|
||||
methodBlocks.put(elem.descString(), elem.tree().getBody().toString()
|
||||
//replace all self() invocations with this
|
||||
.replaceAll("this\\.<(.*)>self\\(\\)", "this")
|
||||
.replaceAll("self\\(\\)", "this")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
core/assets-raw/sprites/units/omura-cell.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
core/assets-raw/sprites/units/omura.png
Normal file
After Width: | Height: | Size: 11 KiB |
@ -311,3 +311,4 @@
|
||||
63433=dacite-wall|block-dacite-wall-medium
|
||||
63432=dacite-boulder|block-dacite-boulder-medium
|
||||
63431=large-logic-display|block-large-logic-display-medium
|
||||
63430=omura|unit-omura-medium
|
||||
|
Before Width: | Height: | Size: 647 KiB After Width: | Height: | Size: 609 KiB |
Before Width: | Height: | Size: 958 KiB After Width: | Height: | Size: 849 KiB |
Before Width: | Height: | Size: 365 KiB After Width: | Height: | Size: 657 KiB |
Before Width: | Height: | Size: 185 KiB After Width: | Height: | Size: 185 KiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.3 MiB |
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 186 KiB |
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.4 MiB |
@ -59,7 +59,7 @@ public class Pathfinder implements Runnable{
|
||||
Flowfield[][][] cache;
|
||||
|
||||
/** tile data, see PathTileStruct */
|
||||
int[][] tiles;
|
||||
int[][] tiles = new int[0][0];
|
||||
/** unordered array of path data for iteration only. DO NOT iterate or access this in the main thread. */
|
||||
Seq<Flowfield> threadList = new Seq<>(), mainList = new Seq<>();
|
||||
/** handles task scheduling on the update thread. */
|
||||
|
@ -989,6 +989,53 @@ public class Fx{
|
||||
|
||||
}).ground(400f),
|
||||
|
||||
railShoot = new Effect(24f, e -> {
|
||||
e.scaled(10f, b -> {
|
||||
color(Color.white, Color.lightGray, b.fin());
|
||||
stroke(b.fout() * 3f + 0.2f);
|
||||
Lines.circle(b.x, b.y, b.fin() * 50f);
|
||||
});
|
||||
|
||||
color(Pal.orangeSpark);
|
||||
|
||||
for(int i : Mathf.signs){
|
||||
Drawf.tri(e.x, e.y, 13f * e.fout(), 85f, e.rotation + 90f * i);
|
||||
}
|
||||
}),
|
||||
|
||||
railTrail = new Effect(16f, e -> {
|
||||
color(Pal.orangeSpark);
|
||||
|
||||
for(int i : Mathf.signs){
|
||||
Drawf.tri(e.x, e.y, 10f * e.fout(), 24f, e.rotation + 90 + 90f * i);
|
||||
}
|
||||
}),
|
||||
|
||||
railHit = new Effect(18f, 200f, e -> {
|
||||
if(true){
|
||||
color(Pal.orangeSpark);
|
||||
|
||||
for(int i : Mathf.signs){
|
||||
Drawf.tri(e.x, e.y, 10f * e.fout(), 60f, e.rotation + 140f * i);
|
||||
}
|
||||
}else{
|
||||
e.scaled(7f, b -> {
|
||||
color(Color.white, Color.lightGray, b.fin());
|
||||
stroke(b.fout() * 2f + 0.2f);
|
||||
Lines.circle(b.x, b.y, b.fin() * 28f);
|
||||
});
|
||||
|
||||
color(Pal.orangeSpark);
|
||||
float rot = e.rotation + Mathf.randomSeedRange(e.id, 20f);
|
||||
float w = 9f * e.fout();
|
||||
|
||||
Drawf.tri(e.x, e.y, w, 100f, rot);
|
||||
Drawf.tri(e.x, e.y, w, 10f, rot + 180f);
|
||||
}
|
||||
|
||||
|
||||
}),
|
||||
|
||||
lancerLaserShoot = new Effect(21f, e -> {
|
||||
color(Pal.lancerLaser);
|
||||
|
||||
@ -1070,6 +1117,15 @@ public class Fx{
|
||||
});
|
||||
}),
|
||||
|
||||
cloudsmoke = new Effect(70, e -> {
|
||||
randLenVectors(e.id, 12, 15f + e.fin() * 45f, (x, y) -> {
|
||||
float size = e.fslope() * 2f;
|
||||
color(Color.gray);
|
||||
alpha(e.fslope());
|
||||
Fill.circle(e.x + x, e.y + y, size);
|
||||
});
|
||||
}),
|
||||
|
||||
nuclearcloud = new Effect(90, 200f, e -> {
|
||||
randLenVectors(e.id, 10, e.finpow() * 90f, (x, y) -> {
|
||||
float size = e.fout() * 14f;
|
||||
@ -1295,10 +1351,11 @@ public class Fx{
|
||||
|
||||
}),
|
||||
|
||||
//TODO fix false in constructor
|
||||
ripple = new Effect(30, e -> {
|
||||
e.lifetime = 30f*e.rotation;
|
||||
|
||||
color(Tmp.c1.set(e.color).mul(1.5f));
|
||||
stroke(e.fout() + 0.4f);
|
||||
stroke(e.fout() * 1.4f);
|
||||
Lines.circle(e.x, e.y, (2f + e.fin() * 4f) * e.rotation);
|
||||
}).ground(),
|
||||
|
||||
|
@ -2,6 +2,7 @@ package mindustry.content;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.ai.types.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.ctype.*;
|
||||
@ -42,7 +43,7 @@ public class UnitTypes implements ContentList{
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class}) UnitType alpha, beta, gamma;
|
||||
|
||||
//water + commander
|
||||
public static @EntityDef({Unitc.class, WaterMovec.class, Commanderc.class}) UnitType risso, minke, bryde;
|
||||
public static @EntityDef({Unitc.class, WaterMovec.class, Commanderc.class}) UnitType risso, minke, bryde, omura;
|
||||
|
||||
//special block unit type
|
||||
public static @EntityDef({Unitc.class, BlockUnitc.class}) UnitType block;
|
||||
@ -668,8 +669,8 @@ public class UnitTypes implements ContentList{
|
||||
width = height = 25f;
|
||||
collidesTiles = collides = true;
|
||||
ammoMultiplier = 4f;
|
||||
splashDamageRadius = 95f;
|
||||
splashDamage = 90f;
|
||||
splashDamageRadius = 90f;
|
||||
splashDamage = 75f;
|
||||
backColor = Pal.sapBulletBack;
|
||||
frontColor = lightningColor = Pal.sapBullet;
|
||||
lightning = 5;
|
||||
@ -690,7 +691,7 @@ public class UnitTypes implements ContentList{
|
||||
width = height = 20f;
|
||||
collidesTiles = false;
|
||||
splashDamageRadius = 80f;
|
||||
splashDamage = 45f;
|
||||
splashDamage = 40f;
|
||||
backColor = Pal.sapBulletBack;
|
||||
frontColor = lightningColor = Pal.sapBullet;
|
||||
lightning = 2;
|
||||
@ -1164,7 +1165,7 @@ public class UnitTypes implements ContentList{
|
||||
accel = 0.2f;
|
||||
rotateSpeed = 1.8f;
|
||||
drag = 0.17f;
|
||||
hitsize = 14f;
|
||||
hitsize = 16f;
|
||||
armor = 6f;
|
||||
immunities = ObjectSet.with(StatusEffects.wet);
|
||||
rotateShooting = false;
|
||||
@ -1252,6 +1253,55 @@ public class UnitTypes implements ContentList{
|
||||
}});
|
||||
}};
|
||||
|
||||
omura = new UnitType("omura"){{
|
||||
health = 20000;
|
||||
speed = 0.62f;
|
||||
drag = 0.18f;
|
||||
hitsize = 50f;
|
||||
armor = 15f;
|
||||
accel = 0.19f;
|
||||
rotateSpeed = 0.9f;
|
||||
immunities = ObjectSet.with(StatusEffects.wet);
|
||||
|
||||
float spawnTime = 0.75f * Time.toMinutes;
|
||||
|
||||
abilities.add(new UnitSpawnAbility(flare, spawnTime, 19.25f, -31.75f), new UnitSpawnAbility(flare, spawnTime, -19.25f, -31.75f));
|
||||
|
||||
trailLength = 70;
|
||||
trailX = 23f;
|
||||
trailY = -32f;
|
||||
trailScl = 3.5f;
|
||||
|
||||
weapons.add(new Weapon("omura-cannon"){{
|
||||
reload = 110f;
|
||||
cooldownTime = 90f;
|
||||
mirror = false;
|
||||
x = 0f;
|
||||
y = -3.5f;
|
||||
rotateSpeed = 1.4f;
|
||||
rotate = true;
|
||||
shootY = 23f;
|
||||
shake = 6f;
|
||||
recoil = 10.5f;
|
||||
occlusion = 42f;
|
||||
|
||||
shots = 1;
|
||||
ejectEffect = Fx.none;
|
||||
|
||||
bullet = new RailBulletType(){{
|
||||
shootEffect = Fx.railShoot;
|
||||
speed = 65f;
|
||||
lifetime = 8f;
|
||||
pierceEffect = Fx.railHit;
|
||||
updateEffect = Fx.railTrail;
|
||||
hitEffect = Fx.massiveExplosion;
|
||||
smokeEffect = Fx.shootBig2;
|
||||
damage = 1200;
|
||||
pierceDamageFactor = 0.5f;
|
||||
}};
|
||||
}});
|
||||
}};
|
||||
|
||||
//endregion
|
||||
//region core
|
||||
|
||||
|
@ -191,6 +191,10 @@ public class Control implements ApplicationListener, Loadable{
|
||||
|
||||
}
|
||||
|
||||
void resetCamera(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAsync(){
|
||||
Draw.scl = 1f / Core.atlas.find("scale_marker").width;
|
||||
@ -280,6 +284,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
try{
|
||||
net.reset();
|
||||
slot.load();
|
||||
slot.setAutosave(true);
|
||||
state.rules.sector = sector;
|
||||
|
||||
//if there is no base, simulate a new game and place the right loadout at the spawn position
|
||||
|
@ -17,7 +17,7 @@ public class GameState{
|
||||
/** Wave countdown in ticks. */
|
||||
public float wavetime;
|
||||
/** Whether the game is in game over state. */
|
||||
public boolean gameOver = false, launched = false, serverPaused = false;
|
||||
public boolean gameOver = false, launched = false, serverPaused = false, wasTimeout;
|
||||
/** Map that is currently being played on. */
|
||||
public @NonNull Map map = emptyMap;
|
||||
/** The current game rules. */
|
||||
|
@ -337,7 +337,14 @@ public class Logic implements ApplicationListener{
|
||||
|
||||
//force pausing when the player is out of sector time
|
||||
if(state.isOutOfTime()){
|
||||
state.set(State.paused);
|
||||
if(!state.wasTimeout){
|
||||
universe.displayTimeEnd();
|
||||
state.wasTimeout = true;
|
||||
}
|
||||
//if no turn was run.
|
||||
if(state.isOutOfTime()){
|
||||
state.set(State.paused);
|
||||
}
|
||||
}
|
||||
|
||||
if(!state.isPaused()){
|
||||
|
@ -86,12 +86,14 @@ public class Effect{
|
||||
create(this, x, y, rotation, Color.white, data);
|
||||
}
|
||||
|
||||
public void render(int id, Color color, float life, float rotation, float x, float y, Object data){
|
||||
public float render(int id, Color color, float life, float lifetime, float rotation, float x, float y, Object data){
|
||||
container.set(id, color, life, lifetime, rotation, x, y, data);
|
||||
Draw.z(ground ? Layer.debris : Layer.effect);
|
||||
Draw.reset();
|
||||
renderer.get(container);
|
||||
Draw.reset();
|
||||
|
||||
return container.lifetime;
|
||||
}
|
||||
|
||||
public static @Nullable Effect get(int id){
|
||||
@ -125,13 +127,13 @@ public class Effect{
|
||||
|
||||
if(view.overlaps(pos)){
|
||||
EffectState entity = EffectState.create();
|
||||
entity.effect(effect);
|
||||
entity.rotation(rotation);
|
||||
entity.data(data);
|
||||
entity.lifetime(effect.lifetime);
|
||||
entity.effect = effect;
|
||||
entity.rotation = rotation;
|
||||
entity.data = (data);
|
||||
entity.lifetime = (effect.lifetime);
|
||||
entity.set(x, y);
|
||||
entity.color().set(color);
|
||||
if(data instanceof Posc) entity.parent((Posc)data);
|
||||
entity.color.set(color);
|
||||
if(data instanceof Posc) entity.parent = ((Posc)data);
|
||||
entity.add();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,16 @@ package mindustry.entities.abilities;
|
||||
|
||||
import mindustry.gen.*;
|
||||
|
||||
public interface Ability{
|
||||
default void update(Unit unit){}
|
||||
default void draw(Unit unit){}
|
||||
public abstract class Ability implements Cloneable{
|
||||
public void update(Unit unit){}
|
||||
public void draw(Unit unit){}
|
||||
|
||||
public Ability copy(){
|
||||
try{
|
||||
return (Ability)clone();
|
||||
}catch(CloneNotSupportedException e){
|
||||
//I am disgusted
|
||||
throw new RuntimeException("java sucks", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public class ForceFieldAbility implements Ability{
|
||||
public class ForceFieldAbility extends Ability{
|
||||
/** Shield radius. */
|
||||
public float radius = 60f;
|
||||
/** Shield regen speed in damage/tick. */
|
||||
@ -21,18 +21,22 @@ public class ForceFieldAbility implements Ability{
|
||||
/** Cooldown after the shield is broken, in ticks. */
|
||||
public float cooldown = 60f * 5;
|
||||
|
||||
private float realRad;
|
||||
private Unit paramUnit;
|
||||
private final Cons<Shielderc> shieldConsumer = trait -> {
|
||||
/** State: radius scaling. */
|
||||
protected float radiusScale;
|
||||
|
||||
private static float realRad;
|
||||
private static Unit paramUnit;
|
||||
private static ForceFieldAbility paramField;
|
||||
private static final Cons<Shielderc> shieldConsumer = trait -> {
|
||||
if(trait.team() != paramUnit.team && Intersector.isInsideHexagon(paramUnit.x, paramUnit.y, realRad * 2f, trait.x(), trait.y()) && paramUnit.shield > 0){
|
||||
trait.absorb();
|
||||
Fx.absorb.at(trait);
|
||||
|
||||
//break shield
|
||||
if(paramUnit.shield <= trait.damage()){
|
||||
paramUnit.shield -= cooldown * regen;
|
||||
paramUnit.shield -= paramField.cooldown * paramField.regen;
|
||||
|
||||
Fx.shieldBreak.at(paramUnit.x, paramUnit.y, radius, paramUnit.team.color);
|
||||
Fx.shieldBreak.at(paramUnit.x, paramUnit.y, paramField.radius, paramUnit.team.color);
|
||||
}
|
||||
|
||||
paramUnit.shield -= trait.damage();
|
||||
@ -56,13 +60,14 @@ public class ForceFieldAbility implements Ability{
|
||||
}
|
||||
|
||||
if(unit.shield > 0){
|
||||
unit.timer2 = Mathf.lerpDelta(unit.timer2, 1f, 0.06f);
|
||||
radiusScale = Mathf.lerpDelta(radiusScale, 1f, 0.06f);
|
||||
paramUnit = unit;
|
||||
paramField = this;
|
||||
checkRadius(unit);
|
||||
|
||||
Groups.bullet.intersect(unit.x - realRad, unit.y - realRad, realRad * 2f, realRad * 2f, shieldConsumer);
|
||||
}else{
|
||||
unit.timer2 = 0f;
|
||||
radiusScale = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,6 +94,6 @@ public class ForceFieldAbility implements Ability{
|
||||
|
||||
private void checkRadius(Unit unit){
|
||||
//timer2 is used to store radius scale as an effect
|
||||
realRad = unit.timer2 * radius;
|
||||
realRad = radiusScale * radius;
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class HealFieldAbility implements Ability{
|
||||
public class HealFieldAbility extends Ability{
|
||||
public float amount = 1, reload = 100, range = 60;
|
||||
public Effect healEffect = Fx.heal;
|
||||
public Effect activeEffect = Fx.healWave;
|
||||
|
||||
private boolean wasHealed = false;
|
||||
protected float timer;
|
||||
protected boolean wasHealed = false;
|
||||
|
||||
HealFieldAbility(){}
|
||||
|
||||
@ -22,9 +23,9 @@ public class HealFieldAbility implements Ability{
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
unit.timer1 += Time.delta;
|
||||
timer += Time.delta;
|
||||
|
||||
if(unit.timer1 >= reload){
|
||||
if(timer >= reload){
|
||||
wasHealed = false;
|
||||
|
||||
Units.nearby(unit.team, unit.x, unit.y, range, other -> {
|
||||
@ -39,7 +40,7 @@ public class HealFieldAbility implements Ability{
|
||||
activeEffect.at(unit);
|
||||
}
|
||||
|
||||
unit.timer1 = 0f;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class ShieldFieldAbility implements Ability{
|
||||
public class ShieldFieldAbility extends Ability{
|
||||
public float amount = 1, max = 100f, reload = 100, range = 60;
|
||||
public Effect applyEffect = Fx.shieldApply;
|
||||
public Effect activeEffect = Fx.shieldWave;
|
||||
|
||||
private boolean applied = false;
|
||||
protected float timer;
|
||||
protected boolean applied = false;
|
||||
|
||||
ShieldFieldAbility(){}
|
||||
|
||||
@ -23,9 +24,9 @@ public class ShieldFieldAbility implements Ability{
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
unit.timer1 += Time.delta;
|
||||
timer += Time.delta;
|
||||
|
||||
if(unit.timer1 >= reload){
|
||||
if(timer >= reload){
|
||||
applied = false;
|
||||
|
||||
Units.nearby(unit.team, unit.x, unit.y, range, other -> {
|
||||
@ -41,7 +42,7 @@ public class ShieldFieldAbility implements Ability{
|
||||
activeEffect.at(unit);
|
||||
}
|
||||
|
||||
unit.timer1 = 0f;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,14 @@ import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
public class StatusFieldAbility implements Ability{
|
||||
public class StatusFieldAbility extends Ability{
|
||||
public @NonNull StatusEffect effect;
|
||||
public float duration = 60, reload = 100, range = 20;
|
||||
public Effect applyEffect = Fx.heal;
|
||||
public Effect activeEffect = Fx.overdriveWave;
|
||||
|
||||
protected float timer;
|
||||
|
||||
StatusFieldAbility(){}
|
||||
|
||||
public StatusFieldAbility(@NonNull StatusEffect effect, float duration, float reload, float range){
|
||||
@ -24,9 +26,9 @@ public class StatusFieldAbility implements Ability{
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
unit.timer2 += Time.delta;
|
||||
timer += Time.delta;
|
||||
|
||||
if(unit.timer2 >= reload){
|
||||
if(timer >= reload){
|
||||
|
||||
Units.nearby(unit.team, unit.x, unit.y, range, other -> {
|
||||
other.apply(effect, duration);
|
||||
@ -34,7 +36,7 @@ public class StatusFieldAbility implements Ability{
|
||||
|
||||
activeEffect.at(unit);
|
||||
|
||||
unit.timer2 = 0f;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
60
core/src/mindustry/entities/abilities/UnitSpawnAbility.java
Normal file
@ -0,0 +1,60 @@
|
||||
package mindustry.entities.abilities;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class UnitSpawnAbility extends Ability{
|
||||
public @NonNull UnitType type;
|
||||
public float spawnTime = 60f, spawnX, spawnY;
|
||||
public Effect spawnEffect = Fx.spawn;
|
||||
|
||||
protected float timer;
|
||||
|
||||
public UnitSpawnAbility(@NonNull UnitType type, float spawnTime, float spawnX, float spawnY){
|
||||
this.type = type;
|
||||
this.spawnTime = spawnTime;
|
||||
this.spawnX = spawnX;
|
||||
this.spawnY = spawnY;
|
||||
}
|
||||
|
||||
public UnitSpawnAbility(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
timer += Time.delta;
|
||||
|
||||
if(timer >= spawnTime && Units.canCreate(unit.team, type)){
|
||||
|
||||
float x = unit.x + Angles.trnsx(unit.rotation, spawnY, spawnX), y = unit.y + Angles.trnsy(unit.rotation, spawnY, spawnX);
|
||||
spawnEffect.at(x, y);
|
||||
Unit u = type.create(unit.team);
|
||||
u.set(x, y);
|
||||
u.rotation = unit.rotation;
|
||||
if(!Vars.net.client()){
|
||||
u.add();
|
||||
}
|
||||
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Unit unit){
|
||||
if(Units.canCreate(unit.team, type)){
|
||||
Draw.draw(Draw.z(), () -> {
|
||||
float x = unit.x + Angles.trnsx(unit.rotation, spawnY, spawnX), y = unit.y + Angles.trnsy(unit.rotation, spawnY, spawnX);
|
||||
Drawf.construct(x, y, type.icon(Cicon.full), unit.rotation - 90, timer / spawnTime, 1f, timer);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ public abstract class BulletType extends Content{
|
||||
public float hitSize = 4;
|
||||
public float drawSize = 40f;
|
||||
public float drag = 0f;
|
||||
public boolean pierce;
|
||||
public boolean pierce, pierceBuilding;
|
||||
public Effect hitEffect, despawnEffect;
|
||||
|
||||
/** Effect created when shooting. */
|
||||
@ -69,6 +69,8 @@ public abstract class BulletType extends Content{
|
||||
public boolean scaleVelocity;
|
||||
/** Whether this bullet can be hit by point defense. */
|
||||
public boolean hittable = true;
|
||||
/** Whether this bullet can be reflected. */
|
||||
public boolean reflectable = false;
|
||||
|
||||
//additional effects
|
||||
|
||||
@ -131,10 +133,14 @@ public abstract class BulletType extends Content{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void hitTile(Bullet b, Building tile){
|
||||
public void hitTile(Bullet b, Building tile, float initialHealth){
|
||||
hit(b);
|
||||
}
|
||||
|
||||
public void hitEntity(Bullet b, Hitboxc other, float initialHealth){
|
||||
|
||||
}
|
||||
|
||||
public void hit(Bullet b){
|
||||
hit(b, b.x, b.y);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class HealBulletType extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitTile(Bullet b, Building tile){
|
||||
public void hitTile(Bullet b, Building tile, float initialHealth){
|
||||
super.hit(b);
|
||||
|
||||
if(tile.team == b.team && !(tile.block instanceof ConstructBlock)){
|
||||
|
52
core/src/mindustry/entities/bullet/RailBulletType.java
Normal file
@ -0,0 +1,52 @@
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class RailBulletType extends BulletType{
|
||||
public Effect pierceEffect = Fx.hitBulletSmall, updateEffect = Fx.none;
|
||||
/** Multiplier of damage decreased per health pierced. */
|
||||
public float pierceDamageFactor = 1f;
|
||||
|
||||
public RailBulletType(){
|
||||
pierceBuilding = true;
|
||||
pierce = true;
|
||||
reflectable = false;
|
||||
hitEffect = Fx.none;
|
||||
despawnEffect = Fx.none;
|
||||
}
|
||||
|
||||
void handle(Bullet b, Posc pos, float initialHealth){
|
||||
float sub = initialHealth*pierceDamageFactor;
|
||||
|
||||
if(sub >= b.damage){
|
||||
//cause a despawn
|
||||
b.remove();
|
||||
}
|
||||
|
||||
//subtract health from each consecutive pierce
|
||||
b.damage -= Math.min(b.damage, sub);
|
||||
|
||||
if(b.damage > 0){
|
||||
pierceEffect.at(pos.getX(), pos.getY(), b.rotation());
|
||||
}
|
||||
|
||||
hitEffect.at(pos.getX(), pos.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Bullet b){
|
||||
updateEffect.at(b.x, b.y, b.rotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitEntity(Bullet b, Hitboxc entity, float initialHealth){
|
||||
handle(b, entity, initialHealth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitTile(Bullet b, Building tile, float initialHealth){
|
||||
handle(b, tile, initialHealth);
|
||||
}
|
||||
}
|
@ -108,9 +108,9 @@ abstract class BuilderComp implements Unitc{
|
||||
ConstructBuild entity = tile.bc();
|
||||
|
||||
if(current.breaking){
|
||||
entity.deconstruct(base(), core, 1f / entity.buildCost * Time.delta * type().buildSpeed * state.rules.buildSpeedMultiplier);
|
||||
entity.deconstruct(self(), core, 1f / entity.buildCost * Time.delta * type().buildSpeed * state.rules.buildSpeedMultiplier);
|
||||
}else{
|
||||
entity.construct(base(), core, 1f / entity.buildCost * Time.delta * type().buildSpeed * state.rules.buildSpeedMultiplier, current.config);
|
||||
entity.construct(self(), core, 1f / entity.buildCost * Time.delta * type().buildSpeed * state.rules.buildSpeedMultiplier, current.config);
|
||||
}
|
||||
|
||||
current.stuck = Mathf.equal(current.progress, entity.progress);
|
||||
|
@ -80,7 +80,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
if(block.hasPower){
|
||||
//reinit power graph
|
||||
power.graph = new PowerGraph();
|
||||
power.graph.add(base());
|
||||
power.graph.add(self());
|
||||
}
|
||||
}
|
||||
this.rotation = rotation;
|
||||
@ -94,7 +94,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
|
||||
created();
|
||||
|
||||
return base();
|
||||
return self();
|
||||
}
|
||||
|
||||
/** Sets up all the necessary variables, but does not add this entity anywhere. */
|
||||
@ -111,17 +111,17 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
maxHealth(block.health);
|
||||
timer(new Interval(block.timers));
|
||||
|
||||
cons = new ConsumeModule(base());
|
||||
cons = new ConsumeModule(self());
|
||||
if(block.hasItems) items = new ItemModule();
|
||||
if(block.hasLiquids) liquids = new LiquidModule();
|
||||
if(block.hasPower){
|
||||
power = new PowerModule();
|
||||
power.graph.add(base());
|
||||
power.graph.add(self());
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
|
||||
return base();
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -195,17 +195,17 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
public void configure(Object value){
|
||||
//save last used config
|
||||
block.lastConfig = value;
|
||||
Call.tileConfig(player, base(), value);
|
||||
Call.tileConfig(player, self(), value);
|
||||
}
|
||||
|
||||
/** Configure from a server. */
|
||||
public void configureAny(Object value){
|
||||
Call.tileConfig(null, base(), value);
|
||||
Call.tileConfig(null, self(), value);
|
||||
}
|
||||
|
||||
/** Deselect this tile from configuration. */
|
||||
public void deselect(){
|
||||
if(!headless && control.input.frag.config.getSelectedTile() == base()){
|
||||
if(!headless && control.input.frag.config.getSelectedTile() == self()){
|
||||
control.input.frag.config.hideConfig();
|
||||
}
|
||||
}
|
||||
@ -372,7 +372,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
|
||||
/** Returns the amount of items this block can accept. */
|
||||
public int acceptStack(Item item, int amount, Teamc source){
|
||||
if(acceptItem(base(), item) && block.hasItems && (source == null || source.team() == team)){
|
||||
if(acceptItem(self(), item) && block.hasItems && (source == null || source.team() == team)){
|
||||
return Math.min(getMaximumAccepted(item) - items.get(item), amount);
|
||||
}else{
|
||||
return 0;
|
||||
@ -425,8 +425,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
int trns = block.size/2 + 1;
|
||||
Tile next = tile.getNearby(Geometry.d4(rotation).x * trns, Geometry.d4(rotation).y * trns);
|
||||
|
||||
if(next != null && next.build != null && next.build.team == team && next.build.acceptPayload(base(), todump)){
|
||||
next.build.handlePayload(base(), todump);
|
||||
if(next != null && next.build != null && next.build.team == team && next.build.acceptPayload(self(), todump)){
|
||||
next.build.handlePayload(self(), todump);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -446,8 +446,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
Building other = proximity.get((i + dump) % proximity.size);
|
||||
|
||||
if(other.team == team && other.acceptPayload(base(), todump)){
|
||||
other.handlePayload(base(), todump);
|
||||
if(other.team == team && other.acceptPayload(self(), todump)){
|
||||
other.handlePayload(self(), todump);
|
||||
incrementDump(proximity.size);
|
||||
return true;
|
||||
}
|
||||
@ -480,7 +480,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
incrementDump(proximity.size);
|
||||
Building other = proximity.get((i + dump) % proximity.size);
|
||||
other = other.getLiquidDestination(base(), liquid);
|
||||
other = other.getLiquidDestination(self(), liquid);
|
||||
|
||||
if(other != null && other.team == team && other.block.hasLiquids && canDumpLiquid(other, liquid) && other.liquids != null){
|
||||
float ofract = other.liquids.get(liquid) / other.block.liquidCapacity;
|
||||
@ -499,8 +499,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
public void transferLiquid(Building next, float amount, Liquid liquid){
|
||||
float flow = Math.min(next.block.liquidCapacity - next.liquids.get(liquid) - 0.001f, amount);
|
||||
|
||||
if(next.acceptLiquid(base(), liquid, flow)){
|
||||
next.handleLiquid(base(), liquid, flow);
|
||||
if(next.acceptLiquid(self(), liquid, flow)){
|
||||
next.handleLiquid(self(), liquid, flow);
|
||||
liquids.remove(liquid, flow);
|
||||
}
|
||||
}
|
||||
@ -523,7 +523,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
public float moveLiquid(Building next, Liquid liquid){
|
||||
if(next == null) return 0;
|
||||
|
||||
next = next.getLiquidDestination(base(), liquid);
|
||||
next = next.getLiquidDestination(self(), liquid);
|
||||
|
||||
if(next.team == team && next.block.hasLiquids && liquids.get(liquid) > 0f){
|
||||
float ofract = next.liquids.get(liquid) / next.block.liquidCapacity;
|
||||
@ -531,8 +531,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (block.liquidCapacity), liquids.get(liquid));
|
||||
flow = Math.min(flow, next.block.liquidCapacity - next.liquids.get(liquid) - 0.001f);
|
||||
|
||||
if(flow > 0f && ofract <= fract && next.acceptLiquid(base(), liquid, flow)){
|
||||
next.handleLiquid(base(), liquid, flow);
|
||||
if(flow > 0f && ofract <= fract && next.acceptLiquid(self(), liquid, flow)){
|
||||
next.handleLiquid(self(), liquid, flow);
|
||||
liquids.remove(liquid, flow);
|
||||
return flow;
|
||||
}else if(next.liquids.currentAmount() / next.block.liquidCapacity > 0.1f && fract > 0.1f){
|
||||
@ -558,7 +558,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
}
|
||||
|
||||
public Building getLiquidDestination(Building from, Liquid liquid){
|
||||
return base();
|
||||
return self();
|
||||
}
|
||||
|
||||
public @Nullable Payload getPayload(){
|
||||
@ -580,13 +580,13 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
incrementDump(proximity.size);
|
||||
Building other = proximity.get((i + dump) % proximity.size);
|
||||
if(other.team == team && other.acceptItem(base(), item) && canDump(other, item)){
|
||||
other.handleItem(base(), item);
|
||||
if(other.team == team && other.acceptItem(self(), item) && canDump(other, item)){
|
||||
other.handleItem(self(), item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
handleItem(base(), item);
|
||||
handleItem(self(), item);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -598,8 +598,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
incrementDump(proximity.size);
|
||||
Building other = proximity.get((i + dump) % proximity.size);
|
||||
if(other.team == team && other.acceptItem(base(), item) && canDump(other, item)){
|
||||
other.handleItem(base(), item);
|
||||
if(other.team == team && other.acceptItem(self(), item) && canDump(other, item)){
|
||||
other.handleItem(self(), item);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -631,16 +631,16 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
for(int ii = 0; ii < content.items().size; ii++){
|
||||
Item item = content.item(ii);
|
||||
|
||||
if(other.team == team && items.has(item) && other.acceptItem(base(), item) && canDump(other, item)){
|
||||
other.handleItem(base(), item);
|
||||
if(other.team == team && items.has(item) && other.acceptItem(self(), item) && canDump(other, item)){
|
||||
other.handleItem(self(), item);
|
||||
items.remove(item, 1);
|
||||
incrementDump(proximity.size);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(other.team == team && other.acceptItem(base(), todump) && canDump(other, todump)){
|
||||
other.handleItem(base(), todump);
|
||||
if(other.team == team && other.acceptItem(self(), todump) && canDump(other, todump)){
|
||||
other.handleItem(self(), todump);
|
||||
items.remove(todump, 1);
|
||||
incrementDump(proximity.size);
|
||||
return true;
|
||||
@ -665,8 +665,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
/** Try offloading an item to a nearby container in its facing direction. Returns true if success. */
|
||||
public boolean moveForward(Item item){
|
||||
Building other = front();
|
||||
if(other != null && other.team == team && other.acceptItem(base(), item)){
|
||||
other.handleItem(base(), item);
|
||||
if(other != null && other.team == team && other.acceptItem(self(), item)){
|
||||
other.handleItem(self(), item);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -696,7 +696,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
return;
|
||||
}
|
||||
|
||||
power.graph.remove(base());
|
||||
power.graph.remove(self());
|
||||
for(int i = 0; i < power.links.size; i++){
|
||||
Tile other = world.tile(power.links.get(i));
|
||||
if(other != null && other.build != null && other.build.power != null){
|
||||
@ -833,8 +833,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
tempTiles.clear();
|
||||
Geometry.circle(tileX(), tileY(), range, (x, y) -> {
|
||||
Building other = world.build(x, y);
|
||||
if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, base()) && !PowerNode.insulated(other, base())
|
||||
&& !other.proximity().contains(this.<Building>base()) &&
|
||||
if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, self()) && !PowerNode.insulated(other, self())
|
||||
&& !other.proximity().contains(this.<Building>self()) &&
|
||||
!(block.outputsPower && proximity.contains(p -> p.power != null && p.power.graph == other.power.graph))){
|
||||
tempTiles.add(other.tile);
|
||||
}
|
||||
@ -1037,13 +1037,13 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
table.left();
|
||||
for(Consume cons : block.consumes.all()){
|
||||
if(cons.isOptional() && cons.isBoost()) continue;
|
||||
cons.build(base(), table);
|
||||
cons.build(self(), table);
|
||||
}
|
||||
}
|
||||
|
||||
public void displayBars(Table table){
|
||||
for(Func<Building, Bar> bar : block.bars.list()){
|
||||
table.add(bar.get(base())).growX();
|
||||
table.add(bar.get(self())).growX();
|
||||
table.row();
|
||||
}
|
||||
}
|
||||
@ -1069,7 +1069,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
* @return whether or not this block should be deselected.
|
||||
*/
|
||||
public boolean onConfigureTileTapped(Building other){
|
||||
return base() != other;
|
||||
return self() != other;
|
||||
}
|
||||
|
||||
/** Returns whether this config menu should show when the specified player taps it. */
|
||||
@ -1128,7 +1128,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
}
|
||||
|
||||
for(Building other : tmpTiles){
|
||||
other.proximity.remove(base(), true);
|
||||
other.proximity.remove(self(), true);
|
||||
other.onProximityUpdate();
|
||||
}
|
||||
}
|
||||
@ -1144,8 +1144,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
if(other == null || !(other.tile.interactable(team))) continue;
|
||||
|
||||
//add this tile to proximity of nearby tiles
|
||||
if(!other.proximity.contains(base(), true)){
|
||||
other.proximity.add(base());
|
||||
if(!other.proximity.contains(self(), true)){
|
||||
other.proximity.add(self());
|
||||
}
|
||||
|
||||
tmpTiles.add(other);
|
||||
@ -1184,13 +1184,13 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
@Replace
|
||||
@Override
|
||||
public boolean isValid(){
|
||||
return tile.build == base() && !dead();
|
||||
return tile.build == self() && !dead();
|
||||
}
|
||||
|
||||
@Replace
|
||||
@Override
|
||||
public void kill(){
|
||||
Call.tileDestroyed(base());
|
||||
Call.tileDestroyed(self());
|
||||
}
|
||||
|
||||
@Replace
|
||||
@ -1204,10 +1204,10 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
damage /= state.rules.blockHealthMultiplier;
|
||||
}
|
||||
|
||||
Call.tileDamage(base(), health - handleDamage(damage));
|
||||
Call.tileDamage(self(), health - handleDamage(damage));
|
||||
|
||||
if(health <= 0){
|
||||
Call.tileDestroyed(base());
|
||||
Call.tileDestroyed(self());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1292,7 +1292,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
}
|
||||
|
||||
if(block.idleSound != Sounds.none && shouldIdleSound()){
|
||||
loops.play(block.idleSound, base(), block.idleSoundVolume);
|
||||
loops.play(block.idleSound, self(), block.idleSoundVolume);
|
||||
}
|
||||
|
||||
if(enabled || !block.noUpdateDisabled){
|
||||
|
@ -44,17 +44,17 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
||||
|
||||
@Override
|
||||
public void drawBullets(){
|
||||
type.draw(base());
|
||||
type.draw(self());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(){
|
||||
type.init(base());
|
||||
type.init(self());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(){
|
||||
type.despawned(base());
|
||||
type.despawned(self());
|
||||
collided.clear();
|
||||
}
|
||||
|
||||
@ -92,10 +92,12 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
||||
@MethodPriority(100)
|
||||
@Override
|
||||
public void collision(Hitboxc other, float x, float y){
|
||||
type.hit(base(), x, y);
|
||||
type.hit(self(), x, y);
|
||||
float health = 0f;
|
||||
|
||||
if(other instanceof Healthc){
|
||||
Healthc h = (Healthc)other;
|
||||
health = h.health();
|
||||
h.damage(damage);
|
||||
}
|
||||
|
||||
@ -111,30 +113,40 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
||||
}else{
|
||||
collided.add(other.id());
|
||||
}
|
||||
|
||||
type.hitEntity(self(), other, health);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
type.update(base());
|
||||
type.update(self());
|
||||
|
||||
if(type.collidesTiles && type.collides && type.collidesGround){
|
||||
world.raycastEach(world.toTile(lastX()), world.toTile(lastY()), tileX(), tileY(), (x, y) -> {
|
||||
|
||||
Building tile = world.build(x, y);
|
||||
if(tile == null) return false;
|
||||
if(tile == null || !isAdded()) return false;
|
||||
|
||||
if(tile.collide(base()) && type.collides(base(), tile) && !tile.dead() && (type.collidesTeam || tile.team != team)){
|
||||
if(tile.collide(self()) && type.collides(self(), tile) && !tile.dead() && (type.collidesTeam || tile.team != team) && !(type.pierceBuilding && collided.contains(tile.id))){
|
||||
boolean remove = false;
|
||||
|
||||
float health = tile.health;
|
||||
|
||||
if(tile.team != team){
|
||||
remove = tile.collision(base());
|
||||
remove = tile.collision(self());
|
||||
}
|
||||
|
||||
if(remove || type.collidesTeam){
|
||||
type.hitTile(base(), tile);
|
||||
remove();
|
||||
if(!type.pierceBuilding){
|
||||
remove();
|
||||
}else{
|
||||
collided.add(tile.id);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
type.hitTile(self(), tile, health);
|
||||
|
||||
return !type.pierceBuilding;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -146,8 +158,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
||||
public void draw(){
|
||||
Draw.z(Layer.bullet);
|
||||
|
||||
type.draw(base());
|
||||
type.drawLight(base());
|
||||
type.draw(self());
|
||||
type.drawLight(self());
|
||||
}
|
||||
|
||||
/** Sets the bullet's rotation in degrees. */
|
||||
|
@ -59,7 +59,7 @@ abstract class CommanderComp implements Unitc{
|
||||
units.clear();
|
||||
|
||||
Units.nearby(team(), x, y, 200f, u -> {
|
||||
if(u.isAI() && include.get(u) && u != base()){
|
||||
if(u.isAI() && include.get(u) && u != self()){
|
||||
units.add(u);
|
||||
}
|
||||
});
|
||||
@ -79,7 +79,7 @@ abstract class CommanderComp implements Unitc{
|
||||
controlling.addAll(units);
|
||||
for(Unit unit : units){
|
||||
FormationAI ai;
|
||||
unit.controller(ai = new FormationAI(base(), formation));
|
||||
unit.controller(ai = new FormationAI(self(), formation));
|
||||
spacing = Math.max(spacing, ai.formationSize());
|
||||
minFormationSpeed = Math.min(minFormationSpeed, unit.type().speed);
|
||||
}
|
||||
@ -104,7 +104,7 @@ abstract class CommanderComp implements Unitc{
|
||||
void clearCommand(){
|
||||
//reset controlled units
|
||||
for(Unit unit : controlling){
|
||||
if(unit.controller().isBeingControlled(base())){
|
||||
if(unit.controller().isBeingControlled(self())){
|
||||
unit.controller(unit.type().createController());
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,16 @@ import mindustry.gen.*;
|
||||
@EntityDef(value = {EffectStatec.class, Childc.class}, pooled = true, serialize = false)
|
||||
@Component(base = true)
|
||||
abstract class EffectStateComp implements Posc, Drawc, Timedc, Rotc, Childc{
|
||||
@Import float time, lifetime, rotation, x, y;
|
||||
@Import int id;
|
||||
|
||||
Color color = new Color(Color.white);
|
||||
Effect effect;
|
||||
Object data;
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
effect.render(id(), color, time(), rotation(), x(), y(), data);
|
||||
lifetime = effect.render(id, color, time, lifetime, rotation, x, y, data);
|
||||
}
|
||||
|
||||
@Replace
|
||||
|
@ -40,7 +40,7 @@ abstract class EntityComp{
|
||||
return false;
|
||||
}
|
||||
|
||||
<T extends Entityc> T base(){
|
||||
<T extends Entityc> T self(){
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
|
@ -97,11 +97,11 @@ abstract class FireComp implements Timedc, Posc, Firec, Syncc{
|
||||
|
||||
@Override
|
||||
public void afterRead(){
|
||||
Fires.register(base());
|
||||
Fires.register(self());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSync(){
|
||||
Fires.register(base());
|
||||
Fires.register(self());
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
}
|
||||
|
||||
if(!hovering && isGrounded() && floor.isLiquid){
|
||||
if((splashTimer += Mathf.dst(deltaX(), deltaY())) >= 7f){
|
||||
if((splashTimer += Mathf.dst(deltaX(), deltaY())) >= (7f + hitSize()/8f)){
|
||||
floor.walkEffect.at(x, y, hitSize() / 8f, floor.mapColor);
|
||||
splashTimer = 0f;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
||||
deathTimer += Time.delta;
|
||||
if(deathTimer >= deathDelay){
|
||||
//request spawn - this happens serverside only
|
||||
core.requestSpawn(base());
|
||||
core.requestSpawn(self());
|
||||
deathTimer = 0;
|
||||
}
|
||||
}
|
||||
@ -191,7 +191,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
||||
}
|
||||
}
|
||||
|
||||
Events.fire(new UnitChangeEvent(base(), unit));
|
||||
Events.fire(new UnitChangeEvent(self(), unit));
|
||||
}
|
||||
|
||||
boolean dead(){
|
||||
|
@ -128,6 +128,6 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
||||
|
||||
@Override
|
||||
public void afterRead(){
|
||||
Puddles.register(base());
|
||||
Puddles.register(self());
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ abstract class StatusComp implements Posc, Flyingc{
|
||||
return;
|
||||
}else if(entry.effect.reactsWith(effect)){ //find opposite
|
||||
StatusEntry.tmp.effect = entry.effect;
|
||||
entry.effect.getTransition(base(), effect, entry.time, duration, StatusEntry.tmp);
|
||||
entry.effect.getTransition(self(), effect, entry.time, duration, StatusEntry.tmp);
|
||||
entry.time = StatusEntry.tmp.time;
|
||||
|
||||
if(StatusEntry.tmp.effect != entry.effect){
|
||||
@ -125,14 +125,14 @@ abstract class StatusComp implements Posc, Flyingc{
|
||||
armorMultiplier *= entry.effect.armorMultiplier;
|
||||
damageMultiplier *= entry.effect.damageMultiplier;
|
||||
reloadMultiplier *= entry.effect.reloadMultiplier;
|
||||
entry.effect.update(base(), entry.time);
|
||||
entry.effect.update(self(), entry.time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
for(StatusEntry e : statuses){
|
||||
e.effect.draw(base());
|
||||
e.effect.draw(self());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,14 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.abilities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
@ -37,7 +39,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
private UnitType type;
|
||||
boolean spawnedByCore, deactivated;
|
||||
|
||||
transient float timer1, timer2;
|
||||
transient Seq<Ability> abilities = new Seq<>(0);
|
||||
|
||||
public void moveAt(Vec2 vector){
|
||||
moveAt(vector, type.accel);
|
||||
@ -117,7 +119,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
@Override
|
||||
public void controller(UnitController next){
|
||||
this.controller = next;
|
||||
if(controller.unit() != base()) controller.unit(base());
|
||||
if(controller.unit() != self()) controller.unit(self());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -171,7 +173,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
return Units.getCap(team);
|
||||
}
|
||||
|
||||
private void setStats(UnitType type){
|
||||
public void setStats(UnitType type){
|
||||
this.type = type;
|
||||
this.maxHealth = type.health;
|
||||
this.drag = type.drag;
|
||||
@ -181,13 +183,16 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
|
||||
if(controller == null) controller(type.createController());
|
||||
if(mounts().length != type.weapons.size) setupWeapons(type);
|
||||
if(abilities.size != type.abilities.size){
|
||||
abilities = type.abilities.map(Ability::copy);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSync(){
|
||||
//set up type info after reading
|
||||
setStats(this.type);
|
||||
controller.unit(base());
|
||||
controller.unit(self());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -212,7 +217,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
@Override
|
||||
public void remove(){
|
||||
teamIndex.updateCount(team, type, -1);
|
||||
controller.removed(base());
|
||||
controller.removed(self());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -221,7 +226,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
Effect.shake(type.landShake, type.landShake, this);
|
||||
}
|
||||
|
||||
type.landed(base());
|
||||
type.landed(self());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -232,7 +237,15 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
deactivated = false;
|
||||
}
|
||||
|
||||
if(!deactivated) type.update(base());
|
||||
if(!deactivated){
|
||||
type.update(self());
|
||||
|
||||
if(abilities.size > 0){
|
||||
for(Ability a : abilities){
|
||||
a.update(self());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drag = type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f);
|
||||
|
||||
@ -282,7 +295,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
if(tile != null && isGrounded() && !type.hovering){
|
||||
//unit block update
|
||||
if(tile.build != null){
|
||||
tile.build.unitOn(base());
|
||||
tile.build.unitOn(self());
|
||||
}
|
||||
|
||||
//apply damage
|
||||
@ -316,7 +329,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
|
||||
//remove units spawned by the core
|
||||
if(spawnedByCore && !isPlayer()){
|
||||
Call.unitDespawn(base());
|
||||
Call.unitDespawn(self());
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,7 +351,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
Effect.shake(shake, shake, this);
|
||||
type.deathSound.at(this);
|
||||
|
||||
Events.fire(new UnitDestroyEvent(base()));
|
||||
Events.fire(new UnitDestroyEvent(self()));
|
||||
|
||||
if(explosiveness > 7f && isLocal()){
|
||||
Events.fire(Trigger.suicideBomb);
|
||||
@ -364,7 +377,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
|
||||
@Override
|
||||
public void display(Table table){
|
||||
type.display(base(), table);
|
||||
type.display(self(), table);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -374,7 +387,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
type.draw(base());
|
||||
type.draw(self());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,6 +93,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc{
|
||||
for(WeaponMount mount : mounts){
|
||||
Weapon weapon = mount.weapon;
|
||||
mount.reload = Math.max(mount.reload - Time.delta * reloadMultiplier, 0);
|
||||
mount.heat = Math.max(mount.heat - Time.delta * reloadMultiplier / mount.weapon.cooldownTime, 0);
|
||||
|
||||
//flip weapon shoot side for alternating weapons at half reload
|
||||
if(weapon.otherSide != -1 && weapon.alternate && mount.side == weapon.flipSprite &&
|
||||
@ -138,6 +139,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc{
|
||||
shoot(weapon, shootX, shootY, mount.aimX, mount.aimY, shootAngle, Mathf.sign(weapon.x));
|
||||
|
||||
mount.reload = weapon.reload;
|
||||
mount.heat = 1f;
|
||||
|
||||
ammo--;
|
||||
if(ammo < 0) ammo = 0;
|
||||
|
@ -11,6 +11,8 @@ public class WeaponMount{
|
||||
public float rotation;
|
||||
/** destination rotation; do not modify! */
|
||||
public float targetRotation;
|
||||
/** current heat, 0 to 1*/
|
||||
public float heat;
|
||||
/** aiming position in world coordinates */
|
||||
public float aimX, aimY;
|
||||
/** whether to shoot right now */
|
||||
|
@ -128,6 +128,7 @@ public class Saves{
|
||||
sector.save.setName(sector.save.file.nameWithoutExtension());
|
||||
saves.add(sector.save);
|
||||
}
|
||||
sector.save.setAutosave(true);
|
||||
sector.save.save();
|
||||
lastSectorSave = sector.save;
|
||||
Core.settings.put("last-sector-save", sector.save.getName());
|
||||
|
@ -89,11 +89,6 @@ public class SectorInfo{
|
||||
public void update(){
|
||||
internalTimeSpent += Time.delta;
|
||||
|
||||
//time spent exceeds turn duration!
|
||||
if(internalTimeSpent >= turnDuration && internalTimeSpent - Time.delta < turnDuration){
|
||||
universe.displayTimeEnd();
|
||||
}
|
||||
|
||||
//create last stored core items
|
||||
if(lastCoreItems == null){
|
||||
lastCoreItems = new int[content.items().size];
|
||||
|
@ -56,7 +56,7 @@ public class Universe{
|
||||
public void displayTimeEnd(){
|
||||
if(!headless){
|
||||
//check if any sectors are under attack to display this
|
||||
Seq<Sector> attacked = state.getSector().planet.sectors.select(s -> s.hasWaves() && s.hasBase() && !s.isBeingPlayed());
|
||||
Seq<Sector> attacked = state.getSector().planet.sectors.select(s -> s.hasWaves() && s.hasBase() && !s.isBeingPlayed() && s.getSecondsPassed() > 1);
|
||||
|
||||
if(attacked.any()){
|
||||
state.set(State.paused);
|
||||
|
@ -172,6 +172,20 @@ public class Drawf{
|
||||
construct(t, content.icon(Cicon.full), rotation, progress, speed, time);
|
||||
}
|
||||
|
||||
public static void construct(float x, float y, TextureRegion region, float rotation, float progress, float speed, float time){
|
||||
Shaders.build.region = region;
|
||||
Shaders.build.progress = progress;
|
||||
Shaders.build.color.set(Pal.accent);
|
||||
Shaders.build.color.a = speed;
|
||||
Shaders.build.time = -time / 20f;
|
||||
|
||||
Draw.shader(Shaders.build);
|
||||
Draw.rect(region, x, y, rotation);
|
||||
Draw.shader();
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
public static void construct(Building t, TextureRegion region, float rotation, float progress, float speed, float time){
|
||||
Shaders.build.region = region;
|
||||
Shaders.build.progress = progress;
|
||||
|
@ -47,6 +47,7 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
@Override
|
||||
public void buildUI(Group group){
|
||||
|
||||
group.fill(t -> {
|
||||
t.visible(() -> Core.settings.getBool("hints") && ui.hudfrag.shown() && !player.dead() && !player.unit().spawnedByCore() && !(Core.settings.getBool("hints") && lastSchematic != null && !selectRequests.isEmpty()));
|
||||
t.bottom();
|
||||
|
@ -980,6 +980,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
uiGroup.touchable = Touchable.childrenOnly;
|
||||
uiGroup.setFillParent(true);
|
||||
ui.hudGroup.addChild(uiGroup);
|
||||
uiGroup.toBack();
|
||||
buildUI(uiGroup);
|
||||
|
||||
frag.add();
|
||||
|
@ -132,11 +132,6 @@ public class UnitType extends UnlockableContent{
|
||||
}
|
||||
|
||||
public void update(Unit unit){
|
||||
if(abilities.size > 0){
|
||||
for(Ability a : abilities){
|
||||
a.update(unit);
|
||||
}
|
||||
}
|
||||
|
||||
if(unit instanceof Mechc){
|
||||
updateMechEffects(unit);
|
||||
@ -378,8 +373,8 @@ public class UnitType extends UnlockableContent{
|
||||
drawDeactive(unit);
|
||||
}
|
||||
|
||||
if(abilities.size > 0){
|
||||
for(Ability a : abilities){
|
||||
if(unit.abilities.size > 0){
|
||||
for(Ability a : unit.abilities){
|
||||
Draw.reset();
|
||||
a.draw(unit);
|
||||
}
|
||||
@ -512,10 +507,23 @@ public class UnitType extends UnlockableContent{
|
||||
Drawf.shadow(wx, wy, weapon.occlusion);
|
||||
}
|
||||
|
||||
Draw.rect(weapon.region, wx, wy,
|
||||
Draw.rect(weapon.region,
|
||||
wx, wy,
|
||||
width * Draw.scl * -Mathf.sign(weapon.flipSprite),
|
||||
weapon.region.height * Draw.scl,
|
||||
weaponRotation);
|
||||
|
||||
if(weapon.heatRegion.found() && mount.heat > 0){
|
||||
Draw.color(weapon.heatColor, mount.heat);
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.rect(weapon.heatRegion,
|
||||
wx, wy,
|
||||
width * Draw.scl * -Mathf.sign(weapon.flipSprite),
|
||||
weapon.region.height * Draw.scl,
|
||||
weaponRotation);
|
||||
Draw.blend();
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
|
@ -2,12 +2,14 @@ package mindustry.type;
|
||||
|
||||
import arc.*;
|
||||
import arc.audio.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.io.*;
|
||||
|
||||
public class Weapon{
|
||||
@ -51,6 +53,8 @@ public class Weapon{
|
||||
public float shotDelay = 0;
|
||||
/** The half-radius of the cone in which shooting will start. */
|
||||
public float shootCone = 5f;
|
||||
/** ticks to cool down the heat region */
|
||||
public float cooldownTime = 20f;
|
||||
/** whether shooter rotation is ignored when shooting. */
|
||||
public boolean ignoreRotation = false;
|
||||
/** min velocity required for this weapon to shoot */
|
||||
@ -63,6 +67,10 @@ public class Weapon{
|
||||
public Sound noAmmoSound = Sounds.click;
|
||||
/** displayed region (autoloaded) */
|
||||
public TextureRegion region;
|
||||
/** heat region, must be same size as region (optional) */
|
||||
public TextureRegion heatRegion;
|
||||
/** heat region tint */
|
||||
public Color heatColor = Pal.turretHeat;
|
||||
|
||||
public Weapon(String name){
|
||||
this.name = name;
|
||||
@ -80,6 +88,7 @@ public class Weapon{
|
||||
|
||||
public void load(){
|
||||
region = Core.atlas.find(name, Core.atlas.find("clear"));
|
||||
heatRegion = Core.atlas.find(name + "-heat");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -164,8 +164,8 @@ public abstract class Weather extends UnlockableContent{
|
||||
|
||||
life -= Time.delta;
|
||||
|
||||
weather.update(base());
|
||||
weather.updateEffect(base());
|
||||
weather.update(self());
|
||||
weather.updateEffect(self());
|
||||
|
||||
if(life < 0){
|
||||
remove();
|
||||
@ -178,14 +178,14 @@ public abstract class Weather extends UnlockableContent{
|
||||
Draw.draw(Layer.weather, () -> {
|
||||
weather.rand.setSeed(0);
|
||||
Draw.alpha(renderer.weatherAlpha() * opacity);
|
||||
weather.drawOver(base());
|
||||
weather.drawOver(self());
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
Draw.draw(Layer.debris, () -> {
|
||||
weather.rand.setSeed(0);
|
||||
Draw.alpha(renderer.weatherAlpha() * opacity);
|
||||
weather.drawUnder(base());
|
||||
weather.drawUnder(self());
|
||||
Draw.reset();
|
||||
});
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class Wall extends Block{
|
||||
//deflect bullets if necessary
|
||||
if(deflect){
|
||||
//slow bullets are not deflected
|
||||
if(bullet.vel().len() <= 0.2f) return true;
|
||||
if(bullet.vel().len() <= 0.2f || !bullet.type.reflectable) return true;
|
||||
|
||||
//bullet reflection chance depends on bullet damage
|
||||
if(!Mathf.chance(chanceDeflect / bullet.damage())) return true;
|
||||
|
@ -77,6 +77,7 @@ public abstract class Turret extends Block{
|
||||
public Cons<TurretBuild> drawer = tile -> Draw.rect(region, tile.x + tr2.x, tile.y + tr2.y, tile.rotation - 90);
|
||||
public Cons<TurretBuild> heatDrawer = tile -> {
|
||||
if(tile.heat <= 0.00001f) return;
|
||||
|
||||
Draw.color(heatColor, tile.heat);
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.rect(heatRegion, tile.x + tr2.x, tile.y + tr2.y, tile.rotation - 90);
|
||||
|
@ -318,6 +318,12 @@ public class LogicBlock extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
//logic blocks cause write problems when picked up
|
||||
@Override
|
||||
public boolean canPickup(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float range(){
|
||||
return range;
|
||||
|