Some refactoring

This commit is contained in:
Anuken
2019-10-16 14:22:54 -04:00
parent 47f423540d
commit b2ea1b7ca5
30 changed files with 67 additions and 111 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 KiB

After

Width:  |  Height:  |  Size: 500 KiB

View File

@@ -1681,6 +1681,7 @@ public class Blocks implements ContentList{
type = UnitTypes.ghoul;
produceTime = 1150;
size = 3;
maxSpawn = 2;
consumes.power(1.2f);
consumes.items(new ItemStack(Items.silicon, 15), new ItemStack(Items.titanium, 10));
}};
@@ -1690,6 +1691,7 @@ public class Blocks implements ContentList{
type = UnitTypes.revenant;
produceTime = 2000;
size = 4;
maxSpawn = 2;
consumes.power(3f);
consumes.items(new ItemStack(Items.silicon, 40), new ItemStack(Items.titanium, 30));
}};

View File

@@ -460,6 +460,7 @@ public class Bullets implements ContentList{
hitEffect = Fx.hitFlameSmall;
despawnEffect = Fx.none;
status = StatusEffects.burning;
keepVelocity = false;
}
@Override
@@ -503,6 +504,7 @@ public class Bullets implements ContentList{
hitSize = 4;
lifetime = 16f;
pierce = true;
keepVelocity = false;
}
@Override

View File

