mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-09 23:37:51 +07:00
Updated uCore, added new respawn mechanics
This commit is contained in:
@ -27,7 +27,7 @@ allprojects {
|
||||
gdxVersion = '1.9.8'
|
||||
roboVMVersion = '2.3.0'
|
||||
aiVersion = '1.8.1'
|
||||
uCoreVersion = '88326fc'
|
||||
uCoreVersion = 'a077c3a'
|
||||
|
||||
getVersionString = {
|
||||
String buildVersion = getBuildVersion()
|
||||
|
BIN
core/assets-raw/sprites/blocks/distribution/core-open.png
Normal file
BIN
core/assets-raw/sprites/blocks/distribution/core-open.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 602 B |
BIN
core/assets-raw/sprites/blocks/distribution/core-top.png
Normal file
BIN
core/assets-raw/sprites/blocks/distribution/core-top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 567 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 111 KiB |
@ -53,9 +53,9 @@ public class Fx implements ContentList {
|
||||
});
|
||||
|
||||
spawn = new Effect(23, e -> {
|
||||
Lines.stroke(2f);
|
||||
Draw.color(Color.DARK_GRAY, Color.SCARLET, e.fin());
|
||||
Lines.circle(e.x, e.y, 7f - e.fin() * 6f);
|
||||
Lines.stroke(2f * e.fout());
|
||||
Draw.color(Palette.accent);
|
||||
Lines.poly(e.x, e.y, 4, 3f + e.fin() * 8f);
|
||||
Draw.reset();
|
||||
});
|
||||
}
|
||||
|
@ -177,7 +177,6 @@ public class Control extends Module{
|
||||
});
|
||||
}
|
||||
|
||||
//TODO drop player method
|
||||
public void addPlayer(int index){
|
||||
if(players.length < index + 1){
|
||||
Player[] old = players;
|
||||
|
@ -55,6 +55,7 @@ public class Renderer extends RendererModule{
|
||||
private OverlayRenderer overlays = new OverlayRenderer();
|
||||
|
||||
public Renderer() {
|
||||
pixelate = true;
|
||||
Lines.setCircleVertices(14);
|
||||
|
||||
Shaders.init();
|
||||
@ -114,17 +115,12 @@ public class Renderer extends RendererModule{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
pixelate = Settings.getBool("pixelate");
|
||||
int scale = Settings.getBool("pixelate") ? Core.cameraScale : 1;
|
||||
int scale = Core.cameraScale;
|
||||
|
||||
effectSurface = Graphics.createSurface(scale);
|
||||
pixelSurface = Graphics.createSurface(scale);
|
||||
}
|
||||
|
||||
public void setPixelate(boolean pixelate){
|
||||
this.pixelate = pixelate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
|
||||
@ -399,10 +395,8 @@ public class Renderer extends RendererModule{
|
||||
targetscale = amount;
|
||||
clampScale();
|
||||
//scale up all surfaces in preparation for the zoom
|
||||
if(Settings.getBool("pixelate")){
|
||||
for(Surface surface : Graphics.getSurfaces()){
|
||||
surface.setScale(targetscale);
|
||||
}
|
||||
for(Surface surface : Graphics.getSurfaces()){
|
||||
surface.setScale(targetscale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,11 @@ import io.anuke.mindustry.net.NetEvents;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.Floor;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.mindustry.world.blocks.types.storage.CoreBlock.CoreEntity;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
@ -55,8 +59,8 @@ public class Player extends Unit implements BlockBuilder {
|
||||
public boolean isLocal = false;
|
||||
public Timer timer = new Timer(4);
|
||||
|
||||
private boolean respawning;
|
||||
private float walktime;
|
||||
private float respawntime;
|
||||
private Queue<BuildRequest> placeQueue = new Queue<>();
|
||||
|
||||
public Player(){
|
||||
@ -113,6 +117,7 @@ public class Player extends Unit implements BlockBuilder {
|
||||
@Override
|
||||
public void onDeath(){
|
||||
dead = true;
|
||||
respawning = false;
|
||||
placeQueue.clear();
|
||||
if(Net.active()){
|
||||
NetEvents.handleUnitDeath(this);
|
||||
@ -122,14 +127,13 @@ public class Player extends Unit implements BlockBuilder {
|
||||
float flammability = (inventory.hasItem() ? inventory.getItem().item.flammability * inventory.getItem().amount : 0f);
|
||||
DamageArea.dynamicExplosion(x, y, flammability, explosiveness, 0f, getSize()/2f, Palette.darkFlame);
|
||||
Effects.sound("die", this);
|
||||
|
||||
respawntime = respawnduration;
|
||||
super.onDeath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteDeath(){
|
||||
dead = true;
|
||||
respawning = true;
|
||||
Effects.effect(ExplosionFx.explosion, this);
|
||||
Effects.shake(4f, 5f, this);
|
||||
Effects.sound("die", this);
|
||||
@ -296,19 +300,14 @@ public class Player extends Unit implements BlockBuilder {
|
||||
return;
|
||||
}
|
||||
|
||||
if(respawntime > 0){
|
||||
if(isDead()){
|
||||
CoreEntity entity = (CoreEntity)getClosestCore();
|
||||
|
||||
respawntime -= Timers.delta();
|
||||
|
||||
if(respawntime <= 0){
|
||||
set(world.getSpawnX(), world.getSpawnY());
|
||||
heal();
|
||||
add();
|
||||
Effects.sound("respawn");
|
||||
}
|
||||
}
|
||||
|
||||
if(isDead()) return;
|
||||
if(!respawning && entity != null && entity.trySetPlayer(this)){
|
||||
respawning = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(mech.flying){
|
||||
updateFlying();
|
||||
@ -328,7 +327,6 @@ public class Player extends Unit implements BlockBuilder {
|
||||
public void reset(){
|
||||
weapon = Weapons.blaster;
|
||||
team = Team.blue;
|
||||
respawntime = -1;
|
||||
inventory.clear();
|
||||
upgrades.clear();
|
||||
placeQueue.clear();
|
||||
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
@ -19,6 +20,24 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class Units {
|
||||
private static Rectangle rect = new Rectangle();
|
||||
|
||||
/**Returns whether there are any entities on this tile.*/
|
||||
public static boolean anyEntities(Tile tile){
|
||||
Block type = tile.block();
|
||||
rect.setSize(type.size * tilesize, type.size * tilesize);
|
||||
rect.setCenter(tile.drawx(), tile.drawy());
|
||||
|
||||
boolean[] value = new boolean[1];
|
||||
|
||||
Units.getNearby(rect, unit -> {
|
||||
if(value[0]) return;
|
||||
if(unit.hitbox.getRect(unit.x, unit.y).overlaps(rect)){
|
||||
value[0] = true;
|
||||
}
|
||||
});
|
||||
|
||||
return value[0];
|
||||
}
|
||||
|
||||
/**Returns the neareset ally tile in a range.*/
|
||||
public static TileEntity findAllyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
||||
return findTile(x, y, range, tile -> !state.teams.areEnemies(team, tile.getTeam()) && pred.test(tile));
|
||||
@ -130,7 +149,7 @@ public class Units {
|
||||
Entities.getNearby(group, rect, entity -> cons.accept((Unit)entity));
|
||||
}
|
||||
|
||||
//now check all enemy players
|
||||
//now check all ally players
|
||||
Entities.getNearby(playerGroup, rect, player -> {
|
||||
if(((Unit)player).team == team) cons.accept((Unit)player);
|
||||
});
|
||||
|
@ -163,19 +163,6 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
graphics.sliderPref("previewopacity", 50, 0, 100, i -> i + "%");
|
||||
graphics.checkPref("indicators", true);
|
||||
graphics.checkPref("healthbars", true);
|
||||
graphics.checkPref("pixelate", true, b -> {
|
||||
if(b){
|
||||
renderer.pixelSurface.setScale(Core.cameraScale);
|
||||
renderer.effectSurface.setScale(Core.cameraScale);
|
||||
//Graphics.getEffects1().setScale(Core.cameraScale);
|
||||
//Graphics.getEffects2().setScale(Core.cameraScale);
|
||||
}else{
|
||||
renderer.effectSurface.setScale(1);
|
||||
//Graphics.getEffects1().setScale(1);
|
||||
//Graphics.getEffects2().setScale(1);
|
||||
}
|
||||
renderer.setPixelate(b);
|
||||
});
|
||||
}
|
||||
|
||||
private void back(){
|
||||
|
@ -1,11 +1,10 @@
|
||||
package io.anuke.mindustry.world.blocks.types.defense;
|
||||
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import io.anuke.mindustry.content.fx.BlockFx;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.content.fx.BlockFx;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.Wall;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
@ -16,8 +15,6 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class Door extends Wall{
|
||||
protected final Rectangle rect = new Rectangle();
|
||||
|
||||
@ -56,7 +53,7 @@ public class Door extends Wall{
|
||||
public boolean tapped(Tile tile, Player player){
|
||||
DoorEntity entity = tile.entity();
|
||||
|
||||
if(anyEntities(tile) && entity.open){
|
||||
if(Units.anyEntities(tile) && entity.open){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -70,23 +67,6 @@ public class Door extends Wall{
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean anyEntities(Tile tile){
|
||||
Block type = tile.block();
|
||||
rect.setSize(type.size * tilesize, type.size * tilesize);
|
||||
rect.setCenter(tile.drawx(), tile.drawy());
|
||||
|
||||
boolean[] value = new boolean[1];
|
||||
|
||||
Units.getNearby(rect, unit -> {
|
||||
if(value[0]) return;
|
||||
if(unit.hitbox.getRect(unit.x, unit.y).overlaps(rect)){
|
||||
value[0] = true;
|
||||
}
|
||||
});
|
||||
|
||||
return value[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
return new DoorEntity();
|
||||
|
@ -1,18 +1,24 @@
|
||||
package io.anuke.mindustry.world.blocks.types.storage;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import io.anuke.mindustry.entities.ItemTransfer;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Shaders;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemType;
|
||||
import io.anuke.mindustry.world.BlockFlag;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.EnumSet;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
|
||||
@ -27,7 +33,8 @@ public class CoreBlock extends StorageBlock {
|
||||
public CoreBlock(String name) {
|
||||
super(name);
|
||||
|
||||
solid = true;
|
||||
solid = false;
|
||||
solidifes = true;
|
||||
update = true;
|
||||
unbreakable = true;
|
||||
size = 3;
|
||||
@ -36,6 +43,52 @@ public class CoreBlock extends StorageBlock {
|
||||
flags = EnumSet.of(BlockFlag.resupplyPoint, BlockFlag.target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile) {
|
||||
CoreEntity entity = tile.entity();
|
||||
|
||||
Draw.rect(entity.solid ? name : name + "-open", tile.drawx(), tile.drawy());
|
||||
|
||||
Draw.alpha(entity.heat);
|
||||
Draw.rect(name + "-top", tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
|
||||
if(entity.currentPlayer != null) {
|
||||
Player player = entity.currentPlayer;
|
||||
|
||||
TextureRegion region = Draw.region(player.mech.name);
|
||||
|
||||
Shaders.build.region = region;
|
||||
Shaders.build.progress = entity.progress;
|
||||
Shaders.build.color.set(Palette.accent);
|
||||
Shaders.build.time = -entity.time / 10f;
|
||||
|
||||
Graphics.shader(Shaders.build, false);
|
||||
Shaders.build.apply();
|
||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||
Graphics.shader();
|
||||
|
||||
Draw.color(Palette.accent);
|
||||
|
||||
Lines.lineAngleCenter(
|
||||
tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 3f * size),
|
||||
tile.drawy(),
|
||||
90,
|
||||
size * Vars.tilesize /2f);
|
||||
|
||||
Draw.reset();
|
||||
|
||||
//Draw.rect(name + (!entity.solid ? "-top-open" : "-top"), tile.drawx(), tile.drawy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolidFor(Tile tile) {
|
||||
CoreEntity entity = tile.entity();
|
||||
|
||||
return entity.solid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unit source){
|
||||
if(acceptItem(item, tile, tile) && hasItems && source.team == tile.getTeam()){
|
||||
@ -74,12 +127,36 @@ public class CoreBlock extends StorageBlock {
|
||||
|
||||
@Override
|
||||
public void update(Tile tile) {
|
||||
CoreEntity entity = tile.entity();
|
||||
|
||||
if(tile.entity.timer.get(timerSupply, supplyInterval)){
|
||||
if(!entity.solid && !Units.anyEntities(tile)){
|
||||
entity.solid = true;
|
||||
}
|
||||
|
||||
if(entity.currentPlayer != null){
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f);
|
||||
entity.time += Timers.delta();
|
||||
entity.progress += 1f / Vars.respawnduration;
|
||||
|
||||
if(entity.progress >= 1f){
|
||||
Effects.effect(Fx.spawn, entity);
|
||||
entity.progress = 0;
|
||||
entity.solid = false;
|
||||
entity.currentPlayer.heal();
|
||||
entity.currentPlayer.rotation = 90f;
|
||||
entity.currentPlayer.baseRotation = 90f;
|
||||
entity.currentPlayer.set(tile.drawx(), tile.drawy()).add();
|
||||
entity.currentPlayer = null;
|
||||
}
|
||||
}else{
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.1f);
|
||||
}
|
||||
|
||||
if(entity.solid && tile.entity.timer.get(timerSupply, supplyInterval)){
|
||||
rect.setSize(supplyRadius*2).setCenter(tile.drawx(), tile.drawy());
|
||||
|
||||
Units.getNearby(tile.getTeam(), rect, unit -> {
|
||||
if(unit.distanceTo(tile.drawx(), tile.drawy()) > supplyRadius) return;
|
||||
if(unit.isDead() || unit.distanceTo(tile.drawx(), tile.drawy()) > supplyRadius) return;
|
||||
|
||||
for(int i = 0; i < tile.entity.items.items.length; i ++){
|
||||
Item item = Item.getByID(i);
|
||||
@ -93,4 +170,25 @@ public class CoreBlock extends StorageBlock {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity() {
|
||||
return new CoreEntity();
|
||||
}
|
||||
|
||||
public class CoreEntity extends TileEntity{
|
||||
Player currentPlayer;
|
||||
boolean solid = true;
|
||||
float progress;
|
||||
float time;
|
||||
float heat;
|
||||
|
||||
public boolean trySetPlayer(Player player){
|
||||
if(currentPlayer != null) return false;
|
||||
player.set(tile.drawx(), tile.drawy());
|
||||
currentPlayer = player;
|
||||
progress = 0f;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.anuke.mindustry.world.blocks.types.units;
|
||||
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import io.anuke.mindustry.Vars;
|
||||
@ -149,8 +148,6 @@ public class UnitFactory extends Block {
|
||||
|
||||
entity.openCountdown = openDuration;
|
||||
|
||||
//Timers.run(openDuration, () -> entity.open = false);
|
||||
|
||||
for(ItemStack stack : requirements){
|
||||
entity.items.removeItem(stack.item, stack.amount);
|
||||
}
|
||||
|
Reference in New Issue
Block a user