Many new modding improvements
This commit is contained in:
@@ -5,8 +5,9 @@ const log = function(context, obj){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const readString = path => Vars.mods.getScripts().readString(path)
|
const readString = path => Vars.mods.getScripts().readString(path)
|
||||||
|
|
||||||
const readBytes = path => Vars.mods.getScripts().readBytes(path)
|
const readBytes = path => Vars.mods.getScripts().readBytes(path)
|
||||||
|
const loadMusic = path => Vars.mods.getScripts().loadMusic(path)
|
||||||
|
const loadSound = path => Vars.mods.getScripts().loadSound(path)
|
||||||
|
|
||||||
var scriptName = "base.js"
|
var scriptName = "base.js"
|
||||||
var modName = "none"
|
var modName = "none"
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ const log = function(context, obj){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const readString = path => Vars.mods.getScripts().readString(path)
|
const readString = path => Vars.mods.getScripts().readString(path)
|
||||||
|
|
||||||
const readBytes = path => Vars.mods.getScripts().readBytes(path)
|
const readBytes = path => Vars.mods.getScripts().readBytes(path)
|
||||||
|
const loadMusic = path => Vars.mods.getScripts().loadMusic(path)
|
||||||
|
const loadSound = path => Vars.mods.getScripts().loadSound(path)
|
||||||
|
|
||||||
var scriptName = "base.js"
|
var scriptName = "base.js"
|
||||||
var modName = "none"
|
var modName = "none"
|
||||||
@@ -40,6 +41,7 @@ importPackage(Packages.arc)
|
|||||||
importPackage(Packages.arc.func)
|
importPackage(Packages.arc.func)
|
||||||
importPackage(Packages.arc.graphics)
|
importPackage(Packages.arc.graphics)
|
||||||
importPackage(Packages.arc.graphics.g2d)
|
importPackage(Packages.arc.graphics.g2d)
|
||||||
|
importPackage(Packages.arc.graphics.gl)
|
||||||
importPackage(Packages.arc.math)
|
importPackage(Packages.arc.math)
|
||||||
importPackage(Packages.arc.math.geom)
|
importPackage(Packages.arc.math.geom)
|
||||||
importPackage(Packages.arc.scene)
|
importPackage(Packages.arc.scene)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class MusicControl{
|
|||||||
public Seq<Music> ambientMusic = Seq.with();
|
public Seq<Music> ambientMusic = Seq.with();
|
||||||
/** darker music, used in times of conflict */
|
/** darker music, used in times of conflict */
|
||||||
public Seq<Music> darkMusic = Seq.with();
|
public Seq<Music> darkMusic = Seq.with();
|
||||||
|
|
||||||
protected Music lastRandomPlayed;
|
protected Music lastRandomPlayed;
|
||||||
protected Interval timer = new Interval();
|
protected Interval timer = new Interval();
|
||||||
protected @Nullable Music current;
|
protected @Nullable Music current;
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ public class UnitTypes implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
zenith = new UnitType("zenith"){{
|
zenith = new UnitType("zenith"){{
|
||||||
health = 1000;
|
health = 700;
|
||||||
speed = 1.9f;
|
speed = 1.9f;
|
||||||
accel = 0.04f;
|
accel = 0.04f;
|
||||||
drag = 0.016f;
|
drag = 0.016f;
|
||||||
@@ -492,13 +492,13 @@ public class UnitTypes implements ContentList{
|
|||||||
range = 140f;
|
range = 140f;
|
||||||
hitsize = 18f;
|
hitsize = 18f;
|
||||||
lowAltitude = true;
|
lowAltitude = true;
|
||||||
armor = 6f;
|
armor = 5f;
|
||||||
|
|
||||||
engineOffset = 12f;
|
engineOffset = 12f;
|
||||||
engineSize = 3f;
|
engineSize = 3f;
|
||||||
|
|
||||||
weapons.add(new Weapon("zenith-missiles"){{
|
weapons.add(new Weapon("zenith-missiles"){{
|
||||||
reload = 32f;
|
reload = 40f;
|
||||||
x = 7f;
|
x = 7f;
|
||||||
rotate = true;
|
rotate = true;
|
||||||
shake = 1f;
|
shake = 1f;
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ public class Renderer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(){
|
public void draw(){
|
||||||
|
Events.fire(Trigger.preDraw);
|
||||||
|
|
||||||
camera.update();
|
camera.update();
|
||||||
|
|
||||||
if(Float.isNaN(camera.position.x) || Float.isNaN(camera.position.y)){
|
if(Float.isNaN(camera.position.x) || Float.isNaN(camera.position.y)){
|
||||||
@@ -205,6 +207,8 @@ public class Renderer implements ApplicationListener{
|
|||||||
|
|
||||||
Draw.sort(true);
|
Draw.sort(true);
|
||||||
|
|
||||||
|
Events.fire(Trigger.draw);
|
||||||
|
|
||||||
if(pixelator.enabled()){
|
if(pixelator.enabled()){
|
||||||
pixelator.register();
|
pixelator.register();
|
||||||
}
|
}
|
||||||
@@ -254,6 +258,8 @@ public class Renderer implements ApplicationListener{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
Draw.flush();
|
Draw.flush();
|
||||||
Draw.sort(false);
|
Draw.sort(false);
|
||||||
|
|
||||||
|
Events.fire(Trigger.postDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawBackground(){
|
private void drawBackground(){
|
||||||
|
|||||||
@@ -128,6 +128,8 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
public void update(){
|
public void update(){
|
||||||
if(disableUI || Core.scene == null) return;
|
if(disableUI || Core.scene == null) return;
|
||||||
|
|
||||||
|
Events.fire(Trigger.uiDrawBegin);
|
||||||
|
|
||||||
Core.scene.act();
|
Core.scene.act();
|
||||||
Core.scene.draw();
|
Core.scene.draw();
|
||||||
|
|
||||||
@@ -143,6 +145,8 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
control.tutorial.draw();
|
control.tutorial.draw();
|
||||||
Draw.flush();
|
Draw.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Events.fire(Trigger.uiDrawEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -30,7 +30,12 @@ public class EventType{
|
|||||||
openWiki,
|
openWiki,
|
||||||
teamCoreDamage,
|
teamCoreDamage,
|
||||||
socketConfigChanged,
|
socketConfigChanged,
|
||||||
update
|
update,
|
||||||
|
draw,
|
||||||
|
preDraw,
|
||||||
|
postDraw,
|
||||||
|
uiDrawBegin,
|
||||||
|
uiDrawEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WinEvent{}
|
public static class WinEvent{}
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ public class Layer{
|
|||||||
|
|
||||||
public static final float
|
public static final float
|
||||||
|
|
||||||
|
//min layer
|
||||||
|
min = -11,
|
||||||
|
|
||||||
//background, which may be planets or an image or nothing at all
|
//background, which may be planets or an image or nothing at all
|
||||||
background = -10,
|
background = -10,
|
||||||
|
|
||||||
@@ -81,7 +84,10 @@ public class Layer{
|
|||||||
end = 200,
|
end = 200,
|
||||||
|
|
||||||
//things after pixelation - used for text
|
//things after pixelation - used for text
|
||||||
endPixeled = 210
|
endPixeled = 210,
|
||||||
|
|
||||||
|
//max layer
|
||||||
|
max = 220
|
||||||
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,14 +132,12 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//draw schematic requests
|
//draw schematic requests
|
||||||
for(BuildPlan request : selectRequests){
|
selectRequests.each(req -> {
|
||||||
request.animScale = 1f;
|
req.animScale = 1f;
|
||||||
drawRequest(request);
|
drawRequest(req);
|
||||||
}
|
});
|
||||||
|
|
||||||
for(BuildPlan request : selectRequests){
|
selectRequests.each(this::drawOverRequest);
|
||||||
drawOverRequest(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(player.isBuilder()){
|
if(player.isBuilder()){
|
||||||
//draw things that may be placed soon
|
//draw things that may be placed soon
|
||||||
|
|||||||
@@ -538,11 +538,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
if(test.get(req)) return req;
|
if(test.get(req)) return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(BuildPlan req : selectRequests){
|
return selectRequests.find(test);
|
||||||
if(test.get(req)) return req;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawBreakSelection(int x1, int y1, int x2, int y2){
|
protected void drawBreakSelection(int x1, int y1, int x2, int y2){
|
||||||
|
|||||||
@@ -177,9 +177,7 @@ public class LExecutor{
|
|||||||
public void run(LExecutor exec){
|
public void run(LExecutor exec){
|
||||||
int address = exec.numi(index);
|
int address = exec.numi(index);
|
||||||
|
|
||||||
if(address >= 0 && address < exec.links.length){
|
exec.setobj(output, address >= 0 && address < exec.links.length ? exec.links[address] : null);
|
||||||
exec.setobj(output, exec.links[address]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
79
core/src/mindustry/mod/ModLoadingMusic.java
Normal file
79
core/src/mindustry/mod/ModLoadingMusic.java
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
package mindustry.mod;
|
||||||
|
|
||||||
|
import arc.audio.*;
|
||||||
|
import arc.mock.*;
|
||||||
|
import arc.util.ArcAnnotate.*;
|
||||||
|
|
||||||
|
public class ModLoadingMusic implements Music{
|
||||||
|
public @NonNull Music music = new MockMusic();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void play(){
|
||||||
|
music.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pause(){
|
||||||
|
music.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop(){
|
||||||
|
music.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPlaying(){
|
||||||
|
return music.isPlaying();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLooping(){
|
||||||
|
return music.isLooping();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLooping(boolean isLooping){
|
||||||
|
music.setLooping(isLooping);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getVolume(){
|
||||||
|
return music.getVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVolume(float volume){
|
||||||
|
music.setVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPan(float pan, float volume){
|
||||||
|
music.setPan(pan, volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getPosition(){
|
||||||
|
return music.getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPosition(float position){
|
||||||
|
music.setPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(){
|
||||||
|
music.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCompletionListener(OnCompletionListener listener){
|
||||||
|
music.setCompletionListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDisposed(){
|
||||||
|
return music.isDisposed();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package mindustry.mod;
|
package mindustry.mod;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.assets.*;
|
||||||
|
import arc.audio.*;
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
|
import arc.mock.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.Log.*;
|
import arc.util.Log.*;
|
||||||
@@ -73,7 +76,7 @@ public class Scripts implements Disposable{
|
|||||||
Log.log(level, "[@]: @", source, message);
|
Log.log(level, "[@]: @", source, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
//utility mod functions
|
//region utility mod functions
|
||||||
|
|
||||||
public String readString(String path){
|
public String readString(String path){
|
||||||
return Vars.tree.get(path, true).readString();
|
return Vars.tree.get(path, true).readString();
|
||||||
@@ -83,6 +86,38 @@ public class Scripts implements Disposable{
|
|||||||
return Vars.tree.get(path, true).readBytes();
|
return Vars.tree.get(path, true).readBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Sound loadSound(String soundName){
|
||||||
|
if(Vars.headless) return new MockSound();
|
||||||
|
|
||||||
|
String name = "sounds/" + soundName;
|
||||||
|
String path = Vars.tree.get(name + ".ogg").exists() && !Vars.ios ? name + ".ogg" : name + ".mp3";
|
||||||
|
|
||||||
|
if(Core.assets.contains(path, Sound.class)) return Core.assets.get(path, Sound.class);
|
||||||
|
ModLoadingSound sound = new ModLoadingSound();
|
||||||
|
AssetDescriptor<?> desc = Core.assets.load(path, Sound.class);
|
||||||
|
desc.loaded = result -> sound.sound = (Sound)result;
|
||||||
|
desc.errored = Throwable::printStackTrace;
|
||||||
|
|
||||||
|
return sound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Music loadMusic(String soundName){
|
||||||
|
if(Vars.headless) return new MockMusic();
|
||||||
|
|
||||||
|
String name = "music/" + soundName;
|
||||||
|
String path = Vars.tree.get(name + ".ogg").exists() && !Vars.ios ? name + ".ogg" : name + ".mp3";
|
||||||
|
|
||||||
|
if(Core.assets.contains(path, Music.class)) return Core.assets.get(path, Music.class);
|
||||||
|
ModLoadingMusic sound = new ModLoadingMusic();
|
||||||
|
AssetDescriptor<?> desc = Core.assets.load(path, Music.class);
|
||||||
|
desc.loaded = result -> sound.music = (Music)result;
|
||||||
|
desc.errored = Throwable::printStackTrace;
|
||||||
|
|
||||||
|
return sound;
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
public void run(LoadedMod mod, Fi file){
|
public void run(LoadedMod mod, Fi file){
|
||||||
currentMod = mod;
|
currentMod = mod;
|
||||||
run(file.readString(), file.name(), true);
|
run(file.readString(), file.name(), true);
|
||||||
|
|||||||
@@ -28,11 +28,8 @@ public class CoreItemsDisplay extends Table{
|
|||||||
update(() -> {
|
update(() -> {
|
||||||
CoreBuild core = Vars.player.team().core();
|
CoreBuild core = Vars.player.team().core();
|
||||||
|
|
||||||
for(Item item : content.items()){
|
if(content.items().contains(item -> core != null && core.items.get(item) > 0 && usedItems.add(item))){
|
||||||
if(core != null && core.items.get(item) > 0 && usedItems.add(item)){
|
rebuild();
|
||||||
rebuild();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
float mspeed = speed * tilesize * 55f;
|
float mspeed = speed * tilesize * 55f;
|
||||||
float centerSpeed = 0.1f;
|
float centerSpeed = 0.1f;
|
||||||
float centerDstScl = 3f;
|
float centerDstScl = 3f;
|
||||||
float tx = Geometry.d4x[rotation], ty = Geometry.d4y[rotation];
|
float tx = Geometry.d4x(rotation), ty = Geometry.d4y(rotation);
|
||||||
|
|
||||||
float centerx = 0f, centery = 0f;
|
float centerx = 0f, centery = 0f;
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,6 @@ public class LogicBlock extends Block{
|
|||||||
stream.readInt();
|
stream.readInt();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
for(int i = 0; i < total; i++){
|
for(int i = 0; i < total; i++){
|
||||||
String name = stream.readUTF();
|
String name = stream.readUTF();
|
||||||
short x = stream.readShort(), y = stream.readShort();
|
short x = stream.readShort(), y = stream.readShort();
|
||||||
@@ -290,6 +289,7 @@ public class LogicBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
asm.putConst("@links", executor.links.length);
|
asm.putConst("@links", executor.links.length);
|
||||||
|
asm.putConst("@ipt", instructionsPerTick);
|
||||||
|
|
||||||
//store any older variables
|
//store any older variables
|
||||||
for(Var var : executor.vars){
|
for(Var var : executor.vars){
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import arc.files.*;
|
|||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.graphics.g2d.TextureAtlas.*;
|
import arc.graphics.g2d.TextureAtlas.*;
|
||||||
|
import arc.graphics.gl.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
@@ -16,14 +17,14 @@ import java.lang.reflect.*;
|
|||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ScriptStubGenerator{
|
public class ScriptMainGenerator{
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception{
|
public static void main(String[] args) throws Exception{
|
||||||
String base = "mindustry";
|
String base = "mindustry";
|
||||||
Seq<String> blacklist = Seq.with("plugin", "mod", "net", "io", "tools");
|
Seq<String> blacklist = Seq.with("plugin", "mod", "net", "io", "tools");
|
||||||
Seq<String> nameBlacklist = Seq.with("ClassAccess");
|
Seq<String> nameBlacklist = Seq.with("ClassAccess");
|
||||||
Seq<Class<?>> whitelist = Seq.with(Draw.class, Fill.class, Lines.class, Core.class, TextureAtlas.class, TextureRegion.class, Time.class, System.class, PrintStream.class,
|
Seq<Class<?>> whitelist = Seq.with(Draw.class, Fill.class, Lines.class, Core.class, TextureAtlas.class, TextureRegion.class, Time.class, System.class, PrintStream.class,
|
||||||
AtlasRegion.class, String.class, Mathf.class, Angles.class, Color.class, Runnable.class, Object.class, Icon.class, Tex.class,
|
AtlasRegion.class, String.class, Mathf.class, Angles.class, Color.class, Runnable.class, Object.class, Icon.class, Tex.class, Shader.class,
|
||||||
Sounds.class, Musics.class, Call.class, Texture.class, TextureData.class, Pixmap.class, I18NBundle.class, Interval.class, DataInput.class, DataOutput.class,
|
Sounds.class, Musics.class, Call.class, Texture.class, TextureData.class, Pixmap.class, I18NBundle.class, Interval.class, DataInput.class, DataOutput.class,
|
||||||
DataInputStream.class, DataOutputStream.class, Integer.class, Float.class, Double.class, Long.class, Boolean.class, Short.class, Byte.class, Character.class);
|
DataInputStream.class, DataOutputStream.class, Integer.class, Float.class, Double.class, Long.class, Boolean.class, Short.class, Byte.class, Character.class);
|
||||||
Seq<String> nopackage = Seq.with("java.lang", "java");
|
Seq<String> nopackage = Seq.with("java.lang", "java");
|
||||||
Reference in New Issue
Block a user