Bugfixes / Sprite update / Multiplayer in-game editor / Drone tweaks

This commit is contained in:
Anuken
2019-06-17 21:35:19 -04:00
parent bc3405d11d
commit 185a7bb7d8
49 changed files with 4906 additions and 4819 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 920 B

After

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 606 B

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 475 B

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 850 B

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 877 B

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 B

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 B

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -35,7 +35,6 @@ level.mode = Gamemode:
showagain = Don't show again next session showagain = Don't show again next session
coreattack = < Core is under attack! > coreattack = < Core is under attack! >
nearpoint = [[ [scarlet]LEAVE DROP POINT IMMEDIATELY[] ]\nannihilation imminent nearpoint = [[ [scarlet]LEAVE DROP POINT IMMEDIATELY[] ]\nannihilation imminent
outofbounds = [[ OUT OF BOUNDS ]\n[]self-destruct in {0}
database = Core Database database = Core Database
savegame = Save Game savegame = Save Game
loadgame = Load Game loadgame = Load Game
@@ -790,9 +789,9 @@ block.blast-mixer.name = Blast Mixer
block.solar-panel.name = Solar Panel block.solar-panel.name = Solar Panel
block.solar-panel-large.name = Large Solar Panel block.solar-panel-large.name = Large Solar Panel
block.oil-extractor.name = Oil Extractor block.oil-extractor.name = Oil Extractor
block.draug-factory.name = Draug Miner Factory block.draug-factory.name = Draug Miner Drone Factory
block.spirit-factory.name = Spirit Drone Factory block.spirit-factory.name = Spirit Repair Drone Factory
block.phantom-factory.name = Phantom Drone Factory block.phantom-factory.name = Phantom Builder Drone Factory
block.wraith-factory.name = Wraith Fighter Factory block.wraith-factory.name = Wraith Fighter Factory
block.ghoul-factory.name = Ghoul Bomber Factory block.ghoul-factory.name = Ghoul Bomber Factory
block.dagger-factory.name = Dagger Mech Factory block.dagger-factory.name = Dagger Mech Factory
@@ -837,10 +836,10 @@ team.orange.name = orange
team.none.name = gray team.none.name = gray
team.green.name = green team.green.name = green
team.purple.name = purple team.purple.name = purple
unit.spirit.name = Spirit Drone unit.spirit.name = Spirit Repair Drone
unit.spirit.description = The starter drone unit. Spawns in the core by default. Automatically mines ores and repairs blocks. unit.spirit.description = Automatically repairs blocks.
unit.phantom.name = Phantom Drone unit.phantom.name = Phantom Builder Drone
unit.phantom.description = An advanced drone unit. Automatically mines ores and repairs blocks. Significantly more effective than a spirit drone. unit.phantom.description = An advanced drone unit. Helps players build blocks
unit.dagger.name = Dagger unit.dagger.name = Dagger
unit.dagger.description = A basic ground unit. Useful in swarms. unit.dagger.description = A basic ground unit. Useful in swarms.
unit.crawler.name = Crawler unit.crawler.name = Crawler

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 709 B

After

Width:  |  Height:  |  Size: 709 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 276 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 402 KiB

After

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 KiB

After

Width:  |  Height:  |  Size: 295 KiB

View File

@@ -424,8 +424,8 @@ public class Blocks implements ContentList{
hasLiquids = true; hasLiquids = true;
hasPower = true; hasPower = true;
consumes.power(2f); consumes.power(1.8f);
consumes.item(Items.coal, 4); consumes.item(Items.coal, 3);
consumes.liquid(Liquids.water, 0.1f); consumes.liquid(Liquids.water, 0.1f);
}}; }};

View File

@@ -197,7 +197,14 @@ public class Logic implements ApplicationListener{
Entities.update(bulletGroup); Entities.update(bulletGroup);
Entities.update(tileGroup); Entities.update(tileGroup);
Entities.update(fireGroup); Entities.update(fireGroup);
}else{
for(EntityGroup group : unitGroups){
group.updateEvents();
collisions.updatePhysics(group);
}
} }
Entities.update(playerGroup); Entities.update(playerGroup);
//effect group only contains item transfers in the headless version, update it! //effect group only contains item transfers in the headless version, update it!

