Added basic respawning
This commit is contained in:
@@ -5,7 +5,6 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.pooling.*;
|
||||
@@ -45,7 +44,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
||||
return unit instanceof Minerc;
|
||||
}
|
||||
|
||||
public @Nullable Tilec closestCore(){
|
||||
public @Nullable CoreEntity closestCore(){
|
||||
return state.teams.closestCore(x(), y(), team);
|
||||
}
|
||||
|
||||
@@ -64,17 +63,14 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
||||
clearUnit();
|
||||
}
|
||||
|
||||
CoreEntity core = closestCore();
|
||||
|
||||
if(!dead()){
|
||||
x(unit.x());
|
||||
y(unit.y());
|
||||
unit.team(team);
|
||||
}else if(!team.cores().isEmpty()){
|
||||
//try to respawn
|
||||
Array<CoreEntity> cores = team.cores();
|
||||
|
||||
if(!cores.isEmpty()){
|
||||
//TODO respawning
|
||||
}
|
||||
}else if(core != null){
|
||||
core.requestSpawn((Playerc)this);
|
||||
}
|
||||
|
||||
textFadeTime -= Time.delta() / (60 * 5);
|
||||
|
||||
@@ -4,7 +4,12 @@ import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.renderer;
|
||||
|
||||
@@ -87,5 +92,63 @@ public class Drawf{
|
||||
Draw.rect(Core.atlas.find("shape-3"), x, y - oy + length / 2f, width, length, width / 2f, oy, rotation - 90);
|
||||
}
|
||||
|
||||
public static void drawRespawn(Tilec tile, float heat, float progress, float time, UnitType to, @Nullable Playerc player){
|
||||
float x = tile.x(), y = tile.y();
|
||||
progress = Mathf.clamp(progress);
|
||||
|
||||
Draw.color(Pal.darkMetal);
|
||||
Lines.stroke(2f * heat);
|
||||
Fill.poly(x, y, 4, 10f * heat);
|
||||
|
||||
Draw.reset();
|
||||
if(player != null){
|
||||
TextureRegion region = to.icon(Cicon.full);
|
||||
|
||||
Draw.color(0f, 0f, 0f, 0.4f * progress);
|
||||
Draw.rect("circle-shadow", x, y, region.getWidth() / 3f, region.getWidth() / 3f);
|
||||
Draw.color();
|
||||
|
||||
Shaders.build.region = region;
|
||||
Shaders.build.progress = progress;
|
||||
Shaders.build.color.set(Pal.accent);
|
||||
Shaders.build.time = -time / 10f;
|
||||
|
||||
Draw.shader(Shaders.build, true);
|
||||
Draw.rect(region, x, y);
|
||||
Draw.shader();
|
||||
|
||||
Draw.color(Pal.accentBack);
|
||||
|
||||
float pos = Mathf.sin(time, 6f, 8f);
|
||||
|
||||
Lines.lineAngleCenter(x + pos, y, 90, 16f - Math.abs(pos) * 2f);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
Lines.stroke(2f * heat);
|
||||
|
||||
Draw.color(Pal.accentBack);
|
||||
Lines.poly(x, y, 4, 8f * heat);
|
||||
|
||||
float oy = -7f, len = 6f * heat;
|
||||
Lines.stroke(5f);
|
||||
Draw.color(Pal.darkMetal);
|
||||
Lines.line(x - len, y + oy, x + len, y + oy, CapStyle.none);
|
||||
for(int i : Mathf.signs){
|
||||
Fill.tri(x + len * i, y + oy - Lines.getStroke()/2f, x + len * i, y + oy + Lines.getStroke()/2f, x + (len + Lines.getStroke() * heat) * i, y + oy);
|
||||
}
|
||||
|
||||
Lines.stroke(3f);
|
||||
Draw.color(Pal.accent);
|
||||
Lines.line(x - len, y + oy, x - len + len*2 * progress, y + oy, CapStyle.none);
|
||||
for(int i : Mathf.signs){
|
||||
Fill.tri(x + len * i, y + oy - Lines.getStroke()/2f, x + len * i, y + oy + Lines.getStroke()/2f, x + (len + Lines.getStroke() * heat) * i, y + oy);
|
||||
}
|
||||
Draw.reset();
|
||||
|
||||
if(Vars.net.active() && player != null){
|
||||
tile.block().drawPlaceText(player.name(), tile.tileX(), tile.tileY() - (Math.max((tile.block().size-1)/2, 0)), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import mindustry.world.modules.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class CoreBlock extends StorageBlock{
|
||||
public UnitType mech = UnitTypes.starter;
|
||||
public UnitType unitType = UnitTypes.phantom;
|
||||
|
||||
public CoreBlock(String name){
|
||||
super(name);
|
||||
@@ -35,17 +35,19 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void onUnitRespawn(Tilec tile, Playerc player){
|
||||
public static void onPlayerSpawn(Tile tile, Playerc player){
|
||||
if(player == null || tile == null) return;
|
||||
|
||||
//TODO really fix
|
||||
Fx.spawn.at(tile);
|
||||
//progress = 0;
|
||||
//spawnPlayer = player;
|
||||
//TODO fix
|
||||
//spawnPlayer.onRespawn(tile);
|
||||
//spawnPlayer.applyImpulse(0, 8f);
|
||||
//spawnPlayer = null;
|
||||
CoreEntity entity = tile.ent();
|
||||
CoreBlock block = (CoreBlock)tile.block();
|
||||
Fx.spawn.at(entity);
|
||||
entity.progress = 0;
|
||||
|
||||
Unitc unit = block.unitType.create(tile.team());
|
||||
unit.set(entity);
|
||||
unit.impulse(0f, 8f);
|
||||
unit.controller(player);
|
||||
unit.add();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,10 +69,21 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
public class CoreEntity extends TileEntity{
|
||||
// protected Playerc spawnPlayer;
|
||||
//protected float progress;
|
||||
protected float time;
|
||||
protected float heat;
|
||||
protected float time, heat, progress;
|
||||
protected int storageCapacity;
|
||||
protected boolean shouldBuild;
|
||||
protected Playerc lastRequested;
|
||||
|
||||
public void requestSpawn(Playerc player){
|
||||
shouldBuild = true;
|
||||
if(lastRequested == null){
|
||||
lastRequested = player;
|
||||
}
|
||||
|
||||
if(progress >= 1f){
|
||||
Call.onPlayerSpawn(tile, player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(){
|
||||
@@ -183,8 +196,7 @@ public class CoreBlock extends StorageBlock{
|
||||
@Override
|
||||
public void drawLayer(){
|
||||
if(heat > 0.001f){
|
||||
//TODO implement
|
||||
//RespawnBlock.drawRespawn(tile, heat, progress, time, spawnPlayer, mech);
|
||||
Drawf.drawRespawn(this, heat, progress, time, unitType, lastRequested);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,31 +212,23 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
//TODO implement
|
||||
/*
|
||||
if(spawnPlayer != null){
|
||||
if(!spawnPlayer.dead() || !spawnPlayer.isAdded()){
|
||||
spawnPlayer = null;
|
||||
return;
|
||||
|
||||
if(shouldBuild){
|
||||
heat = Mathf.lerpDelta(heat, 1f, 0.1f);
|
||||
time += delta();
|
||||
progress += 1f / state.rules.respawnTime * delta();
|
||||
}else{
|
||||
progress = 0f;
|
||||
heat = Mathf.lerpDelta(heat, 0f, 0.1f);
|
||||
}
|
||||
|
||||
spawnPlayer.set(x, y);
|
||||
heat = Mathf.lerpDelta(heat, 1f, 0.1f);
|
||||
time += delta();
|
||||
progress += 1f / state.rules.respawnTime * delta();
|
||||
|
||||
if(progress >= 1f){
|
||||
Call.onUnitRespawn(tile, spawnPlayer);
|
||||
}
|
||||
}else{
|
||||
heat = Mathf.lerpDelta(heat, 0f, 0.1f);
|
||||
}*/
|
||||
shouldBuild = false;
|
||||
lastRequested = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldActiveSound(){
|
||||
//TODO
|
||||
return false;//spawnPlayer != null;
|
||||
return shouldBuild;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user