mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-25 05:51:47 -08:00
Pad respawning
This commit is contained in:
parent
67940476af
commit
696e6cb84b
6 changed files with 9 additions and 57 deletions
|
|
@ -3,7 +3,6 @@ package io.anuke.mindustry.ai;
|
|||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.IntArray;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
|
|
@ -11,8 +10,8 @@ import io.anuke.arc.util.Tmp;
|
|||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.Damage;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.type.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.Squad;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||
import io.anuke.mindustry.game.SpawnGroup;
|
||||
import io.anuke.mindustry.world.Pos;
|
||||
|
|
@ -68,7 +67,6 @@ public class WaveSpawner{
|
|||
|
||||
if(group.type.isFlying){
|
||||
for(FlyerSpawn spawn : flySpawns){
|
||||
Squad squad = new Squad();
|
||||
float margin = 40f; //how far away from the edge flying units spawn
|
||||
float trns = (world.width() + world.height()) * tilesize;
|
||||
spawnX = Mathf.clamp(world.width() * tilesize / 2f + Angles.trnsx(spawn.angle, trns), -margin, world.width() * tilesize + margin);
|
||||
|
|
@ -77,15 +75,12 @@ public class WaveSpawner{
|
|||
|
||||
for(int i = 0; i < spawned; i++){
|
||||
BaseUnit unit = group.createUnit(waveTeam);
|
||||
unit.setWave();
|
||||
unit.setSquad(squad);
|
||||
unit.set(spawnX + Mathf.range(spread), spawnY + Mathf.range(spread));
|
||||
unit.add();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(GroundSpawn spawn : groundSpawns){
|
||||
Squad squad = new Squad();
|
||||
spawnX = spawn.x * tilesize;
|
||||
spawnY = spawn.y * tilesize;
|
||||
spread = tilesize*3;
|
||||
|
|
@ -94,8 +89,6 @@ public class WaveSpawner{
|
|||
Tmp.v1.rnd(spread);
|
||||
|
||||
BaseUnit unit = group.createUnit(waveTeam);
|
||||
unit.setWave();
|
||||
unit.setSquad(squad);
|
||||
unit.set(spawnX + Tmp.v1.x, spawnY + Tmp.v1.y);
|
||||
|
||||
Time.run(i*5, () -> {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import io.anuke.mindustry.entities.EntityGroup;
|
|||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.traits.ShooterTrait;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.entities.units.Squad;
|
||||
import io.anuke.mindustry.entities.units.StateMachine;
|
||||
import io.anuke.mindustry.entities.units.UnitDrops;
|
||||
import io.anuke.mindustry.entities.units.UnitState;
|
||||
|
|
@ -50,8 +49,6 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||
protected StateMachine state = new StateMachine();
|
||||
protected TargetTrait target;
|
||||
|
||||
protected boolean isWave;
|
||||
protected Squad squad;
|
||||
protected int spawner = noSpawner;
|
||||
|
||||
/**internal constructor used for deserialization, DO NOT USE*/
|
||||
|
|
@ -93,16 +90,6 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||
this.spawner = tile.pos();
|
||||
}
|
||||
|
||||
/**Sets this to a 'wave' unit, which means it has slightly different AI and will not run out of ammo.*/
|
||||
public void setWave(){
|
||||
isWave = true;
|
||||
}
|
||||
|
||||
public void setSquad(Squad squad){
|
||||
this.squad = squad;
|
||||
squad.units++;
|
||||
}
|
||||
|
||||
public void rotate(float angle){
|
||||
rotation = Mathf.slerpDelta(rotation, angle, type.rotatespeed);
|
||||
}
|
||||
|
|
@ -331,7 +318,6 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||
public void writeSave(DataOutput stream) throws IOException{
|
||||
super.writeSave(stream);
|
||||
stream.writeByte(type.id);
|
||||
stream.writeBoolean(isWave);
|
||||
stream.writeInt(spawner);
|
||||
}
|
||||
|
||||
|
|
@ -339,7 +325,6 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||
public void readSave(DataInput stream) throws IOException{
|
||||
super.readSave(stream);
|
||||
byte type = stream.readByte();
|
||||
this.isWave = stream.readBoolean();
|
||||
this.spawner = stream.readInt();
|
||||
|
||||
this.type = content.getByID(ContentType.unit, type);
|
||||
|
|
|
|||
|
|
@ -150,11 +150,6 @@ public abstract class FlyingUnit extends BaseUnit{
|
|||
Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair)) != null){
|
||||
setState(retreat);
|
||||
}
|
||||
|
||||
if(squad != null){
|
||||
squad.direction.add(velocity.x / squad.units, velocity.y / squad.units);
|
||||
velocity.setAngle(Mathf.slerpDelta(velocity.angle(), squad.direction.angle(), 0.3f));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||
public boolean achievedFlight;
|
||||
public Color color = new Color();
|
||||
public Mech mech;
|
||||
public SpawnerTrait spawner;
|
||||
public SpawnerTrait spawner, lastSpawner;
|
||||
|
||||
public NetConnection con;
|
||||
public int playerIndex = 0;
|
||||
|
|
@ -90,6 +90,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||
player.dead = true;
|
||||
player.placeQueue.clear();
|
||||
player.onDeath();
|
||||
player.mech = (player.isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -760,16 +761,18 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||
|
||||
if(spawner != null && spawner.isValid()){
|
||||
spawner.updateSpawning(this);
|
||||
}else{
|
||||
CoreEntity entity = (CoreEntity) getClosestCore();
|
||||
if(entity != null && !netServer.isWaitingForPlayers()){
|
||||
this.spawner = (SpawnerTrait)entity.tile.entity;
|
||||
}else if(!netServer.isWaitingForPlayers()){
|
||||
if(lastSpawner != null && lastSpawner.isValid()){
|
||||
this.spawner = lastSpawner;
|
||||
}else if(getClosestCore() != null){
|
||||
this.spawner = (SpawnerTrait)getClosestCore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void beginRespawning(SpawnerTrait spawner){
|
||||
this.spawner = spawner;
|
||||
this.lastSpawner = spawner;
|
||||
this.dead = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
package io.anuke.mindustry.entities.units;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
|
||||
/**
|
||||
* Used to group entities together, for formations and such.
|
||||
* Usually, squads are used by units spawned in the same wave.
|
||||
*/
|
||||
//TODO remove? is this necessary?
|
||||
public class Squad{
|
||||
public Vector2 direction = new Vector2();
|
||||
public int units;
|
||||
|
||||
private long lastUpdated;
|
||||
|
||||
protected void update(){
|
||||
if(Core.graphics.getFrameId() != lastUpdated){
|
||||
direction.setZero();
|
||||
lastUpdated = Core.graphics.getFrameId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -212,7 +212,6 @@ public class MechPad extends Block{
|
|||
|
||||
@Override
|
||||
public void updateSpawning(Player unit){
|
||||
|
||||
if(player == null){
|
||||
progress = 0f;
|
||||
player = unit;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue