mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-30 04:10:41 -08:00
More plugin customization / Renamed Rectangle
This commit is contained in:
parent
6080a7e4bc
commit
d6d6dc29dc
35 changed files with 166 additions and 90 deletions
|
|
@ -63,7 +63,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||
});
|
||||
|
||||
Events.on(PlayEvent.class, event -> {
|
||||
player.setTeam(state.rules.pvp ? netServer.assignTeam(player, playerGroup.all()) : state.rules.defaultTeam);
|
||||
player.setTeam(netServer.assignTeam(player, playerGroup.all()));
|
||||
player.setDead(true);
|
||||
player.add();
|
||||
|
||||
|
|
|
|||
|
|
@ -160,9 +160,17 @@ public class NetClient implements ApplicationListener{
|
|||
throw new ValidateException(player, "Player has sent a message above the text limit.");
|
||||
}
|
||||
|
||||
String original = message;
|
||||
|
||||
//check if it's a command
|
||||
CommandResponse response = netServer.clientCommands.handleMessage(message, player);
|
||||
if(response.type == ResponseType.noCommand){ //no command to handle
|
||||
message = netServer.admins.filterMessage(player, message);
|
||||
//supress chat message if it's filtered out
|
||||
if(message == null){
|
||||
return;
|
||||
}
|
||||
|
||||
//server console logging
|
||||
Log.info("&y{0}: &lb{1}", player.name, message);
|
||||
|
||||
|
|
@ -190,7 +198,7 @@ public class NetClient implements ApplicationListener{
|
|||
}
|
||||
}
|
||||
|
||||
Events.fire(new PlayerChatEvent(player, message));
|
||||
Events.fire(new PlayerChatEvent(player, message, original));
|
||||
}
|
||||
|
||||
public static String colorizeName(int id, String name){
|
||||
|
|
|
|||
|
|
@ -33,14 +33,31 @@ import static mindustry.Vars.*;
|
|||
|
||||
public class NetServer implements ApplicationListener{
|
||||
private final static int maxSnapshotSize = 430, timerBlockSync = 0;
|
||||
private final static float serverSyncTime = 12, kickDuration = 30 * 1000, blockSyncTime = 60 * 10;
|
||||
private final static float serverSyncTime = 12, kickDuration = 30 * 1000, blockSyncTime = 60 * 8;
|
||||
private final static Vec2 vector = new Vec2();
|
||||
private final static Rectangle viewport = new Rectangle();
|
||||
private final static Rect viewport = new Rect();
|
||||
/** If a player goes away of their server-side coordinates by this distance, they get teleported back. */
|
||||
private final static float correctDist = 16f;
|
||||
|
||||
public final Administration admins = new Administration();
|
||||
public final CommandHandler clientCommands = new CommandHandler("/");
|
||||
public TeamAssigner assigner = (player, players) -> {
|
||||
if(state.rules.pvp){
|
||||
//find team with minimum amount of players and auto-assign player to that.
|
||||
TeamData re = state.teams.getActive().min(data -> {
|
||||
int count = 0;
|
||||
for(Player other : players){
|
||||
if(other.getTeam() == data.team && other != player){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
});
|
||||
return re == null ? null : re.team;
|
||||
}
|
||||
|
||||
return state.rules.defaultTeam;
|
||||
};
|
||||
|
||||
private boolean closing = false;
|
||||
private Interval timer = new Interval();
|
||||
|
|
@ -199,10 +216,8 @@ public class NetServer implements ApplicationListener{
|
|||
con.player = player;
|
||||
|
||||
//playing in pvp mode automatically assigns players to teams
|
||||
if(state.rules.pvp){
|
||||
player.setTeam(assignTeam(player, playerGroup.all()));
|
||||
Log.info("Auto-assigned player {0} to team {1}.", player.name, player.getTeam());
|
||||
}
|
||||
player.setTeam(assignTeam(player, playerGroup.all()));
|
||||
Log.info("Auto-assigned player {0} to team {1}.", player.name, player.getTeam());
|
||||
|
||||
sendWorldData(player);
|
||||
|
||||
|
|
@ -403,17 +418,7 @@ public class NetServer implements ApplicationListener{
|
|||
}
|
||||
|
||||
public Team assignTeam(Player current, Iterable<Player> players){
|
||||
//find team with minimum amount of players and auto-assign player to that.
|
||||
TeamData re = state.teams.getActive().min(data -> {
|
||||
int count = 0;
|
||||
for(Player other : players){
|
||||
if(other.getTeam() == data.team && other != current){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
});
|
||||
return re == null ? null : re.team;
|
||||
return assigner.assign(current, players);
|
||||
}
|
||||
|
||||
public void sendWorldData(Player player){
|
||||
|
|
@ -784,4 +789,8 @@ public class NetServer implements ApplicationListener{
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public interface TeamAssigner{
|
||||
Team assign(Player player, Iterable<Player> players);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class Renderer implements ApplicationListener{
|
|||
private float camerascale = targetscale;
|
||||
private float landscale = 0f, landTime;
|
||||
private float minZoomScl = Scl.scl(0.01f);
|
||||
private Rectangle rect = new Rectangle(), rect2 = new Rectangle();
|
||||
private Rect rect = new Rect(), rect2 = new Rect();
|
||||
private float shakeIntensity, shaketime;
|
||||
|
||||
public Renderer(){
|
||||
|
|
@ -56,8 +56,8 @@ public class Renderer implements ApplicationListener{
|
|||
Effects.setEffectProvider((effect, color, x, y, rotation, data) -> {
|
||||
if(effect == Fx.none) return;
|
||||
if(Core.settings.getBool("effects")){
|
||||
Rectangle view = camera.bounds(rect);
|
||||
Rectangle pos = rect2.setSize(effect.size).setCenter(x, y);
|
||||
Rect view = camera.bounds(rect);
|
||||
Rect pos = rect2.setSize(effect.size).setCenter(x, y);
|
||||
|
||||
if(view.overlaps(pos)){
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class MapView extends Element implements GestureListener{
|
|||
private boolean grid = false;
|
||||
private GridImage image = new GridImage(0, 0);
|
||||
private Vec2 vec = new Vec2();
|
||||
private Rectangle rect = new Rectangle();
|
||||
private Rect rect = new Rect();
|
||||
private Vec2[][] brushPolygons = new Vec2[MapEditor.brushSizes.length][0];
|
||||
|
||||
private boolean drawing;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ import static mindustry.Vars.*;
|
|||
|
||||
/** Utility class for damaging in an area. */
|
||||
public class Damage{
|
||||
private static Rectangle rect = new Rectangle();
|
||||
private static Rectangle hitrect = new Rectangle();
|
||||
private static Rect rect = new Rect();
|
||||
private static Rect hitrect = new Rect();
|
||||
private static Vec2 tr = new Vec2();
|
||||
private static GridBits bits = new GridBits(30, 30);
|
||||
private static IntQueue propagation = new IntQueue();
|
||||
|
|
@ -127,7 +127,7 @@ public class Damage{
|
|||
|
||||
Cons<Unit> cons = e -> {
|
||||
e.hitbox(hitrect);
|
||||
Rectangle other = hitrect;
|
||||
Rect other = hitrect;
|
||||
other.y -= expand;
|
||||
other.x -= expand;
|
||||
other.width += expand * 2;
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ public class EntityCollisions{
|
|||
private static final float seg = 1f;
|
||||
|
||||
//tile collisions
|
||||
private Rectangle tmp = new Rectangle();
|
||||
private Rect tmp = new Rect();
|
||||
private Vec2 vector = new Vec2();
|
||||
private Vec2 l1 = new Vec2();
|
||||
private Rectangle r1 = new Rectangle();
|
||||
private Rectangle r2 = new Rectangle();
|
||||
private Rect r1 = new Rect();
|
||||
private Rect r2 = new Rect();
|
||||
|
||||
//entity collisions
|
||||
private Array<SolidTrait> arrOut = new Array<>();
|
||||
|
|
@ -57,7 +57,7 @@ public class EntityCollisions{
|
|||
|
||||
public void moveDelta(SolidTrait entity, float deltax, float deltay, boolean x){
|
||||
|
||||
Rectangle rect = r1;
|
||||
Rect rect = r1;
|
||||
entity.hitboxTile(rect);
|
||||
entity.hitboxTile(r2);
|
||||
rect.x += deltax;
|
||||
|
|
@ -84,7 +84,7 @@ public class EntityCollisions{
|
|||
entity.setY(entity.getY() + rect.y - r2.y);
|
||||
}
|
||||
|
||||
public boolean overlapsTile(Rectangle rect){
|
||||
public boolean overlapsTile(Rect rect){
|
||||
rect.getCenter(vector);
|
||||
int r = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ public class EntityGroup<T extends Entity>{
|
|||
private final Array<T> entitiesToRemove = new Array<>(false, 32);
|
||||
private final Array<T> entitiesToAdd = new Array<>(false, 32);
|
||||
private final Array<T> intersectArray = new Array<>();
|
||||
private final Rectangle intersectRect = new Rectangle();
|
||||
private final Rect intersectRect = new Rect();
|
||||
private IntMap<T> map;
|
||||
private QuadTree tree;
|
||||
private Cons<T> removeListener;
|
||||
private Cons<T> addListener;
|
||||
|
||||
private final Rectangle viewport = new Rectangle();
|
||||
private final Rect viewport = new Rect();
|
||||
private int count = 0;
|
||||
|
||||
public EntityGroup(int id, Class<T> type, boolean useTree){
|
||||
|
|
@ -34,7 +34,7 @@ public class EntityGroup<T extends Entity>{
|
|||
this.type = type;
|
||||
|
||||
if(useTree){
|
||||
tree = new QuadTree<>(new Rectangle(0, 0, 0, 0));
|
||||
tree = new QuadTree<>(new Rect(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ public class EntityGroup<T extends Entity>{
|
|||
/** Resizes the internal quadtree, if it is enabled.*/
|
||||
public void resize(float x, float y, float w, float h){
|
||||
if(useTree){
|
||||
tree = new QuadTree<>(new Rectangle(x, y, w, h));
|
||||
tree = new QuadTree<>(new Rect(x, y, w, h));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import static mindustry.Vars.*;
|
|||
|
||||
/** Utility class for unit and team interactions.*/
|
||||
public class Units{
|
||||
private static Rectangle hitrect = new Rectangle();
|
||||
private static Rect hitrect = new Rect();
|
||||
private static Unit result;
|
||||
private static float cdist;
|
||||
private static boolean boolResult;
|
||||
|
|
@ -188,7 +188,7 @@ public class Units{
|
|||
}
|
||||
|
||||
/** Iterates over all units in a rectangle. */
|
||||
public static void nearby(Rectangle rect, Cons<Unit> cons){
|
||||
public static void nearby(Rect rect, Cons<Unit> cons){
|
||||
nearby(rect.x, rect.y, rect.width, rect.height, cons);
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ public class Units{
|
|||
}
|
||||
|
||||
/** Iterates over all units that are enemies of this team. */
|
||||
public static void nearbyEnemies(Team team, Rectangle rect, Cons<Unit> cons){
|
||||
public static void nearbyEnemies(Team team, Rect rect, Cons<Unit> cons){
|
||||
nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package mindustry.entities.bullet;
|
||||
|
||||
import arc.math.geom.Rectangle;
|
||||
import arc.math.geom.Rect;
|
||||
import arc.util.Time;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.Units;
|
||||
import mindustry.entities.type.Bullet;
|
||||
|
||||
public class FlakBulletType extends BasicBulletType{
|
||||
protected static Rectangle rect = new Rectangle();
|
||||
protected static Rect rect = new Rect();
|
||||
protected float explodeRange = 30f;
|
||||
|
||||
public FlakBulletType(float speed, float damage){
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
|
|||
public static final float lifetime = 10f;
|
||||
|
||||
private static final RandomXS128 random = new RandomXS128();
|
||||
private static final Rectangle rect = new Rectangle();
|
||||
private static final Rect rect = new Rect();
|
||||
private static final Array<Unit> entities = new Array<>();
|
||||
private static final IntSet hit = new IntSet();
|
||||
private static final int maxChain = 8;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
|||
private static final float maxLiquid = 70f;
|
||||
private static final int maxGeneration = 2;
|
||||
private static final Color tmp = new Color();
|
||||
private static final Rectangle rect = new Rectangle();
|
||||
private static final Rectangle rect2 = new Rectangle();
|
||||
private static final Rect rect = new Rect();
|
||||
private static final Rect rect2 = new Rect();
|
||||
private static int seeds;
|
||||
|
||||
private int loadedPosition = -1;
|
||||
|
|
@ -151,13 +151,13 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
|||
}
|
||||
|
||||
@Override
|
||||
public void hitbox(Rectangle rectangle){
|
||||
rectangle.setCenter(x, y).setSize(tilesize);
|
||||
public void hitbox(Rect rect){
|
||||
rect.setCenter(x, y).setSize(tilesize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitboxTile(Rectangle rectangle){
|
||||
rectangle.setCenter(x, y).setSize(0f);
|
||||
public void hitboxTile(Rect rect){
|
||||
rect.setCenter(x, y).setSize(0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ public interface BuilderTrait extends Entity, TeamTrait{
|
|||
return this;
|
||||
}
|
||||
|
||||
public Rectangle bounds(Rectangle rect){
|
||||
public Rect bounds(Rect rect){
|
||||
if(breaking){
|
||||
return rect.set(-100f, -100f, 0f, 0f);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ import mindustry.Vars;
|
|||
|
||||
public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, Entity, Position{
|
||||
|
||||
void hitbox(Rectangle rectangle);
|
||||
void hitbox(Rect rect);
|
||||
|
||||
void hitboxTile(Rectangle rectangle);
|
||||
void hitboxTile(Rect rect);
|
||||
|
||||
Vec2 lastPosition();
|
||||
|
||||
|
|
|
|||
|
|
@ -352,13 +352,13 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void hitbox(Rectangle rectangle){
|
||||
rectangle.setSize(type.hitsize).setCenter(x, y);
|
||||
public void hitbox(Rect rect){
|
||||
rect.setSize(type.hitsize).setCenter(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitboxTile(Rectangle rectangle){
|
||||
rectangle.setSize(type.hitsizeTile).setCenter(x, y);
|
||||
public void hitboxTile(Rect rect){
|
||||
rect.setSize(type.hitsizeTile).setCenter(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -246,13 +246,13 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool
|
|||
}
|
||||
|
||||
@Override
|
||||
public void hitbox(Rectangle rectangle){
|
||||
rectangle.setSize(type.hitSize).setCenter(x, y);
|
||||
public void hitbox(Rect rect){
|
||||
rect.setSize(type.hitSize).setCenter(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitboxTile(Rectangle rectangle){
|
||||
rectangle.setSize(type.hitSize).setCenter(x, y);
|
||||
public void hitboxTile(Rect rect){
|
||||
rect.setSize(type.hitSize).setCenter(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
|||
private static final int timerShootRight = 1;
|
||||
private static final float liftoffBoost = 0.2f;
|
||||
|
||||
private static final Rectangle rect = new Rectangle();
|
||||
private static final Rect rect = new Rect();
|
||||
|
||||
//region instance variables
|
||||
|
||||
|
|
@ -93,13 +93,13 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void hitbox(Rectangle rectangle){
|
||||
rectangle.setSize(mech.hitsize).setCenter(x, y);
|
||||
public void hitbox(Rect rect){
|
||||
rect.setSize(mech.hitsize).setCenter(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitboxTile(Rectangle rectangle){
|
||||
rectangle.setSize(mech.hitsize * 2f / 3f).setCenter(x, y);
|
||||
public void hitboxTile(Rect rect){
|
||||
rect.setSize(mech.hitsize * 2f / 3f).setCenter(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -62,10 +62,13 @@ public class EventType{
|
|||
public static class PlayerChatEvent{
|
||||
public final Player player;
|
||||
public final String message;
|
||||
/** The original, unfiltered message. */
|
||||
public final String originalMessage;
|
||||
|
||||
public PlayerChatEvent(Player player, String message){
|
||||
public PlayerChatEvent(Player player, String message, String originalMessage){
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
this.originalMessage = originalMessage;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,8 @@ public class Rules{
|
|||
public Team defaultTeam = Team.sharded;
|
||||
/** team of the enemy in waves/sectors */
|
||||
public Team waveTeam = Team.crux;
|
||||
/** special tags for additional info */
|
||||
public StringMap tags = new StringMap();
|
||||
|
||||
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
|
||||
public Rules copy(){
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class MinimapRenderer implements Disposable{
|
|||
private Pixmap pixmap;
|
||||
private Texture texture;
|
||||
private TextureRegion region;
|
||||
private Rectangle rect = new Rectangle();
|
||||
private Rect rect = new Rect();
|
||||
private float zoom = 4;
|
||||
|
||||
public MinimapRenderer(){
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import static mindustry.Vars.*;
|
|||
public class OverlayRenderer{
|
||||
private static final float indicatorLength = 14f;
|
||||
private static final float spawnerMargin = tilesize*11f;
|
||||
private static final Rectangle rect = new Rectangle();
|
||||
private static final Rect rect = new Rect();
|
||||
private float buildFadeTime;
|
||||
|
||||
public void drawBottom(){
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
/** Maximum line length. */
|
||||
final static int maxLength = 100;
|
||||
final static Vec2 stackTrns = new Vec2();
|
||||
final static Rectangle r1 = new Rectangle(), r2 = new Rectangle();
|
||||
final static Rect r1 = new Rect(), r2 = new Rect();
|
||||
/** Distance on the back from where items originate. */
|
||||
final static float backTrns = 3f;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class JsonIO{
|
|||
|
||||
@Override
|
||||
public void writeValue(Object value, Class knownType, Class elementType){
|
||||
if(value instanceof mindustry.ctype.MappableContent){
|
||||
if(value instanceof MappableContent){
|
||||
try{
|
||||
getWriter().value(((MappableContent)value).name);
|
||||
}catch(IOException e){
|
||||
|
|
@ -95,6 +95,18 @@ public class JsonIO{
|
|||
}
|
||||
});
|
||||
|
||||
json.setSerializer(Team.class, new Serializer<Team>(){
|
||||
@Override
|
||||
public void write(Json json, Team object, Class knownType){
|
||||
json.writeValue(object.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Team read(Json json, JsonValue jsonData, Class type){
|
||||
return Team.get(jsonData.asInt());
|
||||
}
|
||||
});
|
||||
|
||||
json.setSerializer(Block.class, new Serializer<Block>(){
|
||||
@Override
|
||||
public void write(Json json, Block object, Class knownType){
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package mindustry.net;
|
||||
|
||||
import arc.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.Vars;
|
||||
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.type.*;
|
||||
|
||||
import static mindustry.Vars.headless;
|
||||
import static mindustry.game.EventType.*;
|
||||
|
|
@ -14,6 +15,7 @@ public class Administration{
|
|||
private ObjectMap<String, PlayerInfo> playerInfo = new ObjectMap<>();
|
||||
private Array<String> bannedIPs = new Array<>();
|
||||
private Array<String> whitelist = new Array<>();
|
||||
private Array<ChatFilter> chatFilters = new Array<>();
|
||||
|
||||
public Administration(){
|
||||
Core.settings.defaults(
|
||||
|
|
@ -24,6 +26,23 @@ public class Administration{
|
|||
load();
|
||||
}
|
||||
|
||||
/** Adds a chat filter. This will transform the chat messages of every player.
|
||||
* This functionality can be used to implement things like swear filters and special commands.
|
||||
* Note that commands (starting with /) are not filtered.*/
|
||||
public void addChatFilter(ChatFilter filter){
|
||||
chatFilters.add(filter);
|
||||
}
|
||||
|
||||
/** Filters out a chat message. */
|
||||
public @Nullable String filterMessage(Player player, String message){
|
||||
String current = message;
|
||||
for(ChatFilter f : chatFilters){
|
||||
current = f.filter(player, message);
|
||||
if(current == null) return null;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
public int getPlayerLimit(){
|
||||
return Core.settings.getInt("playerlimit", 0);
|
||||
}
|
||||
|
|
@ -334,6 +353,11 @@ public class Administration{
|
|||
}
|
||||
}
|
||||
|
||||
public interface ChatFilter{
|
||||
/** @return the filtered message; a null string signals that the message should not be sent. */
|
||||
@Nullable String filter(Player player, String message);
|
||||
}
|
||||
|
||||
public static class TraceInfo{
|
||||
public String ip, uuid;
|
||||
public boolean modded, mobile;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import arc.util.pooling.*;
|
|||
import mindustry.gen.*;
|
||||
|
||||
public class Bar extends Element{
|
||||
private static Rectangle scissor = new Rectangle();
|
||||
private static Rect scissor = new Rect();
|
||||
|
||||
private Floatp fraction;
|
||||
private String name = "";
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class DeployDialog extends FloatingDialog{
|
|||
private final float nodeSize = Scl.scl(230f);
|
||||
private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
|
||||
private ZoneInfoDialog info = new ZoneInfoDialog();
|
||||
private Rectangle bounds = new Rectangle();
|
||||
private Rect bounds = new Rect();
|
||||
private View view = new View();
|
||||
|
||||
public DeployDialog(){
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class TechTreeDialog extends FloatingDialog{
|
|||
private final float nodeSize = Scl.scl(60f);
|
||||
private ObjectSet<TechTreeNode> nodes = new ObjectSet<>();
|
||||
private TechTreeNode root = new TechTreeNode(TechTree.root, null);
|
||||
private Rectangle bounds = new Rectangle();
|
||||
private Rect bounds = new Rect();
|
||||
private ItemsDisplay items;
|
||||
private View view;
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ public class TechTreeDialog extends FloatingDialog{
|
|||
miny = Math.min(n.y - n.height/2f, miny);
|
||||
maxy = Math.max(n.y + n.height/2f, maxy);
|
||||
}
|
||||
bounds = new Rectangle(minx, miny, maxx - minx, maxy - miny);
|
||||
bounds = new Rect(minx, miny, maxx - minx, maxy - miny);
|
||||
bounds.y += nodeSize*1.5f;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ public class BranchTreeLayout implements TreeLayout{
|
|||
}
|
||||
}
|
||||
|
||||
public Rectangle getBounds(){
|
||||
return new Rectangle(boundsLeft, boundsBottom, boundsRight - boundsLeft, boundsTop - boundsBottom);
|
||||
public Rect getBounds(){
|
||||
return new Rect(boundsLeft, boundsBottom, boundsRight - boundsLeft, boundsTop - boundsBottom);
|
||||
}
|
||||
|
||||
private void calcSizeOfLevels(TreeNode node, int level){
|
||||
|
|
|
|||
|
|
@ -864,7 +864,7 @@ public class Block extends BlockStorage{
|
|||
return ((size + 1) % 2) * tilesize / 2f;
|
||||
}
|
||||
|
||||
public Rectangle bounds(int x, int y, Rectangle rect){
|
||||
public Rect bounds(int x, int y, Rect rect){
|
||||
return rect.setSize(size * tilesize).setCenter(x * tilesize + offset(), y * tilesize + offset());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ public class Tile implements Position, TargetTrait{
|
|||
return tmpArray;
|
||||
}
|
||||
|
||||
public Rectangle getHitbox(Rectangle rect){
|
||||
public Rect getHitbox(Rect rect){
|
||||
return rect.setSize(block().size * tilesize).setCenter(drawx(), drawy());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ public class DeflectorWall extends Wall{
|
|||
public static final float hitTime = 10f;
|
||||
|
||||
protected float maxDamageDeflect = 10f;
|
||||
protected Rectangle rect = new Rectangle();
|
||||
protected Rectangle rect2 = new Rectangle();
|
||||
protected Rect rect = new Rect();
|
||||
protected Rect rect2 = new Rect();
|
||||
|
||||
public DeflectorWall(String name){
|
||||
super(name);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import java.io.*;
|
|||
import static mindustry.Vars.*;
|
||||
|
||||
public class Door extends Wall{
|
||||
protected final static Rectangle rect = new Rectangle();
|
||||
protected final static Rect rect = new Rect();
|
||||
|
||||
public final int timerToggle = timers++;
|
||||
public Effect openfx = Fx.dooropen;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import arc.graphics.Color;
|
|||
import arc.graphics.g2d.*;
|
||||
import arc.math.Angles;
|
||||
import arc.math.Mathf;
|
||||
import arc.math.geom.Rectangle;
|
||||
import arc.math.geom.Rect;
|
||||
import arc.util.Time;
|
||||
import mindustry.entities.Units;
|
||||
import mindustry.entities.type.TileEntity;
|
||||
|
|
@ -19,7 +19,7 @@ import mindustry.world.meta.*;
|
|||
import static mindustry.Vars.tilesize;
|
||||
|
||||
public class RepairPoint extends Block{
|
||||
private static Rectangle rect = new Rectangle();
|
||||
private static Rect rect = new Rect();
|
||||
|
||||
public int timerTarget = timers++;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=29782072a3c824715118f51ebe23c189ba0d9597
|
||||
archash=60a9ebe264f92f2c3082596c77b9ab29474c4a7f
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import arc.util.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.io.TypeIO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import mindustry.io.*;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.*;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class IOTests{
|
||||
|
||||
|
|
@ -49,5 +49,23 @@ public class IOTests{
|
|||
assertEquals(rules.attackMode, res.attackMode);
|
||||
}
|
||||
|
||||
@Test
|
||||
void writeRules2(){
|
||||
Rules rules = new Rules();
|
||||
rules.attackMode = true;
|
||||
rules.tags.put("blah", "bleh");
|
||||
rules.buildSpeedMultiplier = 99.1f;
|
||||
|
||||
String str = JsonIO.write(rules);
|
||||
Rules res = JsonIO.read(Rules.class, str);
|
||||
|
||||
assertEquals(rules.buildSpeedMultiplier, res.buildSpeedMultiplier);
|
||||
assertEquals(rules.attackMode, res.attackMode);
|
||||
assertEquals(rules.tags.get("blah"), res.tags.get("blah"));
|
||||
|
||||
String str2 = JsonIO.write(new Rules(){{
|
||||
attackMode = true;
|
||||
}});
|
||||
Log.info(str2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue