diff --git a/annotations/src/main/java/mindustry/annotations/Annotations.java b/annotations/src/main/java/mindustry/annotations/Annotations.java index c6fc772af2..c335d5ad42 100644 --- a/annotations/src/main/java/mindustry/annotations/Annotations.java +++ b/annotations/src/main/java/mindustry/annotations/Annotations.java @@ -88,6 +88,7 @@ public class Annotations{ boolean collide() default false; boolean spatial() default false; boolean mapping() default false; + boolean update() default false; } /** Indicates an entity definition. */ @@ -107,6 +108,8 @@ public class Annotations{ boolean genio() default true; /** Whether I made a massive mistake by merging two different class branches */ boolean legacy() default false; + /** Groups to exclude. */ + String[] excludeGroups() default {}; } /** Indicates an internal interface for entity components. */ diff --git a/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java b/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java index 3fd49ae6d9..b15ce300a0 100644 --- a/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java +++ b/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java @@ -242,7 +242,7 @@ public class EntityProcess extends BaseProcessor{ boolean collides = an.collide(); groupDefs.add(new GroupDefinition(name, - ClassName.bestGuess(packageName + "." + groupType), types, an.spatial(), an.mapping(), collides)); + ClassName.bestGuess(packageName + "." + groupType), types, an.spatial(), an.mapping(), collides, an.update())); TypeSpec.Builder accessor = TypeSpec.interfaceBuilder("IndexableEntity__" + name); accessor.addMethod(MethodSpec.methodBuilder("setIndex__" + name).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC).addParameter(int.class, "index").returns(void.class).build()); @@ -258,7 +258,7 @@ public class EntityProcess extends BaseProcessor{ //all component classes (not interfaces) Seq components = allComponents(type); - Seq groups = groupDefs.select(g -> (!g.components.isEmpty() && !g.components.contains(s -> !components.contains(s))) || g.manualInclusions.contains(type)); + Seq groups = groupDefs.select(g -> (!g.components.isEmpty() && !Structs.contains(ann.excludeGroups(), g.name) && !g.components.contains(s -> !components.contains(s))) || g.manualInclusions.contains(type)); ObjectMap> methods = new ObjectMap<>(); ObjectMap specVariables = new ObjectMap<>(); ObjectSet usedFields = new ObjectSet<>(); @@ -700,7 +700,11 @@ public class EntityProcess extends BaseProcessor{ } } - groupUpdate.addStatement("all.update()"); + for(GroupDefinition group : groupDefs){ + if(group.updates){ + groupUpdate.addStatement("$L.update()", group.name); + } + } for(GroupDefinition group : groupDefs){ if(group.collides){ @@ -985,16 +989,17 @@ public class EntityProcess extends BaseProcessor{ final String name; final ClassName baseType; final Seq components; - final boolean spatial, mapping, collides; + final boolean spatial, mapping, collides, updates; final ObjectSet manualInclusions = new ObjectSet<>(); - public GroupDefinition(String name, ClassName bestType, Seq components, boolean spatial, boolean mapping, boolean collides){ + public GroupDefinition(String name, ClassName bestType, Seq components, boolean spatial, boolean mapping, boolean collides, boolean updates){ this.baseType = bestType; this.components = components; this.name = name; this.spatial = spatial; this.mapping = mapping; this.collides = collides; + this.updates = updates; } @Override diff --git a/core/assets/scripts/base.js b/core/assets/scripts/base.js index 4cfe9ef574..d58116bc1f 100755 --- a/core/assets/scripts/base.js +++ b/core/assets/scripts/base.js @@ -17,6 +17,7 @@ const floatp = method => new Floatp(){get: method} const cons = method => new Cons(){get: method} const prov = method => new Prov(){get: method} const func = method => new Func(){get: method} +const getRealClass = value => Vars.mods.getScripts().getClass(value); const newEffect = (lifetime, renderer) => new Effect.Effect(lifetime, new Effect.EffectRenderer({render: renderer})) Call = Packages.mindustry.gen.Call diff --git a/core/assets/scripts/global.js b/core/assets/scripts/global.js index ed444e3609..3d084816fe 100755 --- a/core/assets/scripts/global.js +++ b/core/assets/scripts/global.js @@ -19,6 +19,7 @@ const floatp = method => new Floatp(){get: method} const cons = method => new Cons(){get: method} const prov = method => new Prov(){get: method} const func = method => new Func(){get: method} +const getRealClass = value => Vars.mods.getScripts().getClass(value); const newEffect = (lifetime, renderer) => new Effect.Effect(lifetime, new Effect.EffectRenderer({render: renderer})) Call = Packages.mindustry.gen.Call diff --git a/core/src/mindustry/entities/GroupDefs.java b/core/src/mindustry/entities/GroupDefs.java index 465d49a58f..c99ef9d62a 100644 --- a/core/src/mindustry/entities/GroupDefs.java +++ b/core/src/mindustry/entities/GroupDefs.java @@ -4,11 +4,11 @@ import mindustry.annotations.Annotations.*; import mindustry.gen.*; class GroupDefs{ - @GroupDef(value = Entityc.class) G all; + @GroupDef(value = Entityc.class, update = true) G all; @GroupDef(value = Playerc.class, mapping = true) G player; @GroupDef(value = Bulletc.class, spatial = true, collide = true) G bullet; @GroupDef(value = Unitc.class, spatial = true, mapping = true) G unit; - @GroupDef(value = Buildingc.class) G build; + @GroupDef(value = Buildingc.class, update = true) G build; @GroupDef(value = Syncc.class, mapping = true) G sync; @GroupDef(value = Drawc.class) G draw; @GroupDef(value = Firec.class) G fire; diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 406245f7d8..03c8f5e669 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -47,7 +47,7 @@ import java.util.*; import static mindustry.Vars.*; -@EntityDef(value = {Buildingc.class}, isFinal = false, genio = false, serialize = false) +@EntityDef(value = {Buildingc.class}, excludeGroups = {"all"}, isFinal = false, genio = false, serialize = false) @Component(base = true, genInterface = false) abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, QuadTreeObject, Displayable, Sized, Senseable, Controllable, Settable{ //region vars and initialization @@ -459,6 +459,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, /** Sets the time scale of the building to the given intensity, unless it's above that value */ public void applyBoost(float intensity, float duration){ + if(!block.canOverdrive) return; //do not refresh time scale when getting a lower intensity if(intensity >= this.timeScale - 0.001f){ timeScaleDuration = Math.max(timeScaleDuration, duration); @@ -2232,8 +2233,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, @Override public void update(){ - //TODO refactor to timestamp-based system? - if((timeScaleDuration -= Time.delta) <= 0f || !block.canOverdrive){ + //TODO refactor to separate loop? + if((timeScaleDuration -= Time.delta) <= 0f){ timeScale = 1f; } diff --git a/core/src/mindustry/mod/Scripts.java b/core/src/mindustry/mod/Scripts.java index 7bf81dddb7..148ed591c0 100644 --- a/core/src/mindustry/mod/Scripts.java +++ b/core/src/mindustry/mod/Scripts.java @@ -81,6 +81,10 @@ public class Scripts implements Disposable{ return new float[capacity]; } + public Class getClass(Object object){ + return object == null ? null : object.getClass(); + } + public void run(LoadedMod mod, Fi file){ currentMod = mod; run(file.readString(), mod.name + "/" + file.name(), true); diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 20b5b76843..84bca543d2 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -427,7 +427,7 @@ public class Turret extends ReloadTurret{ } public boolean isShooting(){ - return alwaysShooting || (isControlled() ? unit.isShooting() : logicControlled() ? logicShooting : target != null); + return alwaysShooting || (unit.controller() instanceof Player ? unit.isShooting() : logicControlled() ? logicShooting : target != null); } @Override diff --git a/core/src/mindustry/world/blocks/liquid/LiquidJunction.java b/core/src/mindustry/world/blocks/liquid/LiquidJunction.java index 1e3e93a66b..014d4f877e 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidJunction.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidJunction.java @@ -11,6 +11,8 @@ public class LiquidJunction extends LiquidBlock{ public LiquidJunction(String name){ super(name); floating = true; + destructible = true; + update = false; } @Override diff --git a/gradle.properties b/gradle.properties index acb5f700dc..59271527e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,4 +26,4 @@ org.gradle.caching=true org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 android.enableR8.fullMode=false -archash=7c7c92f0ba +archash=b1991c0aea