Outline changes

This commit is contained in:
Anuken 2020-09-18 21:14:04 -04:00
parent 8dd1c5f1f8
commit aae045b5dd
14 changed files with 8440 additions and 7579 deletions

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 624 KiB

After

Width:  |  Height:  |  Size: 642 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 850 KiB

After

Width:  |  Height:  |  Size: 735 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 695 KiB

After

Width:  |  Height:  |  Size: 1,013 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 187 KiB

Before After
Before After

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 2.5 MiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

After

Width:  |  Height:  |  Size: 188 KiB

Before After
Before After

View file

@ -2,7 +2,6 @@ package mindustry.content;
import arc.graphics.*;
import arc.struct.*;
import arc.util.*;
import mindustry.ai.types.*;
import mindustry.annotations.Annotations.*;
import mindustry.ctype.*;
@ -62,6 +61,7 @@ public class UnitTypes implements ContentList{
reload = 14f;
x = 4f;
y = 2f;
top = false;
ejectEffect = Fx.shellEjectSmall;
bullet = Bullets.standardCopper;
}});
@ -76,6 +76,7 @@ public class UnitTypes implements ContentList{
immunities.add(StatusEffects.burning);
weapons.add(new Weapon("flamethrower"){{
top = false;
shootSound = Sounds.flame;
shootY = 2f;
reload = 14f;
@ -107,6 +108,7 @@ public class UnitTypes implements ContentList{
mechFrontSway = 0.55f;
weapons.add(new Weapon("artillery"){{
top = false;
y = 1f;
x = 9f;
reload = 60f;
@ -143,6 +145,7 @@ public class UnitTypes implements ContentList{
weapons.add(
new Weapon("scepter-weapon"){{
top = false;
y = 1f;
x = 16f;
shootY = 8f;
@ -202,6 +205,7 @@ public class UnitTypes implements ContentList{
weapons.add(
new Weapon("reign-weapon"){{
top = false;
y = 1f;
x = 21.5f;
shootY = 11f;
@ -260,6 +264,7 @@ public class UnitTypes implements ContentList{
abilities.add(new HealFieldAbility(10f, 60f * 4, 60f));
weapons.add(new Weapon("heal-weapon"){{
top = false;
shootY = 2f;
reload = 24f;
x = 4.5f;
@ -288,6 +293,7 @@ public class UnitTypes implements ContentList{
abilities.add(new ShieldFieldAbility(20f, 40f, 60f * 5, 60f));
weapons.add(new Weapon("heal-shotgun-weapon"){{
top = false;
x = 5f;
shake = 2.2f;
y = 0.5f;
@ -337,6 +343,7 @@ public class UnitTypes implements ContentList{
abilities.add(new ForceFieldAbility(60f, 0.3f, 400f, 60f * 6));
weapons.add(new Weapon("beam-weapon"){{
top = false;
shake = 2f;
shootY = 4f;
x = 6.5f;
@ -407,6 +414,7 @@ public class UnitTypes implements ContentList{
groundLayer = Layer.legUnit - 1f;
weapons.add(new Weapon("eruption"){{
top = false;
shootY = 3f;
reload = 10f;
ejectEffect = Fx.none;
@ -1188,7 +1196,7 @@ public class UnitTypes implements ContentList{
shootY = 7f;
shake = 5f;
recoil = 4f;
occlusion = 17f;
occlusion = 12f;
shots = 1;
inaccuracy = 3f;
@ -1279,7 +1287,7 @@ public class UnitTypes implements ContentList{
rotateSpeed = 4f;
mirror = false;
occlusion = 30f;
occlusion = 20f;
shootY = 2f;
recoil = 4f;
@ -1351,7 +1359,7 @@ public class UnitTypes implements ContentList{
immunities = ObjectSet.with(StatusEffects.wet);
rotateShooting = false;
float spawnTime = 0.5f * Time.toMinutes;
float spawnTime = 60f * 25f;
abilities.add(new UnitSpawnAbility(flare, spawnTime, 19.25f, -31.75f), new UnitSpawnAbility(flare, spawnTime, -19.25f, -31.75f));
@ -1446,6 +1454,7 @@ public class UnitTypes implements ContentList{
lowAltitude = true;
weapons.add(new Weapon("small-mount-weapon"){{
top = false;
reload = 20f;
x = 3f;
y = 0.5f;
@ -1483,6 +1492,7 @@ public class UnitTypes implements ContentList{
hitsize = 10f;
weapons.add(new Weapon("small-mount-weapon"){{
top = false;
reload = 15f;
x = 1f;
y = 2f;

View file

@ -32,7 +32,7 @@ import mindustry.world.blocks.units.*;
import static mindustry.Vars.*;
public class UnitType extends UnlockableContent{
public static final float shadowTX = -12, shadowTY = -13, shadowColor = Color.toFloatBits(0, 0, 0, 0.22f);
public static final float shadowTX = -12, shadowTY = -13, shadowColor = Color.toFloatBits(0, 0, 0, 0.22f), outlineSpace = 0.01f;
private static final Vec2 legOffset = new Vec2();
/** If true, the unit is always at elevation 1. */
@ -81,7 +81,6 @@ public class UnitType extends UnlockableContent{
public float lightRadius = 60f, lightOpacity = 0.6f;
public Color lightColor = Pal.powerLight;
public boolean drawCell = true, drawItems = true, drawShields = true;
public int parts = 0;
public int trailLength = 3;
public float trailX = 4f, trailY = -3f, trailScl = 1f;
/** Whether the unit can heal blocks. Initialized in init() */
@ -93,8 +92,8 @@ public class UnitType extends UnlockableContent{
public Seq<Weapon> weapons = new Seq<>();
public TextureRegion baseRegion, legRegion, region, shadowRegion, cellRegion,
occlusionRegion, jointRegion, footRegion, legBaseRegion, baseJointRegion;
public TextureRegion[] partRegions, partCellRegions, wreckRegions;
occlusionRegion, jointRegion, footRegion, legBaseRegion, baseJointRegion, outlineRegion;
public TextureRegion[] wreckRegions;
public UnitType(String name){
super(name);
@ -291,16 +290,9 @@ public class UnitType extends UnlockableContent{
baseRegion = Core.atlas.find(name + "-base");
cellRegion = Core.atlas.find(name + "-cell", Core.atlas.find("power-cell"));
occlusionRegion = Core.atlas.find("circle-shadow");
outlineRegion = Core.atlas.find(name + "-outline");
shadowRegion = icon(Cicon.full);
partRegions = new TextureRegion[parts];
partCellRegions = new TextureRegion[parts];
for(int i = 0; i < parts; i++){
partRegions[i] = Core.atlas.find(name + "-part" + i);
partCellRegions[i] = Core.atlas.find(name + "-cell" + i);
}
wreckRegions = new TextureRegion[3];
for(int i = 0; i < wreckRegions.length; i++){
wreckRegions[i] = Core.atlas.find(name + "-wreck" + i);
@ -351,8 +343,13 @@ public class UnitType extends UnlockableContent{
drawPayload((Unit & Payloadc)unit);
}
//TODO
drawOcclusion(unit);
Draw.z(z - outlineSpace);
drawOutline(unit);
Draw.z(z);
if(engineSize > 0) drawEngine(unit);
drawBody(unit);
@ -507,6 +504,20 @@ public class UnitType extends UnlockableContent{
Drawf.shadow(wx, wy, weapon.occlusion);
}
if(weapon.outlineRegion.found()){
float z = Draw.z();
if(!weapon.top) Draw.z(z - outlineSpace);
Draw.rect(weapon.outlineRegion,
wx, wy,
width * Draw.scl * -Mathf.sign(weapon.flipSprite),
weapon.region.height * Draw.scl,
weaponRotation);
Draw.z(z);
}
Draw.rect(weapon.region,
wx, wy,
width * Draw.scl * -Mathf.sign(weapon.flipSprite),
@ -529,10 +540,16 @@ public class UnitType extends UnlockableContent{
Draw.reset();
}
public void drawOutline(Unit unit){
if(Core.atlas.isFound(outlineRegion)){
Draw.rect(outlineRegion, unit.x, unit.y, unit.rotation - 90);
}
}
public void drawBody(Unit unit){
applyColor(unit);
Draw.rect(region, unit, unit.rotation - 90);
Draw.rect(region, unit.x, unit.y, unit.rotation - 90);
Draw.reset();
}
@ -541,7 +558,7 @@ public class UnitType extends UnlockableContent{
applyColor(unit);
Draw.color(cellColor(unit));
Draw.rect(cellRegion, unit, unit.rotation - 90);
Draw.rect(cellRegion, unit.x, unit.y, unit.rotation - 90);
Draw.reset();
}
@ -551,7 +568,7 @@ public class UnitType extends UnlockableContent{
public void drawLight(Unit unit){
if(lightRadius > 0){
Drawf.light(unit.team, unit, lightRadius, lightColor, lightOpacity);
Drawf.light(unit.team, unit.x, unit.y, lightRadius, lightColor, lightOpacity);
}
}

View file

@ -27,6 +27,8 @@ public class Weapon{
public boolean alternate = true;
/** whether to rotate toward the target independently of unit */
public boolean rotate = false;
/** whether to draw the outline on top. */
public boolean top = true;
/** rotation speed of weapon when rotation is enabled, in degrees/t*/
public float rotateSpeed = 20f;
/** weapon reload in frames */
@ -71,6 +73,8 @@ public class Weapon{
public TextureRegion region;
/** heat region, must be same size as region (optional) */
public TextureRegion heatRegion;
/** outline region to display if top is false */
public TextureRegion outlineRegion;
/** heat region tint */
public Color heatColor = Pal.turretHeat;
@ -91,6 +95,7 @@ public class Weapon{
public void load(){
region = Core.atlas.find(name, Core.atlas.find("clear"));
heatRegion = Core.atlas.find(name + "-heat");
outlineRegion = Core.atlas.find(name + "-outline");
}
}

View file

@ -2,6 +2,7 @@ package mindustry.tools;
import arc.*;
import arc.files.*;
import arc.func.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
@ -312,23 +313,36 @@ public class Generators{
type.load();
type.init();
//TODO decide whether to keep weapon outlines or not
if(true)
for(Weapon weapon : type.weapons){
if(weapon.rotate && outlined.add(weapon.name) && ImagePacker.has(weapon.name)){
ImagePacker.get(weapon.name).outline(4, Pal.darkerMetal).save(weapon.name);
Color outc = Pal.darkerMetal;
//Func<Image, Image> outlineS = i -> i.shadow(0.8f, 9);
Func<Image, Image> outline = i -> i.outline(4, outc);
Cons<TextureRegion> outliner = t -> {
if(t != null && t.found()){
ImagePacker.replace(t, outline.get(ImagePacker.get(t)));
}
};
((GenRegion)Core.atlas.find(weapon.name)).path.delete();
for(Weapon weapon : type.weapons){
if(outlined.add(weapon.name) && ImagePacker.has(weapon.name)){
outline.get(ImagePacker.get(weapon.name)).save(weapon.name + "-outline");
//old outline
//ImagePacker.get(weapon.name).outline(4, Pal.darkerMetal).save(weapon.name);
}
}
Image image = ImagePacker.get(type.parts > 0 ? type.partRegions[0] : type.region);
for(int i = 1; i < type.parts; i++){
image.draw(ImagePacker.get(type.partRegions[i]));
}
if(type.parts > 0){
image.save(type.name);
}
//baseRegion, legRegion, region, shadowRegion, cellRegion,
// occlusionRegion, jointRegion, footRegion, legBaseRegion, baseJointRegion, outlineRegion;
outliner.get(type.jointRegion);
outliner.get(type.footRegion);
outliner.get(type.legBaseRegion);
outliner.get(type.baseJointRegion);
Image image = ImagePacker.get(type.region);
outline.get(image).save(type.name + "-outline");
//ImagePacker.replace(type.region, outline.get(image));
if(type.constructor.get() instanceof Mechc){
image.drawCenter(type.baseRegion);
@ -337,15 +351,7 @@ public class Generators{
image.draw(type.region);
}
Image baseCell = ImagePacker.get(type.parts > 0 ? type.partCellRegions[0] : type.cellRegion);
for(int i = 1; i < type.parts; i++){
baseCell.draw(ImagePacker.get(type.partCellRegions[i]));
}
if(type.parts > 0){
image.save(type.name + "-cell");
}
Image baseCell = ImagePacker.get(type.cellRegion);
Image cell = new Image(type.cellRegion.width, type.cellRegion.height);
cell.each((x, y) -> cell.draw(x, y, baseCell.getColor(x, y).mul(Color.valueOf("ffa665"))));

View file

@ -4,6 +4,7 @@ import arc.func.*;
import arc.graphics.Color;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import mindustry.tools.ImagePacker.*;
@ -88,6 +89,49 @@ class Image{
return out;
}
Image shadow(float alpha, int rad){
Image out = silhouette(new Color(0f, 0f, 0f, alpha)).blur(rad);
out.draw(this);
return out;
}
Image silhouette(Color color){
Image out = copy();
each((x, y) -> out.draw(x, y, getColor(x, y).set(color.r, color.g, color.b, this.color.a * color.a)));
return out;
}
Image blur(int radius){
Image out = copy();
Color c = new Color();
int[] sum = {0};
for(int x = 0; x < out.width; x++){
for(int y = 0; y < out.height; y++){
sum[0] = 0;
Geometry.circle(x, y, radius, (cx, cy) -> {
int rx = Mathf.clamp(cx, 0, out.width - 1), ry = Mathf.clamp(cy, 0, out.height - 1);
Color other = getColor(rx, ry);
c.r += other.r;
c.g += other.g;
c.b += other.b;
c.a += other.a;
sum[0] ++;
});
c.mula(1f / sum[0]);
out.draw(x, y, c);
}
}
return out;
}
void each(Intc2 cons){
for(int x = 0; x < width; x++){
for(int y = 0; y < height; y++){

View file

@ -163,6 +163,15 @@ public class ImagePacker{
return new Image(imageCache.get(((AtlasRegion)region).name));
}
static void replace(String name, Image image){
image.save(name);
((GenRegion)Core.atlas.find(name)).path.delete();
}
static void replace(TextureRegion region, Image image){
replace(((GenRegion)region).name, image);
}
static void err(String message, Object... args){
throw new IllegalArgumentException(Strings.format(message, args));
}