Rudimentary rendering
@ -275,7 +275,7 @@ public class EntityProcess extends BaseProcessor{
|
||||
groupsBuilder.addField(ParameterizedTypeName.get(
|
||||
ClassName.bestGuess("mindustry.entities.EntityGroup"), itype), group.name, Modifier.PUBLIC, Modifier.STATIC);
|
||||
|
||||
groupInit.addStatement("$L = new $T<>($L, $L)", group.name, groupc, group.def.spatial(), group.def.mapping());
|
||||
groupInit.addStatement("$L = new $T<>($L.class, $L, $L)", group.name, groupc, itype, group.def.spatial(), group.def.mapping());
|
||||
}
|
||||
|
||||
//write the groups
|
||||
|
@ -218,3 +218,5 @@
|
||||
63526=oil|liquid-oil-icon
|
||||
63525=cryofluid|liquid-cryofluid-icon
|
||||
63524=underflow-gate|block-underflow-gate-medium
|
||||
63523=dart-ship-pad|block-dart-ship-pad-medium
|
||||
63522=alpha-mech-pad|block-alpha-mech-pad-medium
|
||||
|
Before Width: | Height: | Size: 751 B After Width: | Height: | Size: 768 B |
Before Width: | Height: | Size: 723 KiB After Width: | Height: | Size: 694 KiB |
Before Width: | Height: | Size: 900 KiB After Width: | Height: | Size: 262 KiB |
Before Width: | Height: | Size: 262 KiB After Width: | Height: | Size: 900 KiB |
@ -172,8 +172,8 @@ public class Call {
|
||||
|
||||
public static synchronized void onClientShapshot(int snapshotID, float x, float y, float pointerX,
|
||||
float pointerY, float rotation, float baseRotation, float xVelocity, float yVelocity,
|
||||
Tile mining, boolean boosting, boolean shooting, boolean chatting, boolean building,
|
||||
BuildRequest[] requests, float viewX, float viewY, float viewWidth, float viewHeight) {
|
||||
Tile mining, boolean boosting, boolean shooting, boolean chatting, BuildRequest[] requests,
|
||||
float viewX, float viewY, float viewWidth, float viewHeight) {
|
||||
if(mindustry.Vars.net.client()) {
|
||||
mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new);
|
||||
packet.writeBuffer = TEMP_BUFFER;
|
||||
@ -193,7 +193,6 @@ public class Call {
|
||||
TEMP_BUFFER.put(boosting ? (byte)1 : 0);
|
||||
TEMP_BUFFER.put(shooting ? (byte)1 : 0);
|
||||
TEMP_BUFFER.put(chatting ? (byte)1 : 0);
|
||||
TEMP_BUFFER.put(building ? (byte)1 : 0);
|
||||
mindustry.io.TypeIO.writeRequests(TEMP_BUFFER, requests);
|
||||
TEMP_BUFFER.putFloat(viewX);
|
||||
TEMP_BUFFER.putFloat(viewY);
|
||||
|
@ -188,6 +188,7 @@ public class Vars implements Loadable{
|
||||
|
||||
public static void init(){
|
||||
Serialization.init();
|
||||
Groups.init();
|
||||
DefaultSerializers.typeMappings.put("mindustry.type.ContentType", "mindustry.ctype.ContentType");
|
||||
|
||||
if(loadLocales){
|
||||
|
@ -201,7 +201,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
}
|
||||
|
||||
void createPlayer(){
|
||||
//player = new Playerc();
|
||||
player = PlayerEntity.create();
|
||||
player.name(Core.settings.getString("name"));
|
||||
player.color().set(Core.settings.getInt("color-0"));
|
||||
|
||||
@ -244,28 +244,6 @@ public class Control implements ApplicationListener, Loadable{
|
||||
});
|
||||
}
|
||||
|
||||
//TODO remove, make it viable on a server
|
||||
/*public void playZone(Zone zone){
|
||||
|
||||
ui.loadAnd(() -> {
|
||||
logic.reset();
|
||||
net.reset();
|
||||
world.loadGenerator(zone.generator);
|
||||
zone.rules.get(state.rules);
|
||||
state.rules.zone = zone;
|
||||
for(Tilec core : state.teams.playerCores()){
|
||||
for(ItemStack stack : zone.getStartingItems()){
|
||||
core.items().add(stack.item, stack.amount);
|
||||
}
|
||||
}
|
||||
state.set(State.playing);
|
||||
state.wavetime = state.rules.waveSpacing;
|
||||
control.saves.zoneSave();
|
||||
logic.play();
|
||||
Events.fire(Trigger.newGame);
|
||||
});
|
||||
}*/
|
||||
|
||||
public void playSector(Sector sector){
|
||||
ui.loadAnd(() -> {
|
||||
logic.reset();
|
||||
|
@ -122,8 +122,7 @@ public class NetClient implements ApplicationListener{
|
||||
|
||||
net.handleClient(InvokePacket.class, packet -> {
|
||||
packet.writeBuffer.position(0);
|
||||
//TODO fix remote read client
|
||||
// RemoteReadClient.readPacket(packet.writeBuffer, packet.type);
|
||||
RemoteReadClient.readPacket(packet.writeBuffer, packet.type);
|
||||
});
|
||||
}
|
||||
|
||||
@ -176,8 +175,7 @@ public class NetClient implements ApplicationListener{
|
||||
|
||||
//invoke event for all clients but also locally
|
||||
//this is required so other clients get the correct name even if they don't know who's sending it yet
|
||||
//TODO uncomment when it works
|
||||
//Call.sendMessage(message, colorizeName(player.id(), player.name()), player);
|
||||
Call.sendMessage(message, colorizeName(player.id(), player.name()), player);
|
||||
}else{
|
||||
//log command to console but with brackets
|
||||
Log.info("<&y{0}: &lm{1}&lg>", player.name(), message);
|
||||
|
@ -188,8 +188,7 @@ public class NetServer implements ApplicationListener{
|
||||
con.modclient = true;
|
||||
}
|
||||
|
||||
//TODO place instance of player here
|
||||
Playerc player = null;//new Playerc();
|
||||
Playerc player = PlayerEntity.create();
|
||||
player.admin(admins.isAdmin(uuid, packet.usid));
|
||||
player.con(con);
|
||||
player.con().usid = packet.usid;
|
||||
@ -222,8 +221,7 @@ public class NetServer implements ApplicationListener{
|
||||
net.handleServer(InvokePacket.class, (con, packet) -> {
|
||||
if(con.player == null) return;
|
||||
try{
|
||||
//TODO uncomment when compilation works
|
||||
//RemoteReadServer.readPacket(packet.writeBuffer, packet.type, con.player);
|
||||
RemoteReadServer.readPacket(packet.writeBuffer, packet.type, con.player);
|
||||
}catch(ValidateException e){
|
||||
Log.debug("Validation failed for '{0}': {1}", e.player, e.getMessage());
|
||||
}catch(RuntimeException e){
|
||||
@ -483,7 +481,7 @@ public class NetServer implements ApplicationListener{
|
||||
float rotation, float baseRotation,
|
||||
float xVelocity, float yVelocity,
|
||||
Tile mining,
|
||||
boolean boosting, boolean shooting, boolean chatting, boolean building,
|
||||
boolean boosting, boolean shooting, boolean chatting,
|
||||
BuildRequest[] requests,
|
||||
float viewX, float viewY, float viewWidth, float viewHeight
|
||||
){
|
||||
@ -603,8 +601,7 @@ public class NetServer implements ApplicationListener{
|
||||
}else if(action == AdminAction.trace){
|
||||
TraceInfo info = new TraceInfo(other.con().address, other.uuid(), other.con().modclient, other.con().mobile);
|
||||
if(player.con() != null){
|
||||
//TODO uncomment
|
||||
//Call.onTraceInfo(player.con(), other, info);
|
||||
Call.onTraceInfo(player.con(), other, info);
|
||||
}else{
|
||||
NetClient.onTraceInfo(other, info);
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
@ -23,7 +25,7 @@ public class Renderer implements ApplicationListener{
|
||||
public final LightRenderer lights = new LightRenderer();
|
||||
public final Pixelator pixelator = new Pixelator();
|
||||
|
||||
public FrameBuffer shieldBuffer = new FrameBuffer(2, 2);
|
||||
public FrameBuffer effectBuffer = new FrameBuffer(2, 2);
|
||||
private Bloom bloom;
|
||||
private Color clearColor;
|
||||
private float targetscale = Scl.scl(4);
|
||||
@ -104,7 +106,7 @@ public class Renderer implements ApplicationListener{
|
||||
@Override
|
||||
public void dispose(){
|
||||
minimap.dispose();
|
||||
shieldBuffer.dispose();
|
||||
effectBuffer.dispose();
|
||||
blocks.dispose();
|
||||
if(bloom != null){
|
||||
bloom.dispose();
|
||||
@ -169,7 +171,115 @@ public class Renderer implements ApplicationListener{
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
//TODO do it
|
||||
camera.update();
|
||||
|
||||
if(Float.isNaN(camera.position.x) || Float.isNaN(camera.position.y)){
|
||||
camera.position.set(player);
|
||||
}
|
||||
|
||||
graphics.clear(clearColor);
|
||||
|
||||
if(!graphics.isHidden() && (Core.settings.getBool("animatedwater") || Core.settings.getBool("animatedshields")) && (effectBuffer.getWidth() != graphics.getWidth() || effectBuffer.getHeight() != graphics.getHeight())){
|
||||
effectBuffer.resize(graphics.getWidth(), graphics.getHeight());
|
||||
}
|
||||
|
||||
Draw.proj(camera.projection());
|
||||
|
||||
blocks.floor.drawFloor();
|
||||
|
||||
render(RenderLayer.floor);
|
||||
|
||||
blocks.processBlocks();
|
||||
blocks.drawShadows();
|
||||
Draw.color();
|
||||
|
||||
blocks.floor.beginDraw();
|
||||
blocks.floor.drawLayer(CacheLayer.walls);
|
||||
blocks.floor.endDraw();
|
||||
|
||||
blocks.drawBlocks(Layer.block);
|
||||
blocks.drawFog();
|
||||
|
||||
blocks.drawDestroyed();
|
||||
|
||||
Draw.shader(Shaders.blockbuild, true);
|
||||
blocks.drawBlocks(Layer.placement);
|
||||
Draw.shader();
|
||||
|
||||
blocks.drawBlocks(Layer.overlay);
|
||||
|
||||
render(RenderLayer.groundShadows);
|
||||
render(RenderLayer.ground);
|
||||
|
||||
blocks.drawBlocks(Layer.turret);
|
||||
|
||||
render(RenderLayer.flyingShadows);
|
||||
|
||||
blocks.drawBlocks(Layer.power);
|
||||
blocks.drawBlocks(Layer.lights);
|
||||
|
||||
render(RenderLayer.flying);
|
||||
|
||||
Draw.flush();
|
||||
if(bloom != null && !pixelator.enabled()){
|
||||
bloom.capture();
|
||||
}
|
||||
|
||||
render(RenderLayer.bullets);
|
||||
render(RenderLayer.effects);
|
||||
|
||||
Draw.flush();
|
||||
if(bloom != null && !pixelator.enabled()){
|
||||
bloom.render();
|
||||
}
|
||||
|
||||
overlays.drawBottom();
|
||||
if(player.isBuilder()){
|
||||
player.builder().drawBuildRequests();
|
||||
}
|
||||
|
||||
overlays.drawTop();
|
||||
|
||||
//TODO should use (draw)
|
||||
Groups.player.each(p -> !p.dead(), Playerc::drawName);
|
||||
|
||||
if(state.rules.lighting){
|
||||
lights.draw();
|
||||
}
|
||||
|
||||
drawLanding();
|
||||
|
||||
Draw.color();
|
||||
Draw.flush();
|
||||
}
|
||||
|
||||
private void render(RenderLayer layer){
|
||||
|
||||
}
|
||||
|
||||
private void drawLanding(){
|
||||
if(landTime > 0 && player.closestCore() != null){
|
||||
float fract = landTime / Fx.coreLand.lifetime;
|
||||
Tilec entity = player.closestCore();
|
||||
|
||||
TextureRegion reg = entity.block().icon(Cicon.full);
|
||||
float scl = Scl.scl(4f) / camerascale;
|
||||
float s = reg.getWidth() * Draw.scl * scl * 4f * fract;
|
||||
|
||||
Draw.color(Pal.lightTrail);
|
||||
Draw.rect("circle-shadow", entity.getX(), entity.getY(), s, s);
|
||||
|
||||
Angles.randLenVectors(1, (1f- fract), 100, 1000f * scl * (1f-fract), (x, y, fin, fout) -> {
|
||||
Lines.stroke(scl * fin);
|
||||
Lines.lineAngle(entity.getX() + x, entity.getY() + y, Mathf.angle(x, y), (fin * 20 + 1f) * scl);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
Draw.mixcol(Color.white, fract);
|
||||
Draw.rect(reg, entity.getX(), entity.getY(), reg.getWidth() * Draw.scl * scl, reg.getHeight() * Draw.scl * scl, fract * 135f);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
/*
|
||||
public void draw(){
|
||||
@ -182,8 +292,8 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
graphics.clear(clearColor);
|
||||
|
||||
if(!graphics.isHidden() && (Core.settings.getBool("animatedwater") || Core.settings.getBool("animatedshields")) && (shieldBuffer.getWidth() != graphics.getWidth() || shieldBuffer.getHeight() != graphics.getHeight())){
|
||||
shieldBuffer.resize(graphics.getWidth(), graphics.getHeight());
|
||||
if(!graphics.isHidden() && (Core.settings.getBool("animatedwater") || Core.settings.getBool("animatedshields")) && (effectBuffer.getWidth() != graphics.getWidth() || effectBuffer.getHeight() != graphics.getHeight())){
|
||||
effectBuffer.resize(graphics.getWidth(), graphics.getHeight());
|
||||
}
|
||||
|
||||
Draw.proj(camera.projection());
|
||||
@ -246,15 +356,15 @@ public class Renderer implements ApplicationListener{
|
||||
if(shieldGroup.countInBounds() > 0){
|
||||
if(settings.getBool("animatedshields") && Shaders.shield != null){
|
||||
Draw.flush();
|
||||
shieldBuffer.begin();
|
||||
effectBuffer.begin();
|
||||
graphics.clear(Color.clear);
|
||||
shieldGroup.draw();
|
||||
shieldGroup.draw(shield -> true, ShieldEntity::drawOver);
|
||||
Draw.flush();
|
||||
shieldBuffer.end();
|
||||
effectBuffer.end();
|
||||
Draw.shader(Shaders.shield);
|
||||
Draw.color(Pal.accent);
|
||||
Draw.rect(Draw.wrap(shieldBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
|
||||
Draw.rect(Draw.wrap(effectBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
|
||||
Draw.color();
|
||||
Draw.shader();
|
||||
}else{
|
||||
|
@ -138,8 +138,7 @@ public class EditorTile extends Tile{
|
||||
Block block = block();
|
||||
|
||||
if(block.hasEntity()){
|
||||
//TODO uncomment once this mess is figure out
|
||||
//entity = block.newEntity().init(this, false);
|
||||
entity = block.newEntity().init(this, false);
|
||||
entity.cons(new ConsumeModule(entity));
|
||||
if(block.hasItems) entity.items(new ItemModule());
|
||||
if(block.hasLiquids) entity.liquids(new LiquidModule());
|
||||
|
@ -12,6 +12,7 @@ import mindustry.content.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@ -29,8 +30,7 @@ public class Damage{
|
||||
public static void dynamicExplosion(float x, float y, float flammability, float explosiveness, float power, float radius, Color color){
|
||||
for(int i = 0; i < Mathf.clamp(power / 20, 0, 6); i++){
|
||||
int branches = 5 + Mathf.clamp((int)(power / 30), 1, 20);
|
||||
//TODO uncomment
|
||||
//Time.run(i * 2f + Mathf.random(4f), () -> Lightning.create(Team.derelict, Pal.power, 3, x, y, Mathf.random(360f), branches + Mathf.range(2)));
|
||||
Time.run(i * 2f + Mathf.random(4f), () -> Lightning.create(Team.derelict, Pal.power, 3, x, y, Mathf.random(360f), branches + Mathf.range(2)));
|
||||
}
|
||||
|
||||
for(int i = 0; i < Mathf.clamp(flammability / 4, 0, 30); i++){
|
||||
|
@ -12,7 +12,7 @@ import static mindustry.Vars.*;
|
||||
/** Represents a group of a certain type of entity.*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class EntityGroup<T extends Entityc> implements Iterable<T>{
|
||||
private final Array<T> array = new Array<>(false, 32);
|
||||
private final Array<T> array;
|
||||
private final Array<T> intersectArray = new Array<>();
|
||||
private final Rect intersectRect = new Rect();
|
||||
private IntMap<T> map;
|
||||
@ -21,7 +21,9 @@ public class EntityGroup<T extends Entityc> implements Iterable<T>{
|
||||
|
||||
private int index;
|
||||
|
||||
public EntityGroup(boolean spatial, boolean mapping){
|
||||
public EntityGroup(Class<T> type, boolean spatial, boolean mapping){
|
||||
array = new Array<>(false, 32, type);
|
||||
|
||||
if(spatial){
|
||||
tree = new QuadTree<>(new Rect(0, 0, 0, 0));
|
||||
}
|
||||
|
@ -708,8 +708,10 @@ public class EntityComps{
|
||||
admin = typing = false;
|
||||
lastText = null;
|
||||
textFadeTime = 0f;
|
||||
unit.controller(unit.type().createController());
|
||||
unit = null;
|
||||
if(!dead()){
|
||||
unit.controller(unit.type().createController());
|
||||
unit = Nulls.unit;
|
||||
}
|
||||
}
|
||||
|
||||
public void update(){
|
||||
@ -757,7 +759,7 @@ public class EntityComps{
|
||||
}
|
||||
|
||||
boolean dead(){
|
||||
return unit == Nulls.builder;
|
||||
return unit.isNull();
|
||||
}
|
||||
|
||||
String uuid(){
|
||||
|
@ -57,7 +57,7 @@ public enum CacheLayer{
|
||||
if(!Core.settings.getBool("animatedwater")) return;
|
||||
|
||||
renderer.blocks.floor.endc();
|
||||
renderer.shieldBuffer.begin();
|
||||
renderer.effectBuffer.begin();
|
||||
Core.graphics.clear(Color.clear);
|
||||
renderer.blocks.floor.beginc();
|
||||
}
|
||||
@ -66,10 +66,10 @@ public enum CacheLayer{
|
||||
if(!Core.settings.getBool("animatedwater")) return;
|
||||
|
||||
renderer.blocks.floor.endc();
|
||||
renderer.shieldBuffer.end();
|
||||
renderer.effectBuffer.end();
|
||||
|
||||
Draw.shader(shader);
|
||||
Draw.rect(Draw.wrap(renderer.shieldBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
|
||||
Draw.rect(Draw.wrap(renderer.effectBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
|
||||
Draw.shader();
|
||||
|
||||
renderer.blocks.floor.beginc();
|
||||
|
@ -247,6 +247,8 @@ public class MenuRenderer implements Disposable{
|
||||
}
|
||||
|
||||
private void drawFlyers(){
|
||||
//TODO fix
|
||||
if(true) return;
|
||||
Draw.color(0f, 0f, 0f, 0.4f);
|
||||
|
||||
TextureRegion icon = flyerType.icon(Cicon.full);
|
||||
|
11
core/src/mindustry/graphics/RenderLayer.java
Normal file
@ -0,0 +1,11 @@
|
||||
package mindustry.graphics;
|
||||
|
||||
public enum RenderLayer{
|
||||
floor,
|
||||
groundShadows,
|
||||
ground,
|
||||
flyingShadows,
|
||||
flying,
|
||||
bullets,
|
||||
effects
|
||||
}
|
@ -74,7 +74,10 @@ public class Fonts{
|
||||
int ch = Integer.parseInt(character);
|
||||
TextureRegion region = Core.atlas.find(texture);
|
||||
|
||||
if(region.getTexture() != uitex) throw new IllegalArgumentException("Font icon '" + texture + "' is not in the UI texture.");
|
||||
if(region.getTexture() != uitex){
|
||||
continue;
|
||||
//throw new IllegalArgumentException("Font icon '" + texture + "' is not in the UI texture.");
|
||||
}
|
||||
|
||||
unicodeIcons.put(nametex[0], ch);
|
||||
|
||||
|
@ -457,7 +457,6 @@ public class Tile implements Position{
|
||||
Block block = block();
|
||||
|
||||
if(block.hasEntity()){
|
||||
//TODO assign data and don't use new entity
|
||||
entity = block.newEntity().init(this, block.update);
|
||||
entity.cons(new ConsumeModule(entity));
|
||||
if(block.hasItems) entity.items(new ItemModule());
|
||||
|
@ -184,34 +184,10 @@ public class Generators{
|
||||
}
|
||||
});
|
||||
|
||||
ImagePacker.generate("mech-icons", () -> {
|
||||
for(Mech mech : content.<Mech>getBy(ContentType.mech)){
|
||||
mech.load();
|
||||
mech.weapon.load();
|
||||
|
||||
Image image = ImagePacker.get(mech.region);
|
||||
|
||||
if(!mech.flying){
|
||||
image.drawCenter(mech.baseRegion);
|
||||
image.drawCenter(mech.legRegion);
|
||||
image.drawCenter(mech.legRegion, true, false);
|
||||
image.drawCenter(mech.region);
|
||||
}
|
||||
|
||||
int off = image.width / 2 - mech.weapon.region.getWidth() / 2;
|
||||
|
||||
for(int i : Mathf.signs){
|
||||
image.draw(mech.weapon.region, i * (int)mech.weaponOffsetX*4 + off, -(int)mech.weaponOffsetY*4 + off, i > 0, false);
|
||||
}
|
||||
|
||||
image.save("mech-" + mech.name + "-full");
|
||||
}
|
||||
});
|
||||
|
||||
ImagePacker.generate("unit-icons", () -> {
|
||||
content.<UnitType>getBy(ContentType.unit).each(type -> !type.flying, type -> {
|
||||
content.units().each(type -> !type.flying, type -> {
|
||||
type.load();
|
||||
type.weapon.load();
|
||||
type.weapons.each(Weapon::load);
|
||||
|
||||
Image image = ImagePacker.get(type.region);
|
||||
|
||||
@ -220,12 +196,14 @@ public class Generators{
|
||||
image.draw(type.legRegion, true, false);
|
||||
image.draw(type.region);
|
||||
|
||||
//TODO draw weapons with proper offsets
|
||||
/*
|
||||
for(boolean b : Mathf.booleans){
|
||||
image.draw(type.weapon.region,
|
||||
(int)(Mathf.sign(b) * type.weapon.width / Draw.scl + image.width / 2 - type.weapon.region.getWidth() / 2),
|
||||
(int)(type.weaponOffsetY / Draw.scl + image.height / 2f - type.weapon.region.getHeight() / 2f),
|
||||
b, false);
|
||||
}
|
||||
}*/
|
||||
|
||||
image.save("unit-" + type.name + "-full");
|
||||
});
|
||||
|