@@ -43,15 +43,17 @@ public class Mechs implements ContentList{
velocityRnd = 0.1f;
ejectEffect = Fx.none;
bullet = new HealBulletType(){{
backColor = engineColor;
healPercent = 3f;
//TODO decide on color or remove healing properties
//backColor = engineColor;
homingPower = 20f;
bulletHeight = 4f;
bulletWidth = 1.5f;
damage = 3f;
speed = 4f;
lifetime = 40f;
shootEffect = Fx.shootHealYellow;
smokeEffect = hitEffect = despawnEffect = Fx.hitYellowLaser;
//shootEffect = Fx.shootHealYellow;
//smokeEffect = hitEffect = despawnEffect = Fx.hitYellowLaser;
}};
}};
}
@@ -63,36 +65,6 @@ public class Mechs implements ContentList{
};
alpha = new Mech("alpha-mech", false){
{
drillPower = 1;
mineSpeed = 1.5f;
mass = 1.2f;
speed = 0.5f;
itemCapacity = 40;
boostSpeed = 0.95f;
buildPower = 1.2f;
engineColor = Color.valueOf("ffd37f");
health = 250f;
weapon = new Weapon("blaster"){{
length = 1.5f;
reload = 14f;
roundrobin = true;
ejectEffect = Fx.shellEjectSmall;
bullet = Bullets.standardMechSmall;
}};
}
@Override
public void updateAlt(Player player){
player.healBy(Time.delta() * 0.09f);
}
};
delta = new Mech("delta-mech", false){
float cooldown = 120;
{
drillPower = -1;
speed = 0.75f;
@@ -108,27 +80,41 @@ public class Mechs implements ContentList{
weapon = new Weapon("shockgun"){{
shake = 2f;
length = 1f;
reload = 55f;
shotDelay = 3f;
reload = 60f;
roundrobin = true;
shots = 2;
inaccuracy = 0f;
ejectEffect = Fx.none;
bullet = Bullets.lightning;
bullet = Bullets.lancerLaser;
shootSound = Sounds.spark;
}};
}
//todo this is a useless ability
@Override
public void onLand(Player player){
if(player.timer.get(Player.timerAbility, cooldown)){
Effects.shake(1f, 1f, player);
Effects.effect(Fx.landShock, player);
for(int i = 0; i < 8; i++){
Time.run(Mathf.random(8f), () -> Lightning.create(player.getTeam(), Pal.lancerLaser, 17f * Vars.state.rules.playerDamageMultiplier, player.x, player.y, Mathf.random(360f), 14));
}
}
public void updateAlt(Player player){
player.healBy(Time.delta() * 0.09f);
}
};
delta = new Mech("delta-mech", false){
{
drillPower = 1;
mineSpeed = 1.5f;
mass = 1.2f;
speed = 0.5f;
itemCapacity = 40;
boostSpeed = 0.95f;
buildPower = 1.2f;
engineColor = Color.valueOf("ffd37f");
health = 250f;
weaponOffsetX = 4f;
weapon = new Weapon("flamethrower"){{
length = 1.5f;
reload = 10f;
width = 4f;
roundrobin = true;
bullet = Bullets.basicFlame;
}};
}
};

View File

@@ -29,8 +29,8 @@ import java.text.*;
import java.util.*;
import static io.anuke.arc.Core.*;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.Vars.net;
import static io.anuke.mindustry.Vars.*;
/**
* Control module.

View File

@@ -8,7 +8,7 @@ import io.anuke.mindustry.*;
/** Base interface for an unlockable content type. */
public abstract class UnlockableContent extends MappableContent{
/** Localized, formal name. Never null. Set to block name if not found in bundle. */
/** Localized, formal name. Never null. Set to internal name if not found in bundle. */
public String localizedName;
/** Localized description. May be null. */
public String description;
@@ -40,11 +40,6 @@ public abstract class UnlockableContent extends MappableContent{
return cicons[icon.ordinal()];
}
/** Returns the localized name of this content. */
public abstract String localizedName();
//public abstract TextureRegion getContentIcon();
/** This should show all necessary info about this content in the specified table. */
public abstract void displayInfo(Table table);

View File

@@ -55,7 +55,7 @@ public class Mods implements Loadable{
public void importMod(FileHandle file) throws IOException{
FileHandle dest = modDirectory.child(file.name());
if(dest.exists()){
throw new IOException("A mod with the same filename already exists!");
throw new IOException("A file with the same name already exists in the mod folder!");
}
file.copyTo(dest);

View File

@@ -51,14 +51,9 @@ public class Item extends UnlockableContent{
ContentDisplay.displayItem(table, this);
}
@Override
public String localizedName(){
return Core.bundle.get("item." + this.name + ".name");
}
@Override
public String toString(){
return localizedName();
return localizedName;
}
@Override

View File

@@ -45,14 +45,9 @@ public class Liquid extends UnlockableContent{
ContentDisplay.displayLiquid(table, this);
}
@Override
public String localizedName(){
return Core.bundle.get("liquid." + this.name + ".name");
}
@Override
public String toString(){
return localizedName();
return localizedName;
}
@Override

View File

@@ -45,10 +45,6 @@ public class Mech extends UnlockableContent{
this(name, false);
}
public String localizedName(){
return Core.bundle.get("mech." + name + ".name");
}
public void updateAlt(Player player){
}
@@ -112,6 +108,6 @@ public class Mech extends UnlockableContent{
@Override
public String toString(){
return localizedName();
return localizedName;
}
}

View File

@@ -63,11 +63,6 @@ public class UnitType extends UnlockableContent{
ContentDisplay.displayUnit(table, this);
}
@Override
public String localizedName(){
return Core.bundle.get("unit." + name + ".name");
}
@Override
public void load(){
weapon.load();

View File

@@ -113,11 +113,12 @@ public class Weapon{
shooter.velocity().add(Tmp.v1);
Tmp.v1.trns(rotation, 3f);
boolean parentize = ammo.keepVelocity;
Effects.shake(weapon.shake, weapon.shake, x, y);
Effects.effect(weapon.ejectEffect, x, y, rotation * -Mathf.sign(left));
Effects.effect(ammo.shootEffect, x + Tmp.v1.x, y + Tmp.v1.y, rotation, shooter);
Effects.effect(ammo.smokeEffect, x + Tmp.v1.x, y + Tmp.v1.y, rotation, shooter);
Effects.effect(ammo.shootEffect, x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? shooter : null);
Effects.effect(ammo.smokeEffect, x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? shooter : null);
//reset timer for remote players
shooter.getTimer().get(shooter.getShootTimer(left), weapon.reload);
@@ -172,7 +173,6 @@ public class Weapon{
if(owner == null) return;
Tmp.v1.trns(angle, 3f);
Bullet.create(bullet,
owner, owner.getTeam(), x + Tmp.v1.x, y + Tmp.v1.y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd));
Bullet.create(bullet, owner, owner.getTeam(), x + Tmp.v1.x, y + Tmp.v1.y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd));
}
}

View File

@@ -200,11 +200,6 @@ public class Zone extends UnlockableContent{
public void displayInfo(Table table){
}
@Override
public String localizedName(){
return Core.bundle.get("zone." + name + ".name");
}
@Override
public ContentType getContentType(){
return ContentType.zone;

View File

@@ -67,7 +67,7 @@ public class ContentDisplay{
table.table(title -> {
title.addImage(item.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + item.localizedName()).padLeft(5);
title.add("[accent]" + item.localizedName).padLeft(5);
});
table.row();
@@ -98,7 +98,7 @@ public class ContentDisplay{
table.table(title -> {
title.addImage(liquid.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + liquid.localizedName()).padLeft(5);
title.add("[accent]" + liquid.localizedName).padLeft(5);
});
table.row();
@@ -132,7 +132,7 @@ public class ContentDisplay{
public static void displayMech(Table table, Mech mech){
table.table(title -> {
title.addImage(mech.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + mech.localizedName()).padLeft(5);
title.add("[accent]" + mech.localizedName).padLeft(5);
});
table.left().defaults().left();
@@ -180,7 +180,7 @@ public class ContentDisplay{
public static void displayUnit(Table table, UnitType unit){
table.table(title -> {
title.addImage(unit.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + unit.localizedName()).padLeft(5);
title.add("[accent]" + unit.localizedName).padLeft(5);
});
table.row();

View File

@@ -15,7 +15,7 @@ public class ItemDisplay extends Table{
public ItemDisplay(Item item, int amount, boolean showName){
add(new ItemImage(new ItemStack(item, amount))).size(8 * 4).padRight(amount > 99 ? 12 : 0);
if(showName) add(item.localizedName()).padLeft(4 + amount > 99 ? 4 : 0);
if(showName) add(item.localizedName).padLeft(4 + amount > 99 ? 4 : 0);
this.item = item;
this.amount = amount;

View File

@@ -30,7 +30,7 @@ public class ItemsDisplay extends Table{
if(item.type == ItemType.material && data.isUnlocked(item)){
t.label(() -> format(item)).left();
t.addImage(item.icon(Cicon.small)).size(8 * 3).padLeft(4).padRight(4);
t.add(item.localizedName()).color(Color.lightGray).left();
t.add(item.localizedName).color(Color.lightGray).left();
t.row();
}
}

View File

@@ -34,6 +34,6 @@ public class LiquidDisplay extends Table{
add(StatUnit.perSecond.localized()).padLeft(2).padRight(5).color(Color.lightGray);
}
add(liquid.localizedName());
add(liquid.localizedName);
}
}

View File

@@ -66,7 +66,7 @@ public class DatabaseDialog extends FloatingDialog{
if(unlocked(unlock)){
image.clicked(() -> Vars.ui.content.show(unlock));
image.addListener(new Tooltip(t -> t.background(Tex.button).add(unlock.localizedName())));
image.addListener(new Tooltip(t -> t.background(Tex.button).add(unlock.localizedName)));
}
if((++count) % maxWidth == 0){

View File

@@ -148,7 +148,7 @@ public class DeployDialog extends FloatingDialog{
}).color(Color.darkGray).grow()));
}
TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName()), Styles.squaret, () -> {
TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName), Styles.squaret, () -> {
control.saves.getZoneSlot().cautiousLoad(() -> {
hide();
ui.loadAnd(() -> {
@@ -225,7 +225,7 @@ public class DeployDialog extends FloatingDialog{
});
if(zone.unlocked() && !hidden(zone)){
button.labelWrap(zone.localizedName()).style(Styles.outlineLabel).width(140).growX().get().setAlignment(Align.center);
button.labelWrap(zone.localizedName).style(Styles.outlineLabel).width(140).growX().get().setAlignment(Align.center);
}else{
Consumer<Element> flasher = zone.canUnlock() && !hidden(zone) ? e -> e.update(() -> e.getColor().set(Color.white).lerp(Pal.accent, Mathf.absin(3f, 1f))) : e -> {};
flasher.accept(button.addImage(Icon.locked).get());

View File

@@ -319,7 +319,7 @@ public class TechTreeDialog extends FloatingDialog{
t.table(list -> {
list.left();
list.addImage(req.item.icon(Cicon.small)).size(8 * 3).padRight(3);
list.add(req.item.localizedName()).color(Color.lightGray);
list.add(req.item.localizedName).color(Color.lightGray);
list.label(() -> " " + Math.min(data.getItem(req.item), req.amount) + " / " + req.amount)
.update(l -> l.setColor(data.has(req.item, req.amount) ? Color.lightGray : Color.scarlet));
}).fillX().left();

View File

@@ -95,7 +95,7 @@ public class ZoneInfoDialog extends FloatingDialog{
}).growX();
}else{
cont.add(zone.localizedName()).color(Pal.accent).growX().center();
cont.add(zone.localizedName).color(Pal.accent).growX().center();
cont.row();
cont.addImage().color(Pal.accent).height(3).pad(6).growX();
cont.row();

View File

@@ -254,7 +254,7 @@ public class HudFragment extends Fragment{
t.add(new Minimap().visible(() -> Core.settings.getBool("minimap") && !state.rules.tutorial));
t.row();
//position
t.label(() -> world.toTile(player.x) + "," + world.toTile(player.y))
t.label(() -> world.toTile(player.x) + "," + world.toTile(player.y)).style(Styles.outlineLabel)
.visible(() -> Core.settings.getBool("position") && !state.rules.tutorial);
t.top().right();
});

View File

@@ -220,7 +220,7 @@ public class PlacementFragment extends Fragment{
req.table(line -> {
line.left();
line.addImage(stack.item.icon(Cicon.small)).size(8 * 2);
line.add(stack.item.localizedName()).color(Color.lightGray).padLeft(2).left();
line.add(stack.item.localizedName).color(Color.lightGray).padLeft(2).left();
line.labelWrap(() -> {
TileEntity core = player.getClosestCore();
if(core == null || state.rules.infiniteResources) return "*/*";

View File

@@ -360,11 +360,6 @@ public class Block extends BlockStorage{
return sum;
}
@Override
public String localizedName(){
return localizedName;
}
@Override
public void displayInfo(Table table){
ContentDisplay.displayBlock(table, this);
@@ -517,7 +512,7 @@ public class Block extends BlockStorage{
}else{
current = entity -> entity.liquids.current();
}
bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName(),
bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName,
() -> current.get(entity).color, () -> entity.liquids.get(current.get(entity)) / liquidCapacity));
}

View File

@@ -14,7 +14,7 @@ public class OreBlock extends OverlayFloor{
public OreBlock(Item ore){
super("ore-" + ore.name);
this.localizedName = ore.localizedName();
this.localizedName = ore.localizedName;
this.itemDrop = ore;
this.variants = 3;
this.color.set(ore.color);
@@ -27,7 +27,7 @@ public class OreBlock extends OverlayFloor{
}
public void setup(Item ore){
this.localizedName = ore.localizedName();
this.localizedName = ore.localizedName;
this.itemDrop = ore;
this.color.set(ore.color);
}
@@ -78,6 +78,6 @@ public class OreBlock extends OverlayFloor{
@Override
public String getDisplayName(Tile tile){
return itemDrop.localizedName();
return itemDrop.localizedName;
}
}

View File

@@ -186,7 +186,7 @@ public class Drill extends Block{
Item item = list.get(i);
table.addImage(Core.atlas.find(item.name + "1")).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
table.add(item.localizedName());
table.add(item.localizedName);
if(i != list.size - 1){
table.add("/").padLeft(5).padRight(5);
}

View File

@@ -28,7 +28,7 @@ public class AmmoListValue<T extends UnlockableContent> implements StatValue{
for(T t : map.keys()){
BulletType type = map.get(t);
table.addImage(icon(t)).size(3 * 8).padRight(4).right().top();
table.add(t.localizedName()).padRight(10).left().top();
table.add(t.localizedName).padRight(10).left().top();
table.table(Tex.underline, bt -> {
bt.left().defaults().padRight(3).left();