Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features
This commit is contained in:
@@ -40,7 +40,7 @@ public class Vars implements Loadable{
|
||||
public static boolean loadLocales = true;
|
||||
/** Whether the logger is loaded. */
|
||||
public static boolean loadedLogger = false, loadedFileLogger = false;
|
||||
/** Whether to enable various experimental features (e.g. cliffs) */
|
||||
/** Whether to enable various experimental features (e.g. spawn positions for spawn groups) */
|
||||
public static boolean experimental = false;
|
||||
/** Name of current Steam player. */
|
||||
public static String steamPlayerName = "";
|
||||
|
||||
@@ -369,13 +369,13 @@ public class Fx{
|
||||
|
||||
Fill.circle(e.x, e.y, e.fin() * 10);
|
||||
Drawf.light(e.x, e.y, e.fin() * 20f, Pal.heal, 0.7f);
|
||||
}),
|
||||
}).followParent(true),
|
||||
|
||||
greenLaserChargeSmall = new Effect(40f, 100f, e -> {
|
||||
color(Pal.heal);
|
||||
stroke(e.fin() * 2f);
|
||||
Lines.circle(e.x, e.y, e.fout() * 50f);
|
||||
}),
|
||||
}).followParent(true),
|
||||
|
||||
greenCloud = new Effect(80f, e -> {
|
||||
color(Pal.heal);
|
||||
|
||||
@@ -452,6 +452,7 @@ public class UnitTypes implements ContentList{
|
||||
x = y = 0f;
|
||||
|
||||
firstShotDelay = Fx.greenLaserChargeSmall.lifetime - 1f;
|
||||
parentizeEffects = true;
|
||||
|
||||
reload = 155f;
|
||||
recoil = 0f;
|
||||
@@ -541,6 +542,7 @@ public class UnitTypes implements ContentList{
|
||||
shootStatusDuration = 60f * 2f;
|
||||
shootStatus = StatusEffects.unmoving;
|
||||
firstShotDelay = Fx.greenLaserCharge.lifetime;
|
||||
parentizeEffects = true;
|
||||
|
||||
bullet = new LaserBulletType(){{
|
||||
length = 460f;
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package mindustry.core;
|
||||
|
||||
import arc.*;
|
||||
import arc.assets.*;
|
||||
import arc.assets.loaders.*;
|
||||
import arc.assets.loaders.MusicLoader.*;
|
||||
import arc.assets.loaders.SoundLoader.*;
|
||||
import arc.audio.*;
|
||||
import arc.files.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.*;
|
||||
|
||||
/** Handles files in a modded context. */
|
||||
public class FileTree implements FileHandleResolver{
|
||||
@@ -40,4 +45,30 @@ public class FileTree implements FileHandleResolver{
|
||||
public Fi resolve(String fileName){
|
||||
return get(fileName);
|
||||
}
|
||||
|
||||
public Sound loadSound(String soundName){
|
||||
if(Vars.headless) return new Sound();
|
||||
|
||||
String name = "sounds/" + soundName;
|
||||
String path = Vars.tree.get(name + ".ogg").exists() ? name + ".ogg" : name + ".mp3";
|
||||
|
||||
var sound = new Sound();
|
||||
AssetDescriptor<?> desc = Core.assets.load(path, Sound.class, new SoundParameter(sound));
|
||||
desc.errored = Throwable::printStackTrace;
|
||||
|
||||
return sound;
|
||||
}
|
||||
|
||||
public Music loadMusic(String soundName){
|
||||
if(Vars.headless) return new Music();
|
||||
|
||||
String name = "music/" + soundName;
|
||||
String path = Vars.tree.get(name + ".ogg").exists() ? name + ".ogg" : name + ".mp3";
|
||||
|
||||
var music = new Music();
|
||||
AssetDescriptor<?> desc = Core.assets.load(path, Music.class, new MusicParameter(music));
|
||||
desc.errored = Throwable::printStackTrace;
|
||||
|
||||
return music;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
||||
|
||||
public TextureRegion icon(){
|
||||
//display default icon for dead players
|
||||
if(dead()) return core() == null ? UnitTypes.alpha.fullIcon : ((CoreBlock)core().block).unitType.fullIcon;
|
||||
if(dead()) return core() == null ? UnitTypes.alpha.fullIcon : ((CoreBlock)bestCore().block).unitType.fullIcon;
|
||||
|
||||
return unit.icon();
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public class ContentParser{
|
||||
ObjectMap<Class<?>, ContentType> contentTypes = new ObjectMap<>();
|
||||
ObjectSet<Class<?>> implicitNullable = ObjectSet.with(TextureRegion.class, TextureRegion[].class, TextureRegion[][].class);
|
||||
ObjectMap<String, AssetDescriptor<?>> sounds = new ObjectMap<>();
|
||||
Seq<ParseListener> listeners = new Seq<>();
|
||||
|
||||
ObjectMap<Class<?>, FieldParser> classParsers = new ObjectMap<>(){{
|
||||
put(Effect.class, (type, data) -> {
|
||||
@@ -178,7 +179,10 @@ public class ContentParser{
|
||||
@Override
|
||||
public <T> T readValue(Class<T> type, Class elementType, JsonValue jsonData, Class keyType){
|
||||
T t = internalRead(type, elementType, jsonData, keyType);
|
||||
if(t != null) checkNullFields(t);
|
||||
if(t != null && !Reflect.isWrapper(t.getClass()) && (type == null || !type.isPrimitive())){
|
||||
checkNullFields(t);
|
||||
listeners.each(hook -> hook.parsed(type, jsonData, t));
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -805,4 +809,8 @@ public class ContentParser{
|
||||
public float time = 60f * 10f;
|
||||
}
|
||||
|
||||
public interface ParseListener{
|
||||
void parsed(Class<?> type, JsonValue jsonData, Object result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.MultiPacker.*;
|
||||
import mindustry.mod.ContentParser.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
@@ -651,6 +652,11 @@ public class Mods implements Loadable{
|
||||
parser.markError(content, error);
|
||||
}
|
||||
|
||||
/** Adds a listener for parsed JSON objects. */
|
||||
public void addParseListener(ParseListener hook){
|
||||
parser.listeners.add(hook);
|
||||
}
|
||||
|
||||
/** @return a list of mods and versions, in the format name:version. */
|
||||
public Seq<String> getModStrings(){
|
||||
return mods.select(l -> !l.meta.hidden && l.enabled()).map(l -> l.name + ":" + l.meta.version);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package mindustry.mod;
|
||||
|
||||
import arc.*;
|
||||
import arc.assets.*;
|
||||
import arc.assets.loaders.MusicLoader.*;
|
||||
import arc.assets.loaders.SoundLoader.*;
|
||||
import arc.audio.*;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
@@ -85,30 +82,14 @@ public class Scripts implements Disposable{
|
||||
return Vars.tree.get(path, true).readBytes();
|
||||
}
|
||||
|
||||
//kept for backwards compatibility
|
||||
public Sound loadSound(String soundName){
|
||||
if(Vars.headless) return new Sound();
|
||||
|
||||
String name = "sounds/" + soundName;
|
||||
String path = Vars.tree.get(name + ".ogg").exists() ? name + ".ogg" : name + ".mp3";
|
||||
|
||||
var sound = new Sound();
|
||||
AssetDescriptor<?> desc = Core.assets.load(path, Sound.class, new SoundParameter(sound));
|
||||
desc.errored = Throwable::printStackTrace;
|
||||
|
||||
return sound;
|
||||
return Vars.tree.loadSound(soundName);
|
||||
}
|
||||
|
||||
//kept for backwards compatibility
|
||||
public Music loadMusic(String soundName){
|
||||
if(Vars.headless) return new Music();
|
||||
|
||||
String name = "music/" + soundName;
|
||||
String path = Vars.tree.get(name + ".ogg").exists() ? name + ".ogg" : name + ".mp3";
|
||||
|
||||
var music = new Music();
|
||||
AssetDescriptor<?> desc = Core.assets.load(path, Music.class, new MusicParameter(music));
|
||||
desc.errored = Throwable::printStackTrace;
|
||||
|
||||
return music;
|
||||
return Vars.tree.loadMusic(soundName);
|
||||
}
|
||||
|
||||
/** Ask the user to select a file to read for a certain purpose like "Please upload a sprite" */
|
||||
|
||||
@@ -91,6 +91,8 @@ public class Weapon implements Cloneable{
|
||||
public boolean ignoreRotation = false;
|
||||
/** min velocity required for this weapon to shoot */
|
||||
public float minShootVelocity = -1f;
|
||||
/** should the shoot effects follow the unit (effects need followParent set to true for this to work) */
|
||||
public boolean parentizeEffects;
|
||||
/** internal value used for alternation - do not change! */
|
||||
public int otherSide = -1;
|
||||
/** sound used for shooting */
|
||||
@@ -333,7 +335,7 @@ public class Weapon implements Cloneable{
|
||||
Angles.shotgun(shots, spacing, rotation, f -> mount.bullet = bullet(unit, shootX, shootY, f + Mathf.range(inaccuracy), lifeScl));
|
||||
}
|
||||
|
||||
boolean parentize = ammo.keepVelocity;
|
||||
boolean parentize = ammo.keepVelocity || parentizeEffects;
|
||||
|
||||
if(delay){
|
||||
Time.run(firstShotDelay, () -> {
|
||||
|
||||
Reference in New Issue
Block a user