Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Nov 1, 2021
2 parents 0639e3e + 450f651 commit 779bab0
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 53 deletions.
2 changes: 2 additions & 0 deletions core/assets/bundles/bundle_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@ weather.sandstorm.name = Tempête de sable
weather.sporestorm.name = Tempête de spores
weather.fog.name = Brouillard

sectorlist = Secteurs
sectorlist.attacked = {0} pris d'assaut
sectors.unexplored = [lightgray]Inexploré
sectors.resources = Ressources :
sectors.production = Production :
Expand Down
8 changes: 7 additions & 1 deletion core/assets/bundles/bundle_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ waves.every = каждый
waves.waves = волна(ы)
waves.perspawn = за появление
waves.shields = ед. щита/волну
waves.sort = Сортировать по
waves.sort.reverse = Обратная сортировка
waves.sort.begin = Начало
waves.sort.health = Здоровье
waves.sort.type = Тип
waves.to = до
waves.max = максимум единиц
waves.guardian = Страж
Expand Down Expand Up @@ -895,6 +900,7 @@ setting.seconds = {0} секунд
setting.milliseconds = {0} миллисекунд
setting.fullscreen.name = Полноэкранный режим
setting.borderlesswindow.name = Безрамочное окно
setting.borderlesswindow.description = Для вступления изменений в силу может потребоваться перезагрузка игры.
setting.fps.name = Показывать FPS и пинг
setting.smoothcamera.name = Плавная камера
setting.vsync.name = Вертикальная синхронизация
Expand Down Expand Up @@ -1513,7 +1519,7 @@ block.liquid-router.description = Принимает жидкости из од
block.liquid-tank.description = Хранит большое количество жидкости. Выводит жидкости во все стороны, подобно жидкостному маршрутизатору.
block.liquid-junction.description = Действует как мост для двух пересекающихся трубопроводов.
block.bridge-conduit.description = Перемещает жидкости над любой местностью или зданиями.
block.liquid-container.description = Хранит большое количество жидкости. Выводит их во все стороны, как жидкостный маршрутизатор.
block.liquid-container.description = Хранит небольшое количество жидкости. Выводит жидкости во все стороны, подобно жидкостному маршрутизатору.
block.phase-conduit.description = Перемещает жидкости над любой местностью или зданиями. Большая дистанция, чем у жидкостного моста, но требует энергию.
block.power-node.description = Передает питание на подключенные узлы. Узел будет получать питание или поставлять питание на любые соседние блоки.
block.power-node-large.description = Усовершенствованный силовой узел с большей дальностью.
Expand Down
101 changes: 80 additions & 21 deletions core/assets/bundles/bundle_vi.properties

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions core/src/mindustry/content/Blocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import arc.struct.*;
import mindustry.*;
import mindustry.ctype.*;
import mindustry.entities.*;
import mindustry.entities.bullet.*;
import mindustry.gen.*;
import mindustry.graphics.*;
Expand Down Expand Up @@ -1839,7 +1840,7 @@ Items.surgeAlloy, new PointBulletType(){{
size = 4;
shootCone = 2f;
shootSound = Sounds.railgun;
unitSort = (u, x, y) -> -u.maxHealth + Mathf.dst2(u.x, u.y, x, y) / 6400f;
unitSort = UnitSorts.strongest;

coolantMultiplier = 0.4f;

Expand Down Expand Up @@ -2287,4 +2288,4 @@ Items.surgeAlloy, new PointBulletType(){{

//endregion
}
}
}
29 changes: 3 additions & 26 deletions core/src/mindustry/core/NetClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,33 +260,10 @@ public static void sendChatMessage(Player player, String message){

//a command was sent, now get the output
if(response.type != ResponseType.valid){
String text;

//send usage
if(response.type == ResponseType.manyArguments){
text = "[scarlet]Too many arguments. Usage:[lightgray] " + response.command.text + "[gray] " + response.command.paramText;
}else if(response.type == ResponseType.fewArguments){
text = "[scarlet]Too few arguments. Usage:[lightgray] " + response.command.text + "[gray] " + response.command.paramText;
}else{ //unknown command
int minDst = 0;
Command closest = null;

for(Command command : netServer.clientCommands.getCommandList()){
int dst = Strings.levenshtein(command.text, response.runCommand);
if(dst < 3 && (closest == null || dst < minDst)){
minDst = dst;
closest = command;
}
}

if(closest != null){
text = "[scarlet]Unknown command. Did you mean \"[lightgray]" + closest.text + "[]\"?";
}else{
text = "[scarlet]Unknown command. Check [lightgray]/help[scarlet].";
}
String text = netServer.invalidHandler.handle(player, response);
if(text != null){
player.sendMessage(text);
}

player.sendMessage(text);
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions core/src/mindustry/core/NetServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,32 @@ public class NetServer implements ApplicationListener{
/** Converts a message + NULLABLE player sender into a single string. Override for custom prefixes/suffixes. */
public ChatFormatter chatFormatter = (player, message) -> player == null ? message : "[coral][[" + player.coloredName() + "[coral]]:[white] " + message;

/** Handles an incorrect command response. Returns text that will be sent to player. Override for customisation. */
public InvalidCommandHandler invalidHandler = (player, response) -> {
if(response.type == ResponseType.manyArguments){
return "[scarlet]Too many arguments. Usage:[lightgray] " + response.command.text + "[gray] " + response.command.paramText;
}else if(response.type == ResponseType.fewArguments){
return "[scarlet]Too few arguments. Usage:[lightgray] " + response.command.text + "[gray] " + response.command.paramText;
}else{ //unknown command
int minDst = 0;
Command closest = null;

for(Command command : netServer.clientCommands.getCommandList()){
int dst = Strings.levenshtein(command.text, response.runCommand);
if(dst < 3 && (closest == null || dst < minDst)){
minDst = dst;
closest = command;
}
}

if(closest != null){
return "[scarlet]Unknown command. Did you mean \"[lightgray]" + closest.text + "[]\"?";
}else{
return "[scarlet]Unknown command. Check [lightgray]/help[scarlet].";
}
}
};

private boolean closing = false;
private Interval timer = new Interval();

Expand Down Expand Up @@ -994,4 +1020,8 @@ public interface ChatFormatter{
/** @return text to be placed before player name */
String format(@Nullable Player player, String message);
}

public interface InvalidCommandHandler{
String handle(Player player, CommandResponse response);
}
}
14 changes: 14 additions & 0 deletions core/src/mindustry/entities/UnitSorts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package mindustry.entities;

import arc.math.*;
import mindustry.entities.Units.*;
import mindustry.gen.*;

public class UnitSorts{
public static Sortf

closest = Unit::dst2,
farthest = (u, x, y) -> -u.dst2(x, y),
strongest = (u, x, y) -> -u.maxHealth + Mathf.dst2(u.x, u.y, x, y) / 6400f,
weakest = (u, x, y) -> u.maxHealth + Mathf.dst2(u.x, u.y, x, y) / 6400f;
}
4 changes: 3 additions & 1 deletion core/src/mindustry/mod/ContentParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import mindustry.content.TechTree.*;
import mindustry.ctype.*;
import mindustry.entities.*;
import mindustry.entities.Units.*;
import mindustry.entities.abilities.*;
import mindustry.entities.bullet.*;
import mindustry.entities.effect.*;
Expand Down Expand Up @@ -61,6 +62,7 @@ public class ContentParser{
readFields(result, data);
return result;
});
put(Sortf.class, (type, data) -> field(UnitSorts.class, data));
put(Interp.class, (type, data) -> field(Interp.class, data));
put(CacheLayer.class, (type, data) -> field(CacheLayer.class, data));
put(Attribute.class, (type, data) -> Attribute.get(data.asString()));
Expand Down Expand Up @@ -826,4 +828,4 @@ public interface ParseListener{
void parsed(Class<?> type, JsonValue jsonData, Object result);
}

}
}
4 changes: 2 additions & 2 deletions core/src/mindustry/world/blocks/defense/turrets/Turret.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class Turret extends ReloadTurret{
public Effect chargeBeginEffect = Fx.none;
public Sound chargeSound = Sounds.none;

public Sortf unitSort = Unit::dst2;
public Sortf unitSort = UnitSorts.closest;

protected Vec2 tr = new Vec2();
protected Vec2 tr2 = new Vec2();
Expand Down Expand Up @@ -508,4 +508,4 @@ public byte version(){
return 1;
}
}
}
}

0 comments on commit 779bab0

Please sign in to comment.