c l e a n u p
This commit is contained in:
@@ -34,7 +34,7 @@ public class Damage{
|
||||
}
|
||||
|
||||
for(int i = 0; i < Mathf.clamp(flammability / 4, 0, 30); i++){
|
||||
Time.run(i / 2f, () -> Call.createBullet(Bullets.fireball, Team.derelict, x, y, Mathf.random(360f), 1, 1));
|
||||
Time.run(i / 2f, () -> Call.createBullet(Bullets.fireball, Team.derelict, x, y, -1f, Mathf.random(360f), 1, 1));
|
||||
}
|
||||
|
||||
int waves = Mathf.clamp((int)(explosiveness / 4), 0, 30);
|
||||
|
||||
@@ -31,6 +31,10 @@ public class EntityGroup<T extends Entityc> implements Iterable<T>{
|
||||
}
|
||||
}
|
||||
|
||||
public void sort(Comparator<? super T> comp){
|
||||
array.sort(comp);
|
||||
}
|
||||
|
||||
public void update(){
|
||||
|
||||
if(useTree()){
|
||||
|
||||
@@ -51,6 +51,19 @@ public class Predict{
|
||||
return sol;
|
||||
}
|
||||
|
||||
public static Vec2 intercept(Position src, Hitboxc dst, float v){
|
||||
return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), dst.deltaX(), dst.deltaY(), v);
|
||||
}
|
||||
|
||||
public static Vec2 intercept(Position src, Position dst, float v){
|
||||
float ddx = 0, ddy = 0;
|
||||
if(dst instanceof Hitboxc){
|
||||
ddx = ((Hitboxc)dst).deltaX();
|
||||
ddy = ((Hitboxc)dst).deltaY();
|
||||
}
|
||||
return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), ddx, ddy, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #intercept(float, float, float, float, float, float, float)}.
|
||||
*/
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package mindustry.entities;
|
||||
|
||||
/**
|
||||
* Marks an entity as serializable.
|
||||
*/
|
||||
public interface SaveTrait extends Saveable{
|
||||
byte version();
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package mindustry.entities;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/** Marks something as saveable; not necessarily used for entities. */
|
||||
public interface Saveable{
|
||||
void writeSave(DataOutput stream) throws IOException;
|
||||
void readSave(DataInput stream, byte version) throws IOException;
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class Units{
|
||||
* @return whether the target is invalid
|
||||
*/
|
||||
public static boolean invalidateTarget(Teamc target, Team team, float x, float y, float range){
|
||||
return target == null || (range != Float.MAX_VALUE && !target.withinDst(x, y, range)) || target.team() == team || !target.isValid();
|
||||
return target == null || (range != Float.MAX_VALUE && !target.withinDst(x, y, range)) || target.team() == team || (target instanceof Healthc && !((Healthc)target).isValid());
|
||||
}
|
||||
|
||||
/** See {@link #invalidateTarget(Teamc, Team, float, float, float)} */
|
||||
|
||||
@@ -47,12 +47,13 @@ public class LiquidBulletType extends BulletType{
|
||||
super.update(b);
|
||||
|
||||
if(liquid.canExtinguish()){
|
||||
//TODO implement
|
||||
Tile tile = world.tileWorld(b.x(), b.y());
|
||||
if(tile != null && Fire.has(tile.x, tile.y)){
|
||||
Fire.extinguish(tile, 100f);
|
||||
b.remove();
|
||||
hit(b);
|
||||
}
|
||||
//if(tile != null && Fire.has(tile.x, tile.y)){
|
||||
//Fire.extinguish(tile, 100f);
|
||||
// b.remove();
|
||||
// hit(b);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,13 +67,14 @@ public class LiquidBulletType extends BulletType{
|
||||
@Override
|
||||
public void hit(Bulletc b, float hitx, float hity){
|
||||
hitEffect.at(hitx, hity, liquid.color);
|
||||
Puddle.deposit(world.tileWorld(hitx, hity), liquid, puddleSize);
|
||||
//TODO implement
|
||||
// Puddle.deposit(world.tileWorld(hitx, hity), liquid, puddleSize);
|
||||
|
||||
if(liquid.temperature <= 0.5f && liquid.flammability < 0.3f){
|
||||
float intensity = 400f;
|
||||
Fire.extinguish(world.tileWorld(hitx, hity), intensity);
|
||||
//Fire.extinguish(world.tileWorld(hitx, hity), intensity);
|
||||
for(Point2 p : Geometry.d4){
|
||||
Fire.extinguish(world.tileWorld(hitx + p.x * tilesize, hity + p.y * tilesize), intensity);
|
||||
// Fire.extinguish(world.tileWorld(hitx + p.x * tilesize, hity + p.y * tilesize), intensity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,11 @@ public class EntityComps{
|
||||
private UnitController controller;
|
||||
private UnitDef type;
|
||||
|
||||
@Override
|
||||
public int itemCapacity(){
|
||||
return type.itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float bounds(){
|
||||
return hitSize() * 2f;
|
||||
@@ -288,7 +293,7 @@ public class EntityComps{
|
||||
|
||||
@Component
|
||||
abstract class TimerComp{
|
||||
@ReadOnly Interval timer = new Interval(6);
|
||||
Interval timer = new Interval(6);
|
||||
|
||||
public boolean timer(int index, float time){
|
||||
return timer.get(index, time);
|
||||
@@ -433,11 +438,11 @@ public class EntityComps{
|
||||
}
|
||||
|
||||
@Component
|
||||
class RotComp{
|
||||
abstract class RotComp implements Entityc{
|
||||
float rotation;
|
||||
|
||||
void interpolate(){
|
||||
Syncc sync = (Syncc)this;
|
||||
Syncc sync = as(Syncc.class);
|
||||
|
||||
if(sync.interpolator().values.length > 0){
|
||||
rotation = sync.interpolator().values[0];
|
||||
@@ -446,7 +451,7 @@ public class EntityComps{
|
||||
}
|
||||
|
||||
@Component
|
||||
static abstract class TileComp implements Posc, Teamc, Healthc, Tilec{
|
||||
static abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
||||
static final float timeToSleep = 60f * 1;
|
||||
static final ObjectSet<Tile> tmpTiles = new ObjectSet<>();
|
||||
static int sleepingEntities = 0;
|
||||
@@ -460,7 +465,6 @@ public class EntityComps{
|
||||
LiquidModule liquids;
|
||||
ConsumeModule cons;
|
||||
|
||||
private Interval timer;
|
||||
private float timeScale = 1f, timeScaleDuration;
|
||||
|
||||
private @Nullable SoundLoop sound;
|
||||
@@ -481,7 +485,7 @@ public class EntityComps{
|
||||
|
||||
health(block.health);
|
||||
maxHealth(block.health);
|
||||
timer = new Interval(block.timers);
|
||||
timer(new Interval(block.timers));
|
||||
|
||||
if(shouldAdd){
|
||||
add();
|
||||
@@ -490,6 +494,12 @@ public class EntityComps{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyBoost(float intensity, float duration){
|
||||
timeScale = Math.max(timeScale, intensity);
|
||||
timeScaleDuration = Math.max(timeScaleDuration, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float timeScale(){
|
||||
return timeScale;
|
||||
@@ -505,11 +515,6 @@ public class EntityComps{
|
||||
cons.trigger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean timer(int id, float time){
|
||||
return timer.get(id, time);
|
||||
}
|
||||
|
||||
/** Scaled delta. */
|
||||
@Override
|
||||
public float delta(){
|
||||
@@ -671,8 +676,10 @@ public class EntityComps{
|
||||
}
|
||||
|
||||
@Component
|
||||
abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
||||
@Nullable Unitc unit;
|
||||
abstract static class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
||||
private static final Unitc noUnit = GenericUnitEntity.create();
|
||||
|
||||
@NonNull @ReadOnly Unitc unit = noUnit;
|
||||
|
||||
@ReadOnly Team team = Team.sharded;
|
||||
String name = "noname";
|
||||
@@ -698,7 +705,7 @@ public class EntityComps{
|
||||
}
|
||||
|
||||
public void update(){
|
||||
if(unit != null){
|
||||
if(!dead()){
|
||||
x(unit.x());
|
||||
y(unit.y());
|
||||
unit.team(team);
|
||||
@@ -712,13 +719,29 @@ public class EntityComps{
|
||||
}
|
||||
}
|
||||
|
||||
public void clearUnit(){
|
||||
unit(noUnit);
|
||||
}
|
||||
|
||||
public Unitc unit(){
|
||||
if(dead()){
|
||||
//TODO remove
|
||||
Log.err("WARNING: DEAD PLAYER UNIT ACCESSED");
|
||||
new RuntimeException().printStackTrace();
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void unit(Unitc unit){
|
||||
if(unit == null) throw new IllegalArgumentException("Unit cannot be null. Use clearUnit() instead.");
|
||||
this.unit = unit;
|
||||
unit.team(team);
|
||||
if(unit != noUnit){
|
||||
unit.team(team);
|
||||
}
|
||||
}
|
||||
|
||||
boolean dead(){
|
||||
return unit == null;
|
||||
return unit == noUnit;
|
||||
}
|
||||
|
||||
String uuid(){
|
||||
@@ -1472,12 +1495,13 @@ public class EntityComps{
|
||||
}
|
||||
|
||||
@Component
|
||||
abstract class ItemsComp{
|
||||
abstract class ItemsComp implements Posc{
|
||||
@ReadOnly ItemStack stack = new ItemStack();
|
||||
|
||||
abstract int itemCapacity();
|
||||
|
||||
void update(){
|
||||
@Override
|
||||
public void update(){
|
||||
stack.amount = Mathf.clamp(stack.amount, 0, itemCapacity());
|
||||
}
|
||||
|
||||
@@ -1506,11 +1530,19 @@ public class EntityComps{
|
||||
stack.item = item;
|
||||
stack.amount = Mathf.clamp(stack.amount, 0, itemCapacity());
|
||||
}
|
||||
|
||||
int maxAccepted(Item item){
|
||||
return stack.item != item && stack.amount > 0 ? 0 : itemCapacity() - stack.amount;
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
abstract class MassComp implements Velc{
|
||||
float mass;
|
||||
float mass = 1f;
|
||||
|
||||
public void applyImpulse(float x, float y){
|
||||
vel().add(x / mass, y / mass);
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
|
||||
@@ -19,4 +19,7 @@ class EntityDefs{
|
||||
|
||||
@EntityDef({PlayerComp.class})
|
||||
class PlayerDef{}
|
||||
|
||||
@EntityDef({UnitComp.class})
|
||||
class GenericUnitDef{}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,8 @@ import mindustry.gen.*;
|
||||
public interface UnitController{
|
||||
void unit(Unitc unit);
|
||||
Unitc unit();
|
||||
|
||||
default void command(UnitCommand command){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user