Added configurable global server rules
This commit is contained in:
@@ -25,6 +25,8 @@ public class Rules{
|
||||
public boolean pvp;
|
||||
/** Whether enemy units drop random items on death. */
|
||||
public boolean unitDrops = true;
|
||||
/** Whether reactors can explode and damage other blocks. */
|
||||
public boolean reactorExplosions = true;
|
||||
/** How fast unit pads build units. */
|
||||
public float unitBuildSpeedMultiplier = 1f;
|
||||
/** How much health units start with. */
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.arc.util.serialization.Json.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.ctype.MappableContent;
|
||||
import io.anuke.mindustry.ctype.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
@@ -31,6 +31,10 @@ public class JsonIO{
|
||||
}
|
||||
};
|
||||
|
||||
public static Json json(){
|
||||
return json;
|
||||
}
|
||||
|
||||
public static String write(Object object){
|
||||
return json.toJson(object, object.getClass());
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.reflect.Field;
|
||||
import io.anuke.arc.util.reflect.*;
|
||||
import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.arc.util.serialization.Json.*;
|
||||
import io.anuke.arc.util.serialization.Jval.*;
|
||||
@@ -361,7 +359,7 @@ public class ContentParser{
|
||||
|
||||
private <T> T make(Class<T> type){
|
||||
try{
|
||||
java.lang.reflect.Constructor<T> cons = type.getDeclaredConstructor();
|
||||
Constructor<T> cons = type.getDeclaredConstructor();
|
||||
cons.setAccessible(true);
|
||||
return cons.newInstance();
|
||||
}catch(Exception e){
|
||||
@@ -371,7 +369,7 @@ public class ContentParser{
|
||||
|
||||
private <T> T make(Class<T> type, String name){
|
||||
try{
|
||||
java.lang.reflect.Constructor<T> cons = type.getDeclaredConstructor(String.class);
|
||||
Constructor<T> cons = type.getDeclaredConstructor(String.class);
|
||||
cons.setAccessible(true);
|
||||
return cons.newInstance(name);
|
||||
}catch(Exception e){
|
||||
@@ -381,7 +379,7 @@ public class ContentParser{
|
||||
|
||||
private <T> Prov<T> supply(Class<T> type){
|
||||
try{
|
||||
java.lang.reflect.Constructor<T> cons = type.getDeclaredConstructor();
|
||||
Constructor<T> cons = type.getDeclaredConstructor();
|
||||
return () -> {
|
||||
try{
|
||||
return cons.newInstance();
|
||||
@@ -457,7 +455,7 @@ public class ContentParser{
|
||||
Field field = metadata.field;
|
||||
try{
|
||||
field.set(object, parser.readValue(field.getType(), metadata.elementType, child, metadata.keyType));
|
||||
}catch(ReflectionException ex){
|
||||
}catch(IllegalAccessException ex){
|
||||
throw new SerializationException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex);
|
||||
}catch(SerializationException ex){
|
||||
ex.addTrace(field.getName() + " (" + type.getName() + ")");
|
||||
|
||||
@@ -135,13 +135,11 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
number("$rules.dropzoneradius", false, f -> rules.dropZoneRadius = f * tilesize, () -> rules.dropZoneRadius / tilesize, () -> true);
|
||||
|
||||
title("$rules.title.respawns");
|
||||
//limited respawns don't work on PvP, commented out until they're fixed
|
||||
//check("$rules.limitedRespawns", b -> rules.limitedRespawns = b, () -> rules.limitedRespawns);
|
||||
//number("$rules.respawns", true, f -> rules.respawns = (int)f, () -> rules.respawns, () -> rules.limitedRespawns);
|
||||
number("$rules.respawntime", f -> rules.respawnTime = f * 60f, () -> rules.respawnTime / 60f);
|
||||
|
||||
title("$rules.title.resourcesbuilding");
|
||||
check("$rules.infiniteresources", b -> rules.infiniteResources = b, () -> rules.infiniteResources);
|
||||
check("$rules.reactorexplosions", b -> rules.reactorExplosions = b, () -> rules.reactorExplosions);
|
||||
number("$rules.buildcostmultiplier", false, f -> rules.buildCostMultiplier = f, () -> rules.buildCostMultiplier, () -> !rules.infiniteResources);
|
||||
number("$rules.buildspeedmultiplier", f -> rules.buildSpeedMultiplier = f, () -> rules.buildSpeedMultiplier);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import io.anuke.mindustry.world.meta.StatUnit;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class NuclearReactor extends PowerGenerator{
|
||||
protected final int timerFuel = timers++;
|
||||
@@ -127,7 +127,7 @@ public class NuclearReactor extends PowerGenerator{
|
||||
|
||||
int fuel = entity.items.get(consumes.<ConsumeItems>get(ConsumeType.item).items[0].item);
|
||||
|
||||
if(fuel < 5 && entity.heat < 0.5f) return;
|
||||
if((fuel < 5 && entity.heat < 0.5f) || !state.rules.reactorExplosions) return;
|
||||
|
||||
Effects.shake(6f, 16f, tile.worldx(), tile.worldy());
|
||||
Effects.effect(Fx.nuclearShockwave, tile.worldx(), tile.worldy());
|
||||
|
||||
Reference in New Issue
Block a user