mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-04 20:30:20 +03:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69944a2b63 | ||
|
|
0ceb58a105 | ||
|
|
5e8da856e7 | ||
|
|
ee412e1994 | ||
|
|
02736524bd | ||
|
|
c357b97b3b | ||
|
|
dbe7251c6b | ||
|
|
7ae90f655c | ||
|
|
669ce6dfbb | ||
|
|
4dc55e5594 | ||
|
|
4b824f7a4c | ||
|
|
3435132e87 | ||
|
|
d49b15b2a0 |
@@ -69,7 +69,8 @@ android{
|
||||
}
|
||||
|
||||
defaultConfig{
|
||||
Integer vcode = new Properties().with{p -> p.load(new FileInputStream(file('../core/assets/version.properties'))); return p }['androidBuildCode']?.toInteger() ?: 1
|
||||
Properties props = new Properties().with{p -> p.load(file('../core/assets/version.properties').newReader()); return p }
|
||||
Integer vcode = props['androidBuildCode']?.toInteger() ?: 1
|
||||
def versionNameResult = "$versionNumber-$versionType-${getBuildVersion().replace(" ", "-")}"
|
||||
|
||||
applicationId "io.anuke.mindustry"
|
||||
@@ -78,6 +79,9 @@ android{
|
||||
|
||||
versionName versionNameResult
|
||||
versionCode vcode
|
||||
|
||||
props['androidBuildCode'] = (vcode + 1).toString()
|
||||
props.store(file('../core/assets/version.properties').newWriter(), null)
|
||||
}
|
||||
|
||||
compileOptions{
|
||||
|
||||
@@ -288,6 +288,7 @@ editor.resizemap = Resize Map
|
||||
editor.mapname = Map Name:
|
||||
editor.overwrite = [accent]Warning!\nThis overwrites an existing map.
|
||||
editor.overwrite.confirm = [scarlet]Warning![] A map with this name already exists. Are you sure you want to overwrite it?
|
||||
editor.exists = A map with this name already exists.
|
||||
editor.selectmap = Select a map to load:
|
||||
|
||||
toolmode.replace = Replace
|
||||
|
||||
@@ -46,6 +46,7 @@ public class StatusEffects implements ContentList{
|
||||
if(unit.getTeam() == waveTeam){
|
||||
Events.fire(Trigger.shock);
|
||||
}
|
||||
result.set(this, time);
|
||||
}));
|
||||
opposite(() -> burning);
|
||||
}};
|
||||
|
||||
@@ -371,7 +371,11 @@ public class Control implements ApplicationListener, Loadable{
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
//TODO find out why this happens on Android
|
||||
if(assets == null) return;
|
||||
|
||||
saves.update();
|
||||
|
||||
//update and load any requested assets
|
||||
assets.update();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.core;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.Input.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.math.*;
|
||||
@@ -25,6 +26,11 @@ public interface Platform{
|
||||
/** Steam: Share a map on the workshop.*/
|
||||
default void publishMap(Map map){}
|
||||
|
||||
/** Steam: Return external workshop maps to be loaded.*/
|
||||
default Array<FileHandle> getExternalMaps(){
|
||||
return Array.with();
|
||||
}
|
||||
|
||||
/** Steam: Open workshop for maps.*/
|
||||
default void openWorkshop(){}
|
||||
|
||||
|
||||
@@ -325,8 +325,9 @@ public class UI implements ApplicationListener, Loadable{
|
||||
cont.row();
|
||||
cont.addImage().width(300f).pad(2).height(4f).color(Color.scarlet);
|
||||
cont.row();
|
||||
cont.add(text).pad(2f).growX().wrap();
|
||||
buttons.addButton("$ok", this::hide).size(120, 50).pad(4);
|
||||
cont.add(text).pad(2f).growX().wrap().get().setAlignment(Align.center);
|
||||
cont.row();
|
||||
cont.addButton("$ok", this::hide).size(120, 50).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ public class EntityGroup<T extends Entity>{
|
||||
private final Array<T> entityArray = new Array<>(false, 32);
|
||||
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 IntMap<T> map;
|
||||
private QuadTree tree;
|
||||
private Consumer<T> removeListener;
|
||||
@@ -161,6 +163,15 @@ public class EntityGroup<T extends Entity>{
|
||||
tree().getIntersect(out, x, y, width, height);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Array<T> intersect(float x, float y, float width, float height){
|
||||
intersectArray.clear();
|
||||
//don't waste time for empty groups
|
||||
if(isEmpty()) return intersectArray;
|
||||
tree().getIntersect(intersectArray, intersectRect.set(x, y, width, height));
|
||||
return intersectArray;
|
||||
}
|
||||
|
||||
public QuadTree tree(){
|
||||
if(!useTree) throw new RuntimeException("This group does not support quadtrees! Enable quadtrees when creating it.");
|
||||
return tree;
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.entities.type;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
@@ -212,15 +213,24 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
float radScl = 1.5f;
|
||||
float fsize = getSize() / radScl;
|
||||
moveVector.setZero();
|
||||
float cx = x - fsize/2f, cy = y - fsize/2f;
|
||||
|
||||
Units.nearby(x - fsize/2f, y - fsize/2f, fsize, fsize, en -> {
|
||||
if(en == this || en.isFlying() != isFlying()) return;
|
||||
for(Team team : Team.all){
|
||||
avoid(unitGroups[team.ordinal()].intersect(cx, cy, fsize, fsize));
|
||||
}
|
||||
|
||||
avoid(playerGroup.intersect(cx, cy, fsize, fsize));
|
||||
velocity.add(moveVector.x / mass() * Time.delta(), moveVector.y / mass() * Time.delta());
|
||||
}
|
||||
|
||||
private void avoid(Array<? extends Unit> arr){
|
||||
float radScl = 1.5f;
|
||||
|
||||
for(Unit en : arr){
|
||||
float dst = dst(en);
|
||||
float scl = Mathf.clamp(1f - dst / (getSize()/(radScl*2f) + en.getSize()/(radScl*2f)));
|
||||
moveVector.add(Tmp.v1.set((x - en.x) * scl, (y - en.y) * scl).limit(0.4f));
|
||||
});
|
||||
|
||||
velocity.add(moveVector.x / mass() * Time.delta(), moveVector.y / mass() * Time.delta());
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable TileEntity getClosestCore(){
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package io.anuke.mindustry.entities.units;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.Bits;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.Tmp;
|
||||
import io.anuke.arc.util.pooling.Pools;
|
||||
import io.anuke.mindustry.content.StatusEffects;
|
||||
import io.anuke.mindustry.entities.traits.Saveable;
|
||||
import io.anuke.mindustry.entities.type.Unit;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.StatusEffect;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.pooling.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -28,8 +26,8 @@ public class Statuses implements Saveable{
|
||||
private float damageMultiplier;
|
||||
private float armorMultiplier;
|
||||
|
||||
public void handleApply(io.anuke.mindustry.entities.type.Unit unit, StatusEffect effect, float duration){
|
||||
if(effect == StatusEffects.none || unit.isImmune(effect)) return; //don't apply empty or immune effects
|
||||
public void handleApply(Unit unit, StatusEffect effect, float duration){
|
||||
if(effect == StatusEffects.none || effect == null || unit.isImmune(effect)) return; //don't apply empty or immune effects
|
||||
|
||||
if(statuses.size > 0){
|
||||
//check for opposite effects
|
||||
@@ -39,6 +37,7 @@ public class Statuses implements Saveable{
|
||||
entry.time = Math.max(entry.time, duration);
|
||||
return;
|
||||
}else if(entry.effect.reactsWith(effect)){ //find opposite
|
||||
globalResult.effect = entry.effect;
|
||||
entry.effect.getTransition(unit, effect, entry.time, duration, globalResult);
|
||||
entry.time = globalResult.time;
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ public class Tutorial{
|
||||
}
|
||||
},;
|
||||
|
||||
protected final String line = Core.bundle.has("tutorial." + name() + ".mobile") && mobile ? "tutorial." + name() + ".mobile" : "tutorial." + name();
|
||||
protected String line = "";
|
||||
protected final Function<String, String> text;
|
||||
protected Array<String> sentences;
|
||||
protected final BooleanProvider done;
|
||||
@@ -203,7 +203,10 @@ public class Tutorial{
|
||||
|
||||
/** displayed tutorial stage text.*/
|
||||
public String text(){
|
||||
if(sentences == null) this.sentences = Array.select(Core.bundle.get(line).split("\n"), s -> !s.isEmpty());
|
||||
if(sentences == null){
|
||||
this.line = Core.bundle.has("tutorial." + name() + ".mobile") && mobile ? "tutorial." + name() + ".mobile" : "tutorial." + name();
|
||||
this.sentences = Array.select(Core.bundle.get(line).split("\n"), s -> !s.isEmpty());
|
||||
}
|
||||
String line = sentences.get(control.tutorial.sentence);
|
||||
return line.contains("{") ? text.get(line) : line;
|
||||
}
|
||||
|
||||
@@ -67,33 +67,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
public MobileInput(){
|
||||
Events.on(ClientLoadEvent.class, e -> {
|
||||
GestureDetector dec = new GestureDetector(20, 0.5f, 0.4f, 0.15f, this){
|
||||
boolean clearMouse = false;
|
||||
|
||||
@Override
|
||||
public boolean touchDown(int x, int y, int pointer, KeyCode button){
|
||||
if(Core.scene.hasMouse(x, y)){
|
||||
clearMouse = true;
|
||||
return false;
|
||||
}
|
||||
return super.touchDown(x, y, pointer, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchDragged(int x, int y, int pointer){
|
||||
if(!clearMouse){
|
||||
return super.touchDragged(x, y, pointer);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchUp(int x, int y, int pointer, KeyCode button){
|
||||
clearMouse = false;
|
||||
return super.touchUp(x, y, pointer, button);
|
||||
}
|
||||
};
|
||||
Core.input.getInputProcessors().insert(0, dec);
|
||||
Core.input.getInputProcessors().add(new GestureDetector(20, 0.5f, 0.4f, 0.15f, this));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.anuke.arc.assets.loaders.*;
|
||||
import io.anuke.arc.assets.loaders.resolvers.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
|
||||
@@ -25,6 +26,21 @@ public class MapPreviewLoader extends TextureLoader{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Texture loadSync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter){
|
||||
try{
|
||||
return super.loadSync(manager, fileName, file, parameter);
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
try{
|
||||
return new Texture(file);
|
||||
}catch(Throwable e2){
|
||||
e2.printStackTrace();
|
||||
return new Texture("sprites/error.png");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureParameter parameter){
|
||||
return Array.with(new AssetDescriptor<>("contentcreate", Content.class));
|
||||
|
||||
@@ -67,7 +67,7 @@ public class Plugins{
|
||||
URLClassLoader classLoader = new URLClassLoader(new URL[]{jar.file().toURI().toURL()}, ClassLoader.getSystemClassLoader());
|
||||
Class<?> main = classLoader.loadClass(meta.main);
|
||||
metas.put(main, meta);
|
||||
return new LoadedPlugin(jar, zip, (Plugin)main.newInstance(), meta);
|
||||
return new LoadedPlugin(jar, zip, (Plugin)main.getDeclaredConstructor().newInstance(), meta);
|
||||
}
|
||||
|
||||
/** Represents a plugin that has been loaded from a jar file.*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import io.anuke.arc.collection.ObjectMap;
|
||||
import io.anuke.arc.function.Supplier;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.Effects.Effect;
|
||||
|
||||
@@ -53,12 +53,18 @@ public class MapsDialog extends FloatingDialog{
|
||||
|
||||
buttons.addImageTextButton("$editor.newmap", Icon.add, () -> {
|
||||
ui.showTextInput("$editor.newmap", "$name", "", text -> {
|
||||
ui.loadAnd(() -> {
|
||||
Runnable show = () -> ui.loadAnd(() -> {
|
||||
hide();
|
||||
ui.editor.show();
|
||||
ui.editor.editor.getTags().put("name", text);
|
||||
Events.fire(new MapMakeEvent());
|
||||
});
|
||||
|
||||
if(maps.byName(text) != null){
|
||||
ui.showErrorMessage("$editor.exists");
|
||||
}else{
|
||||
show.run();
|
||||
}
|
||||
});
|
||||
}).size(210f, 64f);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class MinimapDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
cont.clearChildren();
|
||||
cont.clear();
|
||||
|
||||
cont.table(Tex.pane,t -> {
|
||||
t.addRect((x, y, width, height) -> {
|
||||
|
||||
@@ -32,7 +32,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class BlockInventoryFragment extends Fragment{
|
||||
private final static float holdWithdraw = 20f;
|
||||
|
||||
private Table table;
|
||||
private Table table = new Table();
|
||||
private Tile tile;
|
||||
private float holdTime = 0f;
|
||||
private boolean holding;
|
||||
@@ -52,7 +52,6 @@ public class BlockInventoryFragment extends Fragment{
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
table = new Table();
|
||||
table.setName("inventory");
|
||||
table.setTransform(true);
|
||||
parent.setTransform(true);
|
||||
|
||||
@@ -572,9 +572,6 @@ public class HudFragment extends Fragment{
|
||||
}
|
||||
|
||||
shown = !shown;
|
||||
if(flip != null){
|
||||
flip.getParent().act(Core.graphics.getDeltaTime());
|
||||
}
|
||||
}
|
||||
|
||||
private void addWaveTable(Button table){
|
||||
|
||||
@@ -24,7 +24,6 @@ public class ItemBridge extends Block{
|
||||
protected int timerTransport = timers++;
|
||||
protected int range;
|
||||
protected float transportTime = 2f;
|
||||
protected IntArray removals = new IntArray();
|
||||
protected TextureRegion endRegion, bridgeRegion, arrowRegion;
|
||||
|
||||
private static int lastPlaced = Pos.invalid;
|
||||
@@ -162,21 +161,15 @@ public class ItemBridge extends Block{
|
||||
entity.time += entity.cycleSpeed * entity.delta();
|
||||
entity.time2 += (entity.cycleSpeed - 1f) * entity.delta();
|
||||
|
||||
removals.clear();
|
||||
|
||||
IntSetIterator it = entity.incoming.iterator();
|
||||
|
||||
while(it.hasNext){
|
||||
int i = it.next();
|
||||
Tile other = world.tile(i);
|
||||
if(!linkValid(tile, other, false)){
|
||||
removals.add(i);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
for(int j = 0; j < removals.size; j++)
|
||||
entity.incoming.remove(removals.get(j));
|
||||
|
||||
Tile other = world.tile(entity.link);
|
||||
if(!linkValid(tile, other)){
|
||||
entity.link = Pos.invalid;
|
||||
@@ -184,7 +177,7 @@ public class ItemBridge extends Block{
|
||||
entity.uptime = 0f;
|
||||
}else{
|
||||
|
||||
if(entity.cons.valid()){
|
||||
if(entity.cons.valid() && (!hasPower || Mathf.isZero(1f - entity.power.satisfaction))){
|
||||
entity.uptime = Mathf.lerpDelta(entity.uptime, 1f, 0.04f);
|
||||
}else{
|
||||
entity.uptime = Mathf.lerpDelta(entity.uptime, 0f, 0.02f);
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.*;
|
||||
@@ -63,7 +64,7 @@ public class Router extends Block{
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
Tile other = proximity.get((i + counter) % proximity.size);
|
||||
if(set) tile.rotation((byte)((tile.rotation() + 1) % proximity.size));
|
||||
if(other == from) continue;
|
||||
if(other == from && from.block() == Blocks.overflowGate) continue;
|
||||
if(other.block().acceptItem(item, other, Edges.getFacingEdge(tile, other))){
|
||||
return other;
|
||||
}
|
||||
|
||||
@@ -77,8 +77,9 @@ public class LaunchPad extends StorageBlock{
|
||||
for(Item item : Vars.content.items()){
|
||||
Events.fire(Trigger.itemLaunch);
|
||||
Effects.effect(Fx.padlaunch, tile);
|
||||
data.addItem(item, entity.items.get(item));
|
||||
entity.items.set(item, 0);
|
||||
int used = Math.min(entity.items.get(item), itemCapacity);
|
||||
data.addItem(item, used);
|
||||
entity.items.remove(item, used);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,18 @@ public class SWorkshop implements SteamUGCCallback{
|
||||
|
||||
private Map lastMap;
|
||||
|
||||
public SWorkshop(){
|
||||
int items = ugc.getNumSubscribedItems();
|
||||
SteamPublishedFileID[] ids = new SteamPublishedFileID[items];
|
||||
ugc.getSubscribedItems(ids);
|
||||
for(int i = 0; i < items; i++){
|
||||
SteamPublishedFileID id = ids[i];
|
||||
ItemInstallInfo info = new ItemInstallInfo();
|
||||
ugc.getItemInstallInfo(id, info);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void publishMap(Map map){
|
||||
FloatingDialog dialog = new FloatingDialog("$confirm");
|
||||
dialog.setFillParent(false);
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=1fda7fc4ed52e00fdbd6b9a5fab9af6add78dc63
|
||||
archash=de8be7efb888294932a9d41140ac9a71b4ff7f18
|
||||
|
||||
Reference in New Issue
Block a user