View File

@@ -17,6 +17,7 @@ import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
import io.anuke.mindustry.entities.traits.SyncTrait; import io.anuke.mindustry.entities.traits.SyncTrait;
import io.anuke.mindustry.entities.traits.TypeTrait; import io.anuke.mindustry.entities.traits.TypeTrait;
import io.anuke.mindustry.entities.type.Player; import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.entities.type.Unit;
import io.anuke.mindustry.game.Version; import io.anuke.mindustry.game.Version;
import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.gen.RemoteReadClient; import io.anuke.mindustry.gen.RemoteReadClient;
@@ -230,7 +231,7 @@ public class NetClient implements ApplicationListener{
byte typeID = input.readByte(); byte typeID = input.readByte();
SyncTrait entity = group == null ? null : (SyncTrait)group.getByID(id); SyncTrait entity = group == null ? null : (SyncTrait)group.getByID(id);
boolean add = false; boolean add = false, created = false;
if(entity == null && id == player.id){ if(entity == null && id == player.id){
entity = player; entity = player;
@@ -244,11 +245,20 @@ public class NetClient implements ApplicationListener{
if(!netClient.isEntityUsed(entity.getID())){ if(!netClient.isEntityUsed(entity.getID())){
add = true; add = true;
} }
created = true;
} }
//read the entity //read the entity
entity.read(input); entity.read(input);
if(created){
//set initial starting position
entity.setNet(entity.getInterpolator().target.x, entity.getInterpolator().target.y);
if(entity instanceof Unit && entity.getInterpolator().targets.length > 0){
((Unit)entity).rotation = entity.getInterpolator().targets[0];
}
}
if(add){ if(add){
entity.add(); entity.add();
netClient.addRemovedEntity(entity.getID()); netClient.addRemovedEntity(entity.getID());

View File

@@ -90,6 +90,14 @@ public class World implements ApplicationListener{
return tiles == null ? 0 : tiles[0].length; return tiles == null ? 0 : tiles[0].length;
} }
public int unitWidth(){
return width()*tilesize;
}
public int unitHeight(){
return height()*tilesize;
}
public @Nullable Tile tile(int pos){ public @Nullable Tile tile(int pos){
return tiles == null ? null : tile(Pos.x(pos), Pos.y(pos)); return tiles == null ? null : tile(Pos.x(pos), Pos.y(pos));
} }

View File

@@ -96,6 +96,7 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait{
} }
time = Mathf.clamp(time + Time.delta(), 0, lifetime()); time = Mathf.clamp(time + Time.delta(), 0, lifetime());
map.put(tile.pos(), this);
if(Net.client()){ if(Net.client()){
return; return;

View File

@@ -265,6 +265,15 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
} }
} }
//repel player out of bounds
final float warpDst = 230f;
if(x < 0) velocity.x += (-x/warpDst);
if(y < 0) velocity.y += (-y/warpDst);
if(x > world.unitWidth()) velocity.x -= (x - world.unitWidth())/warpDst;
if(y > world.unitHeight()) velocity.y -= (y - world.unitHeight())/warpDst;
if(isFlying()){ if(isFlying()){
drownTime = 0f; drownTime = 0f;
move(velocity.x * Time.delta(), velocity.y * Time.delta()); move(velocity.x * Time.delta(), velocity.y * Time.delta());

View File

@@ -150,7 +150,8 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{
} }
boolean isRebuild(){ boolean isRebuild(){
return Vars.state.rules.enemyCheat && team == waveTeam; //disabled until further notice, reason being that it's too annoying when playing enemies and too broken for ally use
return false; //Vars.state.rules.enemyCheat && team == waveTeam;
} }
@Override @Override

View File

@@ -14,7 +14,9 @@ public abstract class SaveFileReader{
protected final DataOutputStream dataBytes = new DataOutputStream(byteOutput); protected final DataOutputStream dataBytes = new DataOutputStream(byteOutput);
protected final ReusableByteOutStream byteOutputSmall = new ReusableByteOutStream(); protected final ReusableByteOutStream byteOutputSmall = new ReusableByteOutStream();
protected final DataOutputStream dataBytesSmall = new DataOutputStream(byteOutputSmall); protected final DataOutputStream dataBytesSmall = new DataOutputStream(byteOutputSmall);
protected final ObjectMap<String, String> fallback = ObjectMap.of(); protected final ObjectMap<String, String> fallback = ObjectMap.of(
);
protected void region(String name, DataInput stream, CounterInputStream counter, IORunner<DataInput> cons) throws IOException{ protected void region(String name, DataInput stream, CounterInputStream counter, IORunner<DataInput> cons) throws IOException{
counter.resetCount(); counter.resetCount();

View File

@@ -86,15 +86,15 @@ public class TypeIO{
@WriteClass(BaseUnit.class) @WriteClass(BaseUnit.class)
public static void writeBaseUnit(ByteBuffer buffer, BaseUnit unit){ public static void writeBaseUnit(ByteBuffer buffer, BaseUnit unit){
buffer.put((byte)unitGroups[unit.getTeam().ordinal()].getID()); buffer.put((byte)unit.getTeam().ordinal());
buffer.putInt(unit.getID()); buffer.putInt(unit.getID());
} }
@ReadClass(BaseUnit.class) @ReadClass(BaseUnit.class)
public static BaseUnit writeBaseUnit(ByteBuffer buffer){ public static BaseUnit readBaseUnit(ByteBuffer buffer){
byte gid = buffer.get(); byte tid = buffer.get();
int id = buffer.getInt(); int id = buffer.getInt();
return (BaseUnit)Entities.getGroup(gid).getByID(id); return unitGroups[tid].getByID(id);
} }
@WriteClass(Tile.class) @WriteClass(Tile.class)
@@ -193,6 +193,16 @@ public class TypeIO{
return Effects.getEffect(buffer.getShort()); return Effects.getEffect(buffer.getShort());
} }
@WriteClass(UnitType.class)
public static void writeUnitType(ByteBuffer buffer, UnitType effect){
buffer.putShort(effect.id);
}
@ReadClass(UnitType.class)
public static UnitType readUnitType(ByteBuffer buffer){
return content.getByID(ContentType.unit, buffer.getShort());
}
@WriteClass(Color.class) @WriteClass(Color.class)
public static void writeColor(ByteBuffer buffer, Color color){ public static void writeColor(ByteBuffer buffer, Color color){
buffer.putInt(Color.rgba8888(color)); buffer.putInt(Color.rgba8888(color));

View File

@@ -10,6 +10,7 @@ import static io.anuke.mindustry.Vars.*;
public class PausedDialog extends FloatingDialog{ public class PausedDialog extends FloatingDialog{
private SaveDialog save = new SaveDialog(); private SaveDialog save = new SaveDialog();
private LoadDialog load = new LoadDialog(); private LoadDialog load = new LoadDialog();
private boolean wasClient = false;
public PausedDialog(){ public PausedDialog(){
super("$menu"); super("$menu");
@@ -55,13 +56,12 @@ public class PausedDialog extends FloatingDialog{
cont.row(); cont.row();
if(!state.isEditor()){ cont.addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw * 2 + 20f);
cont.addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw * 2 + 20f); cont.row();
cont.row();
}
cont.addButton("$quit", () -> { cont.addButton("$quit", () -> {
ui.showConfirm("$confirm", "$quit.confirm", () -> { ui.showConfirm("$confirm", "$quit.confirm", () -> {
wasClient = Net.client();
if(Net.client()) netClient.disconnectQuietly(); if(Net.client()) netClient.disconnectQuietly();
runExitSave(); runExitSave();
hide(); hide();
@@ -85,11 +85,11 @@ public class PausedDialog extends FloatingDialog{
cont.row(); cont.row();
} }
if(!state.isEditor()){ cont.addRowImageTextButton("$hostserver.mobile", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
cont.addRowImageTextButton("$hostserver.mobile", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
}
cont.addRowImageTextButton("$quit", "icon-quit", isize, () -> { cont.addRowImageTextButton("$quit", "icon-quit", isize, () -> {
ui.showConfirm("$confirm", "$quit.confirm", () -> { ui.showConfirm("$confirm", "$quit.confirm", () -> {
wasClient = Net.client();
if(Net.client()) netClient.disconnectQuietly(); if(Net.client()) netClient.disconnectQuietly();
runExitSave(); runExitSave();
hide(); hide();
@@ -99,7 +99,7 @@ public class PausedDialog extends FloatingDialog{
} }
public void runExitSave(){ public void runExitSave(){
if(state.isEditor()){ if(state.isEditor() && !wasClient){
ui.editor.resumeEditing(); ui.editor.resumeEditing();
return; return;
} }

View File

@@ -1,5 +1,7 @@
package io.anuke.mindustry.ui.fragments; package io.anuke.mindustry.ui.fragments;
import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.arc.Core; import io.anuke.arc.Core;
import io.anuke.arc.Events; import io.anuke.arc.Events;
import io.anuke.arc.collection.Array; import io.anuke.arc.collection.Array;
@@ -19,11 +21,10 @@ import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.scene.utils.Elements; import io.anuke.arc.scene.utils.Elements;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Effects;
import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.type.BaseUnit; import io.anuke.mindustry.entities.type.BaseUnit;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.game.EventType.StateChangeEvent; import io.anuke.mindustry.game.EventType.StateChangeEvent;
import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.game.UnlockableContent; import io.anuke.mindustry.game.UnlockableContent;
@@ -181,7 +182,7 @@ public class HudFragment extends Fragment{
teams.left(); teams.left();
int i = 0; int i = 0;
for(Team team : Team.all){ for(Team team : Team.all){
ImageButton button = teams.addImageButton("white", "clear-toggle-partial", 40f, () -> player.setTeam(team)) ImageButton button = teams.addImageButton("white", "clear-toggle-partial", 40f, () -> Call.setPlayerTeamEditor(player, team))
.size(50f).margin(6f).get(); .size(50f).margin(6f).get();
button.getImageCell().grow(); button.getImageCell().grow();
button.getStyle().imageUpColor = team.color; button.getStyle().imageUpColor = team.color;
@@ -199,13 +200,7 @@ public class HudFragment extends Fragment{
int i = 0; int i = 0;
for(UnitType type : content.<UnitType>getBy(ContentType.unit)){ for(UnitType type : content.<UnitType>getBy(ContentType.unit)){
dialog.cont.addImageButton("white", 48, () -> { dialog.cont.addImageButton("white", 48, () -> {
BaseUnit unit = type.create(player.getTeam()); Call.spawnUnitEditor(player, type);
unit.set(player.x, player.y);
unit.rotation = player.rotation;
unit.add();
//trigger the entity to become visible
unitGroups[player.getTeam().ordinal()].updateEvents();
collisions.updatePhysics( unitGroups[player.getTeam().ordinal()]);
dialog.hide(); dialog.hide();
}).get().getStyle().imageUp = new TextureRegionDrawable(type.iconRegion); }).get().getStyle().imageUp = new TextureRegionDrawable(type.iconRegion);
if(++i % 4 == 0) dialog.cont.row(); if(++i % 4 == 0) dialog.cont.row();
@@ -230,10 +225,7 @@ public class HudFragment extends Fragment{
Units.nearby(world.x, world.y, 1f, 1f, unit -> { Units.nearby(world.x, world.y, 1f, 1f, unit -> {
if(!found[0] && unit instanceof BaseUnit){ if(!found[0] && unit instanceof BaseUnit){
if(Core.input.keyTap(KeyCode.MOUSE_LEFT)){ if(Core.input.keyTap(KeyCode.MOUSE_LEFT)){
Effects.effect(Fx.spawn, unit); Call.removeUnitEditor(player, (BaseUnit)unit);
unit.remove();
unitGroups[unit.getTeam().ordinal()].updateEvents();
collisions.updatePhysics(unitGroups[unit.getTeam().ordinal()]);
} }
found[0] = true; found[0] = true;
unit.hitbox(Tmp.r1); unit.hitbox(Tmp.r1);
@@ -242,7 +234,6 @@ public class HudFragment extends Fragment{
position[1] = unit.y; position[1] = unit.y;
} }
}); });
//TODO check for unit removal, remove unit if needed
} }
} }
@@ -284,19 +275,6 @@ public class HudFragment extends Fragment{
.margin(6).update(u -> u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(world.spawner.playerNear()), 0.1f)).get().color.a = 0f; .margin(6).update(u -> u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(world.spawner.playerNear()), 0.1f)).get().color.a = 0f;
}); });
//out of bounds warning
parent.fill(t -> {
t.touchable(Touchable.disabled);
t.visible(() -> !state.is(State.menu));
t.table("flat", c -> c.add("")
.update(l -> {
l.setColor(Tmp.c1.set(Color.WHITE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 10f, 1f)));
l.setText(Core.bundle.format("outofbounds", (int)((boundsCountdown - player.destructTime) / 60f)));
}).get().setAlignment(Align.center, Align.center)).margin(6).update(u -> {
u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(player.isOutOfBounds()), 0.1f);
}).get().color.a = 0f;
});
parent.fill(t -> { parent.fill(t -> {
t.visible(() -> netServer.isWaitingForPlayers() && !state.is(State.menu)); t.visible(() -> netServer.isWaitingForPlayers() && !state.is(State.menu));
t.table("button", c -> c.add("$waiting.players")); t.table("button", c -> c.add("$waiting.players"));
@@ -417,6 +395,30 @@ public class HudFragment extends Fragment{
blockfrag.build(Core.scene.root); blockfrag.build(Core.scene.root);
} }
@Remote(targets = Loc.both, forward = true, called = Loc.both)
public static void setPlayerTeamEditor(Player player, Team team){
if(state.isEditor()){
player.setTeam(team);
}
}
@Remote(targets = Loc.both, called = Loc.server)
public static void spawnUnitEditor(Player player, UnitType type){
if(state.isEditor()){
BaseUnit unit = type.create(player.getTeam());
unit.set(player.x, player.y);
unit.rotation = player.rotation;
unit.add();
}
}
@Remote(targets = Loc.both, called = Loc.server, forward = true)
public static void removeUnitEditor(Player player, BaseUnit unit){
if(state.isEditor() && unit != null){
unit.remove();
}
}
public void showToast(String text){ public void showToast(String text){
Table table = new Table("button"); Table table = new Table("button");
table.update(() -> { table.update(() -> {

View File

@@ -114,7 +114,7 @@ public class ItemBridge extends Block{
float h = (link.y == y ? tilesize : Math.abs(link.y - y) * tilesize - tilesize); float h = (link.y == y ? tilesize : Math.abs(link.y - y) * tilesize - tilesize);
Lines.rect((x + link.x) / 2f * tilesize - w / 2f, (y + link.y) / 2f * tilesize - h / 2f, w, h); Lines.rect((x + link.x) / 2f * tilesize - w / 2f, (y + link.y) / 2f * tilesize - h / 2f, w, h);
Draw.rect("bridge-poly", link.x * tilesize + Geometry.d4[rot].x * tilesize, link.y * tilesize + Geometry.d4[rot].y * tilesize, link.absoluteRelativeTo(x, y) * 90); Draw.rect("bridge-arrow", link.x * tilesize + Geometry.d4[rot].x * tilesize, link.y * tilesize + Geometry.d4[rot].y * tilesize, link.absoluteRelativeTo(x, y) * 90);
} }
Draw.reset(); Draw.reset();
} }

View File

@@ -31,8 +31,7 @@ public class ImpactReactor extends PowerGenerator{
protected int explosionDamage = 2000; protected int explosionDamage = 2000;
protected Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b"); protected Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b");
protected Color ind1 = Color.valueOf("858585"), ind2 = Color.valueOf("fea080"); protected int bottomRegion;
protected int bottomRegion, topRegion, lightRegion;
protected int[] plasmaRegions; protected int[] plasmaRegions;
public ImpactReactor(String name){ public ImpactReactor(String name){
@@ -44,8 +43,6 @@ public class ImpactReactor extends PowerGenerator{
outputsPower = consumesPower = true; outputsPower = consumesPower = true;
bottomRegion = reg("-bottom"); bottomRegion = reg("-bottom");
topRegion = reg("-top");
lightRegion = reg("-light");
plasmaRegions = new int[plasmas]; plasmaRegions = new int[plasmas];
for(int i = 0; i < plasmas; i++){ for(int i = 0; i < plasmas; i++){
plasmaRegions[i] = reg("-plasma-" + i); plasmaRegions[i] = reg("-plasma-" + i);
@@ -112,17 +109,12 @@ public class ImpactReactor extends PowerGenerator{
Draw.rect(region, tile.drawx(), tile.drawy()); Draw.rect(region, tile.drawx(), tile.drawy());
Draw.rect(reg(topRegion), tile.drawx(), tile.drawy());
Draw.color(ind1, ind2, entity.warmup + Mathf.absin(entity.productionEfficiency, 3f, entity.warmup * 0.5f));
Draw.rect(reg(lightRegion), tile.drawx(), tile.drawy());
Draw.color(); Draw.color();
} }
@Override @Override
public TextureRegion[] generateIcons(){ public TextureRegion[] generateIcons(){
return new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name), Core.atlas.find(name + "-top")}; return new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name)};
} }
@Override @Override

View File

@@ -5,15 +5,34 @@ sourceSets.main.java.srcDirs = ["src/"]
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.utils.IntArray import com.badlogic.gdx.utils.*
import com.badlogic.gdx.tools.texturepacker.TexturePacker import com.badlogic.gdx.tools.texturepacker.TexturePacker
import javax.imageio.ImageIO import javax.imageio.ImageIO
import java.awt.Graphics2D
import java.awt.image.BufferedImage import java.awt.image.BufferedImage
def outFolder = "../core/assets-raw/sprites_out/" def outFolder = "../core/assets-raw/sprites_out/"
def genFolder = "../core/assets-raw/sprites_out/generated/" def genFolder = "../core/assets-raw/sprites_out/generated/"
def doAntialias = !project.hasProperty("disableAntialias") def doAntialias = !project.hasProperty("disableAntialias")
def colorMap = new IntMap<List<Color>>(), colorIndexMap = new IntIntMap()
def transformColors = { List<List<String>> list ->
list.each{ colors ->
def newColors = []
colors.each{ hexc ->
newColors += Color.valueOf(hexc)
}
newColors.each{ color ->
colorMap.put(Color.argb8888(color), newColors)
colorIndexMap.put(Color.argb8888(color), newColors.indexOf(color))
}
}
}
transformColors([["6e7080", "989aa4", "b0bac0"], ["bc5452", "ea8878", "feb380"], ["dea158", "f8c266", "ffe18f"], ["feb380", "ea8878", "bc5452"]])
def antialias = { File file -> def antialias = { File file ->
if(!doAntialias || file.lastModified() <= 1000) return if(!doAntialias || file.lastModified() <= 1000) return
@@ -164,6 +183,38 @@ def scaleImage = { File file ->
ImageIO.write(image, "png", file) ImageIO.write(image, "png", file)
} }
def tileImage = { File file ->
def image = ImageIO.read(file)
def color = new Color()
def result = new BufferedImage(image.width * 2, image.height * 2, image.getType())
Graphics2D graphics = result.createGraphics()
graphics.drawImage(image, image.width, 0, -image.width, image.height, null)
graphics.drawImage(image, image.width, 0, image.width, image.height, null)
graphics.drawImage(image, image.width, image.height*2, -image.width, -image.height, null)
graphics.drawImage(image, image.width, image.height*2, image.width, -image.height, null)
for(int x = 0; x < result.width; x++){
for(int y = 0; y < result.height; y++){
int p = result.getRGB(x, y)
if(x <= y){
List<Color> list = colorMap.get(p)
int index = colorIndexMap.get(p, -1)
if(index != -1){
int resultIndex = (x == y ? 1 : index == 2 ? 0 : index == 0 ? 2 : 1);
result.setRGB(x, y, Color.argb8888(list[resultIndex]))
}
}
}
}
ImageIO.write(result, "png", file)
}
task swapColors(){ task swapColors(){
doLast{ doLast{
if(project.hasProperty("colors")){ if(project.hasProperty("colors")){
@@ -228,6 +279,15 @@ task scaleImages(){
} }
} }
task tileImages(){
doLast{
for(def img : project.getProperty("images").split(",")){
println(project.getProperty("startdir") + "/" + img)
tileImage(new File(project.getProperty("startdir") + "/" + img))
}
}
}
task pack(){ task pack(){
dependsOn 'cleanSprites', 'scaleSprites' dependsOn 'cleanSprites', 'scaleSprites'
//finalizedBy 'cleanup' //finalizedBy 'cleanup'