diff --git a/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java b/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java index f0e224375a..7243dd7408 100644 --- a/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java +++ b/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java @@ -136,6 +136,7 @@ public class EntityProcess extends BaseProcessor{ if(!signatures.contains(cname + "()")){ inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC) .addAnnotations(Seq.with(field.annotations()).select(a -> a.toString().contains("Null")).map(AnnotationSpec::get)) + //.addAnnotation(Deprecated.class) //TODO undeprecate .addJavadoc(field.doc() == null ? "" : field.doc()) .returns(field.tname()).build()); } @@ -146,6 +147,7 @@ public class EntityProcess extends BaseProcessor{ inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC) .addJavadoc(field.doc() == null ? "" : field.doc()) .addParameter(ParameterSpec.builder(field.tname(), field.name()) + //.addAnnotation(Deprecated.class) //TODO undeprecate .addAnnotations(Seq.with(field.annotations()) .select(a -> a.toString().contains("Null")).map(AnnotationSpec::get)).build()).build()); } @@ -185,7 +187,7 @@ public class EntityProcess extends BaseProcessor{ } //add interfaces - for(Stype type : depends){ + for(Stype type : deps){ base.addSuperinterface(tname(packageName, interfaceName(type))); } @@ -222,9 +224,13 @@ public class EntityProcess extends BaseProcessor{ return result; }); + //representative component type + Stype repr = types.first(); + String groupType = repr.annotation(Component.class).base() ? baseName(repr) : interfaceName(repr); + boolean collides = an.collide(); groupDefs.add(new GroupDefinition(group.name().startsWith("g") ? group.name().substring(1) : group.name(), - ClassName.bestGuess(packageName + "." + interfaceName(types.first())), types, an.spatial(), an.mapping(), collides)); + ClassName.bestGuess(packageName + "." + groupType), types, an.spatial(), an.mapping(), collides)); } ObjectMap usedNames = new ObjectMap<>(); @@ -232,33 +238,9 @@ public class EntityProcess extends BaseProcessor{ //look at each definition for(Selement type : allDefs){ - EntityDef ann = type.annotation(EntityDef.class); boolean isFinal = ann.isFinal(); - if(type.isType() && (!type.name().endsWith("Def") && !type.name().endsWith("Comp"))){ - err("All entity def names must end with 'Def'/'Comp'", type.e); - } - - String name = type.isType() ? - type.name().replace("Def", "Entity").replace("Comp", "Entity") : - createName(type); - - //skip double classes - if(usedNames.containsKey(name)){ - extraNames.get(usedNames.get(name), ObjectSet::new).add(type.name()); - continue; - } - - usedNames.put(name, type); - extraNames.get(type, ObjectSet::new).add(name); - if(!type.isType()){ - extraNames.get(type, ObjectSet::new).add(type.name()); - } - - TypeSpec.Builder builder = TypeSpec.classBuilder(name).addModifiers(Modifier.PUBLIC); - if(isFinal) builder.addModifiers(Modifier.FINAL); - //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)); @@ -278,8 +260,37 @@ public class EntityProcess extends BaseProcessor{ //whether the main class is the base itself boolean typeIsBase = baseClassType != null && type.has(Component.class) && type.annotation(Component.class).base(); + if(type.isType() && (!type.name().endsWith("Def") && !type.name().endsWith("Comp"))){ + err("All entity def names must end with 'Def'/'Comp'", type.e); + } + + String name = type.isType() ? + type.name().replace("Def", "").replace("Comp", "") : + createName(type); + + //check for type name conflicts + if(!typeIsBase && baseClass != null && name.equals(baseName(baseClassType))){ + name += "Entity"; + } + + //skip double classes + if(usedNames.containsKey(name)){ + extraNames.get(usedNames.get(name), ObjectSet::new).add(type.name()); + continue; + } + + usedNames.put(name, type); + extraNames.get(type, ObjectSet::new).add(name); + if(!type.isType()){ + extraNames.get(type, ObjectSet::new).add(type.name()); + } + + TypeSpec.Builder builder = TypeSpec.classBuilder(name).addModifiers(Modifier.PUBLIC); + + if(isFinal && !typeIsBase) builder.addModifiers(Modifier.FINAL); + //add serialize() boolean - builder.addMethod(MethodSpec.methodBuilder("serialize").addModifiers(Modifier.PUBLIC, Modifier.FINAL).returns(boolean.class).addStatement("return " + ann.serialize()).build()); + builder.addMethod(MethodSpec.methodBuilder("serialize").addModifiers(Modifier.PUBLIC).returns(boolean.class).addStatement("return " + ann.serialize()).build()); //all SyncField fields Seq syncedFields = new Seq<>(); @@ -401,7 +412,7 @@ public class EntityProcess extends BaseProcessor{ //build method using same params/returns MethodSpec.Builder mbuilder = MethodSpec.methodBuilder(first.name()).addModifiers(first.is(Modifier.PRIVATE) ? Modifier.PRIVATE : Modifier.PUBLIC); - if(isFinal || entry.value.contains(s -> s.has(Final.class))) mbuilder.addModifiers(Modifier.FINAL); + //if(isFinal || entry.value.contains(s -> s.has(Final.class))) mbuilder.addModifiers(Modifier.FINAL); if(entry.value.contains(s -> s.has(CallSuper.class))) mbuilder.addAnnotation(CallSuper.class); //add callSuper here if necessary if(first.is(Modifier.STATIC)) mbuilder.addModifiers(Modifier.STATIC); mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get)); @@ -536,7 +547,7 @@ public class EntityProcess extends BaseProcessor{ .returns(tname(packageName + "." + name)) .addStatement(ann.pooled() ? "return Pools.obtain($L.class, " +name +"::new)" : "return new $L()", name).build()); - definitions.add(new EntityDefinition(packageName + "." + name, builder, type, baseClass, components, groups, allFieldSpecs)); + definitions.add(new EntityDefinition(packageName + "." + name, builder, type, typeIsBase ? null : baseClass, components, groups, allFieldSpecs)); } //generate groups @@ -686,12 +697,12 @@ public class EntityProcess extends BaseProcessor{ //getter if(!method.isVoid()){ - def.builder.addMethod(MethodSpec.overriding(method.e).addStatement("return " + var).addModifiers(Modifier.FINAL).build()); + def.builder.addMethod(MethodSpec.overriding(method.e).addStatement("return " + var).build()); } //setter if(method.isVoid() && !Seq.with(field.annotations).contains(f -> f.type.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){ - def.builder.addMethod(MethodSpec.overriding(method.e).addModifiers(Modifier.FINAL).addStatement("this." + var + " = " + var).build()); + def.builder.addMethod(MethodSpec.overriding(method.e).addStatement("this." + var + " = " + var).build()); } } } @@ -709,6 +720,11 @@ public class EntityProcess extends BaseProcessor{ Seq methods = dependencies.flatMap(Stype::methods); methods.sortComparing(Object::toString); + //optionally add superclass + Stype superclass = dependencies.map(this::interfaceToComp).find(s -> s != null && s.annotation(Component.class).base()); + //use the base type when the interface being emulated has a base + TypeName type = superclass != null && interfaceToComp(interf).annotation(Component.class).base() ? tname(baseName(superclass)) : interf.tname(); + //used method signatures ObjectSet signatures = new ObjectSet<>(); @@ -719,6 +735,7 @@ public class EntityProcess extends BaseProcessor{ .addModifiers(Modifier.FINAL); nullBuilder.addSuperinterface(interf.tname()); + if(superclass != null) nullBuilder.superclass(tname(baseName(superclass))); for(Smethod method : methods){ String signature = method.toString(); @@ -726,6 +743,7 @@ public class EntityProcess extends BaseProcessor{ Stype compType = interfaceToComp(method.type()); MethodSpec.Builder builder = MethodSpec.overriding(method.e).addModifiers(Modifier.PUBLIC, Modifier.FINAL); + builder.addAnnotation(OverrideCallSuper.class); //just in case if(!method.isVoid()){ if(method.name().equals("isNull")){ @@ -749,7 +767,7 @@ public class EntityProcess extends BaseProcessor{ signatures.add(signature); } - nullsBuilder.addField(FieldSpec.builder(interf.cname(), Strings.camelize(baseName)).initializer("new " + className + "()").addModifiers(Modifier.FINAL, Modifier.STATIC, Modifier.PUBLIC).build()); + nullsBuilder.addField(FieldSpec.builder(type, Strings.camelize(baseName)).initializer("new " + className + "()").addModifiers(Modifier.FINAL, Modifier.STATIC, Modifier.PUBLIC).build()); write(nullBuilder); } @@ -775,9 +793,8 @@ public class EntityProcess extends BaseProcessor{ String baseName(Stype comp){ String suffix = "Comp"; if(!comp.name().endsWith(suffix)) err("All components must have names that end with 'Comp'", comp.e); - boolean isConcrete = comp.has(EntityDef.class); //concrete base implementations have no "Base" suffix - return comp.name().substring(0, comp.name().length() - suffix.length()) + (isConcrete ? "" : "Base"); + return comp.name().substring(0, comp.name().length() - suffix.length()); } @Nullable Stype interfaceToComp(Stype type){ diff --git a/annotations/src/main/java/mindustry/annotations/remote/RemoteReadGenerator.java b/annotations/src/main/java/mindustry/annotations/remote/RemoteReadGenerator.java index 23fa4e5376..24eb123d34 100644 --- a/annotations/src/main/java/mindustry/annotations/remote/RemoteReadGenerator.java +++ b/annotations/src/main/java/mindustry/annotations/remote/RemoteReadGenerator.java @@ -5,9 +5,7 @@ import com.squareup.javapoet.*; import mindustry.annotations.*; import mindustry.annotations.util.TypeIOResolver.*; -import javax.lang.model.element.Modifier; import javax.lang.model.element.*; -import java.lang.reflect.*; import java.util.*; /** Generates code for reading remote invoke packets on the client and server. */ @@ -39,14 +37,8 @@ public class RemoteReadGenerator{ .returns(void.class); if(needsPlayer){ - //since the player type isn't loaded yet, creating a type def is necessary - //this requires reflection since the TypeName constructor is private for some reason - Constructor cons = TypeName.class.getDeclaredConstructor(String.class); - cons.setAccessible(true); - - TypeName playerType = cons.newInstance("mindustry.gen.Playerc"); //add player parameter - readMethod.addParameter(playerType, "player"); + readMethod.addParameter(ClassName.get(packageName, "Player"), "player"); } CodeBlock.Builder readBlock = CodeBlock.builder(); //start building block of code inside read method @@ -111,7 +103,7 @@ public class RemoteReadGenerator{ if(entry.forward && entry.where.isServer && needsPlayer){ //call forwarded method readBlock.addStatement(packageName + "." + entry.className + "." + entry.element.getSimpleName() + - "__forward(player.con()" + (varResult.length() == 0 ? "" : ", ") + varResult.toString() + ")"); + "__forward(player.con" + (varResult.length() == 0 ? "" : ", ") + varResult.toString() + ")"); } readBlock.nextControlFlow("catch (java.lang.Exception e)"); diff --git a/annotations/src/main/java/mindustry/annotations/remote/RemoteWriteGenerator.java b/annotations/src/main/java/mindustry/annotations/remote/RemoteWriteGenerator.java index 066ee9b6d9..f048c23d60 100644 --- a/annotations/src/main/java/mindustry/annotations/remote/RemoteWriteGenerator.java +++ b/annotations/src/main/java/mindustry/annotations/remote/RemoteWriteGenerator.java @@ -81,8 +81,8 @@ public class RemoteWriteGenerator{ return; } - if(!elem.getParameters().get(0).asType().toString().contains("Playerc")){ - BaseProcessor.err("Client invoke methods should have a first parameter of type Playerc", elem); + if(!elem.getParameters().get(0).asType().toString().contains("Player")){ + BaseProcessor.err("Client invoke methods should have a first parameter of type Player", elem); return; } } diff --git a/annotations/src/main/java/mindustry/annotations/remote/SerializerResolver.java b/annotations/src/main/java/mindustry/annotations/remote/SerializerResolver.java index b41674ffab..7128d6572f 100644 --- a/annotations/src/main/java/mindustry/annotations/remote/SerializerResolver.java +++ b/annotations/src/main/java/mindustry/annotations/remote/SerializerResolver.java @@ -17,6 +17,6 @@ public class SerializerResolver{ } private static boolean isEntity(TypeMirror mirror){ - return !mirror.toString().contains(".") && mirror.toString().endsWith("c"); + return !mirror.toString().contains(".") || mirror.toString().startsWith("mindustry.gen.") && !mirror.toString().startsWith("byte"); } } diff --git a/annotations/src/main/resources/classids.properties b/annotations/src/main/resources/classids.properties index 9643661825..94542d6270 100644 --- a/annotations/src/main/resources/classids.properties +++ b/annotations/src/main/resources/classids.properties @@ -6,15 +6,19 @@ cix=2 draug=3 mace=4 mindustry.entities.comp.BuildingComp=22 -mindustry.entities.comp.BulletComp=5 +mindustry.entities.comp.Buildingomp=11 +mindustry.entities.comp.BulletComp=24 +mindustry.entities.comp.Bulletomp=5 mindustry.entities.comp.DecalComp=6 mindustry.entities.comp.EffectComp=7 +mindustry.entities.comp.EffectInstanceComp=23 +mindustry.entities.comp.EffectStateComp=25 mindustry.entities.comp.FireComp=8 mindustry.entities.comp.LaunchCoreComp=21 mindustry.entities.comp.PlayerComp=9 mindustry.entities.comp.PuddleComp=10 -mindustry.entities.comp.TileComp=11 mindustry.type.Weather.WeatherComp=12 +mindustry.type.Weather.WeatherStateComp=26 mindustry.world.blocks.campaign.CoreLauncher.LaunchCoreComp=13 mindustry.world.blocks.campaign.LaunchPad.LaunchPayloadComp=14 oculon=15 diff --git a/annotations/src/main/resources/revisions/BlockUnitUnit/0.json b/annotations/src/main/resources/revisions/BlockUnitUnit/0.json new file mode 100644 index 0000000000..2160b1858b --- /dev/null +++ b/annotations/src/main/resources/revisions/BlockUnitUnit/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderCommanderMechMinerUnit/0.json b/annotations/src/main/resources/revisions/BuilderCommanderMechMinerUnit/0.json new file mode 100644 index 0000000000..d5684055f5 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderCommanderMechMinerUnit/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderMechUnit/0.json b/annotations/src/main/resources/revisions/BuilderMechUnit/0.json new file mode 100644 index 0000000000..b0bacdb1c1 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderMechUnit/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderMinerPayloadUnit/0.json b/annotations/src/main/resources/revisions/BuilderMinerPayloadUnit/0.json new file mode 100644 index 0000000000..26faae9a77 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderMinerPayloadUnit/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:payloads,type:arc.struct.Seq,size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderMinerUnit/0.json b/annotations/src/main/resources/revisions/BuilderMinerUnit/0.json new file mode 100644 index 0000000000..94f48a7b63 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderMinerUnit/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderUnit/0.json b/annotations/src/main/resources/revisions/BuilderUnit/0.json new file mode 100644 index 0000000000..719d06eac9 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderUnit/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Building/0.json b/annotations/src/main/resources/revisions/Building/0.json new file mode 100644 index 0000000000..c3a6d143c5 --- /dev/null +++ b/annotations/src/main/resources/revisions/Building/0.json @@ -0,0 +1 @@ +{fields:[{name:cons,type:mindustry.world.modules.ConsumeModule,size:-1},{name:health,type:float,size:4},{name:items,type:mindustry.world.modules.ItemModule,size:-1},{name:liquids,type:mindustry.world.modules.LiquidModule,size:-1},{name:power,type:mindustry.world.modules.PowerModule,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuildingEntity/0.json b/annotations/src/main/resources/revisions/BuildingEntity/0.json new file mode 100644 index 0000000000..c3a6d143c5 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuildingEntity/0.json @@ -0,0 +1 @@ +{fields:[{name:cons,type:mindustry.world.modules.ConsumeModule,size:-1},{name:health,type:float,size:4},{name:items,type:mindustry.world.modules.ItemModule,size:-1},{name:liquids,type:mindustry.world.modules.LiquidModule,size:-1},{name:power,type:mindustry.world.modules.PowerModule,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Bullet/0.json b/annotations/src/main/resources/revisions/Bullet/0.json new file mode 100644 index 0000000000..4904375b03 --- /dev/null +++ b/annotations/src/main/resources/revisions/Bullet/0.json @@ -0,0 +1 @@ +{fields:[{name:collided,type:arc.struct.IntSeq,size:-1},{name:damage,type:float,size:4},{name:data,type:java.lang.Object,size:-1},{name:lifetime,type:float,size:4},{name:owner,type:Entityc,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:time,type:float,size:4},{name:type,type:mindustry.entities.bullet.BulletType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Bullet/1.json b/annotations/src/main/resources/revisions/Bullet/1.json new file mode 100644 index 0000000000..c2d8c52eb2 --- /dev/null +++ b/annotations/src/main/resources/revisions/Bullet/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:collided,type:arc.struct.IntSeq,size:-1},{name:damage,type:float,size:4},{name:data,type:java.lang.Object,size:-1},{name:lifetime,type:float,size:4},{name:owner,type:mindustry.gen.Entityc,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:time,type:float,size:4},{name:type,type:mindustry.entities.bullet.BulletType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Bullet/2.json b/annotations/src/main/resources/revisions/Bullet/2.json new file mode 100644 index 0000000000..04b1c437de --- /dev/null +++ b/annotations/src/main/resources/revisions/Bullet/2.json @@ -0,0 +1 @@ +{version:2,fields:[{name:collided,type:arc.struct.IntSeq,size:-1},{name:damage,type:float,size:4},{name:data,type:java.lang.Object,size:-1},{name:lifetime,type:float,size:4},{name:owner,type:Entityc,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:time,type:float,size:4},{name:type,type:mindustry.entities.bullet.BulletType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/CommanderUnitWaterMove/0.json b/annotations/src/main/resources/revisions/CommanderUnitWaterMove/0.json new file mode 100644 index 0000000000..2160b1858b --- /dev/null +++ b/annotations/src/main/resources/revisions/CommanderUnitWaterMove/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Decal/0.json b/annotations/src/main/resources/revisions/Decal/0.json new file mode 100644 index 0000000000..df78246160 --- /dev/null +++ b/annotations/src/main/resources/revisions/Decal/0.json @@ -0,0 +1 @@ +{fields:[{name:color,type:arc.graphics.Color,size:-1},{name:lifetime,type:float,size:4},{name:region,type:arc.graphics.g2d.TextureRegion,size:-1},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Effect/0.json b/annotations/src/main/resources/revisions/Effect/0.json new file mode 100644 index 0000000000..5ce16bf09c --- /dev/null +++ b/annotations/src/main/resources/revisions/Effect/0.json @@ -0,0 +1 @@ +{fields:[{name:color,type:arc.graphics.Color,size:-1},{name:data,type:java.lang.Object,size:-1},{name:effect,type:mindustry.entities.Effect,size:-1},{name:lifetime,type:float,size:4},{name:offsetX,type:float,size:4},{name:offsetY,type:float,size:4},{name:parent,type:Posc,size:-1},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/EffectInstance/0.json b/annotations/src/main/resources/revisions/EffectInstance/0.json new file mode 100644 index 0000000000..5ce16bf09c --- /dev/null +++ b/annotations/src/main/resources/revisions/EffectInstance/0.json @@ -0,0 +1 @@ +{fields:[{name:color,type:arc.graphics.Color,size:-1},{name:data,type:java.lang.Object,size:-1},{name:effect,type:mindustry.entities.Effect,size:-1},{name:lifetime,type:float,size:4},{name:offsetX,type:float,size:4},{name:offsetY,type:float,size:4},{name:parent,type:Posc,size:-1},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/EffectState/0.json b/annotations/src/main/resources/revisions/EffectState/0.json new file mode 100644 index 0000000000..5ce16bf09c --- /dev/null +++ b/annotations/src/main/resources/revisions/EffectState/0.json @@ -0,0 +1 @@ +{fields:[{name:color,type:arc.graphics.Color,size:-1},{name:data,type:java.lang.Object,size:-1},{name:effect,type:mindustry.entities.Effect,size:-1},{name:lifetime,type:float,size:4},{name:offsetX,type:float,size:4},{name:offsetY,type:float,size:4},{name:parent,type:Posc,size:-1},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/EffectState/1.json b/annotations/src/main/resources/revisions/EffectState/1.json new file mode 100644 index 0000000000..0ccd683257 --- /dev/null +++ b/annotations/src/main/resources/revisions/EffectState/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:color,type:arc.graphics.Color,size:-1},{name:data,type:java.lang.Object,size:-1},{name:effect,type:mindustry.entities.Effect,size:-1},{name:lifetime,type:float,size:4},{name:offsetX,type:float,size:4},{name:offsetY,type:float,size:4},{name:parent,type:mindustry.gen.Posc,size:-1},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/EffectState/2.json b/annotations/src/main/resources/revisions/EffectState/2.json new file mode 100644 index 0000000000..fb05e5f923 --- /dev/null +++ b/annotations/src/main/resources/revisions/EffectState/2.json @@ -0,0 +1 @@ +{version:2,fields:[{name:color,type:arc.graphics.Color,size:-1},{name:data,type:java.lang.Object,size:-1},{name:effect,type:mindustry.entities.Effect,size:-1},{name:lifetime,type:float,size:4},{name:offsetX,type:float,size:4},{name:offsetY,type:float,size:4},{name:parent,type:Posc,size:-1},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Fire/0.json b/annotations/src/main/resources/revisions/Fire/0.json new file mode 100644 index 0000000000..a5423a835b --- /dev/null +++ b/annotations/src/main/resources/revisions/Fire/0.json @@ -0,0 +1 @@ +{fields:[{name:baseFlammability,type:float,size:4},{name:block,type:mindustry.world.Block,size:-1},{name:lifetime,type:float,size:4},{name:puddleFlammability,type:float,size:4},{name:tile,type:mindustry.world.Tile,size:-1},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/LaunchCore/0.json b/annotations/src/main/resources/revisions/LaunchCore/0.json new file mode 100644 index 0000000000..86b499e433 --- /dev/null +++ b/annotations/src/main/resources/revisions/LaunchCore/0.json @@ -0,0 +1 @@ +{fields:[{name:block,type:mindustry.world.Block,size:-1},{name:lifetime,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/LaunchPayload/0.json b/annotations/src/main/resources/revisions/LaunchPayload/0.json new file mode 100644 index 0000000000..feba28804f --- /dev/null +++ b/annotations/src/main/resources/revisions/LaunchPayload/0.json @@ -0,0 +1 @@ +{fields:[{name:lifetime,type:float,size:4},{name:stacks,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/LegsUnit/0.json b/annotations/src/main/resources/revisions/LegsUnit/0.json new file mode 100644 index 0000000000..2160b1858b --- /dev/null +++ b/annotations/src/main/resources/revisions/LegsUnit/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/MechUnit/0.json b/annotations/src/main/resources/revisions/MechUnit/0.json new file mode 100644 index 0000000000..32f895e075 --- /dev/null +++ b/annotations/src/main/resources/revisions/MechUnit/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/MinerUnit/0.json b/annotations/src/main/resources/revisions/MinerUnit/0.json new file mode 100644 index 0000000000..5df97253d8 --- /dev/null +++ b/annotations/src/main/resources/revisions/MinerUnit/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Player/0.json b/annotations/src/main/resources/revisions/Player/0.json new file mode 100644 index 0000000000..de2ce4432f --- /dev/null +++ b/annotations/src/main/resources/revisions/Player/0.json @@ -0,0 +1 @@ +{fields:[{name:admin,type:boolean,size:1},{name:boosting,type:boolean,size:1},{name:color,type:arc.graphics.Color,size:-1},{name:mouseX,type:float,size:4},{name:mouseY,type:float,size:4},{name:name,type:java.lang.String,size:-1},{name:shooting,type:boolean,size:1},{name:team,type:mindustry.game.Team,size:-1},{name:typing,type:boolean,size:1},{name:unit,type:Unitc,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Player/1.json b/annotations/src/main/resources/revisions/Player/1.json new file mode 100644 index 0000000000..b1d245c264 --- /dev/null +++ b/annotations/src/main/resources/revisions/Player/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:admin,type:boolean,size:1},{name:boosting,type:boolean,size:1},{name:color,type:arc.graphics.Color,size:-1},{name:mouseX,type:float,size:4},{name:mouseY,type:float,size:4},{name:name,type:java.lang.String,size:-1},{name:shooting,type:boolean,size:1},{name:team,type:mindustry.game.Team,size:-1},{name:typing,type:boolean,size:1},{name:unit,type:Unit,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Player/2.json b/annotations/src/main/resources/revisions/Player/2.json new file mode 100644 index 0000000000..b98ef7435e --- /dev/null +++ b/annotations/src/main/resources/revisions/Player/2.json @@ -0,0 +1 @@ +{version:2,fields:[{name:admin,type:boolean,size:1},{name:boosting,type:boolean,size:1},{name:color,type:arc.graphics.Color,size:-1},{name:mouseX,type:float,size:4},{name:mouseY,type:float,size:4},{name:name,type:java.lang.String,size:-1},{name:shooting,type:boolean,size:1},{name:team,type:mindustry.game.Team,size:-1},{name:typing,type:boolean,size:1},{name:unit,type:mindustry.gen.Unit,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Player/3.json b/annotations/src/main/resources/revisions/Player/3.json new file mode 100644 index 0000000000..3c0245dab3 --- /dev/null +++ b/annotations/src/main/resources/revisions/Player/3.json @@ -0,0 +1 @@ +{version:3,fields:[{name:admin,type:boolean,size:1},{name:boosting,type:boolean,size:1},{name:color,type:arc.graphics.Color,size:-1},{name:mouseX,type:float,size:4},{name:mouseY,type:float,size:4},{name:name,type:java.lang.String,size:-1},{name:shooting,type:boolean,size:1},{name:team,type:mindustry.game.Team,size:-1},{name:typing,type:boolean,size:1},{name:unit,type:Unit,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Player/4.json b/annotations/src/main/resources/revisions/Player/4.json new file mode 100644 index 0000000000..5becfa43a0 --- /dev/null +++ b/annotations/src/main/resources/revisions/Player/4.json @@ -0,0 +1 @@ +{version:4,fields:[{name:admin,type:boolean,size:1},{name:boosting,type:boolean,size:1},{name:color,type:arc.graphics.Color,size:-1},{name:mouseX,type:float,size:4},{name:mouseY,type:float,size:4},{name:name,type:java.lang.String,size:-1},{name:shooting,type:boolean,size:1},{name:team,type:mindustry.game.Team,size:-1},{name:typing,type:boolean,size:1},{name:unit,type:Unit,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Puddle/0.json b/annotations/src/main/resources/revisions/Puddle/0.json new file mode 100644 index 0000000000..3c4c644549 --- /dev/null +++ b/annotations/src/main/resources/revisions/Puddle/0.json @@ -0,0 +1 @@ +{fields:[{name:amount,type:float,size:4},{name:generation,type:int,size:4},{name:liquid,type:mindustry.type.Liquid,size:-1},{name:tile,type:mindustry.world.Tile,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Unit/0.json b/annotations/src/main/resources/revisions/Unit/0.json new file mode 100644 index 0000000000..2160b1858b --- /dev/null +++ b/annotations/src/main/resources/revisions/Unit/0.json @@ -0,0 +1 @@ +{fields:[{name:ammo,type:int,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/Weather/0.json b/annotations/src/main/resources/revisions/Weather/0.json new file mode 100644 index 0000000000..84ba06dbcd --- /dev/null +++ b/annotations/src/main/resources/revisions/Weather/0.json @@ -0,0 +1 @@ +{fields:[{name:intensity,type:float,size:4},{name:life,type:float,size:4},{name:opacity,type:float,size:4},{name:weather,type:mindustry.type.Weather,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/WeatherState/0.json b/annotations/src/main/resources/revisions/WeatherState/0.json new file mode 100644 index 0000000000..84ba06dbcd --- /dev/null +++ b/annotations/src/main/resources/revisions/WeatherState/0.json @@ -0,0 +1 @@ +{fields:[{name:intensity,type:float,size:4},{name:life,type:float,size:4},{name:opacity,type:float,size:4},{name:weather,type:mindustry.type.Weather,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8411b695c1..c8f6e725a5 100644 --- a/build.gradle +++ b/build.gradle @@ -176,6 +176,7 @@ allprojects{ sourceCompatibility = 1.8 targetCompatibility = 1.8 options.encoding = "UTF-8" + options.compilerArgs += ["-Xlint:deprecation"] } } diff --git a/core/assets/scripts/global.js b/core/assets/scripts/global.js index 11ced98b60..e42dd8605c 100755 --- a/core/assets/scripts/global.js +++ b/core/assets/scripts/global.js @@ -107,7 +107,7 @@ const BlockBuildBeginEvent = Packages.mindustry.game.EventType.BlockBuildBeginEv const ResearchEvent = Packages.mindustry.game.EventType.ResearchEvent const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent const StateChangeEvent = Packages.mindustry.game.EventType.StateChangeEvent -const TileChangeEvent = Packages.mindustry.game.EventType.TileChangeEvent +const BuildinghangeEvent = Packages.mindustry.game.EventType.BuildinghangeEvent const GameOverEvent = Packages.mindustry.game.EventType.GameOverEvent const TapConfigEvent = Packages.mindustry.game.EventType.TapConfigEvent const TapEvent = Packages.mindustry.game.EventType.TapEvent diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index 1587c69460..24c444c0cb 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -195,7 +195,8 @@ public class Vars implements Loadable{ public static NetServer netServer; public static NetClient netClient; - public static Playerc player; + public static + Player player; @Override public void loadAsync(){ diff --git a/core/src/mindustry/ai/BaseAI.java b/core/src/mindustry/ai/BaseAI.java index 06e7720651..88e224db76 100644 --- a/core/src/mindustry/ai/BaseAI.java +++ b/core/src/mindustry/ai/BaseAI.java @@ -45,7 +45,7 @@ public class BaseAI{ //create AI core unit if(!Groups.unit.contains(u -> u.team() == data.team && u.type() == block.unitType)){ - Unitc unit = block.unitType.create(data.team); + Unit unit = block.unitType.create(data.team); unit.set(data.core()); unit.add(); Fx.spawn.at(unit); diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index 637bed1bbb..de46e53050 100644 --- a/core/src/mindustry/ai/BlockIndexer.java +++ b/core/src/mindustry/ai/BlockIndexer.java @@ -51,7 +51,7 @@ public class BlockIndexer{ private Seq returnArray = new Seq<>(); public BlockIndexer(){ - Events.on(TileChangeEvent.class, event -> { + Events.on(BuildinghangeEvent.class, event -> { if(typeMap.get(event.tile.pos()) != null){ TileIndex index = typeMap.get(event.tile.pos()); for(BlockFlag flag : index.flags){ @@ -164,11 +164,11 @@ public class BlockIndexer{ return flagMap[team.id][type.ordinal()]; } - public boolean eachBlock(Teamc team, float range, Boolf pred, Cons cons){ + public boolean eachBlock(Teamc team, float range, Boolf pred, Cons cons){ return eachBlock(team.team(), team.getX(), team.getY(), range, pred, cons); } - public boolean eachBlock(Team team, float wx, float wy, float range, Boolf pred, Cons cons){ + public boolean eachBlock(Team team, float wx, float wy, float range, Boolf pred, Cons cons){ intSet.clear(); int tx = world.toTile(wx); @@ -181,7 +181,7 @@ public class BlockIndexer{ for(int y = -tileRange + ty; y <= tileRange + ty; y++){ if(!Mathf.within(x * tilesize, y * tilesize, wx, wy, range)) continue; - Tilec other = world.ent(x, y); + Building other = world.ent(x, y); if(other == null) continue; @@ -211,7 +211,7 @@ public class BlockIndexer{ return returnArray; } - public void notifyTileDamaged(Tilec entity){ + public void notifyTileDamaged(Building entity){ if(damagedTiles[(int)entity.team().id] == null){ damagedTiles[(int)entity.team().id] = new TileArray(); } @@ -220,11 +220,11 @@ public class BlockIndexer{ set.add(entity.tile()); } - public Tilec findEnemyTile(Team team, float x, float y, float range, Boolf pred){ + public Building findEnemyTile(Team team, float x, float y, float range, Boolf pred){ for(Team enemy : activeTeams){ if(!team.isEnemy(enemy)) continue; - Tilec entity = indexer.findTile(enemy, x, y, range, pred, true); + Building entity = indexer.findTile(enemy, x, y, range, pred, true); if(entity != null){ return entity; } @@ -233,12 +233,12 @@ public class BlockIndexer{ return null; } - public Tilec findTile(Team team, float x, float y, float range, Boolf pred){ + public Building findTile(Team team, float x, float y, float range, Boolf pred){ return findTile(team, x, y, range, pred, false); } - public Tilec findTile(Team team, float x, float y, float range, Boolf pred, boolean usePriority){ - Tilec closest = null; + public Building findTile(Team team, float x, float y, float range, Boolf pred, boolean usePriority){ + Building closest = null; float dst = 0; float range2 = range * range; @@ -249,7 +249,7 @@ public class BlockIndexer{ for(int tx = rx * quadrantSize; tx < (rx + 1) * quadrantSize && tx < world.width(); tx++){ for(int ty = ry * quadrantSize; ty < (ry + 1) * quadrantSize && ty < world.height(); ty++){ - Tilec e = world.ent(tx, ty); + Building e = world.ent(tx, ty); if(e == null) continue; @@ -390,7 +390,7 @@ public class BlockIndexer{ outer: for(int x = quadrantX * quadrantSize; x < world.width() && x < (quadrantX + 1) * quadrantSize; x++){ for(int y = quadrantY * quadrantSize; y < world.height() && y < (quadrantY + 1) * quadrantSize; y++){ - Tilec result = world.ent(x, y); + Building result = world.ent(x, y); //when a targetable block is found, mark this quadrant as occupied and stop searching if(result != null && result.team() == team){ bits.set(quadrantX, quadrantY); diff --git a/core/src/mindustry/ai/Pathfinder.java b/core/src/mindustry/ai/Pathfinder.java index 5b8f58b93e..c7c7ac00bf 100644 --- a/core/src/mindustry/ai/Pathfinder.java +++ b/core/src/mindustry/ai/Pathfinder.java @@ -63,7 +63,7 @@ public class Pathfinder implements Runnable{ Events.on(ResetEvent.class, event -> stop()); - Events.on(TileChangeEvent.class, event -> updateTile(event.tile)); + Events.on(BuildinghangeEvent.class, event -> updateTile(event.tile)); } /** Packs a tile into its internal representation. */ diff --git a/core/src/mindustry/ai/WaveSpawner.java b/core/src/mindustry/ai/WaveSpawner.java index 61b02e6113..b6b66178a0 100644 --- a/core/src/mindustry/ai/WaveSpawner.java +++ b/core/src/mindustry/ai/WaveSpawner.java @@ -48,7 +48,7 @@ public class WaveSpawner{ eachFlyerSpawn((spawnX, spawnY) -> { for(int i = 0; i < spawned; i++){ - Unitc unit = group.createUnit(state.rules.waveTeam, state.wave - 1); + Unit unit = group.createUnit(state.rules.waveTeam, state.wave - 1); unit.set(spawnX + Mathf.range(spread), spawnY + Mathf.range(spread)); unit.add(); } @@ -61,7 +61,7 @@ public class WaveSpawner{ for(int i = 0; i < spawned; i++){ Tmp.v1.rnd(spread); - Unitc unit = group.createUnit(state.rules.waveTeam, state.wave - 1); + Unit unit = group.createUnit(state.rules.waveTeam, state.wave - 1); unit.set(spawnX + Tmp.v1.x, spawnY + Tmp.v1.y); Time.run(Math.min(i * 5, 60 * 2), () -> spawnEffect(unit)); } @@ -85,8 +85,8 @@ public class WaveSpawner{ } if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam) && !state.teams.playerCores().isEmpty()){ - Tilec firstCore = state.teams.playerCores().first(); - for(Tilec core : state.rules.waveTeam.cores()){ + Building firstCore = state.teams.playerCores().first(); + for(Building core : state.rules.waveTeam.cores()){ Tmp.v1.set(firstCore).sub(core).limit(coreMargin + core.block().size * tilesize); cons.accept(core.x() + Tmp.v1.x, core.y() + Tmp.v1.y, false); } @@ -104,7 +104,7 @@ public class WaveSpawner{ } if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam)){ - for(Tilec core : state.teams.get(state.rules.waveTeam).cores){ + for(Building core : state.teams.get(state.rules.waveTeam).cores){ cons.get(core.x(), core.y()); } } @@ -124,7 +124,7 @@ public class WaveSpawner{ } } - private void spawnEffect(Unitc unit){ + private void spawnEffect(Unit unit){ Fx.unitSpawn.at(unit.x(), unit.y(), 0f, unit); Time.run(30f, () -> { unit.add(); diff --git a/core/src/mindustry/ai/types/FormationAI.java b/core/src/mindustry/ai/types/FormationAI.java index 14f291f7ec..66ca6a9d21 100644 --- a/core/src/mindustry/ai/types/FormationAI.java +++ b/core/src/mindustry/ai/types/FormationAI.java @@ -8,58 +8,58 @@ import mindustry.entities.units.*; import mindustry.gen.*; public class FormationAI extends AIController implements FormationMember{ - public Unitc leader; + public Unit leader; private Vec3 target = new Vec3(); private @Nullable Formation formation; - public FormationAI(Unitc leader, Formation formation){ + public FormationAI(Unit leader, Formation formation){ this.leader = leader; this.formation = formation; } @Override public void init(){ - target.set(unit.x(), unit.y(), 0); + target.set(unit.x, unit.y, 0); } @Override public void updateUnit(){ - if(leader.dead()){ + if(leader.dead){ unit.resetController(); return; } - unit.controlWeapons(leader.isRotate(), leader.isShooting()); + unit.controlWeapons(leader.isRotate(), leader.isShooting); // unit.moveAt(Tmp.v1.set(deltaX, deltaY).limit(unit.type().speed)); - if(leader.isShooting()){ + if(leader.isShooting){ unit.aimLook(leader.aimX(), leader.aimY()); }else{ if(!unit.moving()){ - unit.lookAt(unit.vel().angle()); + unit.lookAt(unit.vel.angle()); }else{ - unit.lookAt(leader.rotation()); + unit.lookAt(leader.rotation); } } Vec2 realtarget = vec.set(target); if(unit.isGrounded() && Vars.world.raycast(unit.tileX(), unit.tileY(), leader.tileX(), leader.tileY(), Vars.world::solid)){ - realtarget.set(Vars.pathfinder.getTargetTile(unit.tileOn(), unit.team(), leader)); + realtarget.set(Vars.pathfinder.getTargetTile(unit.tileOn(), unit.team, leader)); } unit.moveAt(realtarget.sub(unit).limit(unit.type().speed)); } @Override - public void removed(Unitc unit){ + public void removed(Unit unit){ if(formation != null){ formation.removeMember(this); } } @Override - public boolean isBeingControlled(Unitc player){ + public boolean isBeingControlled(Unit player){ return leader == player; } diff --git a/core/src/mindustry/ai/types/GroundAI.java b/core/src/mindustry/ai/types/GroundAI.java index 3a6241e9a5..0a7384ff45 100644 --- a/core/src/mindustry/ai/types/GroundAI.java +++ b/core/src/mindustry/ai/types/GroundAI.java @@ -22,7 +22,7 @@ public class GroundAI extends AIController{ targetClosest(); } - Tilec core = unit.closestEnemyCore(); + Building core = unit.closestEnemyCore(); if(core != null){ if(unit.within(core,unit.range() / 1.1f)){ @@ -81,7 +81,7 @@ public class GroundAI extends AIController{ Tile tile = unit.tileOn(); if(tile == null) return; Tile targetTile = pathfinder.getTargetTile(tile, enemy, FlagTarget.enemyCores); - Tilec core = unit.closestCore(); + Building core = unit.closestCore(); if(tile == targetTile || core == null || unit.within(core, 120f)) return; diff --git a/core/src/mindustry/ai/types/SuicideAI.java b/core/src/mindustry/ai/types/SuicideAI.java index 071492a00d..3ccb620816 100644 --- a/core/src/mindustry/ai/types/SuicideAI.java +++ b/core/src/mindustry/ai/types/SuicideAI.java @@ -20,14 +20,14 @@ public class SuicideAI extends GroundAI{ targetClosest(); } - Tilec core = unit.closestEnemyCore(); + Building core = unit.closestEnemyCore(); boolean rotate = false, shoot = false; if(!Units.invalidateTarget(target, unit, unit.range())){ rotate = true; shoot = unit.within(target, unit.type().weapons.first().bullet.range() + - (target instanceof Tilec ? ((Tilec)target).block().size * Vars.tilesize / 2f : ((Hitboxc)target).hitSize() / 2f)); + (target instanceof Building ? ((Building)target).block().size * Vars.tilesize / 2f : ((Hitboxc)target).hitSize() / 2f)); if(unit.type().hasWeapons()){ unit.aimLook(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed)); diff --git a/core/src/mindustry/async/TeamIndexProcess.java b/core/src/mindustry/async/TeamIndexProcess.java index 2b5c0043a6..b31ebcbe0b 100644 --- a/core/src/mindustry/async/TeamIndexProcess.java +++ b/core/src/mindustry/async/TeamIndexProcess.java @@ -9,10 +9,10 @@ import java.util.*; /** Creates quadtrees per unit team. */ public class TeamIndexProcess implements AsyncProcess{ - private QuadTree[] trees = new QuadTree[Team.all.length]; + private QuadTree[] trees = new QuadTree[Team.all.length]; private int[] counts = new int[Team.all.length]; - public QuadTree tree(Team team){ + public QuadTree tree(Team team){ if(trees[team.uid] == null) trees[team.uid] = new QuadTree<>(Vars.world.getQuadBounds(new Rect())); return trees[team.uid]; @@ -43,9 +43,9 @@ public class TeamIndexProcess implements AsyncProcess{ Arrays.fill(counts, 0); - for(Unitc unit : Groups.unit){ - tree(unit.team()).insert(unit); - counts[unit.team().id] ++; + for(Unit unit : Groups.unit){ + tree(unit.team).insert(unit); + counts[unit.team.id] ++; } } diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 0f31d83147..766481cb29 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -1518,14 +1518,14 @@ public class Blocks implements ContentList{ } @Override - public void init(Bulletc b){ + public void init(Bullet b){ for(int i = 0; i < rays; i++){ Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), rayLength - Math.abs(i - (rays / 2)) * 20f); } } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ super.draw(b); Draw.color(Color.white, Pal.lancerLaser, b.fin()); //Draw.alpha(b.fout()); diff --git a/core/src/mindustry/content/Bullets.java b/core/src/mindustry/content/Bullets.java index 9d764a538a..78af69229f 100644 --- a/core/src/mindustry/content/Bullets.java +++ b/core/src/mindustry/content/Bullets.java @@ -390,19 +390,19 @@ public class Bullets implements ContentList{ } @Override - public void init(Bulletc b){ + public void init(Bullet b){ b.vel().setLength(0.6f + Mathf.random(2f)); } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ Draw.color(Pal.lightFlame, Pal.darkFlame, Color.gray, b.fin()); Fill.circle(b.x(), b.y(), 3f * b.fout()); Draw.reset(); } @Override - public void update(Bulletc b){ + public void update(Bullet b){ if(Mathf.chance(0.04 * Time.delta())){ Tile tile = world.tileWorld(b.x(), b.y()); if(tile != null){ @@ -442,7 +442,7 @@ public class Bullets implements ContentList{ } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ } }; @@ -462,7 +462,7 @@ public class Bullets implements ContentList{ } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ } }; @@ -549,7 +549,7 @@ public class Bullets implements ContentList{ } @Override - public void hit(Bulletc b, float x, float y){ + public void hit(Bullet b, float x, float y){ super.hit(b, x, y); for(int i = 0; i < 3; i++){ diff --git a/core/src/mindustry/content/Fx.java b/core/src/mindustry/content/Fx.java index 16d6fd9fac..d8b11b0da8 100644 --- a/core/src/mindustry/content/Fx.java +++ b/core/src/mindustry/content/Fx.java @@ -26,31 +26,31 @@ public class Fx{ none = new Effect(0, 0f, e -> {}), unitSpawn = new Effect(30f, e -> { - if(!(e.data instanceof Unitc)) return; + if(!(e.data instanceof Unit)) return; alpha(e.fin()); float scl = 1f + e.fout() * 2f; - Unitc unit = (Unitc)e.data; + Unit unit = e.data(); rect(unit.type().region, e.x, e.y, unit.type().region.getWidth() * Draw.scl * scl, unit.type().region.getHeight() * Draw.scl * scl, 180f); }), unitControl = new Effect(30f, e -> { - if(!(e.data instanceof Unitc)) return; + if(!(e.data instanceof Unit)) return; - Unitc select = (Unitc)e.data; + Unit select = e.data(); mixcol(Pal.accent, 1f); alpha(e.fout()); - rect(select.type().icon(Cicon.full), select.x(), select.y(), select.rotation() - 90f); + rect(select.type().icon(Cicon.full), select.x, select.y, select.rotation - 90f); alpha(1f); Lines.stroke(e.fslope() * 1f); - Lines.square(select.x(), select.y(), e.fout() * select.hitSize() * 2f, 45); + Lines.square(select.x, select.y, e.fout() * select.hitSize * 2f, 45); Lines.stroke(e.fslope() * 2f); - Lines.square(select.x(), select.y(), e.fout() * select.hitSize() * 3f, 45f); + Lines.square(select.x, select.y, e.fout() * select.hitSize * 3f, 45f); reset(); }), @@ -1256,7 +1256,7 @@ public class Fx{ unitShieldBreak = new Effect(35, e -> { if(!(e.data instanceof Unitc)) return; - Unitc unit = e.data(); + Unit unit = e.data(); float radius = unit.hitSize() * 1.3f; diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index b0cdd121f4..c93c880f8a 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -127,7 +127,7 @@ public class UnitTypes implements ContentList{ @Override public void update(Unitc player){ - if(player.timer().get(Playerc.timerAbility, healReload)){ + if(player.timer().get(Player.timerAbility, healReload)){ wasHealed = false; Units.nearby(player.team(), player.x, player.y, healRange, unit -> { @@ -707,8 +707,8 @@ public class UnitTypes implements ContentList{ } @Override - public void update(Playerc player){ - if(player.timer.get(Playerc.timerAbility, healReload)){ + public void update(Player player){ + if(player.timer.get(Player.timerAbility, healReload)){ if(indexer.eachBlock(player, healRange, other -> other.entity.damaged(), other -> { other.entity.heal(other.entity.maxHealth() * healPercent / 100f); Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal); @@ -782,9 +782,9 @@ public class UnitTypes implements ContentList{ } @Override - public void update(Playerc player){ + public void update(Player player){ - if(player.timer.get(Playerc.timerAbility, healReload)){ + if(player.timer.get(Player.timerAbility, healReload)){ wasHealed = false; Units.nearby(player.team(), player.x, player.y, healRange, unit -> { @@ -834,12 +834,12 @@ public class UnitTypes implements ContentList{ } @Override - public float getRotationAlpha(Playerc player){ + public float getRotationAlpha(Player player){ return 0.6f - player.shootHeat * 0.3f; } @Override - public float spreadX(Playerc player){ + public float spreadX(Player player){ return player.shootHeat * 2f; } @@ -850,18 +850,18 @@ public class UnitTypes implements ContentList{ } @Override - public void update(Playerc player){ + public void update(Player player){ float scl = 1f - player.shootHeat / 2f*Time.delta(); player.vel().scl(scl); } @Override - public float getExtraArmor(Playerc player){ + public float getExtraArmor(Player player){ return player.shootHeat * 30f; } @Override - public void draw(Playerc player){ + public void draw(Player player){ if(player.shootHeat <= 0.01f) return; Shaders.build.progress = player.shootHeat; @@ -901,10 +901,10 @@ public class UnitTypes implements ContentList{ } @Override - public void update(Playerc player){ + public void update(Player player){ super.update(player); - if(player.timer.get(Playerc.timerAbility, effectReload)){ + if(player.timer.get(Player.timerAbility, effectReload)){ Units.nearby(player.team(), player.x, player.y, effectRange, unit -> { //unit.applyEffect(StatusEffects.overdrive, effectDuration); @@ -955,12 +955,12 @@ public class UnitTypes implements ContentList{ } @Override - public float getRotationAlpha(Playerc player){ + public float getRotationAlpha(Player player){ return 0.5f; } @Override - public void update(Playerc player){ + public void update(Player player){ float scl = scld(player); if(Mathf.chanceDelta((0.15 * scl))){ Fx.hitLancer.at(Pal.lancerLaser, player.x, player.y); @@ -970,7 +970,7 @@ public class UnitTypes implements ContentList{ } @Override - public void draw(Playerc player){ + public void draw(Player player){ float scl = scld(player); if(scl < 0.01f) return; Draw.color(Pal.lancerLaser); @@ -980,7 +980,7 @@ public class UnitTypes implements ContentList{ Draw.blend(); } - float scld(Playerc player){ + float scld(Player player){ return Mathf.clamp((player.vel().len() - minV) / (maxV - minV)); } }; diff --git a/core/src/mindustry/content/Weathers.java b/core/src/mindustry/content/Weathers.java index 2ae14acdf3..beceac902a 100644 --- a/core/src/mindustry/content/Weathers.java +++ b/core/src/mindustry/content/Weathers.java @@ -33,7 +33,7 @@ public class Weathers implements ContentList{ } @Override - public void drawOver(Weatherc state){ + public void drawOver(WeatherState state){ rand.setSeed(0); Tmp.r1.setCentered(Core.camera.position.x, Core.camera.position.y, Core.graphics.getWidth() / renderer.minScale(), Core.graphics.getHeight() / renderer.minScale()); Tmp.r1.grow(padding); @@ -78,7 +78,7 @@ public class Weathers implements ContentList{ } @Override - public void drawOver(Weatherc state){ + public void drawOver(WeatherState state){ Tmp.r1.setCentered(Core.camera.position.x, Core.camera.position.y, Core.graphics.getWidth() / renderer.minScale(), Core.graphics.getHeight() / renderer.minScale()); Tmp.r1.grow(padding); Core.camera.bounds(Tmp.r2); @@ -110,7 +110,7 @@ public class Weathers implements ContentList{ } @Override - public void drawUnder(Weatherc state){ + public void drawUnder(WeatherState state){ Tmp.r1.setCentered(Core.camera.position.x, Core.camera.position.y, Core.graphics.getWidth() / renderer.minScale(), Core.graphics.getHeight() / renderer.minScale()); Tmp.r1.grow(padding); Core.camera.bounds(Tmp.r2); @@ -170,15 +170,15 @@ public class Weathers implements ContentList{ } @Override - public void update(Weatherc state){ + public void update(WeatherState state){ - for(Unitc unit : Groups.unit){ + for(Unit unit : Groups.unit){ unit.impulse(force.x * state.intensity(), force.y * state.intensity()); } } @Override - public void drawOver(Weatherc state){ + public void drawOver(WeatherState state){ rand.setSeed(0); Tmp.r1.setCentered(Core.camera.position.x, Core.camera.position.y, Core.graphics.getWidth() / renderer.minScale(), Core.graphics.getHeight() / renderer.minScale()); Tmp.r1.grow(padding); diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index 8671e58a67..99833d4347 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -74,7 +74,7 @@ public class Control implements ApplicationListener, Loadable{ Events.on(WorldLoadEvent.class, event -> { if(Mathf.zero(player.x()) && Mathf.zero(player.y())){ - Tilec core = state.teams.closestCore(0, 0, player.team()); + Building core = state.teams.closestCore(0, 0, player.team()); if(core != null){ player.set(core); camera.position.set(core); @@ -158,7 +158,7 @@ public class Control implements ApplicationListener, Loadable{ }); Events.on(Trigger.newGame, () -> { - Tilec core = player.closestCore(); + Building core = player.closestCore(); if(core == null) return; @@ -198,9 +198,9 @@ public class Control implements ApplicationListener, Loadable{ } void createPlayer(){ - player = PlayerEntity.create(); - player.name(Core.settings.getString("name")); - player.color().set(Core.settings.getInt("color-0")); + player = Player.create(); + player.name = Core.settings.getString("name"); + player.color.set(Core.settings.getInt("color-0")); if(mobile){ input = new MobileInput(); @@ -243,7 +243,7 @@ public class Control implements ApplicationListener, Loadable{ //TODO move public void handleLaunch(CoreEntity tile){ - LaunchCorec ent = LaunchCoreEntity.create(); + LaunchCorec ent = LaunchCore.create(); ent.set(tile); ent.block(Blocks.coreShard); ent.lifetime(Vars.launchDuration); @@ -268,7 +268,7 @@ public class Control implements ApplicationListener, Loadable{ if(state.rules.defaultTeam.cores().isEmpty()){ //kill all friendly units, since they should be dead anwyay - for(Unitc unit : Groups.unit){ + for(Unit unit : Groups.unit){ if(unit.team() == state.rules.defaultTeam){ unit.remove(); } @@ -347,12 +347,12 @@ public class Control implements ApplicationListener, Loadable{ zone.rules.get(state.rules); //TODO assign zone!! //state.rules.zone = zone; - for(Tilec core : state.teams.playerCores()){ + for(Building core : state.teams.playerCores()){ for(ItemStack stack : zone.getStartingItems()){ core.items().add(stack.item, stack.amount); } } - Tilec core = state.teams.playerCores().first(); + Building core = state.teams.playerCores().first(); core.items().clear(); logic.play(); diff --git a/core/src/mindustry/core/GameState.java b/core/src/mindustry/core/GameState.java index 51ab59a460..88cb0b6dac 100644 --- a/core/src/mindustry/core/GameState.java +++ b/core/src/mindustry/core/GameState.java @@ -33,8 +33,8 @@ public class GameState{ private State state = State.menu; //TODO optimize - public Unitc boss(){ - return Groups.unit.find(u -> u.isBoss() && u.team() == rules.waveTeam); + public Unit boss(){ + return Groups.unit.find(u -> u.isBoss() && u.team == rules.waveTeam); } public void set(State astate){ diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 41518bdf6b..e9f900a162 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -117,7 +117,7 @@ public class Logic implements ApplicationListener{ if(!state.isCampaign()){ for(TeamData team : state.teams.getActive()){ if(team.hasCore()){ - TileEntity entity = team.core(); + Building entity = team.core(); entity.items.clear(); for(ItemStack stack : state.rules.loadout){ entity.items.add(stack.item, stack.amount); @@ -221,7 +221,7 @@ public class Logic implements ApplicationListener{ } //TODO core launch effect - for(Tilec tile : state.teams.playerCores()){ + for(Building tile : state.teams.playerCores()){ Fx.launch.at(tile); } @@ -234,11 +234,11 @@ public class Logic implements ApplicationListener{ //TODO containers must be launched too Time.runTask(30f, () -> { - for(Tilec entity : state.teams.playerCores()){ + for(Building entity : state.teams.playerCores()){ for(Item item : content.items()){ //TODO where do the items go? - //data.addItem(item, entity.items().get(item)); - //Events.fire(new LaunchItemEvent(new ItemStack(item, entity.items().get(item)))); + //data.addItem(item, entity.items.get(item)); + //Events.fire(new LaunchItemEvent(new ItemStack(item, entity.items.get(item)))); } entity.tile().remove(); } diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index 2cb3719ecf..3b551b4b66 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -153,7 +153,7 @@ public class NetClient implements ApplicationListener{ //called on all clients @Remote(targets = Loc.server, variants = Variant.both) - public static void sendMessage(String message, String sender, Playerc playersender){ + public static void sendMessage(String message, String sender, Player playersender){ if(Vars.ui != null){ Vars.ui.chatfrag.addMessage(message, sender); } @@ -174,7 +174,7 @@ public class NetClient implements ApplicationListener{ //called when a server recieves a chat message from a player @Remote(called = Loc.server, targets = Loc.client) - public static void sendChatMessage(Playerc player, String message){ + public static void sendChatMessage(Player player, String message){ if(message.length() > maxTextLength){ throw new ValidateException(player, "Player has sent a message above the text limit."); } @@ -224,7 +224,7 @@ public class NetClient implements ApplicationListener{ } public static String colorizeName(int id, String name){ - Playerc player = Groups.player.getByID(id); + Player player = Groups.player.getByID(id); if(name == null || player == null) return null; return "[#" + player.color().toString().toUpperCase() + "]" + name; } @@ -238,7 +238,7 @@ public class NetClient implements ApplicationListener{ } @Remote(targets = Loc.client) - public static void onPing(Playerc player, long time){ + public static void onPing(Player player, long time){ Call.onPingResponse(player.con(), time); } @@ -248,7 +248,7 @@ public class NetClient implements ApplicationListener{ } @Remote(variants = Variant.one) - public static void onTraceInfo(Playerc player, TraceInfo info){ + public static void onTraceInfo(Player player, TraceInfo info){ if(player != null){ ui.traces.show(player, info); } @@ -458,7 +458,7 @@ public class NetClient implements ApplicationListener{ Tile tile = world.tile(pos); if(tile != null && tile.entity != null){ - tile.entity.items().read(Reads.get(input)); + tile.entity.items.read(Reads.get(input)); }else{ new ItemModule().read(Reads.get(input)); } @@ -563,14 +563,14 @@ public class NetClient implements ApplicationListener{ } } - Unitc unit = player.dead() ? Nulls.unit : player.unit(); + Unit unit = player.dead() ? Nulls.unit : player.unit(); Call.onClientShapshot(lastSent++, - unit.x(), unit.y(), + unit.x, unit.y, player.unit().aimX(), player.unit().aimY(), - unit.rotation(), + unit.rotation, unit instanceof Mechc ? ((Mechc)unit).baseRotation() : 0, - unit.vel().x, unit.vel().y, + unit.vel.x, unit.vel.y, player.miner().mineTile(), control.input.isBoosting, control.input.isShooting, ui.chatfrag.shown(), requests, diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index eeb941b575..256b659c89 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -51,7 +51,7 @@ public class NetServer implements ApplicationListener{ if((state.rules.waveTeam == data.team && state.rules.waves) || !data.team.active()) return Integer.MAX_VALUE; int count = 0; - for(Playerc other : players){ + for(Player other : players){ if(other.team() == data.team && other != player){ count++; } @@ -75,7 +75,7 @@ public class NetServer implements ApplicationListener{ /** Data stream for writing player sync data to. */ private DataOutputStream dataStream = new DataOutputStream(syncStream); /** Packet handlers for custom types of messages. */ - private ObjectMap>> customPacketHandlers = new ObjectMap<>(); + private ObjectMap>> customPacketHandlers = new ObjectMap<>(); public NetServer(){ @@ -207,7 +207,7 @@ public class NetServer implements ApplicationListener{ con.modclient = true; } - Playerc player = PlayerEntity.create(); + Player player = Player.create(); player.admin(admins.isAdmin(uuid, packet.usid)); player.con(con); player.con().usid = packet.usid; @@ -267,7 +267,7 @@ public class NetServer implements ApplicationListener{ } private void registerCommands(){ - clientCommands.register("help", "[page]", "Lists all commands.", (args, player) -> { + clientCommands.register("help", "[page]", "Lists all commands.", (args, player) -> { if(args.length > 0 && !Strings.canParseInt(args[0])){ player.sendMessage("[scarlet]'page' must be a number."); return; @@ -293,7 +293,7 @@ public class NetServer implements ApplicationListener{ player.sendMessage(result.toString()); }); - clientCommands.register("t", "", "Send a message only to your teammates.", (args, player) -> { + clientCommands.register("t", "", "Send a message only to your teammates.", (args, player) -> { String message = admins.filterMessage(player, args[0]); if(message != null){ Groups.player.each(p -> p.team() == player.team(), o -> o.sendMessage(message, player, "[#" + player.team().color.toString() + "]" + NetClient.colorizeName(player.id(), player.name()))); @@ -308,13 +308,13 @@ public class NetServer implements ApplicationListener{ int voteCooldown = 60 * 5; class VoteSession{ - Playerc target; + Player target; ObjectSet voted = new ObjectSet<>(); VoteSession[] map; Timer.Task task; int votes; - public VoteSession(VoteSession[] map, Playerc target){ + public VoteSession(VoteSession[] map, Player target){ this.target = target; this.map = map; this.task = Timer.schedule(() -> { @@ -326,7 +326,7 @@ public class NetServer implements ApplicationListener{ }, voteDuration); } - void vote(Playerc player, int d){ + void vote(Player player, int d){ votes += d; voted.addAll(player.uuid(), admins.getInfo(player.uuid()).lastIP); @@ -352,7 +352,7 @@ public class NetServer implements ApplicationListener{ //current kick sessions VoteSession[] currentlyKicking = {null}; - clientCommands.register("votekick", "[player...]", "Vote to kick a player.", (args, player) -> { + clientCommands.register("votekick", "[player...]", "Vote to kick a player.", (args, player) -> { if(!Config.enableVotekick.bool()){ player.sendMessage("[scarlet]Vote-kick is disabled on this server."); return; @@ -377,7 +377,7 @@ public class NetServer implements ApplicationListener{ }); player.sendMessage(builder.toString()); }else{ - Playerc found; + Player found; if(args[0].length() > 1 && args[0].startsWith("#") && Strings.canParseInt(args[0].substring(1))){ int id = Strings.parseInt(args[0].substring(1)); found = Groups.player.find(p -> p.id() == id); @@ -411,7 +411,7 @@ public class NetServer implements ApplicationListener{ } }); - clientCommands.register("vote", "", "Vote to kick the current player.", (arg, player) -> { + clientCommands.register("vote", "", "Vote to kick the current player.", (arg, player) -> { if(currentlyKicking[0] == null){ player.sendMessage("[scarlet]Nobody is being voted on."); }else{ @@ -441,7 +441,7 @@ public class NetServer implements ApplicationListener{ } }); - clientCommands.register("sync", "Re-synchronize world state.", (args, player) -> { + clientCommands.register("sync", "Re-synchronize world state.", (args, player) -> { if(player.isLocal()){ player.sendMessage("[scarlet]Re-synchronizing as the host is pointless."); }else{ @@ -461,15 +461,15 @@ public class NetServer implements ApplicationListener{ return 2 + (Groups.player.size() > 4 ? 1 : 0); } - public Team assignTeam(Playerc current){ + public Team assignTeam(Player current){ return assigner.assign(current, Groups.player); } - public Team assignTeam(Playerc current, Iterable players){ + public Team assignTeam(Player current, Iterable players){ return assigner.assign(current, players); } - public void sendWorldData(Playerc player){ + public void sendWorldData(Player player){ ByteArrayOutputStream stream = new ByteArrayOutputStream(); DeflaterOutputStream def = new FastDeflaterOutputStream(stream); NetworkIO.writeWorld(player, def); @@ -480,15 +480,15 @@ public class NetServer implements ApplicationListener{ Log.debug("Packed @ compressed bytes of world data.", stream.size()); } - public void addPacketHandler(String type, Cons2 handler){ + public void addPacketHandler(String type, Cons2 handler){ customPacketHandlers.get(type, Seq::new).add(handler); } - public Seq> getPacketHandlers(String type){ + public Seq> getPacketHandlers(String type){ return customPacketHandlers.get(type, Seq::new); } - public static void onDisconnect(Playerc player, String reason){ + public static void onDisconnect(Player player, String reason){ //singleplayer multiplayer wierdness if(player.con() == null){ player.remove(); @@ -510,22 +510,22 @@ public class NetServer implements ApplicationListener{ } @Remote(targets = Loc.client) - public static void serverPacketReliable(Playerc player, String type, String contents){ + public static void serverPacketReliable(Player player, String type, String contents){ if(netServer.customPacketHandlers.containsKey(type)){ - for(Cons2 c : netServer.customPacketHandlers.get(type)){ + for(Cons2 c : netServer.customPacketHandlers.get(type)){ c.get(player, contents); } } } @Remote(targets = Loc.client, unreliable = true) - public static void serverPacketUnreliable(Playerc player, String type, String contents){ + public static void serverPacketUnreliable(Player player, String type, String contents){ serverPacketReliable(player, type, contents); } @Remote(targets = Loc.client, unreliable = true) public static void onClientShapshot( - Playerc player, + Player player, int snapshotID, float x, float y, float pointerX, float pointerY, @@ -599,7 +599,7 @@ public class NetServer implements ApplicationListener{ connection.rejectedRequests.clear(); if(!player.dead()){ - Unitc unit = player.unit(); + Unit unit = player.unit(); unit.vel().set(xVelocity, yVelocity).limit(unit.type().speed); long elapsed = Time.timeSinceMillis(connection.lastRecievedClientTime); @@ -664,7 +664,7 @@ public class NetServer implements ApplicationListener{ } @Remote(targets = Loc.client, called = Loc.server) - public static void onAdminRequest(Playerc player, Playerc other, AdminAction action){ + public static void onAdminRequest(Player player, Player other, AdminAction action){ if(!player.admin()){ Log.warn("ACCESS DENIED: Player @ / @ attempted to perform admin action without proper security access.", @@ -700,7 +700,7 @@ public class NetServer implements ApplicationListener{ } @Remote(targets = Loc.client) - public static void connectConfirm(Playerc player){ + public static void connectConfirm(Player player){ if(player.con() == null || player.con().hasConnected) return; player.add(); @@ -773,7 +773,7 @@ public class NetServer implements ApplicationListener{ syncStream.reset(); short sent = 0; - for(Tilec entity : Groups.tile){ + for(Building entity : Groups.tile){ if(!entity.block().sync) continue; sent ++; @@ -796,7 +796,7 @@ public class NetServer implements ApplicationListener{ } } - public void writeEntitySnapshot(Playerc player) throws IOException{ + public void writeEntitySnapshot(Player player) throws IOException{ syncStream.reset(); Seq cores = state.teams.cores(player.team()); @@ -804,7 +804,7 @@ public class NetServer implements ApplicationListener{ for(CoreEntity entity : cores){ dataStream.writeInt(entity.tile().pos()); - entity.items().write(Writes.get(dataStream)); + entity.items.write(Writes.get(dataStream)); } dataStream.close(); @@ -925,6 +925,6 @@ public class NetServer implements ApplicationListener{ } public interface TeamAssigner{ - Team assign(Playerc player, Iterable players); + Team assign(Player player, Iterable players); } } diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index cf0c911d52..c71ba37178 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -259,7 +259,7 @@ public class Renderer implements ApplicationListener{ private void drawLanding(){ if(landTime > 0 && player.closestCore() != null){ float fract = landTime / Fx.coreLand.lifetime; - Tilec entity = player.closestCore(); + Building entity = player.closestCore(); TextureRegion reg = entity.block().icon(Cicon.full); float scl = Scl.scl(4f) / camerascale; diff --git a/core/src/mindustry/core/World.java b/core/src/mindustry/core/World.java index 415619bf94..476fd2760a 100644 --- a/core/src/mindustry/core/World.java +++ b/core/src/mindustry/core/World.java @@ -102,7 +102,7 @@ public class World{ } @Nullable - public Tile tilec(int x, int y){ + public Tile Building(int x, int y){ Tile tile = tiles.get(x, y); if(tile == null) return null; if(tile.entity != null) return tile.entity.tile(); @@ -110,14 +110,14 @@ public class World{ } @Nullable - public Tilec ent(int x, int y){ + public Building ent(int x, int y){ Tile tile = tile(x, y); if(tile == null) return null; return tile.entity; } @Nullable - public Tilec ent(int pos){ + public Building ent(int pos){ Tile tile = tile(pos); if(tile == null) return null; return tile.entity; @@ -134,7 +134,7 @@ public class World{ } @Nullable - public Tilec entWorld(float x, float y){ + public Building entWorld(float x, float y){ return ent(Math.round(x / tilesize), Math.round(y / tilesize)); } @@ -166,7 +166,7 @@ public class World{ /** * Call to signify the beginning of map loading. - * TileChangeEvents will not be fired until endMapLoad(). + * BuildinghangeEvents will not be fired until endMapLoad(). */ public void beginMapLoad(){ generating = true; @@ -317,7 +317,7 @@ public class World{ public void notifyChanged(Tile tile){ if(!generating){ - Core.app.post(() -> Events.fire(new TileChangeEvent(tile))); + Core.app.post(() -> Events.fire(new BuildinghangeEvent(tile))); } } diff --git a/core/src/mindustry/editor/EditorTile.java b/core/src/mindustry/editor/EditorTile.java index 8af3a40818..386c46c644 100644 --- a/core/src/mindustry/editor/EditorTile.java +++ b/core/src/mindustry/editor/EditorTile.java @@ -109,7 +109,7 @@ public class EditorTile extends Tile{ } @Override - protected void changeEntity(Team team, Prov entityprov){ + protected void changeEntity(Team team, Prov entityprov){ if(state.isGame()){ super.changeEntity(team, entityprov); return; diff --git a/core/src/mindustry/editor/MapGenerateDialog.java b/core/src/mindustry/editor/MapGenerateDialog.java index 1517a63db8..0fafa14815 100644 --- a/core/src/mindustry/editor/MapGenerateDialog.java +++ b/core/src/mindustry/editor/MapGenerateDialog.java @@ -51,7 +51,7 @@ public class MapGenerateDialog extends BaseDialog{ private CachedTile ctile = new CachedTile(){ //nothing. @Override - protected void changeEntity(Team team, Prov entityprov){ + protected void changeEntity(Team team, Prov entityprov){ } }; diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index 26516d8ecb..05fa5167b6 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -72,7 +72,7 @@ public class Damage{ } } - public static void collideLine(Bulletc hitter, Team team, Effect effect, float x, float y, float angle, float length){ + public static void collideLine(Bullet hitter, Team team, Effect effect, float x, float y, float angle, float length){ collideLine(hitter, team, effect, x, y, angle, length, false); } @@ -80,11 +80,11 @@ public class Damage{ * Damages entities in a line. * Only enemies of the specified team are damaged. */ - public static void collideLine(Bulletc hitter, Team team, Effect effect, float x, float y, float angle, float length, boolean large){ + public static void collideLine(Bullet hitter, Team team, Effect effect, float x, float y, float angle, float length, boolean large){ collidedBlocks.clear(); tr.trns(angle, length); Intc2 collider = (cx, cy) -> { - Tilec tile = world.ent(cx, cy); + Building tile = world.ent(cx, cy); if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.team() != team && tile.collide(hitter)){ tile.collision(hitter); collidedBlocks.add(tile.pos()); @@ -122,7 +122,7 @@ public class Damage{ rect.width += expand * 2; rect.height += expand * 2; - Cons cons = e -> { + Cons cons = e -> { e.hitbox(hitrect); Rect other = hitrect; other.y -= expand; @@ -143,8 +143,8 @@ public class Damage{ } /** Damages all entities and blocks in a radius that are enemies of the team. */ - public static void damageUnits(Team team, float x, float y, float size, float damage, Boolf predicate, Cons acceptor){ - Cons cons = entity -> { + public static void damageUnits(Team team, float x, float y, float size, float damage, Boolf predicate, Cons acceptor){ + Cons cons = entity -> { if(!predicate.get(entity)) return; entity.hitbox(hitrect); @@ -180,8 +180,8 @@ public class Damage{ /** Applies a status effect to all enemy units in a range. */ public static void status(Team team, float x, float y, float radius, StatusEffect effect, float duration, boolean air, boolean ground){ - Cons cons = entity -> { - if(entity.team() == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){ + Cons cons = entity -> { + if(entity.team == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){ return; } @@ -203,15 +203,15 @@ public class Damage{ /** Damages all entities and blocks in a radius that are enemies of the team. */ public static void damage(Team team, float x, float y, float radius, float damage, boolean complete, boolean air, boolean ground){ - Cons cons = entity -> { - if(entity.team() == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){ + Cons cons = entity -> { + if(entity.team == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){ return; } float amount = calculateDamage(x, y, entity.getX(), entity.getY(), radius, damage); entity.damage(amount); //TODO better velocity displacement float dst = tr.set(entity.getX() - x, entity.getY() - y).len(); - entity.vel().add(tr.setLength((1f - dst / radius) * 2f / entity.mass())); + entity.vel.add(tr.setLength((1f - dst / radius) * 2f / entity.mass())); if(complete && damage >= 9999999f && entity.isPlayer()){ Events.fire(Trigger.exclusionDeath); diff --git a/core/src/mindustry/entities/Effects.java b/core/src/mindustry/entities/Effects.java index 86f3defddd..d016a69091 100644 --- a/core/src/mindustry/entities/Effects.java +++ b/core/src/mindustry/entities/Effects.java @@ -42,7 +42,7 @@ public class Effects{ Rect pos = Tmp.r2.setSize(effect.size).setCenter(x, y); if(view.overlaps(pos)){ - Effectc entity = EffectEntity.create(); + EffectState entity = EffectState.create(); entity.effect(effect); entity.rotation(rotation); entity.data(data); @@ -58,7 +58,7 @@ public class Effects{ public static void decal(TextureRegion region, float x, float y, float rotation, float lifetime, Color color){ if(headless || region == null || !Core.atlas.isFound(region)) return; - Decalc decal = DecalEntity.create(); + Decal decal = Decal.create(); decal.set(x, y); decal.rotation(rotation); decal.lifetime(lifetime); diff --git a/core/src/mindustry/entities/Fires.java b/core/src/mindustry/entities/Fires.java index a5577c2027..6d329e8f50 100644 --- a/core/src/mindustry/entities/Fires.java +++ b/core/src/mindustry/entities/Fires.java @@ -13,16 +13,16 @@ import static mindustry.Vars.*; public class Fires{ private static final float baseLifetime = 1000f; - private static final IntMap map = new IntMap<>(); + private static final IntMap map = new IntMap<>(); /** Start a fire on the tile. If there already is a file there, refreshes its lifetime. */ public static void create(Tile tile){ if(net.client() || tile == null) return; //not clientside. - Firec fire = map.get(tile.pos()); + Fire fire = map.get(tile.pos()); if(fire == null){ - fire = FireEntity.create(); + fire = Fire.create(); fire.tile(tile); fire.lifetime(baseLifetime); fire.set(tile.worldx(), tile.worldy()); @@ -34,7 +34,7 @@ public class Fires{ } } - public static Firec get(int x, int y){ + public static Fire get(int x, int y){ return map.get(Point2.pack(x, y)); } @@ -42,7 +42,7 @@ public class Fires{ if(!Structs.inBounds(x, y, world.width(), world.height()) || !map.containsKey(Point2.pack(x, y))){ return false; } - Firec fire = map.get(Point2.pack(x, y)); + Fire fire = map.get(Point2.pack(x, y)); return fire.isAdded() && fire.fin() < 1f && fire.tile() != null && fire.tile().x == x && fire.tile().y == y; } @@ -51,7 +51,7 @@ public class Fires{ */ public static void extinguish(Tile tile, float intensity){ if(tile != null && map.containsKey(tile.pos())){ - Firec fire = map.get(tile.pos()); + Fire fire = map.get(tile.pos()); fire.time(fire.time() + intensity * Time.delta()); Fx.steam.at(fire); if(fire.time() >= fire.lifetime()){ @@ -64,7 +64,7 @@ public class Fires{ map.remove(tile.pos()); } - public static void register(Firec fire){ - map.put(fire.tile().pos(), fire); + public static void register(Fire fire){ + map.put(fire.tile.pos(), fire); } } diff --git a/core/src/mindustry/entities/GroupDefs.java b/core/src/mindustry/entities/GroupDefs.java index 4c477fdd91..95c456026d 100644 --- a/core/src/mindustry/entities/GroupDefs.java +++ b/core/src/mindustry/entities/GroupDefs.java @@ -11,5 +11,5 @@ class GroupDefs{ @GroupDef(value = Buildingc.class) G tile; @GroupDef(value = Syncc.class, mapping = true) G sync; @GroupDef(value = Drawc.class) G draw; - @GroupDef(value = Weatherc.class) G weather; + @GroupDef(value = WeatherStatec.class) G weather; } diff --git a/core/src/mindustry/entities/Puddles.java b/core/src/mindustry/entities/Puddles.java index 9d10b84213..3b9f02c75c 100644 --- a/core/src/mindustry/entities/Puddles.java +++ b/core/src/mindustry/entities/Puddles.java @@ -10,22 +10,22 @@ import mindustry.type.*; import mindustry.world.*; public class Puddles{ - private static final IntMap map = new IntMap<>(); + private static final IntMap map = new IntMap<>(); public static final float maxLiquid = 70f; - /** Deposists a Puddlec between tile and source. */ + /** Deposists a Puddle between tile and source. */ public static void deposit(Tile tile, Tile source, Liquid liquid, float amount){ deposit(tile, source, liquid, amount, 0); } - /** Deposists a Puddlec at a tile. */ + /** Deposists a Puddle at a tile. */ public static void deposit(Tile tile, Liquid liquid, float amount){ deposit(tile, tile, liquid, amount, 0); } - /** Returns the Puddlec on the specified tile. May return null. */ - public static Puddlec get(Tile tile){ + /** Returns the Puddle on the specified tile. May return null. */ + public static Puddle get(Tile tile){ return map.get(tile.pos()); } @@ -36,7 +36,7 @@ public class Puddles{ reactPuddle(tile.floor().liquidDrop, liquid, amount, tile, (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); - Puddlec p = map.get(tile.pos()); + Puddle p = map.get(tile.pos()); if(generation == 0 && p != null && p.lastRipple() <= Time.time() - 40f){ Fx.ripple.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, 1f, tile.floor().liquidDrop.color); @@ -45,9 +45,9 @@ public class Puddles{ return; } - Puddlec p = map.get(tile.pos()); + Puddle p = map.get(tile.pos()); if(p == null){ - Puddlec puddle = PuddleEntity.create(); + Puddle puddle = Puddle.create(); puddle.tile(tile); puddle.liquid(liquid); puddle.amount(amount); @@ -73,7 +73,7 @@ public class Puddles{ map.remove(tile.pos()); } - public static void register(Puddlec puddle){ + public static void register(Puddle puddle){ map.put(puddle.tile().pos(), puddle); } @@ -85,12 +85,12 @@ public class Puddles{ if(Mathf.chance(0.006 * amount)){ Call.createBullet(Bullets.fireball, Team.derelict, x, y, Mathf.random(360f), -1f, 1f, 1f); } - }else if(dest.temperature > 0.7f && liquid.temperature < 0.55f){ //cold liquid poured onto hot Puddlec + }else if(dest.temperature > 0.7f && liquid.temperature < 0.55f){ //cold liquid poured onto hot Puddle if(Mathf.chance(0.5f * amount)){ Fx.steam.at(x, y); } return -0.1f * amount; - }else if(liquid.temperature > 0.7f && dest.temperature < 0.55f){ //hot liquid poured onto cold Puddlec + }else if(liquid.temperature > 0.7f && dest.temperature < 0.55f){ //hot liquid poured onto cold Puddle if(Mathf.chance(0.8f * amount)){ Fx.steam.at(x, y); } diff --git a/core/src/mindustry/entities/Units.java b/core/src/mindustry/entities/Units.java index 61fb594d02..3545f21a8f 100644 --- a/core/src/mindustry/entities/Units.java +++ b/core/src/mindustry/entities/Units.java @@ -12,12 +12,12 @@ import static mindustry.Vars.*; /** Utility class for unit and team interactions.*/ public class Units{ private static Rect hitrect = new Rect(); - private static Unitc result; + private static Unit result; private static float cdist; private static boolean boolResult; @Remote(called = Loc.server) - public static void onUnitDeath(Unitc unit){ + public static void onUnitDeath(Unit unit){ unit.killed(); } @@ -31,7 +31,7 @@ public class Units{ } /** @return whether this player can interact with a specific tile. if either of these are null, returns true.*/ - public static boolean canInteract(Playerc player, Tilec tile){ + public static boolean canInteract(Player player, Building tile){ return player == null || tile == null || tile.interactable(player.team()); } @@ -54,7 +54,7 @@ public class Units{ } /** See {@link #invalidateTarget(Posc, Team, float, float, float)} */ - public static boolean invalidateTarget(Teamc target, Unitc targeter, float range){ + public static boolean invalidateTarget(Teamc target, Unit targeter, float range){ return invalidateTarget(target, targeter.team(), targeter.x(), targeter.y(), range); } @@ -91,18 +91,18 @@ public class Units{ } /** Returns the neareset damaged tile. */ - public static Tilec findDamagedTile(Team team, float x, float y){ + public static Building findDamagedTile(Team team, float x, float y){ Tile tile = Geometry.findClosest(x, y, indexer.getDamaged(team)); return tile == null ? null : tile.entity; } /** Returns the neareset ally tile in a range. */ - public static Tilec findAllyTile(Team team, float x, float y, float range, Boolf pred){ + public static Building findAllyTile(Team team, float x, float y, float range, Boolf pred){ return indexer.findTile(team, x, y, range, pred); } /** Returns the neareset enemy tile in a range. */ - public static Tilec findEnemyTile(Team team, float x, float y, float range, Boolf pred){ + public static Building findEnemyTile(Team team, float x, float y, float range, Boolf pred){ if(team == Team.derelict) return null; return indexer.findEnemyTile(team, x, y, range, pred); @@ -110,19 +110,19 @@ public class Units{ /** Returns the closest target enemy. First, units are checked, then tile entities. */ public static Teamc closestTarget(Team team, float x, float y, float range){ - return closestTarget(team, x, y, range, Unitc::isValid); + return closestTarget(team, x, y, range, Unit::isValid); } /** Returns the closest target enemy. First, units are checked, then tile entities. */ - public static Teamc closestTarget(Team team, float x, float y, float range, Boolf unitPred){ + public static Teamc closestTarget(Team team, float x, float y, float range, Boolf unitPred){ return closestTarget(team, x, y, range, unitPred, t -> true); } /** Returns the closest target enemy. First, units are checked, then tile entities. */ - public static Teamc closestTarget(Team team, float x, float y, float range, Boolf unitPred, Boolf tilePred){ + public static Teamc closestTarget(Team team, float x, float y, float range, Boolf unitPred, Boolf tilePred){ if(team == Team.derelict) return null; - Unitc unit = closestEnemy(team, x, y, range, unitPred); + Unit unit = closestEnemy(team, x, y, range, unitPred); if(unit != null){ return unit; }else{ @@ -131,7 +131,7 @@ public class Units{ } /** Returns the closest enemy of this team. Filter by predicate. */ - public static Unitc closestEnemy(Team team, float x, float y, float range, Boolf predicate){ + public static Unit closestEnemy(Team team, float x, float y, float range, Boolf predicate){ if(team == Team.derelict) return null; result = null; @@ -151,11 +151,11 @@ public class Units{ } /** Returns the closest ally of this team. Filter by predicate. No range. */ - public static Unitc closest(Team team, float x, float y, Boolf predicate){ + public static Unit closest(Team team, float x, float y, Boolf predicate){ result = null; cdist = 0f; - for(Unitc e : Groups.unit){ + for(Unit e : Groups.unit){ if(!predicate.get(e) || e.team() != team) continue; float dist = e.dst2(x, y); @@ -169,7 +169,7 @@ public class Units{ } /** Returns the closest ally of this team. Filter by predicate. */ - public static Unitc closest(Team team, float x, float y, float range, Boolf predicate){ + public static Unit closest(Team team, float x, float y, float range, Boolf predicate){ result = null; cdist = 0f; @@ -188,7 +188,7 @@ public class Units{ /** Returns the closest ally of this team. Filter by predicate. * Unlike the closest() function, this only guarantees that unit hitboxes overlap the range. */ - public static Unitc closestOverlap(Team team, float x, float y, float range, Boolf predicate){ + public static Unit closestOverlap(Team team, float x, float y, float range, Boolf predicate){ result = null; cdist = 0f; @@ -206,12 +206,12 @@ public class Units{ } /** Iterates over all units in a rectangle. */ - public static void nearby(Team team, float x, float y, float width, float height, Cons cons){ + public static void nearby(Team team, float x, float y, float width, float height, Cons cons){ teamIndex.tree(team).intersect(x, y, width, height, cons); } /** Iterates over all units in a circle around this position. */ - public static void nearby(Team team, float x, float y, float radius, Cons cons){ + public static void nearby(Team team, float x, float y, float radius, Cons cons){ nearby(team, x - radius, y - radius, radius*2f, radius*2f, unit -> { if(unit.within(x, y, radius)){ cons.get(unit); @@ -220,24 +220,24 @@ public class Units{ } /** Iterates over all units in a rectangle. */ - public static void nearby(float x, float y, float width, float height, Cons cons){ + public static void nearby(float x, float y, float width, float height, Cons cons){ Groups.unit.intersect(x, y, width, height, cons); } /** Iterates over all units in a rectangle. */ - public static void nearby(Rect rect, Cons cons){ + public static void nearby(Rect rect, Cons cons){ nearby(rect.x, rect.y, rect.width, rect.height, cons); } /** Iterates over all units that are enemies of this team. */ - public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons cons){ + public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons cons){ for(Team enemy : state.teams.enemiesOf(team)){ nearby(enemy, x, y, width, height, cons); } } /** Iterates over all units that are enemies of this team. */ - public static void nearbyEnemies(Team team, Rect rect, Cons cons){ + public static void nearbyEnemies(Team team, Rect rect, Cons cons){ nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons); } diff --git a/core/src/mindustry/entities/bullet/ArtilleryBulletType.java b/core/src/mindustry/entities/bullet/ArtilleryBulletType.java index c000ed470a..fcbb331bb3 100644 --- a/core/src/mindustry/entities/bullet/ArtilleryBulletType.java +++ b/core/src/mindustry/entities/bullet/ArtilleryBulletType.java @@ -24,7 +24,7 @@ public class ArtilleryBulletType extends BasicBulletType{ } @Override - public void update(Bulletc b){ + public void update(Bullet b){ super.update(b); if(b.timer(0, 3 + b.fslope() * 2f)){ @@ -33,7 +33,7 @@ public class ArtilleryBulletType extends BasicBulletType{ } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ float baseScale = 0.7f; float scale = (baseScale + b.fslope() * (1f - baseScale)); diff --git a/core/src/mindustry/entities/bullet/BasicBulletType.java b/core/src/mindustry/entities/bullet/BasicBulletType.java index becfc69ec8..f4f7a75d97 100644 --- a/core/src/mindustry/entities/bullet/BasicBulletType.java +++ b/core/src/mindustry/entities/bullet/BasicBulletType.java @@ -39,7 +39,7 @@ public class BasicBulletType extends BulletType{ } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ float height = this.height * ((1f - shrinkY) + shrinkY * b.fout()); float width = this.width * ((1f - shrinkX) + shrinkX * b.fout()); diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index ea9babae9c..cd37fc677e 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -110,19 +110,19 @@ public abstract class BulletType extends Content{ return speed * lifetime * (1f - drag); } - public boolean collides(Bulletc bullet, Tilec tile){ + public boolean collides(Bullet bullet, Building tile){ return true; } - public void hitTile(Bulletc b, Tilec tile){ + public void hitTile(Bullet b, Building tile){ hit(b); } - public void hit(Bulletc b){ + public void hit(Bullet b){ hit(b, b.getX(), b.getY()); } - public void hit(Bulletc b, float x, float y){ + public void hit(Bullet b, float x, float y){ hitEffect.at(x, y, b.rotation(), hitColor); hitSound.at(b); @@ -153,7 +153,7 @@ public abstract class BulletType extends Content{ } } - public void despawned(Bulletc b){ + public void despawned(Bullet b){ despawnEffect.at(b.getX(), b.getY(), b.rotation()); hitSound.at(b); @@ -162,14 +162,14 @@ public abstract class BulletType extends Content{ } } - public void draw(Bulletc b){ + public void draw(Bullet b){ } - public void drawLight(Bulletc b){ + public void drawLight(Bullet b){ Drawf.light(b.team(), b, lightRadius, lightColor, lightOpacity); } - public void init(Bulletc b){ + public void init(Bullet b){ if(killShooter && b.owner() instanceof Healthc){ ((Healthc)b.owner()).kill(); } @@ -179,7 +179,7 @@ public abstract class BulletType extends Content{ } } - public void update(Bulletc b){ + public void update(Bullet b){ if(homingPower > 0.0001f){ Teamc target = Units.closestTarget(b.team(), b.getX(), b.getY(), homingRange, e -> (e.isGrounded() && collidesGround) || (e.isFlying() && collidesAir), t -> collidesGround); if(target != null){ @@ -197,32 +197,32 @@ public abstract class BulletType extends Content{ return ContentType.bullet; } - public Bulletc create(Teamc owner, float x, float y, float angle){ + public Bullet create(Teamc owner, float x, float y, float angle){ return create(owner, owner.team(), x, y, angle); } - public Bulletc create(Entityc owner, Team team, float x, float y, float angle){ + public Bullet create(Entityc owner, Team team, float x, float y, float angle){ return create(owner, team, x, y, angle, 1f); } - public Bulletc create(Entityc owner, Team team, float x, float y, float angle, float velocityScl){ + public Bullet create(Entityc owner, Team team, float x, float y, float angle, float velocityScl){ return create(owner, team, x, y, angle, -1, velocityScl, 1f, null); } - public Bulletc create(Entityc owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl){ + public Bullet create(Entityc owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl){ return create(owner, team, x, y, angle, -1, velocityScl, lifetimeScl, null); } - public Bulletc create(Bulletc parent, float x, float y, float angle){ + public Bullet create(Bullet parent, float x, float y, float angle){ return create(parent.owner(), parent.team(), x, y, angle); } - public Bulletc create(Bulletc parent, float x, float y, float angle, float velocityScl){ + public Bullet create(Bullet parent, float x, float y, float angle, float velocityScl){ return create(parent.owner(), parent.team(), x, y, angle, velocityScl); } - public Bulletc create(@Nullable Entityc owner, Team team, float x, float y, float angle, float damage, float velocityScl, float lifetimeScl, Object data){ - Bulletc bullet = BulletEntity.create(); + public Bullet create(@Nullable Entityc owner, Team team, float x, float y, float angle, float damage, float velocityScl, float lifetimeScl, Object data){ + Bullet bullet = Bullet.create(); bullet.type(this); bullet.owner(owner); bullet.team(team); diff --git a/core/src/mindustry/entities/bullet/ContinuousLaserBulletType.java b/core/src/mindustry/entities/bullet/ContinuousLaserBulletType.java index ea77877b76..910569957c 100644 --- a/core/src/mindustry/entities/bullet/ContinuousLaserBulletType.java +++ b/core/src/mindustry/entities/bullet/ContinuousLaserBulletType.java @@ -43,7 +43,7 @@ public class ContinuousLaserBulletType extends BulletType{ } @Override - public void update(Bulletc b){ + public void update(Bullet b){ //TODO possible laser absorption from blocks //damage every 5 ticks @@ -57,7 +57,7 @@ public class ContinuousLaserBulletType extends BulletType{ } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ float baseLen = length * b.fout(); Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen); @@ -77,7 +77,7 @@ public class ContinuousLaserBulletType extends BulletType{ } @Override - public void drawLight(Bulletc b){ + public void drawLight(Bullet b){ //no light drawn here } diff --git a/core/src/mindustry/entities/bullet/FlakBulletType.java b/core/src/mindustry/entities/bullet/FlakBulletType.java index 689e185d7b..edbf02184f 100644 --- a/core/src/mindustry/entities/bullet/FlakBulletType.java +++ b/core/src/mindustry/entities/bullet/FlakBulletType.java @@ -23,7 +23,7 @@ public class FlakBulletType extends BasicBulletType{ } @Override - public void update(Bulletc b){ + public void update(Bullet b){ super.update(b); if(b.data() instanceof Integer) return; diff --git a/core/src/mindustry/entities/bullet/HealBulletType.java b/core/src/mindustry/entities/bullet/HealBulletType.java index a9c683299d..89814f2634 100644 --- a/core/src/mindustry/entities/bullet/HealBulletType.java +++ b/core/src/mindustry/entities/bullet/HealBulletType.java @@ -28,12 +28,12 @@ public class HealBulletType extends BulletType{ } @Override - public boolean collides(Bulletc b, Tilec tile){ + public boolean collides(Bullet b, Building tile){ return tile.team() != b.team() || tile.healthf() < 1f; } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ Draw.color(backColor); Lines.stroke(bulletWidth); Lines.lineAngleCenter(b.x(), b.y(), b.rotation(), bulletHeight); @@ -43,7 +43,7 @@ public class HealBulletType extends BulletType{ } @Override - public void hitTile(Bulletc b, Tilec tile){ + public void hitTile(Bullet b, Building tile){ super.hit(b); if(tile.team() == b.team() && !(tile.block() instanceof BuildBlock)){ diff --git a/core/src/mindustry/entities/bullet/LaserBulletType.java b/core/src/mindustry/entities/bullet/LaserBulletType.java index c9a3977f77..5931899511 100644 --- a/core/src/mindustry/entities/bullet/LaserBulletType.java +++ b/core/src/mindustry/entities/bullet/LaserBulletType.java @@ -48,7 +48,7 @@ public class LaserBulletType extends BulletType{ } @Override - public void init(Bulletc b){ + public void init(Bullet b){ Tmp.v1.trns(b.rotation(), length); furthest = null; @@ -65,7 +65,7 @@ public class LaserBulletType extends BulletType{ } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ float realLength = b.data() == null ? length : (Float)b.data(); float f = Mathf.curve(b.fin(), 0f, 0.2f); @@ -97,7 +97,7 @@ public class LaserBulletType extends BulletType{ } @Override - public void drawLight(Bulletc b){ + public void drawLight(Bullet b){ //no light drawn here } } diff --git a/core/src/mindustry/entities/bullet/LightningBulletType.java b/core/src/mindustry/entities/bullet/LightningBulletType.java index 4ca0f1d2c2..e8d6a749dc 100644 --- a/core/src/mindustry/entities/bullet/LightningBulletType.java +++ b/core/src/mindustry/entities/bullet/LightningBulletType.java @@ -26,11 +26,11 @@ public class LightningBulletType extends BulletType{ } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ } @Override - public void init(Bulletc b){ + public void init(Bullet b){ Lightning.create(b.team(), lightningColor, damage, b.x(), b.y(), b.rotation(), lightningLength); } } diff --git a/core/src/mindustry/entities/bullet/LiquidBulletType.java b/core/src/mindustry/entities/bullet/LiquidBulletType.java index 835c8a4d32..534cc8a416 100644 --- a/core/src/mindustry/entities/bullet/LiquidBulletType.java +++ b/core/src/mindustry/entities/bullet/LiquidBulletType.java @@ -44,7 +44,7 @@ public class LiquidBulletType extends BulletType{ } @Override - public void update(Bulletc b){ + public void update(Bullet b){ super.update(b); if(liquid.canExtinguish()){ @@ -58,21 +58,21 @@ public class LiquidBulletType extends BulletType{ } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ Draw.color(liquid.color, Color.white, b.fout() / 100f); Fill.circle(b.x(), b.y(), 3f); } @Override - public void despawned(Bulletc b){ + public void despawned(Bullet b){ super.despawned(b); hit(b, b.x(), b.y()); } @Override - public void hit(Bulletc b, float hitx, float hity){ + public void hit(Bullet b, float hitx, float hity){ hitEffect.at(hitx, hity, liquid.color); Puddles.deposit(world.tileWorld(hitx, hity), liquid, puddleSize); diff --git a/core/src/mindustry/entities/bullet/MassDriverBolt.java b/core/src/mindustry/entities/bullet/MassDriverBolt.java index 390eff95d3..9eef1af150 100644 --- a/core/src/mindustry/entities/bullet/MassDriverBolt.java +++ b/core/src/mindustry/entities/bullet/MassDriverBolt.java @@ -22,7 +22,7 @@ public class MassDriverBolt extends BulletType{ } @Override - public void draw(Bulletc b){ + public void draw(Bullet b){ float w = 11f, h = 13f; Draw.color(Pal.bulletYellowBack); @@ -35,7 +35,7 @@ public class MassDriverBolt extends BulletType{ } @Override - public void update(Bulletc b){ + public void update(Bullet b){ //data MUST be an instance of DriverBulletData if(!(b.data() instanceof DriverBulletData)){ hit(b); @@ -81,7 +81,7 @@ public class MassDriverBolt extends BulletType{ } @Override - public void despawned(Bulletc b){ + public void despawned(Bullet b){ super.despawned(b); if(!(b.data() instanceof DriverBulletData)) return; @@ -98,7 +98,7 @@ public class MassDriverBolt extends BulletType{ } @Override - public void hit(Bulletc b, float hitx, float hity){ + public void hit(Bullet b, float hitx, float hity){ super.hit(b, hitx, hity); despawned(b); } diff --git a/core/src/mindustry/entities/bullet/MissileBulletType.java b/core/src/mindustry/entities/bullet/MissileBulletType.java index 1241ad6894..b2f4ca0d6a 100644 --- a/core/src/mindustry/entities/bullet/MissileBulletType.java +++ b/core/src/mindustry/entities/bullet/MissileBulletType.java @@ -22,7 +22,7 @@ public class MissileBulletType extends BasicBulletType{ } @Override - public void update(Bulletc b){ + public void update(Bullet b){ super.update(b); if(Mathf.chanceDelta(0.2)){ diff --git a/core/src/mindustry/entities/comp/BlockUnitComp.java b/core/src/mindustry/entities/comp/BlockUnitComp.java index 1cf2f5cb92..5adec13c6a 100644 --- a/core/src/mindustry/entities/comp/BlockUnitComp.java +++ b/core/src/mindustry/entities/comp/BlockUnitComp.java @@ -10,9 +10,9 @@ import static mindustry.Vars.tilesize; abstract class BlockUnitComp implements Unitc{ @Import Team team; - @ReadOnly transient Tilec tile; + @ReadOnly transient Building tile; - public void tile(Tilec tile){ + public void tile(Building tile){ this.tile = tile; //sets up block stats diff --git a/core/src/mindustry/entities/comp/BuilderComp.java b/core/src/mindustry/entities/comp/BuilderComp.java index e13d5f12bc..53a6dee887 100644 --- a/core/src/mindustry/entities/comp/BuilderComp.java +++ b/core/src/mindustry/entities/comp/BuilderComp.java @@ -54,7 +54,7 @@ abstract class BuilderComp implements Unitc{ } } - Tilec core = core(); + Building core = core(); //nothing to build. if(buildPlan() == null) return; @@ -114,9 +114,9 @@ abstract class BuilderComp implements Unitc{ BuildEntity entity = tile.ent(); if(current.breaking){ - entity.deconstruct(this, core, 1f / entity.buildCost * Time.delta() * type().buildSpeed * state.rules.buildSpeedMultiplier); + entity.deconstruct(base(), core, 1f / entity.buildCost * Time.delta() * type().buildSpeed * state.rules.buildSpeedMultiplier); }else{ - if(entity.construct(this, core, 1f / entity.buildCost * Time.delta() * type().buildSpeed * state.rules.buildSpeedMultiplier, current.hasConfig)){ + if(entity.construct(base(), core, 1f / entity.buildCost * Time.delta() * type().buildSpeed * state.rules.buildSpeedMultiplier, current.hasConfig)){ if(current.hasConfig){ Call.onTileConfig(null, tile.entity, current.config); } @@ -147,7 +147,7 @@ abstract class BuilderComp implements Unitc{ } /** @return whether this request should be skipped, in favor of the next one. */ - boolean shouldSkip(BuildPlan request, @Nullable Tilec core){ + boolean shouldSkip(BuildPlan request, @Nullable Building core){ //requests that you have at least *started* are considered if(state.rules.infiniteResources || team().rules().infiniteResources || request.breaking || core == null) return false; //TODO these are bad criteria diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 9e26d2eb06..c7f795901b 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -37,11 +37,11 @@ import static mindustry.Vars.*; @EntityDef(value = {Buildingc.class}, isFinal = false, genio = false, serialize = false) @Component(base = true) -abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTreeObject, Displayable{ +abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, QuadTreeObject, Displayable{ //region vars and initialization static final float timeToSleep = 60f * 1; - static final ObjectSet tmpTiles = new ObjectSet<>(); - static final Seq tempTileEnts = new Seq<>(); + static final ObjectSet tmpTiles = new ObjectSet<>(); + static final Seq tempTileEnts = new Seq<>(); static final Seq tempTiles = new Seq<>(); static int sleepingEntities = 0; @@ -50,7 +50,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad transient Tile tile; transient Block block; - transient Seq proximity = new Seq<>(8); + transient Seq proximity = new Seq<>(8); transient boolean updateFlow; transient byte dump; @@ -68,7 +68,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad private transient boolean initialized; /** Sets this tile entity data to this and adds it if necessary. */ - public Tilec init(Tile tile, Team team, boolean shouldAdd){ + public Building init(Tile tile, Team team, boolean shouldAdd){ if(!initialized){ create(tile.block(), team); } @@ -82,11 +82,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad created(); - return this; + return base(); } /** Sets up all the necessary variables, but does not add this entity anywhere. */ - public Tilec create(Block block, Team team){ + public Building create(Block block, Team team){ this.tile = emptyTile; this.block = block; this.team = team; @@ -99,17 +99,17 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad maxHealth(block.health); timer(new Interval(block.timers)); - cons = new ConsumeModule(this); + cons = new ConsumeModule(base()); if(block.hasItems) items = new ItemModule(); if(block.hasLiquids) liquids = new LiquidModule(); if(block.hasPower){ power = new PowerModule(); - power.graph.add(this); + power.graph.add(base()); } initialized = true; - return this; + return base(); } @Override @@ -174,17 +174,17 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad public void configure(Object value){ //save last used config block.lastConfig = value; - Call.onTileConfig(player, this, value); + Call.onTileConfig(player, base(), value); } /** Configure from a server. */ public void configureAny(Object value){ - Call.onTileConfig(null, this, value); + Call.onTileConfig(null, base(), value); } /** Deselect this tile from configuration. */ public void deselect(){ - if(!headless && control.input.frag.config.getSelectedTile() == this){ + if(!headless && control.input.frag.config.getSelectedTile() == base()){ control.input.frag.config.hideConfig(); } } @@ -200,11 +200,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad timeScaleDuration = Math.max(timeScaleDuration, duration); } - public Tilec nearby(int dx, int dy){ + public Building nearby(int dx, int dy){ return world.ent(tile.x + dx, tile.y + dy); } - public Tilec nearby(int rotation){ + public Building nearby(int rotation){ if(rotation == 0) return world.ent(tile.x + 1, tile.y); if(rotation == 1) return world.ent(tile.x, tile.y + 1); if(rotation == 2) return world.ent(tile.x - 1, tile.y); @@ -216,7 +216,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad return relativeTo(tile.x, tile.y); } - public byte relativeTo(Tilec tile){ + public byte relativeTo(Building tile){ return relativeTo(tile.tile()); } @@ -229,25 +229,25 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad } /** Multiblock front. */ - public @Nullable Tilec front(){ + public @Nullable Building front(){ int trns = block.size/2 + 1; return nearby(Geometry.d4(rotation()).x * trns, Geometry.d4(rotation()).y * trns); } /** Multiblock back. */ - public @Nullable Tilec back(){ + public @Nullable Building back(){ int trns = block.size/2 + 1; return nearby(Geometry.d4(rotation() + 2).x * trns, Geometry.d4(rotation() + 2).y * trns); } /** Multiblock left. */ - public @Nullable Tilec left(){ + public @Nullable Building left(){ int trns = block.size/2 + 1; return nearby(Geometry.d4(rotation() + 1).x * trns, Geometry.d4(rotation() + 1).y * trns); } /** Multiblock right. */ - public @Nullable Tilec right(){ + public @Nullable Building right(){ int trns = block.size/2 + 1; return nearby(Geometry.d4(rotation() + 3).x * trns, Geometry.d4(rotation() + 3).y * trns); } @@ -323,7 +323,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad } } - /** Returns the version of this TileEntity IO code.*/ + /** Returns the version of this Building IO code.*/ public byte version(){ return 0; } @@ -347,7 +347,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad /** Returns the amount of items this block can accept. */ public int acceptStack(Item item, int amount, Teamc source){ - if(acceptItem(this, item) && block.hasItems && (source == null || source.team() == team())){ + if(acceptItem(base(), item) && block.hasItems && (source == null || source.team() == team)){ return Math.min(getMaximumAccepted(item) - items.get(item), amount); }else{ return 0; @@ -382,11 +382,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad noSleep(); } - public boolean acceptPayload(Tilec source, Payload payload){ + public boolean acceptPayload(Building source, Payload payload){ return false; } - public void handlePayload(Tilec source, Payload payload){ + public void handlePayload(Building source, Payload payload){ } @@ -400,8 +400,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad int trns = block.size/2 + 1; Tile next = tile.getNearby(Geometry.d4(rotation()).x * trns, Geometry.d4(rotation()).y * trns); - if(next != null && next.entity != null && next.entity.team() == team() && next.entity.acceptPayload(this, todump)){ - next.entity.handlePayload(this, todump); + if(next != null && next.entity != null && next.entity.team() == team && next.entity.acceptPayload(base(), todump)){ + next.entity.handlePayload(base(), todump); return true; } @@ -419,10 +419,10 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad int dump = this.dump; for(int i = 0; i < proximity.size; i++){ - Tilec other = proximity.get((i + dump) % proximity.size); + Building other = proximity.get((i + dump) % proximity.size); - if(other.team() == team() && other.acceptPayload(this, todump)){ - other.handlePayload(this, todump); + if(other.team() == team && other.acceptPayload(base(), todump)){ + other.handlePayload(base(), todump); incrementDump(proximity.size); return true; } @@ -433,19 +433,19 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad return false; } - public void handleItem(Tilec source, Item item){ + public void handleItem(Building source, Item item){ items.add(item, 1); } - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return block.consumes.itemFilters.get(item.id) && items.get(item) < getMaximumAccepted(item); } - public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){ + public boolean acceptLiquid(Building source, Liquid liquid, float amount){ return block.hasLiquids && liquids.get(liquid) + amount < block.liquidCapacity && block.consumes.liquidfilters.get(liquid.id); } - public void handleLiquid(Tilec source, Liquid liquid, float amount){ + public void handleLiquid(Building source, Liquid liquid, float amount){ liquids.add(liquid, amount); } @@ -454,11 +454,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad for(int i = 0; i < proximity.size; i++){ incrementDump(proximity.size); - Tilec other = proximity.get((i + dump) % proximity.size); - other = other.getLiquidDestination(this, liquid); + Building other = proximity.get((i + dump) % proximity.size); + other = other.getLiquidDestination(base(), liquid); - if(other != null && other.team() == team() && other.block().hasLiquids && canDumpLiquid(other, liquid) && other.liquids() != null){ - float ofract = other.liquids().get(liquid) / other.block().liquidCapacity; + if(other != null && other.team == team && other.block.hasLiquids && canDumpLiquid(other, liquid) && other.liquids != null){ + float ofract = other.liquids.get(liquid) / other.block.liquidCapacity; float fract = liquids.get(liquid) / block.liquidCapacity; if(ofract < fract) transferLiquid(other, (fract - ofract) * block.liquidCapacity / 2f, liquid); @@ -467,15 +467,15 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad } - public boolean canDumpLiquid(Tilec to, Liquid liquid){ + public boolean canDumpLiquid(Building to, Liquid liquid){ return true; } - public void transferLiquid(Tilec next, float amount, Liquid liquid){ - float flow = Math.min(next.block().liquidCapacity - next.liquids().get(liquid) - 0.001f, amount); + public void transferLiquid(Building next, float amount, Liquid liquid){ + float flow = Math.min(next.block.liquidCapacity - next.liquids.get(liquid) - 0.001f, amount); - if(next.acceptLiquid(this, liquid, flow)){ - next.handleLiquid(this, liquid, flow); + if(next.acceptLiquid(base(), liquid, flow)){ + next.handleLiquid(base(), liquid, flow); liquids.remove(liquid, flow); } } @@ -489,32 +489,32 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad return moveLiquid(next.entity, liquid); }else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){ float leakAmount = liquids.get(liquid) / leakResistance; - Puddles.deposit(next, tile(), liquid, leakAmount); + Puddles.deposit(next, tile, liquid, leakAmount); liquids.remove(liquid, leakAmount); } return 0; } - public float moveLiquid(Tilec next, Liquid liquid){ + public float moveLiquid(Building next, Liquid liquid){ if(next == null) return 0; - next = next.getLiquidDestination(this, liquid); + next = next.getLiquidDestination(base(), liquid); - if(next.team() == team() && next.block().hasLiquids && liquids.get(liquid) > 0f){ + if(next.team() == team && next.block.hasLiquids && liquids.get(liquid) > 0f){ - if(next.acceptLiquid(this, liquid, 0f)){ - float ofract = next.liquids().get(liquid) / next.block().liquidCapacity; + if(next.acceptLiquid(base(), liquid, 0f)){ + float ofract = next.liquids().get(liquid) / next.block.liquidCapacity; float fract = liquids.get(liquid) / block.liquidCapacity * block.liquidPressure; float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (block.liquidCapacity), liquids.get(liquid)); - flow = Math.min(flow, next.block().liquidCapacity - next.liquids().get(liquid) - 0.001f); + flow = Math.min(flow, next.block.liquidCapacity - next.liquids().get(liquid) - 0.001f); - if(flow > 0f && ofract <= fract && next.acceptLiquid(this, liquid, flow)){ - next.handleLiquid(this, liquid, flow); + if(flow > 0f && ofract <= fract && next.acceptLiquid(base(), liquid, flow)){ + next.handleLiquid(base(), liquid, flow); liquids.remove(liquid, flow); return flow; }else if(ofract > 0.1f && fract > 0.1f){ //TODO these are incorrect effect positions - float fx = (x() + next.x()) / 2f, fy = (y() + next.y()) / 2f; + float fx = (x + next.x()) / 2f, fy = (y + next.y()) / 2f; Liquid other = next.liquids().current(); if((other.flammability > 0.3f && liquid.temperature > 0.7f) || (liquid.flammability > 0.3f && other.temperature > 0.7f)){ @@ -535,8 +535,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad return 0; } - public Tilec getLiquidDestination(Tilec from, Liquid liquid){ - return this; + public Building getLiquidDestination(Building from, Liquid liquid){ + return base(); } /** Tries to take the payload. Returns null if no payload is present. */ @@ -553,14 +553,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad for(int i = 0; i < proximity.size; i++){ incrementDump(proximity.size); - Tilec other = proximity.get((i + dump) % proximity.size); - if(other.team() == team() && other.acceptItem(this, item) && canDump(other, item)){ - other.handleItem(this, item); + Building other = proximity.get((i + dump) % proximity.size); + if(other.team() == team && other.acceptItem(base(), item) && canDump(other, item)){ + other.handleItem(base(), item); return; } } - handleItem(this, item); + handleItem(base(), item); } /** @@ -571,9 +571,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad for(int i = 0; i < proximity.size; i++){ incrementDump(proximity.size); - Tilec other = proximity.get((i + dump) % proximity.size); - if(other.team() == team() && other.acceptItem(this, item) && canDump(other, item)){ - other.handleItem(this, item); + Building other = proximity.get((i + dump) % proximity.size); + if(other.team() == team && other.acceptItem(base(), item) && canDump(other, item)){ + other.handleItem(base(), item); return true; } } @@ -598,23 +598,23 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad if(proximity.size == 0) return false; for(int i = 0; i < proximity.size; i++){ - Tilec other = proximity.get((i + dump) % proximity.size); + Building other = proximity.get((i + dump) % proximity.size); if(todump == null){ for(int ii = 0; ii < content.items().size; ii++){ Item item = content.item(ii); - if(other.team() == team() && items.has(item) && other.acceptItem(this, item) && canDump(other, item)){ - other.handleItem(this, item); + if(other.team() == team && items.has(item) && other.acceptItem(base(), item) && canDump(other, item)){ + other.handleItem(base(), item); items.remove(item, 1); incrementDump(proximity.size); return true; } } }else{ - if(other.team() == team() && other.acceptItem(this, todump) && canDump(other, todump)){ - other.handleItem(this, todump); + if(other.team() == team && other.acceptItem(base(), todump) && canDump(other, todump)){ + other.handleItem(base(), todump); items.remove(todump, 1); incrementDump(proximity.size); return true; @@ -632,15 +632,15 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad } /** Used for dumping items. */ - public boolean canDump(Tilec to, Item item){ + public boolean canDump(Building to, Item item){ return true; } /** Try offloading an item to a nearby container in its facing direction. Returns true if success. */ public boolean moveForward(Item item){ - Tilec other = front(); - if(other != null && other.team() == team() && other.acceptItem(this, item)){ - other.handleItem(this, item); + Building other = front(); + if(other != null && other.team() == team && other.acceptItem(base(), item)){ + other.handleItem(base(), item); return true; } return false; @@ -658,9 +658,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad public void updatePowerGraph(){ - for(Tilec other : getPowerConnections(tempTileEnts)){ + for(Building other : getPowerConnections(tempTileEnts)){ if(other.power() != null){ - other.power().graph.add(power.graph); + other.power().graph.addGraph(power.graph); } } } @@ -670,22 +670,22 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad return; } - power.graph.remove(this); + power.graph.remove(base()); for(int i = 0; i < power.links.size; i++){ Tile other = world.tile(power.links.get(i)); - if(other != null && other.entity != null && other.entity.power() != null){ - other.entity.power().links.removeValue(pos()); + if(other != null && other.entity != null && other.entity.power != null){ + other.entity.power.links.removeValue(pos()); } } } - public Seq getPowerConnections(Seq out){ + public Seq getPowerConnections(Seq out){ out.clear(); if(power == null) return out; - for(Tilec other : proximity){ + for(Building other : proximity){ if(other != null && other.power() != null - && !(block.consumesPower && other.block().consumesPower && !block.outputsPower && !other.block().outputsPower) + && !(block.consumesPower && other.block.consumesPower && !block.outputsPower && !other.block.outputsPower) && !power.links.contains(other.pos())){ out.add(other); } @@ -693,7 +693,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad for(int i = 0; i < power.links.size; i++){ Tile link = world.tile(power.links.get(i)); - if(link != null && link.entity != null && link.entity.power() != null) out.add(link.entity); + if(link != null && link.entity != null && link.entity.power != null) out.add(link.entity); } return out; } @@ -731,7 +731,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad int id = pos(); TextureRegion region = Block.cracks[block.size - 1][Mathf.clamp((int)((1f - healthf()) * Block.crackRegions), 0, Block.crackRegions-1)]; Draw.colorl(0.2f, 0.1f + (1f - healthf())* 0.6f); - Draw.rect(region, x(), y(), (id%4)*90); + Draw.rect(region, x, y, (id%4)*90); Draw.color(); } @@ -793,8 +793,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad int range = 10; tempTiles.clear(); Geometry.circle(tileX(), tileY(), range, (x, y) -> { - Tilec other = world.ent(x, y); - if(other != null && other.block() instanceof PowerNode && ((PowerNode)other.block()).linkValid(other, this) && !PowerNode.insulated(other, this) && !other.proximity().contains(this) && + Building other = world.ent(x, y); + if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, base()) && !PowerNode.insulated(other, base()) + && !other.proximity().contains(this.base()) && !(block.outputsPower && proximity.contains(p -> p.power() != null && p.power().graph == other.power().graph))){ tempTiles.add(other.tile()); } @@ -802,7 +803,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile))); if(!tempTiles.isEmpty()){ Tile toLink = tempTiles.first(); - if(!toLink.entity.power().links.contains(pos())){ + if(!toLink.entity.power.links.contains(pos())){ toLink.entity.configureAny(pos()); } } @@ -813,15 +814,15 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad } /** Called every frame a unit is on this */ - public void unitOn(Unitc unit){ + public void unitOn(Unit unit){ } /** Called when a unit that spawned at this tile is removed. */ - public void unitRemoved(Unitc unit){ + public void unitRemoved(Unit unit){ } /** Called when arbitrary configuration is applied to a tile. */ - public void configured(@Nullable Playerc player, @Nullable Object value){ + public void configured(@Nullable Player player, @Nullable Object value){ //null is of type void.class; anonymous classes use their superclass. Class type = value == null ? void.class : value.getClass().isAnonymousClass() ? value.getClass().getSuperclass() : value.getClass(); @@ -831,7 +832,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad } /** Called when the block is tapped.*/ - public void tapped(Playerc player){ + public void tapped(Player player){ } @@ -981,13 +982,13 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad table.left(); for(Consume cons : block.consumes.all()){ if(cons.isOptional() && cons.isBoost()) continue; - cons.build(this, table); + cons.build(base(), table); } } public void displayBars(Table table){ - for(Func bar : block.bars.list()){ - table.add(bar.get(this)).growX(); + for(Func bar : block.bars.list()){ + table.add(bar.get(base())).growX(); table.row(); } } @@ -999,7 +1000,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad /** Update table alignment after configuring.*/ public void updateTableAlign(Table table){ - Vec2 pos = Core.input.mouseScreen(x, y - block().size * tilesize / 2f - 1); + Vec2 pos = Core.input.mouseScreen(x, y - block.size * tilesize / 2f - 1); table.setPosition(pos.x, pos.y, Align.top); } @@ -1012,24 +1013,24 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad * Called when another tile is tapped while this block is selected. * @return whether or not this block should be deselected. */ - public boolean onConfigureTileTapped(Tilec other){ - return this != other; + public boolean onConfigureTileTapped(Building other){ + return base() != other; } /** Returns whether this config menu should show when the specified player taps it. */ - public boolean shouldShowConfigure(Playerc player){ + public boolean shouldShowConfigure(Player player){ return true; } /** Whether this configuration should be hidden now. Called every frame the config is open. */ - public boolean shouldHideConfigure(Playerc player){ + public boolean shouldHideConfigure(Player player){ return false; } public void drawConfigure(){ Draw.color(Pal.accent); Lines.stroke(1f); - Lines.square(x, y, block().size * tilesize / 2f + 1f); + Lines.square(x, y, block.size * tilesize / 2f + 1f); Draw.reset(); } @@ -1042,13 +1043,13 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad return amount; } - public boolean collide(Bulletc other){ + public boolean collide(Bullet other){ return true; } /** Handle a bullet collision. * @return whether the bullet should be removed. */ - public boolean collision(Bulletc other){ + public boolean collision(Bullet other){ damage(other.damage() * other.type().tileDamageMultiplier); return true; @@ -1060,15 +1061,15 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad Point2[] nearby = Edges.getEdges(block.size); for(Point2 point : nearby){ - Tilec other = world.ent(tile.x + point.x, tile.y + point.y); + Building other = world.ent(tile.x + point.x, tile.y + point.y); //remove this tile from all nearby tile's proximities if(other != null){ tmpTiles.add(other); } } - for(Tilec other : tmpTiles){ - other.proximity().remove(this, true); + for(Building other : tmpTiles){ + other.proximity.remove(base(), true); other.onProximityUpdate(); } } @@ -1079,31 +1080,31 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad Point2[] nearby = Edges.getEdges(block.size); for(Point2 point : nearby){ - Tilec other = world.ent(tile.x + point.x, tile.y + point.y); + Building other = world.ent(tile.x + point.x, tile.y + point.y); - if(other == null || !(other.tile().interactable(team()))) continue; + if(other == null || !(other.tile.interactable(team))) continue; //add this tile to proximity of nearby tiles - if(!other.proximity().contains(this, true)){ - other.proximity().add(this); + if(!other.proximity.contains(base(), true)){ + other.proximity.add(base()); } tmpTiles.add(other); } //using a set to prevent duplicates - for(Tilec tile : tmpTiles){ + for(Building tile : tmpTiles){ proximity.add(tile); } - for(Tilec other : tmpTiles){ + for(Building other : tmpTiles){ other.onProximityUpdate(); } onProximityAdded(); onProximityUpdate(); - for(Tilec other : tmpTiles){ + for(Building other : tmpTiles){ other.onProximityUpdate(); } } @@ -1124,7 +1125,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad @Replace @Override public boolean isValid(){ - return tile.entity == this && !dead(); + return tile.entity == base() && !dead(); } @Override @@ -1156,7 +1157,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad } if(block.idleSound != Sounds.none && shouldIdleSound()){ - loops.play(block.idleSound, this, block.idleSoundVolume); + loops.play(block.idleSound, base(), block.idleSoundVolume); } updateTile(); diff --git a/core/src/mindustry/entities/comp/BulletComp.java b/core/src/mindustry/entities/comp/BulletComp.java index 4dcb4f98b9..8843069d37 100644 --- a/core/src/mindustry/entities/comp/BulletComp.java +++ b/core/src/mindustry/entities/comp/BulletComp.java @@ -34,24 +34,24 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw @Override public void drawBullets(){ - type.draw(this); + type.draw(base()); } @Override public void add(){ - type.init(this); + type.init(base()); } @Override public void remove(){ - type.despawned(this); + type.despawned(base()); collided.clear(); } @Override public float damageMultiplier(){ - if(owner instanceof Unitc) return ((Unitc)owner).damageMultiplier() * state.rules.unitDamageMultiplier; - if(owner instanceof Tilec) return state.rules.blockDamageMultiplier; + if(owner instanceof Unit) return ((Unit)owner).damageMultiplier() * state.rules.unitDamageMultiplier; + if(owner instanceof Building) return state.rules.blockDamageMultiplier; return 1f; } @@ -74,7 +74,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw @Replace @Override public boolean collides(Hitboxc other){ - return type.collides && (other instanceof Teamc && ((Teamc)other).team() != team()) + return type.collides && (other instanceof Teamc && ((Teamc)other).team() != team) && !(other instanceof Flyingc && ((((Flyingc)other).isFlying() && !type.collidesAir) || (((Flyingc)other).isGrounded() && !type.collidesGround))) && !(type.pierce && collided.contains(other.id())); //prevent multiple collisions } @@ -82,16 +82,16 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw @MethodPriority(100) @Override public void collision(Hitboxc other, float x, float y){ - type.hit(this, x, y); + type.hit(base(), x, y); if(other instanceof Healthc){ Healthc h = (Healthc)other; h.damage(damage); } - if(other instanceof Unitc){ - Unitc unit = (Unitc)other; - unit.vel().add(Tmp.v3.set(other.x(), other.y()).sub(x, y).setLength(type.knockback / unit.mass())); + if(other instanceof Unit){ + Unit unit = (Unit)other; + unit.vel.add(Tmp.v3.set(unit).sub(x, y).setLength(type.knockback / unit.mass())); unit.apply(type.status, type.statusDuration); } @@ -105,23 +105,23 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw @Override public void update(){ - type.update(this); + type.update(base()); if(type.collidesTiles && type.collides){ world.raycastEach(world.toTile(lastX()), world.toTile(lastY()), tileX(), tileY(), (x, y) -> { - Tilec tile = world.ent(x, y); + Building tile = world.ent(x, y); if(tile == null) return false; - if(tile.collide(this) && type.collides(this, tile) && !tile.dead() && (type.collidesTeam || tile.team() != team())){ + if(tile.collide(base()) && type.collides(base(), tile) && !tile.dead() && (type.collidesTeam || tile.team() != team())){ boolean remove = false; if(tile.team() != team()){ - remove = tile.collision(this); + remove = tile.collision(base()); } if(remove){ - type.hitTile(this, tile); + type.hitTile(base(), tile); remove(); } return true; @@ -136,8 +136,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw public void draw(){ Draw.z(Layer.bullet); - type.draw(this); - type.drawLight(this); + type.draw(base()); + type.drawLight(base()); } /** Sets the bullet's rotation in degrees. */ diff --git a/core/src/mindustry/entities/comp/CommanderComp.java b/core/src/mindustry/entities/comp/CommanderComp.java index 607b0968bf..5462014a16 100644 --- a/core/src/mindustry/entities/comp/CommanderComp.java +++ b/core/src/mindustry/entities/comp/CommanderComp.java @@ -16,7 +16,7 @@ abstract class CommanderComp implements Unitc{ @Import float x, y, rotation; transient @Nullable Formation formation; - transient Seq controlling = new Seq<>(); + transient Seq controlling = new Seq<>(); @Override public void update(){ @@ -42,12 +42,12 @@ abstract class CommanderComp implements Unitc{ clearCommand(); } - void command(Formation formation, Seq units){ + void command(Formation formation, Seq units){ clearCommand(); controlling.addAll(units); - for(Unitc unit : units){ - unit.controller(new FormationAI(this, formation)); + for(Unit unit : units){ + unit.controller(new FormationAI(base(), formation)); } this.formation = formation; @@ -67,8 +67,8 @@ abstract class CommanderComp implements Unitc{ void clearCommand(){ //reset controlled units - for(Unitc unit : controlling){ - if(unit.controller().isBeingControlled(this)){ + for(Unit unit : controlling){ + if(unit.controller().isBeingControlled(base())){ unit.controller(unit.type().createController()); } } diff --git a/core/src/mindustry/entities/comp/DecalComp.java b/core/src/mindustry/entities/comp/DecalComp.java index f1e6e21bc1..f6ee0ef02b 100644 --- a/core/src/mindustry/entities/comp/DecalComp.java +++ b/core/src/mindustry/entities/comp/DecalComp.java @@ -8,7 +8,7 @@ import mindustry.gen.*; import mindustry.graphics.*; @EntityDef(value = {Decalc.class}, pooled = true, serialize = false) -@Component +@Component(base = true) abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{ @Import float x, y, rotation; diff --git a/core/src/mindustry/entities/comp/EffectComp.java b/core/src/mindustry/entities/comp/EffectStateComp.java similarity index 69% rename from core/src/mindustry/entities/comp/EffectComp.java rename to core/src/mindustry/entities/comp/EffectStateComp.java index 7ccd477596..3ad57d5d19 100644 --- a/core/src/mindustry/entities/comp/EffectComp.java +++ b/core/src/mindustry/entities/comp/EffectStateComp.java @@ -5,9 +5,9 @@ import mindustry.annotations.Annotations.*; import mindustry.entities.*; import mindustry.gen.*; -@EntityDef(value = {Effectc.class, Childc.class}, pooled = true, serialize = false) -@Component -abstract class EffectComp implements Posc, Drawc, Timedc, Rotc, Childc{ +@EntityDef(value = {EffectStatec.class, Childc.class}, pooled = true, serialize = false) +@Component(base = true) +abstract class EffectStateComp implements Posc, Drawc, Timedc, Rotc, Childc{ Color color = new Color(Color.white); Effect effect; Object data; diff --git a/core/src/mindustry/entities/comp/EntityComp.java b/core/src/mindustry/entities/comp/EntityComp.java index 0ae1732e87..a0082ec9d5 100644 --- a/core/src/mindustry/entities/comp/EntityComp.java +++ b/core/src/mindustry/entities/comp/EntityComp.java @@ -36,7 +36,11 @@ abstract class EntityComp{ return false; } - T as(Class type){ + T base(){ + return (T)this; + } + + T as(){ return (T)this; } diff --git a/core/src/mindustry/entities/comp/FireComp.java b/core/src/mindustry/entities/comp/FireComp.java index eeaaf41218..a1fc0c5111 100644 --- a/core/src/mindustry/entities/comp/FireComp.java +++ b/core/src/mindustry/entities/comp/FireComp.java @@ -14,7 +14,7 @@ import mindustry.world.*; import static mindustry.Vars.*; @EntityDef(value = {Firec.class}, pooled = true) -@Component +@Component(base = true) abstract class FireComp implements Timedc, Posc, Firec{ private static final float spreadChance = 0.05f, fireballChance = 0.07f; @@ -49,7 +49,7 @@ abstract class FireComp implements Timedc, Posc, Firec{ return; } - Tilec entity = tile.entity; + Building entity = tile.entity; boolean damage = entity != null; float flammability = baseFlammability + puddleFlammability; @@ -97,6 +97,6 @@ abstract class FireComp implements Timedc, Posc, Firec{ @Override public void afterRead(){ - Fires.register(this); + Fires.register(base()); } } diff --git a/core/src/mindustry/entities/comp/ItemsComp.java b/core/src/mindustry/entities/comp/ItemsComp.java index 55a55fd20e..03e0b50e7c 100644 --- a/core/src/mindustry/entities/comp/ItemsComp.java +++ b/core/src/mindustry/entities/comp/ItemsComp.java @@ -7,7 +7,7 @@ import mindustry.type.*; @Component abstract class ItemsComp implements Posc{ - @ReadOnly ItemStack stack = new ItemStack(); + ItemStack stack = new ItemStack(); transient float itemTime; abstract int itemCapacity(); diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index eca9ef3ef6..4c3b1ba175 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -35,7 +35,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{ @Override public void update(){ - Tilec core = closestCore(); + Building core = closestCore(); if(core != null && mineTile != null && mineTile.drop() != null && !acceptsItem(mineTile.drop()) && dst(core) < mineTransferRange){ int accepted = core.acceptStack(item(), stack().amount, this); diff --git a/core/src/mindustry/entities/comp/PayloadComp.java b/core/src/mindustry/entities/comp/PayloadComp.java index fafbc99532..1d81f4a198 100644 --- a/core/src/mindustry/entities/comp/PayloadComp.java +++ b/core/src/mindustry/entities/comp/PayloadComp.java @@ -25,13 +25,13 @@ abstract class PayloadComp implements Posc, Rotc{ payloads.add(load); } - void pickup(Unitc unit){ + void pickup(Unit unit){ unit.remove(); payloads.add(new UnitPayload(unit)); Fx.unitPickup.at(unit); } - void pickup(Tilec tile){ + void pickup(Building tile){ tile.tile().remove(); payloads.add(new BlockPayload(tile)); Fx.unitPickup.at(tile); @@ -69,10 +69,10 @@ abstract class PayloadComp implements Posc, Rotc{ boolean dropUnit(UnitPayload payload){ //TODO create an effect here and/or make them be at a lower elevation - Unitc u = payload.unit; + Unit u = payload.unit; //can't drop ground units - if((tileOn() == null || tileOn().solid()) && u.elevation() < 0.1f){ + if((tileOn() == null || tileOn().solid()) && u.elevation < 0.1f){ return false; } @@ -87,11 +87,11 @@ abstract class PayloadComp implements Posc, Rotc{ /** @return whether the tile has been successfully placed. */ boolean dropBlock(BlockPayload payload){ - Tilec tile = payload.entity; + Building tile = payload.entity; int tx = Vars.world.toTile(x - tile.block().offset()), ty = Vars.world.toTile(y - tile.block().offset()); Tile on = Vars.world.tile(tx, ty); if(on != null && Build.validPlace(tile.block(), tile.team(), tx, ty, tile.rotation())){ - int rot = (int)((rotation() + 45f) / 90f) % 4; + int rot = (int)((rotation + 45f) / 90f) % 4; payload.place(on, rot); Fx.unitDrop.at(tile); diff --git a/core/src/mindustry/entities/comp/PlayerComp.java b/core/src/mindustry/entities/comp/PlayerComp.java index 4bf2e1293a..ae7b22fb6d 100644 --- a/core/src/mindustry/entities/comp/PlayerComp.java +++ b/core/src/mindustry/entities/comp/PlayerComp.java @@ -31,7 +31,9 @@ import static mindustry.Vars.*; abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Drawc{ static final float deathDelay = 30f; - @NonNull @ReadOnly Unitc unit = Nulls.unit; + @Import float x, y; + + @NonNull @ReadOnly Unit unit = Nulls.unit; transient @Nullable NetConnection con; @ReadOnly Team team = Team.sharded; @@ -53,7 +55,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra } public @Nullable CoreEntity closestCore(){ - return state.teams.closestCore(x(), y(), team); + return state.teams.closestCore(x, y, team); } public @Nullable CoreEntity core(){ @@ -106,7 +108,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra //update some basic state to sync things if(unit.type().canBoost){ Tile tile = unit.tileOn(); - unit.elevation(Mathf.approachDelta(unit.elevation(), (tile != null && tile.solid()) || boosting ? 1f : 0f, 0.08f)); + unit.elevation(Mathf.approachDelta(unit.elevation, (tile != null && tile.solid()) || boosting ? 1f : 0f, 0.08f)); } }else if(core != null){ //have a small delay before death to prevent the camera from jumping around too quickly @@ -114,7 +116,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra deathTimer += Time.delta(); if(deathTimer >= deathDelay){ //request spawn - this happens serverside only - core.requestSpawn((Playerc)this); + core.requestSpawn(base()); deathTimer = 0; } } @@ -132,7 +134,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra unit(Nulls.unit); } - public Unitc unit(){ + public Unit unit(){ return unit; } @@ -144,7 +146,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra return !(unit instanceof Builderc) ? Nulls.builder : (Builderc)unit; } - public void unit(Unitc unit){ + public void unit(Unit unit){ if(unit == null) throw new IllegalArgumentException("Unit cannot be null. Use clearUnit() instead."); if(this.unit == unit) return; if(this.unit != Nulls.unit){ @@ -157,7 +159,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra unit.controller(this); } - Events.fire(new UnitChangeEvent((Playerc)this, unit)); + Events.fire(new UnitChangeEvent(base(), unit)); } boolean dead(){ @@ -201,17 +203,17 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra if(!isLocal()){ Draw.color(0f, 0f, 0f, 0.3f); - Fill.rect(unit.x(), unit.y() + nameHeight - layout.height / 2, layout.width + 2, layout.height + 3); + Fill.rect(unit.x, unit.y + nameHeight - layout.height / 2, layout.width + 2, layout.height + 3); Draw.color(); font.setColor(color); - font.draw(name, unit.x(), unit.y() + nameHeight, 0, Align.center, false); + font.draw(name, unit.x, unit.y + nameHeight, 0, Align.center, false); if(admin){ float s = 3f; Draw.color(color.r * 0.5f, color.g * 0.5f, color.b * 0.5f, 1f); - Draw.rect(Icon.adminSmall.getRegion(), unit.x() + layout.width / 2f + 2 + 1, unit.y() + nameHeight - 1.5f, s, s); + Draw.rect(Icon.adminSmall.getRegion(), unit.x + layout.width / 2f + 2 + 1, unit.y + nameHeight - 1.5f, s, s); Draw.color(color); - Draw.rect(Icon.adminSmall.getRegion(), unit.x() + layout.width / 2f + 2 + 1, unit.y() + nameHeight - 1f, s, s); + Draw.rect(Icon.adminSmall.getRegion(), unit.x + layout.width / 2f + 2 + 1, unit.y + nameHeight - 1f, s, s); } } @@ -224,8 +226,8 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra layout.setText(font, text, Color.white, width, Align.bottom, true); Draw.color(0f, 0f, 0f, 0.3f * (textFadeTime <= 0 || lastText == null ? 1f : visualFadeTime)); - Fill.rect(unit.x(), unit.y() + textHeight + layout.height - layout.height/2f, layout.width + 2, layout.height + 3); - font.draw(text, unit.x() - width/2f, unit.y() + textHeight + layout.height, width, Align.center, true); + Fill.rect(unit.x, unit.y + textHeight + layout.height - layout.height/2f, layout.width + 2, layout.height + 3); + font.draw(text, unit.x - width/2f, unit.y + textHeight + layout.height, width, Align.center, true); } Draw.reset(); @@ -247,11 +249,11 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra } } - void sendMessage(String text, Playerc from){ + void sendMessage(String text, Player from){ sendMessage(text, from, NetClient.colorizeName(from.id(), from.name())); } - void sendMessage(String text, Playerc from, String fromName){ + void sendMessage(String text, Player from, String fromName){ if(isLocal()){ if(ui != null){ ui.chatfrag.addMessage(text, fromName); diff --git a/core/src/mindustry/entities/comp/PuddleComp.java b/core/src/mindustry/entities/comp/PuddleComp.java index 909d074f19..7da22d4b53 100644 --- a/core/src/mindustry/entities/comp/PuddleComp.java +++ b/core/src/mindustry/entities/comp/PuddleComp.java @@ -18,7 +18,7 @@ import static mindustry.Vars.*; import static mindustry.entities.Puddles.*; @EntityDef(value = {Puddlec.class}, pooled = true) -@Component +@Component(base = true) abstract class PuddleComp implements Posc, Puddlec, Drawc{ private static final int maxGeneration = 2; private static final Color tmp = new Color(); @@ -128,6 +128,6 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{ @Override public void afterRead(){ - Puddles.register(this); + Puddles.register(base()); } } diff --git a/core/src/mindustry/entities/comp/StatusComp.java b/core/src/mindustry/entities/comp/StatusComp.java index 53cefee8fd..f244500262 100644 --- a/core/src/mindustry/entities/comp/StatusComp.java +++ b/core/src/mindustry/entities/comp/StatusComp.java @@ -13,7 +13,7 @@ import mindustry.gen.*; import mindustry.type.*; import mindustry.world.blocks.environment.*; -import static mindustry.Vars.content; +import static mindustry.Vars.*; @Component abstract class StatusComp implements Posc, Flyingc{ @@ -46,7 +46,7 @@ abstract class StatusComp implements Posc, Flyingc{ return; }else if(entry.effect.reactsWith(effect)){ //find opposite StatusEntry.tmp.effect = entry.effect; - entry.effect.getTransition((Unitc)this, effect, entry.time, duration, StatusEntry.tmp); + entry.effect.getTransition(base(), effect, entry.time, duration, StatusEntry.tmp); entry.time = StatusEntry.tmp.time; if(StatusEntry.tmp.effect != entry.effect){ @@ -128,15 +128,14 @@ abstract class StatusComp implements Posc, Flyingc{ speedMultiplier *= entry.effect.speedMultiplier; armorMultiplier *= entry.effect.armorMultiplier; damageMultiplier *= entry.effect.damageMultiplier; - //TODO ugly casting - entry.effect.update((Unitc)this, entry.time); + entry.effect.update(base(), entry.time); } } } public void draw(){ for(StatusEntry e : statuses){ - e.effect.draw((Unitc)this); + e.effect.draw(base()); } } diff --git a/core/src/mindustry/entities/comp/TeamComp.java b/core/src/mindustry/entities/comp/TeamComp.java index 9f6791002d..ed03caca5c 100644 --- a/core/src/mindustry/entities/comp/TeamComp.java +++ b/core/src/mindustry/entities/comp/TeamComp.java @@ -17,15 +17,15 @@ abstract class TeamComp implements Posc{ return team.rules().cheat; } - public @Nullable Tilec core(){ + public @Nullable Building core(){ return team.core(); } - public @Nullable Tilec closestCore(){ + public @Nullable Building closestCore(){ return state.teams.closestCore(x, y, team); } - public @Nullable Tilec closestEnemyCore(){ + public @Nullable Building closestEnemyCore(){ return state.teams.closestEnemyCore(x, y, team); } } diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index dd148abcc1..a8f8bf4783 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -11,6 +11,7 @@ import mindustry.content.*; import mindustry.entities.*; import mindustry.entities.units.*; import mindustry.game.EventType.*; +import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; @@ -25,6 +26,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I @Import float x, y, rotation, elevation, maxHealth, drag, armor, hitSize, health; @Import boolean dead; + @Import Team team; private UnitController controller; private UnitType type; @@ -60,13 +62,13 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I @Override public float bounds(){ - return hitSize() * 2f; + return hitSize * 2f; } @Override public void controller(UnitController next){ this.controller = next; - if(controller.unit() != this) controller.unit(this); + if(controller.unit() != base()) controller.unit(base()); } @Override @@ -128,7 +130,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I public void afterSync(){ //set up type info after reading setStats(this.type); - controller.unit(this); + controller.unit(base()); } @Override @@ -140,13 +142,13 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I @Override public void add(){ - teamIndex.updateCount(team(), 1); + teamIndex.updateCount(team, 1); } @Override public void remove(){ - teamIndex.updateCount(team(), -1); - controller.removed(this); + teamIndex.updateCount(team, -1); + controller.removed(base()); } @Override @@ -155,17 +157,17 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I Effects.shake(type.landShake, type.landShake, this); } - type.landed(this); + type.landed(base()); } @Override public void update(){ - type.update(this); + type.update(base()); drag(type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f)); //apply knockback based on spawns - if(team() != state.rules.waveTeam){ + if(team != state.rules.waveTeam){ float relativeSize = state.rules.dropZoneRadius + bounds()/2f + 1f; for(Tile spawn : spawner.getSpawns()){ if(within(spawn.worldx(), spawn.worldy(), relativeSize)){ @@ -180,7 +182,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I if(tile != null && isGrounded()){ //unit block update if(tile.entity != null){ - tile.entity.unitOn(this); + tile.entity.unitOn(base()); } //kill when stuck in wall @@ -208,7 +210,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I @Override public void display(Table table){ - type.display(this, table); + type.display(base(), table); } @Override @@ -218,17 +220,17 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I @Override public void draw(){ - type.draw(this); + type.draw(base()); } @Override public boolean isPlayer(){ - return controller instanceof Playerc; + return controller instanceof Player; } @Nullable - public Playerc getPlayer(){ - return isPlayer() ? (Playerc)controller : null; + public Player getPlayer(){ + return isPlayer() ? (Player)controller : null; } @Override @@ -240,12 +242,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I float flammability = item().flammability * stack().amount; Damage.dynamicExplosion(x, y, flammability, explosiveness, 0f, bounds() / 2f, Pal.darkFlame); - Effects.scorch(x, y, (int)(hitSize() / 5)); + Effects.scorch(x, y, (int)(hitSize / 5)); Fx.explosion.at(this); Effects.shake(2f, 2f, this); type.deathSound.at(this); - Events.fire(new UnitDestroyEvent(this)); + Events.fire(new UnitDestroyEvent(base())); if(explosiveness > 7f && isLocal()){ Events.fire(Trigger.suicideBomb); @@ -260,7 +262,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I if(dead || net.client()) return; //deaths are synced; this calls killed() - Call.onUnitDeath(this); + Call.onUnitDeath(base()); } @Override diff --git a/core/src/mindustry/entities/units/AIController.java b/core/src/mindustry/entities/units/AIController.java index 63a852ba0c..3d467a168e 100644 --- a/core/src/mindustry/entities/units/AIController.java +++ b/core/src/mindustry/entities/units/AIController.java @@ -14,7 +14,7 @@ public class AIController implements UnitController{ protected static final Vec2 vec = new Vec2(); protected static final int timerTarget = 0; - protected Unitc unit; + protected Unit unit; protected Teamc target; protected Interval timer = new Interval(4); @@ -23,12 +23,12 @@ public class AIController implements UnitController{ } protected void targetClosestAllyFlag(BlockFlag flag){ - Tile target = Geometry.findClosest(unit.x(), unit.y(), indexer.getAllied(unit.team(), flag)); + Tile target = Geometry.findClosest(unit.x, unit.y, indexer.getAllied(unit.team, flag)); if(target != null) this.target = target.entity; } protected void targetClosestEnemyFlag(BlockFlag flag){ - Tile target = Geometry.findClosest(unit.x(), unit.y(), indexer.getEnemy(unit.team(), flag)); + Tile target = Geometry.findClosest(unit.x, unit.y, indexer.getEnemy(unit.team, flag)); if(target != null) this.target = target.entity; } @@ -37,7 +37,7 @@ public class AIController implements UnitController{ } protected void targetClosest(){ - Teamc newTarget = Units.closestTarget(unit.team(), unit.x(), unit.y(), Math.max(unit.range(), unit.type().range), u -> (unit.type().targetAir && u.isFlying()) || (unit.type().targetGround && !u.isFlying())); + Teamc newTarget = Units.closestTarget(unit.team, unit.x, unit.y, Math.max(unit.range(), unit.type().range), u -> (unit.type().targetAir && u.isFlying()) || (unit.type().targetGround && !u.isFlying())); if(newTarget != null){ target = newTarget; } @@ -48,7 +48,7 @@ public class AIController implements UnitController{ } @Override - public void unit(Unitc unit){ + public void unit(Unit unit){ if(this.unit == unit) return; this.unit = unit; @@ -56,7 +56,7 @@ public class AIController implements UnitController{ } @Override - public Unitc unit(){ + public Unit unit(){ return unit; } } diff --git a/core/src/mindustry/entities/units/UnitController.java b/core/src/mindustry/entities/units/UnitController.java index 7688f084cc..3b3eaa0342 100644 --- a/core/src/mindustry/entities/units/UnitController.java +++ b/core/src/mindustry/entities/units/UnitController.java @@ -3,8 +3,8 @@ package mindustry.entities.units; import mindustry.gen.*; public interface UnitController{ - void unit(Unitc unit); - Unitc unit(); + void unit(Unit unit); + Unit unit(); default void command(UnitCommand command){ @@ -14,11 +14,11 @@ public interface UnitController{ } - default void removed(Unitc unit){ + default void removed(Unit unit){ } - default boolean isBeingControlled(Unitc player){ + default boolean isBeingControlled(Unit player){ return false; } } diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index f8353981b2..98b074f181 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -69,20 +69,20 @@ public class EventType{ public static class CommandIssueEvent{ - public final Tilec tile; + public final Building tile; public final UnitCommand command; - public CommandIssueEvent(Tilec tile, UnitCommand command){ + public CommandIssueEvent(Building tile, UnitCommand command){ this.tile = tile; this.command = command; } } public static class PlayerChatEvent{ - public final Playerc player; + public final Player player; public final String message; - public PlayerChatEvent(Playerc player, String message){ + public PlayerChatEvent(Player player, String message){ this.player = player; this.message = message; } @@ -120,12 +120,12 @@ public class EventType{ /** Called when the player withdraws items from a block. */ public static class WithdrawEvent{ - public final Tilec tile; - public final Playerc player; + public final Building tile; + public final Player player; public final Item item; public final int amount; - public WithdrawEvent(Tilec tile, Playerc player, Item item, int amount){ + public WithdrawEvent(Building tile, Player player, Item item, int amount){ this.tile = tile; this.player = player; this.item = item; @@ -135,12 +135,12 @@ public class EventType{ /** Called when a player deposits items to a block.*/ public static class DepositEvent{ - public final Tilec tile; - public final Playerc player; + public final Building tile; + public final Player player; public final Item item; public final int amount; - public DepositEvent(Tilec tile, Playerc player, Item item, int amount){ + public DepositEvent(Building tile, Player player, Item item, int amount){ this.tile = tile; this.player = player; this.item = item; @@ -150,10 +150,10 @@ public class EventType{ /** Called when the player taps a block. */ public static class TapEvent{ - public final Tilec tile; - public final Playerc player; + public final Building tile; + public final Player player; - public TapEvent(Tilec tile, Playerc player){ + public TapEvent(Building tile, Player player){ this.tile = tile; this.player = player; } @@ -161,11 +161,11 @@ public class EventType{ /** Called when the player sets a specific block. */ public static class TapConfigEvent{ - public final Tilec tile; - public final Playerc player; + public final Building tile; + public final Player player; public final Object value; - public TapConfigEvent(Tilec tile, Playerc player, Object value){ + public TapConfigEvent(Building tile, Player player, Object value){ this.tile = tile; this.player = player; this.value = value; @@ -181,10 +181,10 @@ public class EventType{ } /** Called from the logic thread. Do not access graphics here! */ - public static class TileChangeEvent{ + public static class BuildinghangeEvent{ public final Tile tile; - public TileChangeEvent(Tile tile){ + public BuildinghangeEvent(Tile tile){ this.tile = tile; } } @@ -233,10 +233,10 @@ public class EventType{ public static class BlockBuildEndEvent{ public final Tile tile; public final Team team; - public final @Nullable Unitc unit; + public final @Nullable Unit unit; public final boolean breaking; - public BlockBuildEndEvent(Tile tile, @Nullable Unitc unit, Team team, boolean breaking){ + public BlockBuildEndEvent(Tile tile, @Nullable Unit unit, Team team, boolean breaking){ this.tile = tile; this.team = team; this.unit = unit; @@ -273,26 +273,26 @@ public class EventType{ } public static class UnitDestroyEvent{ - public final Unitc unit; + public final Unit unit; - public UnitDestroyEvent(Unitc unit){ + public UnitDestroyEvent(Unit unit){ this.unit = unit; } } public static class UnitCreateEvent{ - public final Unitc unit; + public final Unit unit; - public UnitCreateEvent(Unitc unit){ + public UnitCreateEvent(Unit unit){ this.unit = unit; } } public static class UnitChangeEvent{ - public final Playerc player; - public final Unitc unit; + public final Player player; + public final Unit unit; - public UnitChangeEvent(Playerc player, Unitc unit){ + public UnitChangeEvent(Player player, Unit unit){ this.player = player; this.unit = unit; } @@ -300,42 +300,42 @@ public class EventType{ /** Called after connecting; when a player recieves world data and is ready to play.*/ public static class PlayerJoin{ - public final Playerc player; + public final Player player; - public PlayerJoin(Playerc player){ + public PlayerJoin(Player player){ this.player = player; } } /** Called when a player connects, but has not joined the game yet.*/ public static class PlayerConnect{ - public final Playerc player; + public final Player player; - public PlayerConnect(Playerc player){ + public PlayerConnect(Player player){ this.player = player; } } public static class PlayerLeave{ - public final Playerc player; + public final Player player; - public PlayerLeave(Playerc player){ + public PlayerLeave(Player player){ this.player = player; } } public static class PlayerBanEvent{ - public final Playerc player; + public final Player player; - public PlayerBanEvent(Playerc player){ + public PlayerBanEvent(Player player){ this.player = player; } } public static class PlayerUnbanEvent{ - public final Playerc player; + public final Player player; - public PlayerUnbanEvent(Playerc player){ + public PlayerUnbanEvent(Player player){ this.player = player; } } diff --git a/core/src/mindustry/game/Schematics.java b/core/src/mindustry/game/Schematics.java index 80c5da054c..cd91ae4aba 100644 --- a/core/src/mindustry/game/Schematics.java +++ b/core/src/mindustry/game/Schematics.java @@ -318,7 +318,7 @@ public class Schematics implements Loadable{ boolean found = false; for(int cx = x; cx <= x2; cx++){ for(int cy = y; cy <= y2; cy++){ - Tilec linked = world.ent(cx, cy); + Building linked = world.ent(cx, cy); if(linked != null &&linked.block().isVisible() && !(linked.block() instanceof BuildBlock)){ int top = linked.block().size/2; @@ -346,7 +346,7 @@ public class Schematics implements Loadable{ IntSet counted = new IntSet(); for(int cx = ox; cx <= ox2; cx++){ for(int cy = oy; cy <= oy2; cy++){ - Tilec tile = world.ent(cx, cy); + Building tile = world.ent(cx, cy); if(tile != null && !counted.contains(tile.pos()) && !(tile.block() instanceof BuildBlock) && (tile.block().isVisible() || (tile.block() instanceof CoreBlock && Core.settings.getBool("coreselect")))){ diff --git a/core/src/mindustry/game/SpawnGroup.java b/core/src/mindustry/game/SpawnGroup.java index f3b2ff0756..ad2cf44592 100644 --- a/core/src/mindustry/game/SpawnGroup.java +++ b/core/src/mindustry/game/SpawnGroup.java @@ -60,8 +60,8 @@ public class SpawnGroup implements Serializable{ * Creates a unit, and assigns correct values based on this group's data. * This method does not add() the unit. */ - public Unitc createUnit(Team team, int wave){ - Unitc unit = type.create(team); + public Unit createUnit(Team team, int wave){ + Unit unit = type.create(team); if(effect != null){ unit.apply(effect, 999999f); diff --git a/core/src/mindustry/game/Teams.java b/core/src/mindustry/game/Teams.java index fedfe2bb37..0e27ef83d5 100644 --- a/core/src/mindustry/game/Teams.java +++ b/core/src/mindustry/game/Teams.java @@ -55,10 +55,10 @@ public class Teams{ return false; } - public void eachEnemyCore(Team team, Cons ret){ + public void eachEnemyCore(Team team, Cons ret){ for(TeamData data : active){ if(areEnemies(team, data.team)){ - for(Tilec tile : data.cores){ + for(Building tile : data.cores){ ret.get(tile); } } diff --git a/core/src/mindustry/game/Tutorial.java b/core/src/mindustry/game/Tutorial.java index 590793a377..62727a618f 100644 --- a/core/src/mindustry/game/Tutorial.java +++ b/core/src/mindustry/game/Tutorial.java @@ -239,7 +239,7 @@ public class Tutorial{ //utility static void placeBlocks(){ - Tilec core = state.teams.playerCores().first(); + Building core = state.teams.playerCores().first(); for(int i = 0; i < blocksToBreak; i++){ world.tile(core.tile().x + blockOffset, core.tile().y + i).remove(); world.tile(core.tile().x + blockOffset, core.tile().y + i).setBlock(Blocks.scrapWall, state.rules.defaultTeam); @@ -247,7 +247,7 @@ public class Tutorial{ } static boolean blocksBroken(){ - Tilec core = state.teams.playerCores().first(); + Building core = state.teams.playerCores().first(); for(int i = 0; i < blocksToBreak; i++){ if(world.tile(core.tile().x + blockOffset, core.tile().y + i).block() == Blocks.scrapWall){ diff --git a/core/src/mindustry/graphics/BlockRenderer.java b/core/src/mindustry/graphics/BlockRenderer.java index 5a6b8d5208..1d72a650cc 100644 --- a/core/src/mindustry/graphics/BlockRenderer.java +++ b/core/src/mindustry/graphics/BlockRenderer.java @@ -33,7 +33,7 @@ public class BlockRenderer implements Disposable{ private float brokenFade = 0f; private FrameBuffer shadows = new FrameBuffer(); private FrameBuffer dark = new FrameBuffer(); - private Seq outArray2 = new Seq<>(); + private Seq outArray2 = new Seq<>(); private Seq shadowEvents = new Seq<>(); private IntSet processedEntities = new IntSet(); private boolean displayStatus = false; @@ -82,7 +82,7 @@ public class BlockRenderer implements Disposable{ dark.end(); }); - Events.on(TileChangeEvent.class, event -> { + Events.on(BuildinghangeEvent.class, event -> { shadowEvents.add(event.tile); int avgx = (int)(camera.position.x / tilesize); @@ -205,8 +205,8 @@ public class BlockRenderer implements Disposable{ lightview.add(tile); } - if(tile.entity != null && tile.entity.power() != null && tile.entity.power().links.size > 0){ - for(Tilec other : tile.entity.getPowerConnections(outArray2)){ + if(tile.entity != null && tile.entity.power != null && tile.entity.power.links.size > 0){ + for(Building other : tile.entity.getPowerConnections(outArray2)){ if(other.block() instanceof PowerNode){ //TODO need a generic way to render connections! tileview.add(other.tile()); } @@ -229,7 +229,7 @@ public class BlockRenderer implements Disposable{ for(int i = 0; i < tileview.size; i++){ Tile tile = tileview.items[i]; Block block = tile.block(); - Tilec entity = tile.entity; + Building entity = tile.entity; Draw.z(Layer.block); @@ -260,7 +260,7 @@ public class BlockRenderer implements Disposable{ //draw lights for(int i = 0; i < lightview.size; i++){ Tile tile = lightview.items[i]; - Tilec entity = tile.entity; + Building entity = tile.entity; if(entity != null){ entity.drawLight(); diff --git a/core/src/mindustry/graphics/Drawf.java b/core/src/mindustry/graphics/Drawf.java index b64ebc3877..70a09d55ae 100644 --- a/core/src/mindustry/graphics/Drawf.java +++ b/core/src/mindustry/graphics/Drawf.java @@ -73,7 +73,7 @@ public class Drawf{ return team == Team.derelict || team == Vars.player.team() || state.rules.enemyLights; } - public static void selected(Tilec tile, Color color){ + public static void selected(Building tile, Color color){ selected(tile.tile(), color); } @@ -188,11 +188,11 @@ public class Drawf{ Draw.rect(Core.atlas.find("shape-3"), x, y - oy + length / 2f, width, length, width / 2f, oy, rotation - 90); } - public static void construct(Tilec t, UnlockableContent content, float rotation, float progress, float speed, float time){ + public static void construct(Building t, UnlockableContent content, float rotation, float progress, float speed, float time){ construct(t, content.icon(Cicon.full), rotation, progress, speed, time); } - public static void construct(Tilec t, TextureRegion region, float rotation, float progress, float speed, float time){ + public static void construct(Building t, TextureRegion region, float rotation, float progress, float speed, float time){ Shaders.build.region = region; Shaders.build.progress = progress; Shaders.build.color.set(Pal.accent); diff --git a/core/src/mindustry/graphics/MinimapRenderer.java b/core/src/mindustry/graphics/MinimapRenderer.java index b3d3dc2099..ab95e0f260 100644 --- a/core/src/mindustry/graphics/MinimapRenderer.java +++ b/core/src/mindustry/graphics/MinimapRenderer.java @@ -22,7 +22,7 @@ import static mindustry.Vars.*; public class MinimapRenderer implements Disposable{ private static final float baseSize = 16f; - private final Seq units = new Seq<>(); + private final Seq units = new Seq<>(); private Pixmap pixmap; private Texture texture; private TextureRegion region; @@ -36,7 +36,7 @@ public class MinimapRenderer implements Disposable{ }); //make sure to call on the graphics thread - Events.on(TileChangeEvent.class, event -> Core.app.post(() -> update(event.tile))); + Events.on(BuildinghangeEvent.class, event -> Core.app.post(() -> update(event.tile))); } public Pixmap getPixmap(){ @@ -87,7 +87,7 @@ public class MinimapRenderer implements Disposable{ rect.set((dx - sz) * tilesize, (dy - sz) * tilesize, sz * 2 * tilesize, sz * 2 * tilesize); - for(Unitc unit : units){ + for(Unit unit : units){ float rx = !withLabels ? (unit.x() - rect.x) / rect.width * w : unit.x() / (world.width() * tilesize) * w; float ry = !withLabels ? (unit.y() - rect.y) / rect.width * h : unit.y() / (world.height() * tilesize) * h; @@ -97,9 +97,9 @@ public class MinimapRenderer implements Disposable{ Draw.reset(); //only disable player names in multiplayer - if(withLabels && unit instanceof Playerc && net.active()){ - Playerc pl = (Playerc)unit; - drawLabel(x + rx, y + ry, pl.name(), unit.team().color); + if(withLabels && unit.isPlayer() && net.active()){ + Player pl = unit.getPlayer(); + drawLabel(x + rx, y + ry, pl.name, unit.team().color); } } diff --git a/core/src/mindustry/graphics/OverlayRenderer.java b/core/src/mindustry/graphics/OverlayRenderer.java index 23f5eeaa0f..c89fd6aa84 100644 --- a/core/src/mindustry/graphics/OverlayRenderer.java +++ b/core/src/mindustry/graphics/OverlayRenderer.java @@ -19,7 +19,7 @@ public class OverlayRenderer{ private static final float spawnerMargin = tilesize*11f; private static final Rect rect = new Rect(); private float buildFade, unitFade; - private Unitc lastSelect; + private Unit lastSelect; public void drawBottom(){ InputHandler input = control.input; @@ -36,7 +36,7 @@ public class OverlayRenderer{ public void drawTop(){ if(Core.settings.getBool("playerindicators")){ - for(Playerc player : Groups.player){ + for(Player player : Groups.player){ if(Vars.player != player && Vars.player.team() == player.team()){ if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f) .setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x(), player.y())){ @@ -67,7 +67,7 @@ public class OverlayRenderer{ InputHandler input = control.input; - Unitc select = input.selectedUnit(); + Unit select = input.selectedUnit(); if(!Core.input.keyDown(Binding.control)) select = null; unitFade = Mathf.lerpDelta(unitFade, Mathf.num(select != null), 0.1f); @@ -79,19 +79,19 @@ public class OverlayRenderer{ if(select instanceof BlockUnitc){ //special selection for block "units" - Fill.square(select.x(), select.y(), ((BlockUnitc)select).tile().block().size * tilesize/2f); + Fill.square(select.x, select.y, ((BlockUnitc)select).tile().block().size * tilesize/2f); }else{ Draw.rect(select.type().icon(Cicon.full), select.x(), select.y(), select.rotation() - 90); } Lines.stroke(unitFade); - Lines.square(select.x(), select.y(), select.hitSize() * 1.5f, Time.time() * 2f); + Lines.square(select.x, select.y, select.hitSize() * 1.5f, Time.time() * 2f); Draw.reset(); } //draw config selected block if(input.frag.config.isShown()){ - Tilec tile = input.frag.config.getSelectedTile(); + Building tile = input.frag.config.getSelectedTile(); tile.drawConfigure(); } @@ -129,7 +129,7 @@ public class OverlayRenderer{ //draw selected block if(input.block == null && !Core.scene.hasMouse()){ Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY()); - Tilec tile = world.entWorld(vec.x, vec.y); + Building tile = world.entWorld(vec.x, vec.y); if(tile != null && tile.team() == player.team()){ tile.drawSelect(); @@ -152,7 +152,7 @@ public class OverlayRenderer{ Lines.circle(v.x, v.y, 6 + Mathf.absin(Time.time(), 5f, 1f)); Draw.reset(); - Tilec tile = world.entWorld(v.x, v.y); + Building tile = world.entWorld(v.x, v.y); if(tile != null && tile.interactable(player.team()) && tile.acceptStack(player.unit().item(), player.unit().stack().amount, player.unit()) > 0){ Lines.stroke(3f, Pal.gray); Lines.square(tile.x(), tile.y(), tile.block().size * tilesize / 2f + 3 + Mathf.absin(Time.time(), 5f, 1f)); diff --git a/core/src/mindustry/graphics/g3d/PlanetGrid.java b/core/src/mindustry/graphics/g3d/PlanetGrid.java index 37a4d1ab15..e4972e3eb7 100644 --- a/core/src/mindustry/graphics/g3d/PlanetGrid.java +++ b/core/src/mindustry/graphics/g3d/PlanetGrid.java @@ -30,7 +30,7 @@ public class PlanetGrid{ PlanetGrid(int size){ this.size = size; - tiles = new Ptile[tileCount(size)]; + tiles = new Ptile[Buildingount(size)]; for(int i = 0; i < tiles.length; i++){ tiles[i] = new Ptile(i, i < 12 ? 5 : 6); } @@ -207,7 +207,7 @@ public class PlanetGrid{ return -1; } - static int tileCount(int size){ + static int Buildingount(int size){ return 10 * Mathf.pow(3, size) + 2; } diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index b1c3e14b87..f3c54b591a 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -199,7 +199,7 @@ public class DesktopInput extends InputHandler{ if(!scene.hasMouse()){ if(Core.input.keyDown(Binding.control) && Core.input.keyTap(Binding.select)){ - Unitc on = selectedUnit(); + Unit on = selectedUnit(); if(on != null){ Call.onUnitControl(player, on); shouldShoot = false; @@ -546,7 +546,7 @@ public class DesktopInput extends InputHandler{ } } - protected void updateMovement(Unitc unit){ + protected void updateMovement(Unit unit){ boolean omni = !(unit instanceof WaterMovec); boolean legs = unit.isGrounded(); @@ -588,12 +588,12 @@ public class DesktopInput extends InputHandler{ Payloadc pay = (Payloadc)unit; if(Core.input.keyTap(Binding.pickupCargo) && pay.payloads().size < unit.type().payloadCapacity){ - Unitc target = Units.closest(player.team(), pay.x(), pay.y(), 30f, u -> u.isAI() && u.isGrounded()); + Unit target = Units.closest(player.team(), pay.x(), pay.y(), 30f, u -> u.isAI() && u.isGrounded()); if(target != null){ pay.pickup(target); }else if(!pay.hasPayload()){ - Tilec tile = world.entWorld(pay.x(), pay.y()); - if(tile != null && tile.team() == unit.team() && tile.block().synthetic()){ + Building tile = world.entWorld(pay.x(), pay.y()); + if(tile != null && tile.team() == unit.team && tile.block().synthetic()){ //pick up block directly if(tile.block().buildVisibility != BuildVisibility.hidden && tile.block().size <= 2){ pay.pickup(tile); diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 4d50e58c4d..57adfee577 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -47,7 +47,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ final static int maxLength = 100; final static Vec2 stackTrns = new Vec2(); final static Rect r1 = new Rect(), r2 = new Rect(); - final static Seq units = new Seq<>(); + final static Seq units = new Seq<>(); /** Distance on the back from where items originate. */ final static float backTrns = 3f; @@ -85,11 +85,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ @Remote(called = Loc.server, unreliable = true) public static void transferItemTo(Item item, int amount, float x, float y, Tile tile){ - if(tile == null || tile.entity == null || tile.entity.items() == null) return; + if(tile == null || tile.entity == null || tile.entity.items == null) return; for(int i = 0; i < Mathf.clamp(amount / 3, 1, 8); i++){ Time.run(i * 3, () -> createItemTransfer(item, amount, x, y, tile, () -> {})); } - tile.entity.items().add(item, amount); + tile.entity.items.add(item, amount); } public static void createItemTransfer(Item item, int amount, float x, float y, Position to, Runnable done){ @@ -105,7 +105,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.client, called = Loc.server) - public static void dropItem(Playerc player, float angle){ + public static void dropItem(Player player, float angle){ if(net.server() && player.unit().stack().amount <= 0){ throw new ValidateException(player, "Player cannot drop an item."); } @@ -115,7 +115,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.both, called = Loc.server, forward = true, unreliable = true) - public static void rotateBlock(Playerc player, Tilec tile, boolean direction){ + public static void rotateBlock(Player player, Building tile, boolean direction){ if(net.server() && (!Units.canInteract(player, tile) || !netServer.admins.allowAction(player, ActionType.rotate, tile.tile(), action -> action.rotation = Mathf.mod(tile.rotation() + Mathf.sign(direction), 4)))){ throw new ValidateException(player, "Player cannot rotate a block."); @@ -127,7 +127,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.both, forward = true, called = Loc.server) - public static void transferInventory(Playerc player, Tilec tile){ + public static void transferInventory(Player player, Building tile){ if(player == null || tile == null) return; if(net.server() && (player.unit().stack().amount <= 0 || !Units.canInteract(player, tile) || !netServer.admins.allowAction(player, ActionType.depositItem, tile.tile(), action -> { @@ -149,14 +149,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ createItemTransfer( item, amount, - player.x() + Angles.trnsx(player.unit().rotation() + 180f, backTrns), player.y() + Angles.trnsy(player.unit().rotation() + 180f, backTrns), + player.x() + Angles.trnsx(player.unit().rotation + 180f, backTrns), player.y() + Angles.trnsy(player.unit().rotation + 180f, backTrns), new Vec2(tile.x() + stackTrns.x, tile.y() + stackTrns.y), () -> tile.handleStack(item, accepted, player.unit()) ); } @Remote(targets = Loc.both, called = Loc.server, forward = true) - public static void onTileTapped(Playerc player, Tilec tile){ + public static void onTileTapped(Player player, Building tile){ if(tile == null || player == null) return; if(net.server() && (!Units.canInteract(player, tile) || !netServer.admins.allowAction(player, ActionType.tapTile, tile.tile(), action -> {}))) throw new ValidateException(player, "Player cannot tap a tile."); @@ -165,7 +165,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.both, called = Loc.both, forward = true) - public static void onTileConfig(Playerc player, Tilec tile, @Nullable Object value){ + public static void onTileConfig(Player player, Building tile, @Nullable Object value){ if(tile == null) return; if(net.server() && (!Units.canInteract(player, tile) || !netServer.admins.allowAction(player, ActionType.configure, tile.tile(), action -> action.config = value))) throw new ValidateException(player, "Player cannot configure a tile."); @@ -174,7 +174,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.both, called = Loc.server, forward = true) - public static void onUnitControl(Playerc player, @Nullable Unitc unit){ + public static void onUnitControl(Player player, @Nullable Unit unit){ //clear player unit when they possess a core if((unit instanceof BlockUnitc && ((BlockUnitc)unit).tile() instanceof CoreEntity)){ Fx.spawn.at(player); @@ -183,9 +183,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ }else if(unit == null){ //just clear the unit (is this used?) player.clearUnit(); //make sure it's AI controlled, so players can't overwrite each other - }else if(unit.isAI() && unit.team() == player.team()){ + }else if(unit.isAI() && unit.team == player.team()){ player.unit(unit); - Time.run(Fx.unitSpirit.lifetime, () -> Fx.unitControl.at(unit.x(), unit.y(), 0f, unit)); + Time.run(Fx.unitSpirit.lifetime, () -> Fx.unitControl.at(unit.x, unit.y, 0f, unit)); if(!player.dead()){ Fx.unitSpirit.at(player.x(), player.y(), 0f, unit); } @@ -193,9 +193,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.both, called = Loc.server, forward = true) - public static void onUnitClear(Playerc player){ + public static void onUnitClear(Player player){ //no free core teleports? - if(!player.dead() && player.unit().spawnedByCore()) return; + if(!player.dead() && player.unit().spawnedByCore) return; Fx.spawn.at(player); player.clearUnit(); @@ -203,7 +203,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.both, called = Loc.server, forward = true) - public static void onUnitCommand(Playerc player){ + public static void onUnitCommand(Player player){ if(player.dead() || !(player.unit() instanceof Commanderc)) return; Commanderc commander = (Commanderc)player.unit(); @@ -212,7 +212,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ commander.clearCommand(); }else{ FormationPattern pattern = new SquareFormation(); - Formation formation = new Formation(new Vec3(player.x(), player.y(), player.unit().rotation()), pattern); + Formation formation = new Formation(new Vec3(player.x(), player.y(), player.unit().rotation), pattern); formation.slotAssignmentStrategy = new DistanceAssignmentStrategy(pattern); units.clear(); @@ -260,7 +260,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } if(controlledType != null && player.dead()){ - Unitc unit = Units.closest(player.team(), player.x(), player.y(), u -> !u.isPlayer() && u.type() == controlledType); + Unit unit = Units.closest(player.team(), player.x(), player.y(), u -> !u.isPlayer() && u.type() == controlledType); if(unit != null){ Call.onUnitControl(player, unit); @@ -270,7 +270,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ public void checkUnit(){ if(controlledType != null){ - Unitc unit = Units.closest(player.team(), player.x(), player.y(), u -> !u.isPlayer() && u.type() == controlledType); + Unit unit = Units.closest(player.team(), player.x(), player.y(), u -> !u.isPlayer() && u.type() == controlledType); if(unit == null && controlledType == UnitTypes.block){ unit = world.entWorld(player.x(), player.y()) instanceof ControlBlock ? ((ControlBlock)world.entWorld(player.x(), player.y())).unit() : null; } @@ -481,7 +481,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ for(int x = dresult.x; x <= dresult.x2; x++){ for(int y = dresult.y; y <= dresult.y2; y++){ - Tile tile = world.tilec(x, y); + Tile tile = world.Building(x, y); if(tile == null || !validBreak(tile.x, tile.y)) continue; drawBreaking(tile.x, tile.y); @@ -597,7 +597,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ int wx = x1 + x * Mathf.sign(x2 - x1); int wy = y1 + y * Mathf.sign(y2 - y1); - Tile tile = world.tilec(wx, wy); + Tile tile = world.Building(wx, wy); if(tile == null) continue; @@ -663,7 +663,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } /** Handles tile tap events that are not platform specific. */ - boolean tileTapped(@Nullable Tilec tile){ + boolean tileTapped(@Nullable Building tile){ if(tile == null){ frag.inv.hide(); frag.config.hideConfig(); @@ -702,7 +702,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ if(tile.interactable(player.team()) && tile.block().consumesTap){ consumed = true; }else if(tile.interactable(player.team()) && tile.block().synthetic() && !consumed){ - if(tile.block().hasItems && tile.items().total() > 0){ + if(tile.block().hasItems && tile.items.total() > 0){ frag.inv.showFor(tile); consumed = true; showedInventory = true; @@ -747,7 +747,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ && tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= miningRange; } - Tilec entAt(float x, float y){ + Building entAt(float x, float y){ return world.ent(tileX(x), tileY(y)); } @@ -796,8 +796,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ return Core.input.mouseWorld(getMouseX(), getMouseY()).sub(x, y).angle(); } - public @Nullable Unitc selectedUnit(){ - Unitc unit = Units.closest(player.team(), Core.input.mouseWorld().x, Core.input.mouseWorld().y, 40f, Unitc::isAI); + public @Nullable Unit selectedUnit(){ + Unit unit = Units.closest(player.team(), Core.input.mouseWorld().x, Core.input.mouseWorld().y, 40f, Unit::isAI); if(unit != null){ unit.hitbox(Tmp.r1); Tmp.r1.grow(6f); @@ -806,7 +806,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } } - Tilec tile = world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y); + Building tile = world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y); if(tile instanceof ControlBlock && tile.team() == player.team()){ return ((ControlBlock)tile).unit(); } @@ -865,7 +865,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ return droppingItem; } - public void tryDropItems(@Nullable Tilec tile, float x, float y){ + public void tryDropItems(@Nullable Building tile, float x, float y){ if(!droppingItem || player.unit().stack().amount <= 0 || canTapPlayer(x, y) || state.isPaused() ){ droppingItem = false; return; @@ -1106,7 +1106,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ protected void updateTouch(){ if(Units.invalidateTarget(target, this) && - !(target instanceof Tilec && ((Tilec)target).damaged() && target.isValid() && target.team() == team && mech.canHeal && dst(target) < mech.range && !(((Tilec)target).block instanceof BuildBlock))){ + !(target instanceof Building && ((Building)target).damaged() && target.isValid() && target.team() == team && mech.canHeal && dst(target) < mech.range && !(((Building)target).block instanceof BuildBlock))){ target = null; } @@ -1121,7 +1121,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ if(moveTarget != null && !moveTarget.dead()){ targetX = moveTarget.getX(); targetY = moveTarget.getY(); - boolean tapping = moveTarget instanceof Tilec && moveTarget.team() == team; + boolean tapping = moveTarget instanceof Building && moveTarget.team() == team; attractDst = 0f; if(tapping){ @@ -1130,7 +1130,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ if(dst(moveTarget) <= 2f * Time.delta()){ if(tapping && !dead()){ - Tile tile = ((Tilec)moveTarget).tile; + Tile tile = ((Building)moveTarget).tile; tile.tapped(this); } @@ -1197,7 +1197,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ mineTile(null); } } - }else if(target.isValid() || (target instanceof Tilec && ((Tilec)target).damaged() && target.team() == team && mech.canHeal && dst(target) < mech.range)){ + }else if(target.isValid() || (target instanceof Building && ((Building)target).damaged() && target.team() == team && mech.canHeal && dst(target) < mech.range)){ //rotate toward and shoot the target if(mech.faceTarget){ rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f); diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 8320bb47d1..1b1c301632 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -68,13 +68,13 @@ public class MobileInput extends InputHandler implements GestureListener{ /** Check and assign targets for a specific position. */ void checkTargets(float x, float y){ - Unitc unit = Units.closestEnemy(player.team(), x, y, 20f, u -> !u.dead()); + Unit unit = Units.closestEnemy(player.team(), x, y, 20f, u -> !u.dead); if(unit != null){ player.miner().mineTile(null); target = unit; }else{ - Tilec tile = world.entWorld(x, y); + Building tile = world.entWorld(x, y); if(tile != null && player.team().isEnemy(tile.team())){ player.miner().mineTile(null); diff --git a/core/src/mindustry/io/TypeIO.java b/core/src/mindustry/io/TypeIO.java index 494aca1117..11b170de44 100644 --- a/core/src/mindustry/io/TypeIO.java +++ b/core/src/mindustry/io/TypeIO.java @@ -140,26 +140,26 @@ public class TypeIO{ return noMounts; } - public static void writeUnit(Writes write, Unitc unit){ + public static void writeUnit(Writes write, Unit unit){ write.b(unit.isNull() ? 0 : unit instanceof BlockUnitc ? 1 : 2); //block units are special if(unit instanceof BlockUnitc){ write.i(((BlockUnitc)unit).tile().pos()); }else{ - write.i(unit.id()); + write.i(unit.id); } } - public static Unitc readUnit(Reads read){ + public static Unit readUnit(Reads read){ byte type = read.b(); int id = read.i(); //nothing if(type == 0) return Nulls.unit; if(type == 2){ //standard unit - Unitc unit = Groups.unit.getByID(id); + Unit unit = Groups.unit.getByID(id); return unit == null ? Nulls.unit : unit; }else if(type == 1){ //block - Tilec tile = world.ent(id); + Building tile = world.ent(id); return tile instanceof ControlBlock ? ((ControlBlock)tile).unit() : Nulls.unit; } return Nulls.unit; @@ -173,11 +173,11 @@ public class TypeIO{ return (T)Groups.all.getByID(read.i()); } - public static void writeTilec(Writes write, Tilec tile){ + public static void writeBuilding(Writes write, Building tile){ write.i(tile == null ? -1 : tile.pos()); } - public static Tilec readTilec(Reads read){ + public static Building readBuilding(Reads read){ return world.ent(read.i()); } @@ -264,9 +264,9 @@ public class TypeIO{ public static void writeController(Writes write, UnitController control){ //no real unit controller state is written, only the type - if(control instanceof Playerc){ + if(control instanceof Player){ write.b(0); - write.i(((Playerc)control).id()); + write.i(((Player)control).id()); }else if(control instanceof FormationAI){ write.b(1); write.i(((FormationAI)control).leader.id()); @@ -279,7 +279,7 @@ public class TypeIO{ byte type = read.b(); if(type == 0){ //is player int id = read.i(); - Playerc player = Groups.player.getByID(id); + Player player = Groups.player.getByID(id); //make sure player exists if(player == null) return prev; return player; diff --git a/core/src/mindustry/io/legacy/LegacySaveVersion.java b/core/src/mindustry/io/legacy/LegacySaveVersion.java index 4e543c7be6..cd52d131f4 100644 --- a/core/src/mindustry/io/legacy/LegacySaveVersion.java +++ b/core/src/mindustry/io/legacy/LegacySaveVersion.java @@ -65,7 +65,7 @@ public abstract class LegacySaveVersion extends SaveVersion{ try{ readChunk(stream, true, in -> { byte version = in.readByte(); - //legacy impl of TileEntity#read() + //legacy impl of Building#read() tile.entity.health(stream.readUnsignedShort()); byte packedrot = stream.readByte(); byte team = Pack.leftByte(packedrot) == 8 ? stream.readByte() : Pack.leftByte(packedrot); @@ -74,9 +74,9 @@ public abstract class LegacySaveVersion extends SaveVersion{ tile.setTeam(Team.get(team)); tile.rotation(rotation); - if(tile.entity.items() != null) tile.entity.items().read(Reads.get(stream)); - if(tile.entity.power() != null) tile.entity.power().read(Reads.get(stream)); - if(tile.entity.liquids() != null) tile.entity.liquids().read(Reads.get(stream)); + if(tile.entity.items != null) tile.entity.items.read(Reads.get(stream)); + if(tile.entity.power != null) tile.entity.power.read(Reads.get(stream)); + if(tile.entity.liquids != null) tile.entity.liquids.read(Reads.get(stream)); if(tile.entity.cons() != null) tile.entity.cons().read(Reads.get(stream)); //read only from subclasses! diff --git a/core/src/mindustry/io/legacy/LegacyTypeTable.java b/core/src/mindustry/io/legacy/LegacyTypeTable.java index f232911503..642c48a189 100644 --- a/core/src/mindustry/io/legacy/LegacyTypeTable.java +++ b/core/src/mindustry/io/legacy/LegacyTypeTable.java @@ -73,7 +73,7 @@ public class LegacyTypeTable{ 13 = Revenant private static final Prov[] build81Table = { - Playerc::new, + Player::new, Fire::new, Puddle::new, MinerDrone::new, @@ -90,7 +90,7 @@ public class LegacyTypeTable{ }; private static final Prov[] build80Table = { - Playerc::new, + Player::new, Fire::new, Puddle::new, Bullet::new, @@ -109,7 +109,7 @@ public class LegacyTypeTable{ }; private static final Prov[] build79Table = { - Playerc::new, + Player::new, Fire::new, Puddle::new, Bullet::new, diff --git a/core/src/mindustry/logic/LogicExecutor.java b/core/src/mindustry/logic/LogicExecutor.java index f702df855e..11f44bc26d 100644 --- a/core/src/mindustry/logic/LogicExecutor.java +++ b/core/src/mindustry/logic/LogicExecutor.java @@ -19,7 +19,7 @@ public class LogicExecutor{ if(counter >= instructions.length) counter = 0; } - Tilec device(short id){ + Building device(short id){ return null; //TODO } @@ -68,8 +68,8 @@ public class LogicExecutor{ } enum ReadOp{ - item((tile, id) -> tile.items() == null ? 0 : tile.items().get(id)), - itemTotal((tile, param) -> tile.items() == null ? 0 : tile.items().total()); + item((tile, id) -> tile.items == null ? 0 : tile.items.get(id)), + itemTotal((tile, param) -> tile.items == null ? 0 : tile.items.total()); final ReadOpLambda function; final String symbol; @@ -80,7 +80,7 @@ public class LogicExecutor{ } interface ReadOpLambda{ - int get(Tilec tile, int parameter); + int get(Building tile, int parameter); } } diff --git a/core/src/mindustry/maps/filters/RandomItemFilter.java b/core/src/mindustry/maps/filters/RandomItemFilter.java index c7b2d7e419..d31c6f40ae 100644 --- a/core/src/mindustry/maps/filters/RandomItemFilter.java +++ b/core/src/mindustry/maps/filters/RandomItemFilter.java @@ -21,7 +21,7 @@ public class RandomItemFilter extends GenerateFilter{ if(tile.block() instanceof StorageBlock && !(tile.block() instanceof CoreBlock)){ for(ItemStack stack : drops){ if(Mathf.chance(chance)){ - tile.entity.items().add(stack.item, Math.min(Mathf.random(stack.amount), tile.block().itemCapacity)); + tile.entity.items.add(stack.item, Math.min(Mathf.random(stack.amount), tile.block().itemCapacity)); } } } diff --git a/core/src/mindustry/maps/generators/BaseGenerator.java b/core/src/mindustry/maps/generators/BaseGenerator.java index b398955105..f5e3516f7e 100644 --- a/core/src/mindustry/maps/generators/BaseGenerator.java +++ b/core/src/mindustry/maps/generators/BaseGenerator.java @@ -63,9 +63,9 @@ public class BaseGenerator{ Schematics.placeLoadout(coreschem.schematic, tile.x, tile.y, team, coreschem.required instanceof Item ? ores.get((Item)coreschem.required) : Blocks.oreCopper); //fill core with every type of item (even non-material) - Tilec entity = tile.entity; + Building entity = tile.entity; for(Item item : content.items()){ - entity.items().add(item, entity.block().itemCapacity); + entity.items.add(item, entity.block().itemCapacity); } } diff --git a/core/src/mindustry/maps/generators/FileMapGenerator.java b/core/src/mindustry/maps/generators/FileMapGenerator.java index 76a297756a..50c89870f2 100644 --- a/core/src/mindustry/maps/generators/FileMapGenerator.java +++ b/core/src/mindustry/maps/generators/FileMapGenerator.java @@ -34,7 +34,7 @@ public class FileMapGenerator implements WorldGenerator{ if(tile.block() instanceof StorageBlock && !(tile.block() instanceof CoreBlock) && state.hasSector()){ for(Content content : state.getSector().data.resources){ if(content instanceof Item && Mathf.chance(0.3)){ - tile.entity.items().add((Item)content, Math.min(Mathf.random(500), tile.block().itemCapacity)); + tile.entity.items.add((Item)content, Math.min(Mathf.random(500), tile.block().itemCapacity)); } } } diff --git a/core/src/mindustry/net/Administration.java b/core/src/mindustry/net/Administration.java index a9b5ff38c2..8dd8274c37 100644 --- a/core/src/mindustry/net/Administration.java +++ b/core/src/mindustry/net/Administration.java @@ -123,7 +123,7 @@ public class Administration{ } /** Filters out a chat message. */ - public @Nullable String filterMessage(Playerc player, String message){ + public @Nullable String filterMessage(Player player, String message){ String current = message; for(ChatFilter f : chatFilters){ current = f.filter(player, current); @@ -138,7 +138,7 @@ public class Administration{ } /** @return whether this action is allowed by the action filters. */ - public boolean allowAction(Playerc player, ActionType type, Tile tile, Cons setter){ + public boolean allowAction(Player player, ActionType type, Tile tile, Cons setter){ PlayerAction act = Pools.obtain(PlayerAction.class, PlayerAction::new); setter.get(act.set(player, type, tile)); for(ActionFilter filter : actionFilters){ @@ -655,7 +655,7 @@ public class Administration{ /** Handles chat messages from players and changes their contents. */ public interface ChatFilter{ /** @return the filtered message; a null string signals that the message should not be sent. */ - @Nullable String filter(Playerc player, String message); + @Nullable String filter(Player player, String message); } /** Allows or disallows player actions. */ @@ -679,7 +679,7 @@ public class Administration{ /** Defines a (potentially dangerous) action that a player has done in the world. * These objects are pooled; do not cache them! */ public static class PlayerAction implements Poolable{ - public @NonNull Playerc player; + public @NonNull Player player; public @NonNull ActionType type; public @NonNull Tile tile; @@ -694,7 +694,7 @@ public class Administration{ public @Nullable Item item; public int itemAmount; - public PlayerAction set(Playerc player, ActionType type, Tile tile){ + public PlayerAction set(Player player, ActionType type, Tile tile){ this.player = player; this.type = type; this.tile = tile; diff --git a/core/src/mindustry/net/NetConnection.java b/core/src/mindustry/net/NetConnection.java index 3fbc5ada21..a735be7ba0 100644 --- a/core/src/mindustry/net/NetConnection.java +++ b/core/src/mindustry/net/NetConnection.java @@ -18,7 +18,7 @@ public abstract class NetConnection{ public final String address; public String uuid = "AAAAAAAA", usid = uuid; public boolean mobile, modclient; - public @Nullable Playerc player; + public @Nullable Player player; public @Nullable Unitc lastUnit; public Vec2 lastPosition = new Vec2(); diff --git a/core/src/mindustry/net/NetworkIO.java b/core/src/mindustry/net/NetworkIO.java index 6fce3740af..c8f5d5de15 100644 --- a/core/src/mindustry/net/NetworkIO.java +++ b/core/src/mindustry/net/NetworkIO.java @@ -18,7 +18,7 @@ import static mindustry.Vars.*; public class NetworkIO{ - public static void writeWorld(Playerc player, OutputStream os){ + public static void writeWorld(Player player, OutputStream os){ try(DataOutputStream stream = new DataOutputStream(os)){ stream.writeUTF(JsonIO.write(state.rules)); diff --git a/core/src/mindustry/net/ValidateException.java b/core/src/mindustry/net/ValidateException.java index 12a4ae4bdc..20bb15af6c 100644 --- a/core/src/mindustry/net/ValidateException.java +++ b/core/src/mindustry/net/ValidateException.java @@ -6,9 +6,9 @@ import mindustry.gen.*; * Thrown when a client sends invalid information. */ public class ValidateException extends RuntimeException{ - public final Playerc player; + public final Player player; - public ValidateException(Playerc player, String s){ + public ValidateException(Player player, String s){ super(s); this.player = player; } diff --git a/core/src/mindustry/type/StatusEffect.java b/core/src/mindustry/type/StatusEffect.java index 632254a9de..ae0a773476 100644 --- a/core/src/mindustry/type/StatusEffect.java +++ b/core/src/mindustry/type/StatusEffect.java @@ -44,7 +44,7 @@ public class StatusEffect extends MappableContent{ } /** Runs every tick on the affected unit while time is greater than 0. */ - public void update(Unitc unit, float time){ + public void update(Unit unit, float time){ if(damage > 0){ unit.damageContinuousPierce(damage); }else if(damage < 0){ //heal unit @@ -73,7 +73,7 @@ public class StatusEffect extends MappableContent{ } } - public void draw(Unitc unit){ + public void draw(Unit unit){ } @@ -87,7 +87,7 @@ public class StatusEffect extends MappableContent{ * @param time The current status effect time * @param newTime The time that the new status effect will last */ - public StatusEntry getTransition(Unitc unit, StatusEffect to, float time, float newTime, StatusEntry result){ + public StatusEntry getTransition(Unit unit, StatusEffect to, float time, float newTime, StatusEntry result){ if(transitions.containsKey(to)){ transitions.get(to).handle(unit, time, newTime, result); return result; @@ -102,6 +102,6 @@ public class StatusEffect extends MappableContent{ } public interface TransitionHandler{ - void handle(Unitc unit, float time, float newTime, StatusEntry result); + void handle(Unit unit, float time, float newTime, StatusEntry result); } } diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index a69443ce03..2e70c04c5e 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -32,7 +32,7 @@ public class UnitType extends UnlockableContent{ private static final Vec2 legOffset = new Vec2(); public boolean flying; - public @NonNull Prov constructor; + public @NonNull Prov constructor; public @NonNull Prov defaultController = () -> !flying ? new GroundAI() : new FlyingAI(); public float speed = 1.1f, boostMultiplier = 1f, rotateSpeed = 5f, baseRotateSpeed = 5f; public float drag = 0.3f, accel = 0.5f, landShake = 0f, rippleScale = 1f; @@ -84,8 +84,8 @@ public class UnitType extends UnlockableContent{ return defaultController.get(); } - public Unitc create(Team team){ - Unitc unit = constructor.get(); + public Unit create(Team team){ + Unit unit = constructor.get(); unit.team(team); unit.type(this); unit.ammo(ammoCapacity); //fill up on ammo upon creation @@ -97,11 +97,11 @@ public class UnitType extends UnlockableContent{ return weapons.size > 0; } - public void update(Unitc unit){} + public void update(Unit unit){} - public void landed(Unitc unit){} + public void landed(Unit unit){} - public void display(Unitc unit, Table table){ + public void display(Unit unit, Table table){ table.table(t -> { t.left(); t.add(new Image(icon(Cicon.medium))).size(8 * 4); @@ -116,7 +116,7 @@ public class UnitType extends UnlockableContent{ bars.row(); if(state.rules.unitAmmo){ - bars.add(new Bar("blocks.ammo", Pal.ammo, () -> (float)unit.ammo() / ammoCapacity)); + bars.add(new Bar("blocks.ammo", Pal.ammo, () -> (float)unit.ammo / ammoCapacity)); bars.row(); } }).growX(); @@ -169,9 +169,9 @@ public class UnitType extends UnlockableContent{ //region drawing - public void draw(Unitc unit){ + public void draw(Unit unit){ Mechc legs = unit instanceof Mechc ? (Mechc)unit : null; - float z = unit.elevation() > 0.5f ? (lowAltitude ? Layer.flyingUnitLow : Layer.flyingUnit) : Layer.groundUnit; + float z = unit.elevation > 0.5f ? (lowAltitude ? Layer.flyingUnitLow : Layer.flyingUnit) : Layer.groundUnit; if(unit.controller().isBeingControlled(player.unit())){ drawControl(unit); @@ -185,21 +185,21 @@ public class UnitType extends UnlockableContent{ Draw.z(z - 0.02f); if(legs != null){ - drawMech(legs); + drawMech((Unit & Mechc)legs); float ft = Mathf.sin(legs.walkTime(), 3f, 3f); - legOffset.trns(legs.baseRotation(), 0f, Mathf.lerp(ft * 0.18f * sway, 0f, unit.elevation())); + legOffset.trns(legs.baseRotation(), 0f, Mathf.lerp(ft * 0.18f * sway, 0f, unit.elevation)); unit.trns(legOffset.x, legOffset.y); } if(unit instanceof Legsc){ - drawLegs((Legsc)unit); + drawLegs((Unit & Legsc)unit); } Draw.z(Math.min(z - 0.01f, Layer.bullet - 1f)); if(unit instanceof Payloadc){ - drawPayload((Payloadc)unit); + drawPayload((Unit & Payloadc)unit); } drawOcclusion(unit); @@ -212,7 +212,7 @@ public class UnitType extends UnlockableContent{ if(drawItems) drawItems(unit); drawLight(unit); - if(unit.shieldAlpha() > 0){ + if(unit.shieldAlpha > 0){ drawShield(unit); } @@ -221,36 +221,36 @@ public class UnitType extends UnlockableContent{ } } - public void drawPayload(Payloadc unit){ + public void drawPayload(T unit){ if(unit.hasPayload()){ Payload pay = unit.payloads().first(); - pay.set(unit.x(), unit.y(), unit.rotation()); + pay.set(unit.x, unit.y, unit.rotation); pay.draw(); } } - public void drawShield(Unitc unit){ + public void drawShield(Unit unit){ float alpha = unit.shieldAlpha(); float radius = unit.hitSize() * 1.3f; - Fill.light(unit.x(), unit.y(), Lines.circleVertices(radius), radius, Tmp.c1.set(Pal.shieldIn), Tmp.c2.set(Pal.shield).lerp(Color.white, Mathf.clamp(unit.hitTime() / 2f)).a(Pal.shield.a * alpha)); + Fill.light(unit.x, unit.y, Lines.circleVertices(radius), radius, Tmp.c1.set(Pal.shieldIn), Tmp.c2.set(Pal.shield).lerp(Color.white, Mathf.clamp(unit.hitTime() / 2f)).a(Pal.shield.a * alpha)); } - public void drawControl(Unitc unit){ + public void drawControl(Unit unit){ Draw.z(Layer.groundUnit - 2); Draw.color(Pal.accent, Color.white, Mathf.absin(4f, 0.3f)); - Lines.poly(unit.x(), unit.y(), 4, unit.hitSize() + 1.5f); + Lines.poly(unit.x, unit.y, 4, unit.hitSize + 1.5f); Draw.reset(); } - public void drawShadow(Unitc unit){ + public void drawShadow(Unit unit){ Draw.color(shadowColor); - Draw.rect(shadowRegion, unit.x() + shadowTX * unit.elevation(), unit.y() + shadowTY * unit.elevation(), unit.rotation() - 90); + Draw.rect(shadowRegion, unit.x + shadowTX * unit.elevation, unit.y + shadowTY * unit.elevation, unit.rotation - 90); Draw.color(); } - public void drawOcclusion(Unitc unit){ + public void drawOcclusion(Unit unit){ Draw.color(0, 0, 0, 0.4f); float rad = 1.6f; float size = Math.max(region.getWidth(), region.getHeight()) * Draw.scl; @@ -258,32 +258,32 @@ public class UnitType extends UnlockableContent{ Draw.color(); } - public void drawItems(Unitc unit){ + public void drawItems(Unit unit){ applyColor(unit); //draw back items - if(unit.hasItem() && unit.itemTime() > 0.01f){ - float size = (itemSize + Mathf.absin(Time.time(), 5f, 1f)) * unit.itemTime(); + if(unit.hasItem() && unit.itemTime > 0.01f){ + float size = (itemSize + Mathf.absin(Time.time(), 5f, 1f)) * unit.itemTime; Draw.mixcol(Pal.accent, Mathf.absin(Time.time(), 5f, 0.5f)); Draw.rect(unit.item().icon(Cicon.medium), - unit.x() + Angles.trnsx(unit.rotation() + 180f, itemOffsetY), - unit.y() + Angles.trnsy(unit.rotation() + 180f, itemOffsetY), - size, size, unit.rotation()); + unit.x + Angles.trnsx(unit.rotation + 180f, itemOffsetY), + unit.y + Angles.trnsy(unit.rotation + 180f, itemOffsetY), + size, size, unit.rotation); Draw.mixcol(); Lines.stroke(1f, Pal.accent); Lines.circle( - unit.x() + Angles.trnsx(unit.rotation() + 180f, itemOffsetY), - unit.y() + Angles.trnsy(unit.rotation() + 180f, itemOffsetY), - (3f + Mathf.absin(Time.time(), 5f, 1f)) * unit.itemTime()); + unit.x + Angles.trnsx(unit.rotation + 180f, itemOffsetY), + unit.y + Angles.trnsy(unit.rotation + 180f, itemOffsetY), + (3f + Mathf.absin(Time.time(), 5f, 1f)) * unit.itemTime); if(unit.isLocal()){ Fonts.outline.draw(unit.stack().amount + "", - unit.x() + Angles.trnsx(unit.rotation() + 180f, itemOffsetY), - unit.y() + Angles.trnsy(unit.rotation() + 180f, itemOffsetY) - 3, - Pal.accent, 0.25f * unit.itemTime() / Scl.scl(1f), false, Align.center + unit.x + Angles.trnsx(unit.rotation + 180f, itemOffsetY), + unit.y + Angles.trnsy(unit.rotation + 180f, itemOffsetY) - 3, + Pal.accent, 0.25f * unit.itemTime / Scl.scl(1f), false, Align.center ); } @@ -291,33 +291,33 @@ public class UnitType extends UnlockableContent{ } } - public void drawEngine(Unitc unit){ + public void drawEngine(Unit unit){ if(!unit.isFlying()) return; - float scale = unit.elevation(); + float scale = unit.elevation; float offset = engineOffset/2f + engineOffset/2f*scale; if(unit instanceof Trailc){ Trail trail = ((Trailc)unit).trail(); - trail.draw(unit.team().color, (engineSize + Mathf.absin(Time.time(), 2f, engineSize / 4f) * scale)); + trail.draw(unit.team.color, (engineSize + Mathf.absin(Time.time(), 2f, engineSize / 4f) * scale)); } - Draw.color(unit.team().color); + Draw.color(unit.team.color); Fill.circle( - unit.x() + Angles.trnsx(unit.rotation() + 180, offset), - unit.y() + Angles.trnsy(unit.rotation() + 180, offset), + unit.x + Angles.trnsx(unit.rotation + 180, offset), + unit.y + Angles.trnsy(unit.rotation + 180, offset), (engineSize + Mathf.absin(Time.time(), 2f, engineSize / 4f)) * scale ); Draw.color(Color.white); Fill.circle( - unit.x() + Angles.trnsx(unit.rotation() + 180, offset - 1f), - unit.y() + Angles.trnsy(unit.rotation() + 180, offset - 1f), + unit.x + Angles.trnsx(unit.rotation + 180, offset - 1f), + unit.y + Angles.trnsy(unit.rotation + 180, offset - 1f), (engineSize + Mathf.absin(Time.time(), 2f, engineSize / 4f)) / 2f * scale ); Draw.color(); } - public void drawWeapons(Unitc unit){ + public void drawWeapons(Unit unit){ applyColor(unit); for(WeaponMount mount : unit.mounts()){ @@ -326,7 +326,7 @@ public class UnitType extends UnlockableContent{ for(int i : (weapon.mirror ? Mathf.signs : Mathf.one)){ i *= Mathf.sign(weapon.flipped); - float rotation = unit.rotation() - 90; + float rotation = unit.rotation - 90; float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0); float width = i > 0 ? -weapon.region.getWidth() : weapon.region.getWidth(); float recoil = -(mount.reload / weapon.reload * weapon.recoil) * (weapon.alternate ? Mathf.num(i == Mathf.sign(mount.side)) : 1); @@ -334,8 +334,8 @@ public class UnitType extends UnlockableContent{ if(weapon.mirror) rotation = weaponRotation; Draw.rect(weapon.region, - unit.x() + Angles.trnsx(rotation, weapon.x * i, weapon.y) + Angles.trnsx(weaponRotation, 0, recoil), - unit.y() + Angles.trnsy(rotation, weapon.x * i, weapon.y) + Angles.trnsy(weaponRotation, 0, recoil), + unit.x + Angles.trnsx(rotation, weapon.x * i, weapon.y) + Angles.trnsx(weaponRotation, 0, recoil), + unit.y + Angles.trnsy(rotation, weapon.x * i, weapon.y) + Angles.trnsy(weaponRotation, 0, recoil), width * Draw.scl * -Mathf.sign(weapon.flipSprite), weapon.region.getHeight() * Draw.scl, weaponRotation); @@ -345,33 +345,33 @@ public class UnitType extends UnlockableContent{ Draw.reset(); } - public void drawBody(Unitc unit){ + public void drawBody(Unit unit){ applyColor(unit); - Draw.rect(region, unit, unit.rotation() - 90); + Draw.rect(region, unit, unit.rotation - 90); Draw.reset(); } - public void drawCell(Unitc unit){ + public void drawCell(Unit unit){ applyColor(unit); Draw.color(cellColor(unit)); - Draw.rect(cellRegion, unit, unit.rotation() - 90); + Draw.rect(cellRegion, unit, unit.rotation - 90); Draw.reset(); } - public Color cellColor(Unitc unit){ - return Tmp.c1.set(Color.black).lerp(unit.team().color, unit.healthf() + Mathf.absin(Time.time(), Math.max(unit.healthf() * 5f, 1f), 1f - unit.healthf())); + public Color cellColor(Unit unit){ + return Tmp.c1.set(Color.black).lerp(unit.team.color, unit.healthf() + Mathf.absin(Time.time(), Math.max(unit.healthf() * 5f, 1f), 1f - unit.healthf())); } - public void drawLight(Unitc unit){ + public void drawLight(Unit unit){ if(lightRadius > 0){ - Drawf.light(unit.team(), unit, lightRadius, lightColor, lightOpacity); + Drawf.light(unit.team, unit, lightRadius, lightColor, lightOpacity); } } - public void drawLegs(Legsc unit){ + public void drawLegs(T unit){ //Draw.z(Layer.groundUnit - 0.02f); Leg[] legs = unit.legs(); @@ -385,7 +385,7 @@ public class UnitType extends UnlockableContent{ //TODO should be below/above legs if(baseRegion.found()){ - Draw.rect(baseRegion, unit.x(), unit.y(), rotation); + Draw.rect(baseRegion, unit.x, unit.y, rotation); } //TODO figure out layering @@ -427,14 +427,14 @@ public class UnitType extends UnlockableContent{ Draw.reset(); } - public void drawMech(Mechc unit){ + public void drawMech(T unit){ Draw.reset(); - Draw.mixcol(Color.white, unit.hitTime()); + Draw.mixcol(Color.white, unit.hitTime); - float e = unit.elevation(); + float e = unit.elevation; float sin = Mathf.lerp(Mathf.sin(unit.walkTime(), 3f, 1f), 0f, e); - float ft = sin*(2.5f + (unit.hitSize()-8f)/2f); + float ft = sin*(2.5f + (unit.hitSize-8f)/2f); float boostTrns = e * 2f; Floor floor = unit.isFlying() ? Blocks.air.asFloor() : unit.floorOn(); @@ -445,8 +445,8 @@ public class UnitType extends UnlockableContent{ for(int i : Mathf.signs){ Draw.rect(legRegion, - unit.x() + Angles.trnsx(unit.baseRotation(), ft * i - boostTrns, -boostTrns*i), - unit.y() + Angles.trnsy(unit.baseRotation(), ft * i - boostTrns, -boostTrns*i), + unit.x + Angles.trnsx(unit.baseRotation(), ft * i - boostTrns, -boostTrns*i), + unit.y + Angles.trnsy(unit.baseRotation(), ft * i - boostTrns, -boostTrns*i), legRegion.getWidth() * i * Draw.scl, legRegion.getHeight() * Draw.scl - Math.max(-sin * i, 0) * legRegion.getHeight() * 0.5f * Draw.scl, unit.baseRotation() - 90 + 35f*i*e); @@ -463,10 +463,10 @@ public class UnitType extends UnlockableContent{ Draw.mixcol(); } - public void applyColor(Unitc unit){ - Draw.mixcol(Color.white, unit.hitTime()); - if(unit.drownTime() > 0 && unit.floorOn().isDeep()){ - Draw.mixcol(unit.floorOn().mapColor, unit.drownTime() * 0.8f); + public void applyColor(Unit unit){ + Draw.mixcol(Color.white, unit.hitTime); + if(unit.drownTime > 0 && unit.floorOn().isDeep()){ + Draw.mixcol(unit.floorOn().mapColor, unit.drownTime * 0.8f); } } diff --git a/core/src/mindustry/type/Weather.java b/core/src/mindustry/type/Weather.java index 3910b22017..6111dbed92 100644 --- a/core/src/mindustry/type/Weather.java +++ b/core/src/mindustry/type/Weather.java @@ -17,9 +17,9 @@ public abstract class Weather extends MappableContent{ //internals public Rand rand = new Rand(); - public Prov type = WeatherEntity::create; + public Prov type = WeatherState::create; - public Weather(String name, Prov type){ + public Weather(String name, Prov type){ super(name); this.type = type; } @@ -28,16 +28,16 @@ public abstract class Weather extends MappableContent{ super(name); } - public Weatherc create(){ + public WeatherState create(){ return create(1f); } - public Weatherc create(float intensity){ + public WeatherState create(float intensity){ return create(intensity, duration); } - public Weatherc create(float intensity, float duration){ - Weatherc entity = type.get(); + public WeatherState create(float intensity, float duration){ + WeatherState entity = type.get(); entity.intensity(intensity); entity.init(this); entity.life(duration); @@ -54,15 +54,15 @@ public abstract class Weather extends MappableContent{ if(e != null) e.remove(); } - public void update(Weatherc state){ + public void update(WeatherState state){ } - public void drawOver(Weatherc state){ + public void drawOver(WeatherState state){ } - public void drawUnder(Weatherc state){ + public void drawUnder(WeatherState state){ } @@ -107,9 +107,9 @@ public abstract class Weather extends MappableContent{ } } - @EntityDef(value = {Weatherc.class}, pooled = true, isFinal = false) - @Component - abstract static class WeatherComp implements Drawc{ + @EntityDef(value = {WeatherStatec.class}, pooled = true, isFinal = false) + @Component(base = true) + abstract static class WeatherStateComp implements Drawc{ private static final float fadeTime = 60 * 4; Weather weather; @@ -129,7 +129,7 @@ public abstract class Weather extends MappableContent{ life -= Time.delta(); - weather.update((Weatherc)this); + weather.update(base()); if(life < 0){ remove(); @@ -142,14 +142,14 @@ public abstract class Weather extends MappableContent{ Draw.draw(Layer.weather, () -> { weather.rand.setSeed(0); Draw.alpha(renderer.weatherAlpha() * opacity); - weather.drawOver((Weatherc)this); + weather.drawOver(base()); Draw.reset(); }); Draw.draw(Layer.debris, () -> { weather.rand.setSeed(0); Draw.alpha(renderer.weatherAlpha() * opacity); - weather.drawUnder((Weatherc)this); + weather.drawUnder(base()); Draw.reset(); }); } diff --git a/core/src/mindustry/ui/dialogs/SchematicsDialog.java b/core/src/mindustry/ui/dialogs/SchematicsDialog.java index 49114836b4..04e0522f2e 100644 --- a/core/src/mindustry/ui/dialogs/SchematicsDialog.java +++ b/core/src/mindustry/ui/dialogs/SchematicsDialog.java @@ -338,7 +338,7 @@ public class SchematicsDialog extends BaseDialog{ for(ItemStack s : arr){ r.image(s.item.icon(Cicon.small)).left(); r.label(() -> { - Tilec core = player.core(); + Building core = player.core(); if(core == null || state.rules.infiniteResources || core.items().has(s.item, s.amount)) return "[lightgray]" + s.amount + ""; return (core.items().has(s.item, s.amount) ? "[lightgray]" : "[scarlet]") + Math.min(core.items().get(s.item), s.amount) + "[lightgray]/" + s.amount; }).padLeft(2).left().padRight(4); diff --git a/core/src/mindustry/ui/dialogs/TraceDialog.java b/core/src/mindustry/ui/dialogs/TraceDialog.java index 05f9ea5f0a..d01d5376d3 100644 --- a/core/src/mindustry/ui/dialogs/TraceDialog.java +++ b/core/src/mindustry/ui/dialogs/TraceDialog.java @@ -14,7 +14,7 @@ public class TraceDialog extends BaseDialog{ setFillParent(false); } - public void show(Playerc player, TraceInfo info){ + public void show(Player player, TraceInfo info){ cont.clear(); Table table = new Table(Tex.clear); diff --git a/core/src/mindustry/ui/fragments/BlockConfigFragment.java b/core/src/mindustry/ui/fragments/BlockConfigFragment.java index 2d1270e036..b111a9c551 100644 --- a/core/src/mindustry/ui/fragments/BlockConfigFragment.java +++ b/core/src/mindustry/ui/fragments/BlockConfigFragment.java @@ -13,7 +13,7 @@ import static mindustry.Vars.*; public class BlockConfigFragment extends Fragment{ private Table table = new Table(); - private Tilec configTile; + private Building configTile; @Override public void build(Group parent){ @@ -38,11 +38,11 @@ public class BlockConfigFragment extends Fragment{ return table.isVisible() && configTile != null; } - public Tilec getSelectedTile(){ + public Building getSelectedTile(){ return configTile; } - public void showConfig(Tilec tile){ + public void showConfig(Building tile){ if(tile.configTapped()){ configTile = tile; diff --git a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java index c1b3c59d5e..2f4c2c4862 100644 --- a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java @@ -32,7 +32,7 @@ public class BlockInventoryFragment extends Fragment{ private final static float holdShrink = 120f; private Table table = new Table(); - private Tilec tile; + private Building tile; private float holdTime = 0f, emptyTime; private boolean holding; private float[] shrinkHoldTimes = new float[content.items().size]; @@ -43,7 +43,7 @@ public class BlockInventoryFragment extends Fragment{ } @Remote(called = Loc.server, targets = Loc.both, forward = true) - public static void requestItem(Playerc player, Tilec tile, Item item, int amount){ + public static void requestItem(Player player, Building tile, Item item, int amount){ if(player == null || tile == null || !tile.interactable(player.team())) return; amount = Mathf.clamp(amount, 0, player.unit().itemCapacity()); int fa = amount; @@ -71,13 +71,13 @@ public class BlockInventoryFragment extends Fragment{ parent.addChild(table); } - public void showFor(Tilec t){ + public void showFor(Building t){ if(this.tile == t){ hide(); return; } this.tile = t; - if(tile == null || !tile.block().isAccessible() || tile.items().total() == 0) + if(tile == null || !tile.block().isAccessible() || tile.items.total() == 0) return; rebuild(true); } @@ -109,7 +109,7 @@ public class BlockInventoryFragment extends Fragment{ if(state.isMenu() || tile == null || !tile.isValid() || !tile.block().isAccessible() || emptyTime >= holdShrink){ hide(); }else{ - if(tile.items().total() == 0){ + if(tile.items.total() == 0){ emptyTime += Time.delta(); }else{ emptyTime = 0f; @@ -119,7 +119,7 @@ public class BlockInventoryFragment extends Fragment{ holdTime += Time.delta(); if(holdTime >= holdWithdraw){ - int amount = Math.min(tile.items().get(lastItem), player.unit().maxAccepted(lastItem)); + int amount = Math.min(tile.items.get(lastItem), player.unit().maxAccepted(lastItem)); Call.requestItem(player, tile, lastItem, amount); holding = false; holdTime = 0f; @@ -134,7 +134,7 @@ public class BlockInventoryFragment extends Fragment{ if(shrinkHoldTimes.length != content.items().size) shrinkHoldTimes = new float[content.items().size]; for(int i = 0; i < content.items().size; i++){ - boolean has = tile.items().has(content.item(i)); + boolean has = tile.items.has(content.item(i)); boolean had = container.contains(i); if(has){ shrinkHoldTimes[i] = 0f; @@ -159,7 +159,7 @@ public class BlockInventoryFragment extends Fragment{ for(int i = 0; i < content.items().size; i++){ Item item = content.item(i); - if(!tile.items().has(item)) continue; + if(!tile.items.has(item)) continue; container.add(i); @@ -172,14 +172,14 @@ public class BlockInventoryFragment extends Fragment{ if(tile == null || !tile.isValid()){ return ""; } - return round(tile.items().get(item)); + return round(tile.items.get(item)); }); image.addListener(l); image.addListener(new InputListener(){ @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){ - if(!canPick.get() || tile == null || !tile.isValid() || tile.items() == null || !tile.items().has(item)) return false; + if(!canPick.get() || tile == null || !tile.isValid() || tile.items == null || !tile.items.has(item)) return false; int amount = Math.min(1, player.unit().maxAccepted(item)); if(amount > 0){ Call.requestItem(player, tile, item, amount); diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 8d818950a0..2c6877e7fb 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -373,7 +373,7 @@ public class HudFragment extends Fragment{ } @Remote(targets = Loc.both, forward = true, called = Loc.both) - public static void setPlayerTeamEditor(Playerc player, Team team){ + public static void setPlayerTeamEditor(Player player, Team team){ if(state.isEditor() && player != null){ player.team(team); } diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index 3ead933791..e147332d81 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -90,7 +90,7 @@ public class PlacementFragment extends Fragment{ scrollPositions.put(currentCategory, blockPane.getScrollY()); if(Core.input.keyDown(Binding.pick) && player.isBuilder()){ //mouse eyedropper select - Tilec tile = world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y); + Building tile = world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y); Block tryRecipe = tile == null ? null : tile.block(); Object tryConfig = tile == null ? null : tile.config(); @@ -224,7 +224,7 @@ public class PlacementFragment extends Fragment{ button.resizeImage(Cicon.medium.size); button.update(() -> { //color unplacable things gray - Tilec core = player.core(); + Building core = player.core(); Color color = (state.rules.infiniteResources || (core != null && (core.items().has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources))) && player.isBuilder() ? Color.white : Color.gray; button.forEach(elem -> elem.setColor(color)); button.setChecked(control.input.block == block); @@ -317,7 +317,7 @@ public class PlacementFragment extends Fragment{ line.image(stack.item.icon(Cicon.small)).size(8 * 2); line.add(stack.item.localizedName).maxWidth(140f).fillX().color(Color.lightGray).padLeft(2).left().get().setEllipsis(true); line.labelWrap(() -> { - Tilec core = player.core(); + Building core = player.core(); if(core == null || state.rules.infiniteResources) return "*/*"; int amount = core.items().get(stack.item); @@ -442,7 +442,7 @@ public class PlacementFragment extends Fragment{ if(Core.scene.hasMouse() || topTable.hit(v.x, v.y, false) != null) return null; //check for a unit - Unitc unit = Units.closestOverlap(player.team(), Core.input.mouseWorldX(), Core.input.mouseWorldY(), 5f, u -> !u.isLocal()); + Unit unit = Units.closestOverlap(player.team(), Core.input.mouseWorldX(), Core.input.mouseWorldY(), 5f, u -> !u.isLocal()); //if cursor has a unit, display it if(unit != null) return unit; diff --git a/core/src/mindustry/ui/fragments/PlayerListFragment.java b/core/src/mindustry/ui/fragments/PlayerListFragment.java index 66482d3fde..fca3153bf4 100644 --- a/core/src/mindustry/ui/fragments/PlayerListFragment.java +++ b/core/src/mindustry/ui/fragments/PlayerListFragment.java @@ -74,7 +74,7 @@ public class PlayerListFragment extends Fragment{ float h = 74f; found = false; - Groups.player.sort(Structs.comparing(Playerc::team)); + Groups.player.sort(Structs.comparing(Player::team)); Groups.player.each(user -> { found = true; NetConnection connection = user.con(); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 38aeee0d0a..5aa3ec62a3 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -172,7 +172,7 @@ public class Block extends UnlockableContent{ /** Whether this block has instant transfer.*/ public boolean instantTransfer = false; - protected Prov entityType = null; //initialized later + protected Prov entityType = null; //initialized later public ObjectMap, Cons2> configurations = new ObjectMap<>(); protected TextureRegion[] generatedIcons; @@ -184,7 +184,7 @@ public class Block extends UnlockableContent{ public static TextureRegion[][] cracks; protected static final Seq tempTiles = new Seq<>(); - protected static final Seq tempTileEnts = new Seq<>(); + protected static final Seq tempTileEnts = new Seq<>(); /** Dump timer ID.*/ protected final int timerDump = timers++; @@ -307,15 +307,15 @@ public class Block extends UnlockableContent{ bars.add("health", entity -> new Bar("blocks.health", Pal.health, entity::healthf).blink(Color.white)); if(hasLiquids){ - Func current; + Func current; if(consumes.has(ConsumeType.liquid) && consumes.get(ConsumeType.liquid) instanceof ConsumeLiquid){ Liquid liquid = consumes.get(ConsumeType.liquid).liquid; current = entity -> liquid; }else{ - current = entity -> entity.liquids().current(); + current = entity -> entity.liquids.current(); } - bars.add("liquid", entity -> new Bar(() -> entity.liquids().get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName, - () -> current.get(entity).barColor(), () -> entity.liquids().get(current.get(entity)) / liquidCapacity)); + bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName, + () -> current.get(entity).barColor(), () -> entity.liquids.get(current.get(entity)) / liquidCapacity)); } if(hasPower && consumes.hasPower()){ @@ -323,12 +323,12 @@ public class Block extends UnlockableContent{ boolean buffered = cons.buffered; float capacity = cons.capacity; - bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power().status * capacity) ? "" : (int)(entity.power().status * capacity)) : - Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.power().graph.getPowerProduced() + entity.power().graph.getBatteryStored() > 0f ? 1f : entity.power().status)); + bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power.status * capacity) ? "" : (int)(entity.power.status * capacity)) : + Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.power.graph.getPowerProduced() + entity.power.graph.getBatteryStored() > 0f ? 1f : entity.power.status)); } if(hasItems && configurable){ - bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items().total()), () -> Pal.items, () -> (float)entity.items().total() / itemCapacity)); + bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items.total()), () -> Pal.items, () -> (float)entity.items.total() / itemCapacity)); } } @@ -383,12 +383,12 @@ public class Block extends UnlockableContent{ } /** Configure when a null value is passed.*/ - public void configClear(Cons cons){ + public void configClear(Cons cons){ configurations.put(void.class, (tile, value) -> cons.get((E)tile)); } /** Listen for a config by class type. */ - public void config(Class type, Cons2 config){ + public void config(Class type, Cons2 config){ configurations.put(type, config); } @@ -454,7 +454,7 @@ public class Block extends UnlockableContent{ return destructible || update; } - public final Tilec newEntity(){ + public final Building newEntity(){ return entityType.get(); } @@ -536,11 +536,11 @@ public class Block extends UnlockableContent{ } while(entityType == null && Block.class.isAssignableFrom(current)){ - //first class that is subclass of Tilec - Class type = Structs.find(current.getDeclaredClasses(), t -> Tilec.class.isAssignableFrom(t) && !t.isInterface()); + //first class that is subclass of Building + Class type = Structs.find(current.getDeclaredClasses(), t -> Building.class.isAssignableFrom(t) && !t.isInterface()); if(type != null){ //these are inner classes, so they have an implicit parameter generated - Constructor cons = (Constructor)type.getDeclaredConstructor(type.getDeclaringClass()); + Constructor cons = (Constructor)type.getDeclaredConstructor(type.getDeclaringClass()); entityType = () -> { try{ return cons.newInstance(this); @@ -559,7 +559,7 @@ public class Block extends UnlockableContent{ if(entityType == null){ //assign default value - entityType = TileEntity::create; + entityType = Building::create; } } diff --git a/core/src/mindustry/world/Build.java b/core/src/mindustry/world/Build.java index bc6c214fa8..0c9e92707b 100644 --- a/core/src/mindustry/world/Build.java +++ b/core/src/mindustry/world/Build.java @@ -21,7 +21,7 @@ public class Build{ return; } - Tile tile = world.tilec(x, y); + Tile tile = world.Building(x, y); //this should never happen, but it doesn't hurt to check for links float prevPercent = 1f; diff --git a/core/src/mindustry/world/CachedTile.java b/core/src/mindustry/world/CachedTile.java index 9f291bcb14..7fab1ad5bd 100644 --- a/core/src/mindustry/world/CachedTile.java +++ b/core/src/mindustry/world/CachedTile.java @@ -21,13 +21,13 @@ public class CachedTile extends Tile{ } @Override - protected void changeEntity(Team team, Prov entityprov){ + protected void changeEntity(Team team, Prov entityprov){ entity = null; Block block = block(); if(block.hasEntity()){ - Tilec n = entityprov.get(); + Building n = entityprov.get(); n.cons(new ConsumeModule(entity)); n.tile(this); n.block(block); diff --git a/core/src/mindustry/world/Edges.java b/core/src/mindustry/world/Edges.java index 5ed7dc3318..4b45ca3a32 100644 --- a/core/src/mindustry/world/Edges.java +++ b/core/src/mindustry/world/Edges.java @@ -50,7 +50,7 @@ public class Edges{ } } - public static Tile getFacingEdge(Tilec tile, Tilec other){ + public static Tile getFacingEdge(Building tile, Building other){ return getFacingEdge(tile.block(), tile.tileX(), tile.tileY(), other.tile()); } diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 975806bee7..fea2276823 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -19,12 +19,12 @@ import mindustry.world.blocks.environment.*; import static mindustry.Vars.*; public class Tile implements Position, QuadTreeObject, Displayable{ - static final ObjectSet tileSet = new ObjectSet<>(); + static final ObjectSet tileSet = new ObjectSet<>(); /** Tile traversal cost. */ public short cost = 1; /** Tile entity, usually null. */ - public @Nullable Tilec entity; + public @Nullable Building entity; public short x, y; protected @NonNull Block block; protected @NonNull Floor floor; @@ -106,7 +106,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ } @SuppressWarnings("unchecked") - public T ent(){ + public T ent(){ return (T)entity; } @@ -169,7 +169,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ setBlock(type, team, rotation, type::newEntity); } - public void setBlock(@NonNull Block type, Team team, int rotation, Prov entityprov){ + public void setBlock(@NonNull Block type, Team team, int rotation, Prov entityprov){ changing = true; this.block = type; @@ -185,7 +185,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ if(block.isMultiblock()){ int offsetx = -(block.size - 1) / 2; int offsety = -(block.size - 1) / 2; - Tilec entity = this.entity; + Building entity = this.entity; Block block = this.block; //two passes: first one clears, second one sets @@ -425,7 +425,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ return null; } - public Tilec getNearbyEntity(int rotation){ + public Building getNearbyEntity(int rotation){ if(rotation == 0) return world.ent(x + 1, y); if(rotation == 1) return world.ent(x, y + 1); if(rotation == 2) return world.ent(x - 1, y); @@ -434,19 +434,19 @@ public class Tile implements Position, QuadTreeObject, Displayable{ } // â–² â–² â–¼ â–¼ â—€ â–¶ â—€ â–¶ B A - public @Nullable Tilec front(){ + public @Nullable Building front(){ return getNearbyEntity((rotation + 4) % 4); } - public @Nullable Tilec right(){ + public @Nullable Building right(){ return getNearbyEntity((rotation + 3) % 4); } - public @Nullable Tilec back(){ + public @Nullable Building back(){ return getNearbyEntity((rotation + 2) % 4); } - public @Nullable Tilec left(){ + public @Nullable Building left(){ return getNearbyEntity((rotation + 1) % 4); } @@ -505,7 +505,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ //remove this tile's dangling entities if(entity.block().isMultiblock()){ int cx = entity.tileX(), cy = entity.tileY(); - int size = entity.block().size; + int size = entity.block.size; int offsetx = -(size - 1) / 2; int offsety = -(size - 1) / 2; for(int dx = 0; dx < size; dx++){ @@ -534,9 +534,9 @@ public class Tile implements Position, QuadTreeObject, Displayable{ } } - protected void changeEntity(Team team, Prov entityprov){ + protected void changeEntity(Team team, Prov entityprov){ if(entity != null){ - int size = entity.block().size; + int size = entity.block.size; entity.remove(); entity = null; @@ -544,14 +544,14 @@ public class Tile implements Position, QuadTreeObject, Displayable{ tileSet.clear(); for(Point2 edge : Edges.getEdges(size)){ - Tilec other = world.ent(x + edge.x, y + edge.y); + Building other = world.ent(x + edge.x, y + edge.y); if(other != null){ tileSet.add(other); } } //update proximity, since multiblock was just removed - for(Tilec t : tileSet){ + for(Building t : tileSet){ t.updateProximity(); } } @@ -568,7 +568,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ }else{ //since the entity won't update proximity for us, update proximity for all nearby tiles manually for(Point2 p : Geometry.d4){ - Tilec tile = world.ent(x + p.x, y + p.y); + Building tile = world.ent(x + p.x, y + p.y); if(tile != null && !tile.tile().changing){ tile.onProximityUpdate(); } @@ -633,7 +633,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ @Remote(called = Loc.server, unreliable = true) public static void onTileDamage(Tile tile, float health){ if(tile.entity != null){ - tile.entity.health(health); + tile.entity.health = health; if(tile.entity.damaged()){ indexer.notifyTileDamaged(tile.entity); diff --git a/core/src/mindustry/world/blocks/Autotiler.java b/core/src/mindustry/world/blocks/Autotiler.java index a1c7cd7e5c..73ddc75d3d 100644 --- a/core/src/mindustry/world/blocks/Autotiler.java +++ b/core/src/mindustry/world/blocks/Autotiler.java @@ -146,7 +146,7 @@ public interface Autotiler{ } default boolean blends(Tile tile, int rotation, int direction){ - Tilec other = tile.getNearbyEntity(Mathf.mod(rotation - direction, 4)); + Building other = tile.getNearbyEntity(Mathf.mod(rotation - direction, 4)); return other != null && other.team() == tile.team() && blends(tile, rotation, other.tileX(), other.tileY(), other.rotation(), other.block()); } diff --git a/core/src/mindustry/world/blocks/BuildBlock.java b/core/src/mindustry/world/blocks/BuildBlock.java index 6ff80cee2f..a1b5eadf33 100644 --- a/core/src/mindustry/world/blocks/BuildBlock.java +++ b/core/src/mindustry/world/blocks/BuildBlock.java @@ -108,7 +108,7 @@ public class BuildBlock extends Block{ return true; } - public class BuildEntity extends TileEntity{ + public class BuildEntity extends Building{ /** * The recipe of the block that is being constructed. * If there is no recipe for this block, as is the case with rocks, 'previous' is used. @@ -148,7 +148,7 @@ public class BuildBlock extends Block{ } @Override - public void tapped(Playerc player){ + public void tapped(Player player){ //if the target is constructible, begin constructing if(!headless && cblock != null){ if(control.input.buildWasAutoPaused && !control.input.isBuilding && player.isBuilder()){ @@ -190,7 +190,7 @@ public class BuildBlock extends Block{ }); } - public boolean construct(Unitc builder, @Nullable Tilec core, float amount, boolean configured){ + public boolean construct(Unitc builder, @Nullable Building core, float amount, boolean configured){ if(cblock == null){ kill(); return false; @@ -220,7 +220,7 @@ public class BuildBlock extends Block{ return false; } - public void deconstruct(Unitc builder, @Nullable Tilec core, float amount){ + public void deconstruct(Unitc builder, @Nullable Building core, float amount){ float deconstructMultiplier = state.rules.deconstructRefundMultiplier; if(cblock != null){ diff --git a/core/src/mindustry/world/blocks/ControlBlock.java b/core/src/mindustry/world/blocks/ControlBlock.java index acf4292337..6724ff9205 100644 --- a/core/src/mindustry/world/blocks/ControlBlock.java +++ b/core/src/mindustry/world/blocks/ControlBlock.java @@ -4,7 +4,7 @@ import mindustry.gen.*; /** Any block that has a proxy unit that can be controlled by a player. */ public interface ControlBlock{ - Unitc unit(); + Unit unit(); /** @return whether this block is being controlled by a player. */ default boolean isControlled(){ diff --git a/core/src/mindustry/world/blocks/campaign/LaunchPad.java b/core/src/mindustry/world/blocks/campaign/LaunchPad.java index 5b12cb0ab5..cb3bad20bf 100644 --- a/core/src/mindustry/world/blocks/campaign/LaunchPad.java +++ b/core/src/mindustry/world/blocks/campaign/LaunchPad.java @@ -46,10 +46,10 @@ public class LaunchPad extends Block{ public void setBars(){ super.setBars(); - bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items().total()), () -> Pal.items, () -> (float)entity.items().total() / itemCapacity)); + bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items.total()), () -> Pal.items, () -> (float)entity.items.total() / itemCapacity)); } - public class LaunchPadEntity extends TileEntity{ + public class LaunchPadEntity extends Building{ @Override public void draw(){ super.draw(); @@ -85,7 +85,7 @@ public class LaunchPad extends Block{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return items.total() < itemCapacity; } @@ -95,7 +95,7 @@ public class LaunchPad extends Block{ //launch when full and base conditions are met if(items.total() >= itemCapacity && efficiency() >= 1f && timer(timerLaunch, launchTime / timeScale)){ - LaunchPayloadc entity = LaunchPayloadEntity.create(); + LaunchPayload entity = LaunchPayload.create(); items.each((item, amount) -> entity.stacks().add(new ItemStack(item, amount))); entity.set(this); entity.lifetime(120f); @@ -109,7 +109,7 @@ public class LaunchPad extends Block{ } @EntityDef(LaunchPayloadc.class) - @Component + @Component(base = true) static abstract class LaunchPayloadComp implements Drawc, Timedc, Teamc{ @Import float x,y; diff --git a/core/src/mindustry/world/blocks/campaign/ResearchBlock.java b/core/src/mindustry/world/blocks/campaign/ResearchBlock.java index 4ae6a39f00..2ca9d7aee5 100644 --- a/core/src/mindustry/world/blocks/campaign/ResearchBlock.java +++ b/core/src/mindustry/world/blocks/campaign/ResearchBlock.java @@ -52,7 +52,7 @@ public class ResearchBlock extends Block{ bars.add("progress", (ResearchBlockEntity e) -> new Bar("bar.progress", Pal.ammo, () -> e.researching == null ? 0f : e.researching.progress / e.researching.time)); } - public class ResearchBlockEntity extends TileEntity{ + public class ResearchBlockEntity extends Building{ public @Nullable TechNode researching; public double[] accumulator; @@ -162,7 +162,7 @@ public class ResearchBlock extends Block{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return items.get(item) < getMaximumAccepted(item); } diff --git a/core/src/mindustry/world/blocks/defense/DeflectorWall.java b/core/src/mindustry/world/blocks/defense/DeflectorWall.java index 1072cef4f1..ae2d9e8834 100644 --- a/core/src/mindustry/world/blocks/defense/DeflectorWall.java +++ b/core/src/mindustry/world/blocks/defense/DeflectorWall.java @@ -20,7 +20,7 @@ public class DeflectorWall extends Wall{ super(name); } - public class DeflectorEntity extends TileEntity{ + public class DeflectorEntity extends Building{ public float hit; @Override @@ -40,7 +40,7 @@ public class DeflectorWall extends Wall{ } @Override - public boolean collision(Bulletc bullet){ + public boolean collision(Bullet bullet){ super.collision(bullet); //doesn't reflect powerful bullets diff --git a/core/src/mindustry/world/blocks/defense/Door.java b/core/src/mindustry/world/blocks/defense/Door.java index 50624123e1..705cd1c9aa 100644 --- a/core/src/mindustry/world/blocks/defense/Door.java +++ b/core/src/mindustry/world/blocks/defense/Door.java @@ -41,7 +41,7 @@ public class Door extends Wall{ return req.config == Boolean.TRUE ? openRegion : region; } - public class DoorEntity extends TileEntity{ + public class DoorEntity extends Building{ public boolean open = false; @Override @@ -60,7 +60,7 @@ public class Door extends Wall{ } @Override - public void tapped(Playerc player){ + public void tapped(Player player){ if((Units.anyEntities(tile) && open) || !timer(timerToggle, 30f)){ return; } diff --git a/core/src/mindustry/world/blocks/defense/ForceProjector.java b/core/src/mindustry/world/blocks/defense/ForceProjector.java index 544f3d58c4..86485c0f2e 100644 --- a/core/src/mindustry/world/blocks/defense/ForceProjector.java +++ b/core/src/mindustry/world/blocks/defense/ForceProjector.java @@ -78,7 +78,7 @@ public class ForceProjector extends Block{ Draw.color(); } - public class ForceProjectorEntity extends TileEntity{ + public class ForceProjectorEntity extends Building{ boolean broken = true; float buildup = 0f; float radscl = 0f; diff --git a/core/src/mindustry/world/blocks/defense/MendProjector.java b/core/src/mindustry/world/blocks/defense/MendProjector.java index cd8d979a56..4e1e37007d 100644 --- a/core/src/mindustry/world/blocks/defense/MendProjector.java +++ b/core/src/mindustry/world/blocks/defense/MendProjector.java @@ -55,7 +55,7 @@ public class MendProjector extends Block{ Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent); } - public class MendEntity extends TileEntity{ + public class MendEntity extends Building{ float heat; float charge = Mathf.random(reload); float phaseHeat; diff --git a/core/src/mindustry/world/blocks/defense/OverdriveProjector.java b/core/src/mindustry/world/blocks/defense/OverdriveProjector.java index 239c6ecaac..f21bc14d08 100644 --- a/core/src/mindustry/world/blocks/defense/OverdriveProjector.java +++ b/core/src/mindustry/world/blocks/defense/OverdriveProjector.java @@ -60,7 +60,7 @@ public class OverdriveProjector extends Block{ } } - public class OverdriveEntity extends TileEntity{ + public class OverdriveEntity extends Building{ float heat; float charge = Mathf.random(reload); float phaseHeat; diff --git a/core/src/mindustry/world/blocks/defense/PointDefenseTurret.java b/core/src/mindustry/world/blocks/defense/PointDefenseTurret.java index cbb58d8420..42913d9a2f 100644 --- a/core/src/mindustry/world/blocks/defense/PointDefenseTurret.java +++ b/core/src/mindustry/world/blocks/defense/PointDefenseTurret.java @@ -51,9 +51,9 @@ public class PointDefenseTurret extends Block{ return new TextureRegion[]{baseRegion, region}; } - public class PointDefenseEntity extends TileEntity{ + public class PointDefenseEntity extends Building{ public float rotation = 90, reload; - public @Nullable Bulletc target; + public @Nullable Bullet target; @Override public void updateTile(){ diff --git a/core/src/mindustry/world/blocks/defense/ShockMine.java b/core/src/mindustry/world/blocks/defense/ShockMine.java index 9c2714925c..8421fb4257 100644 --- a/core/src/mindustry/world/blocks/defense/ShockMine.java +++ b/core/src/mindustry/world/blocks/defense/ShockMine.java @@ -25,7 +25,7 @@ public class ShockMine extends Block{ rebuildable = false; } - public class ShockMineEntity extends TileEntity{ + public class ShockMineEntity extends Building{ @Override public void drawTeam(){ @@ -42,7 +42,7 @@ public class ShockMine extends Block{ } @Override - public void unitOn(Unitc unit){ + public void unitOn(Unit unit){ if(unit.team() != team && timer(timerDamage, cooldown)){ for(int i = 0; i < tendrils; i++){ Lightning.create(team, Pal.lancerLaser, damage, x, y, Mathf.random(360f), length); diff --git a/core/src/mindustry/world/blocks/defense/SurgeWall.java b/core/src/mindustry/world/blocks/defense/SurgeWall.java index 21b4b6959c..ae6d9c69bc 100644 --- a/core/src/mindustry/world/blocks/defense/SurgeWall.java +++ b/core/src/mindustry/world/blocks/defense/SurgeWall.java @@ -14,9 +14,9 @@ public class SurgeWall extends Wall{ super(name); } - public class SurgeEntity extends TileEntity{ + public class SurgeEntity extends Building{ @Override - public boolean collision(Bulletc bullet){ + public boolean collision(Bullet bullet){ super.collision(bullet); if(Mathf.chance(lightningChance)){ Lightning.create(team(), Pal.surge, lightningDamage, x, y, bullet.rotation() + 180f, lightningLength); diff --git a/core/src/mindustry/world/blocks/defense/Wall.java b/core/src/mindustry/world/blocks/defense/Wall.java index 1b46442793..201d8b51e3 100644 --- a/core/src/mindustry/world/blocks/defense/Wall.java +++ b/core/src/mindustry/world/blocks/defense/Wall.java @@ -42,7 +42,7 @@ public class Wall extends Block{ return super.canReplace(other) && health > other.health; } - public class WallEntity extends TileEntity{ + public class WallEntity extends Building{ @Override public void draw(){ diff --git a/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java b/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java index 4ffdcb4904..a21e268621 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java @@ -40,7 +40,7 @@ public class ItemTurret extends Turret{ stats.add(BlockStat.ammo, new AmmoListValue<>(ammoTypes)); consumes.add(new ConsumeItemFilter(i -> ammoTypes.containsKey(i)){ @Override - public void build(Tilec tile, Table table){ + public void build(Building tile, Table table){ MultiReqImage image = new MultiReqImage(); content.items().each(i -> filter.get(i) && i.unlockedNow(), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium)), () -> tile != null && !((ItemTurretEntity)tile).ammo.isEmpty() && ((ItemEntry)((ItemTurretEntity)tile).ammo.peek()).item == item))); @@ -49,7 +49,7 @@ public class ItemTurret extends Turret{ } @Override - public boolean valid(Tilec entity){ + public boolean valid(Building entity){ //valid when there's any ammo in the turret return !((ItemTurretEntity)entity).ammo.isEmpty(); } @@ -103,7 +103,7 @@ public class ItemTurret extends Turret{ } @Override - public void handleItem(Tilec source, Item item){ + public void handleItem(Building source, Item item){ if(item == Items.pyratite){ Events.fire(Trigger.flameAmmo); @@ -134,7 +134,7 @@ public class ItemTurret extends Turret{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return ammoTypes.get(item) != null && totalAmmo + ammoTypes.get(item).ammoMultiplier <= maxAmmo; } diff --git a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java index 54278241a0..3f8ab62acb 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java @@ -41,7 +41,7 @@ public class LaserTurret extends PowerTurret{ } public class LaserTurretEntity extends PowerTurretEntity{ - Bulletc bullet; + Bullet bullet; float bulletLife; @Override diff --git a/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java index b65325ec65..8e495ebac1 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java @@ -37,8 +37,8 @@ public class LiquidTurret extends Turret{ stats.add(BlockStat.ammo, new AmmoListValue<>(ammoTypes)); consumes.add(new ConsumeLiquidFilter(i -> ammoTypes.containsKey(i), 1f){ @Override - public boolean valid(Tilec entity){ - return entity.liquids().total() > 0.001f; + public boolean valid(Building entity){ + return entity.liquids.total() > 0.001f; } @Override @@ -118,12 +118,12 @@ public class LiquidTurret extends Turret{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return false; } @Override - public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){ + public boolean acceptLiquid(Building source, Liquid liquid, float amount){ return ammoTypes.get(liquid) != null && (liquids.current() == liquid || (ammoTypes.containsKey(liquids.current()) && liquids.get(liquids.current()) <= ammoTypes.get(liquids.current()).ammoMultiplier + 0.001f)); diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 1376ea9f5a..e5a30fd036 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -138,7 +138,7 @@ public abstract class Turret extends Block{ public abstract BulletType type(); } - public class TurretEntity extends TileEntity implements ControlBlock{ + public class TurretEntity extends Building implements ControlBlock{ public Seq ammo = new Seq<>(); public int totalAmmo; public float reload, rotation = 90, recoil, heat; @@ -154,8 +154,8 @@ public abstract class Turret extends Block{ } @Override - public Unitc unit(){ - return unit; + public Unit unit(){ + return (Unit)unit; } @Override @@ -237,7 +237,7 @@ public abstract class Turret extends Block{ } @Override - public void handleLiquid(Tilec source, Liquid liquid, float amount){ + public void handleLiquid(Building source, Liquid liquid, float amount){ if(acceptCoolant && liquids.currentAmount() <= 0.001f){ Events.fire(Trigger.turretCool); } diff --git a/core/src/mindustry/world/blocks/distribution/ArmoredConveyor.java b/core/src/mindustry/world/blocks/distribution/ArmoredConveyor.java index 82a6f418da..02ca9d0cda 100644 --- a/core/src/mindustry/world/blocks/distribution/ArmoredConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/ArmoredConveyor.java @@ -17,7 +17,7 @@ public class ArmoredConveyor extends Conveyor{ public class ArmoredConveyorEntity extends ConveyorEntity{ @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return super.acceptItem(source, item) && (source.block() instanceof Conveyor || Edges.getFacingEdge(source.tile(), tile).relativeTo(tile) == tile.rotation()); } } diff --git a/core/src/mindustry/world/blocks/distribution/BufferedItemBridge.java b/core/src/mindustry/world/blocks/distribution/BufferedItemBridge.java index b035972da1..2bda6f2aab 100644 --- a/core/src/mindustry/world/blocks/distribution/BufferedItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/BufferedItemBridge.java @@ -23,7 +23,7 @@ public class BufferedItemBridge extends ExtendingItemBridge{ ItemBuffer buffer = new ItemBuffer(bufferCapacity); @Override - public void updateTransport(Tilec other){ + public void updateTransport(Building other){ if(buffer.accepts() && items.total() > 0){ buffer.accept(items.take()); } diff --git a/core/src/mindustry/world/blocks/distribution/Conveyor.java b/core/src/mindustry/world/blocks/distribution/Conveyor.java index 40c39f8617..bf960fb881 100644 --- a/core/src/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/mindustry/world/blocks/distribution/Conveyor.java @@ -91,7 +91,7 @@ public class Conveyor extends Block implements Autotiler{ Mathf.mod(req.tile().rotation() - req.rotation, 2) == 1 ? Blocks.junction : this; } - public class ConveyorEntity extends TileEntity{ + public class ConveyorEntity extends Building{ //parallel array data Item[] ids = new Item[capacity]; float[] xs = new float[capacity]; @@ -99,7 +99,7 @@ public class Conveyor extends Block implements Autotiler{ //amount of items, always < capacity int len = 0; //next entity - @Nullable Tilec next; + @Nullable Building next; @Nullable ConveyorEntity nextc; //whether the next conveyor's rotation == tile rotation boolean aligned; @@ -169,7 +169,7 @@ public class Conveyor extends Block implements Autotiler{ } @Override - public void unitOn(Unitc unit){ + public void unitOn(Unit unit){ if(clogHeat > 0.5f){ return; } @@ -287,7 +287,7 @@ public class Conveyor extends Block implements Autotiler{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ if(len >= capacity) return false; Tile facing = Edges.getFacingEdge(source.tile(), tile); int direction = Math.abs(facing.relativeTo(tile.x, tile.y) - tile.rotation()); @@ -295,7 +295,7 @@ public class Conveyor extends Block implements Autotiler{ } @Override - public void handleItem(Tilec source, Item item){ + public void handleItem(Building source, Item item){ if(len >= capacity) return; byte r = tile.rotation(); diff --git a/core/src/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/mindustry/world/blocks/distribution/ItemBridge.java index 1e8f7087ed..e3f425ec43 100644 --- a/core/src/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ItemBridge.java @@ -122,7 +122,7 @@ public class ItemBridge extends Block{ return null; } - public class ItemBridgeEntity extends TileEntity{ + public class ItemBridgeEntity extends Building{ public int link = -1; public IntSet incoming = new IntSet(); public float uptime; @@ -203,7 +203,7 @@ public class ItemBridge extends Block{ } @Override - public boolean onConfigureTileTapped(Tilec other){ + public boolean onConfigureTileTapped(Building other){ //reverse connection if(other instanceof ItemBridgeEntity && ((ItemBridgeEntity)other).link == pos()){ configure(other.pos()); @@ -257,7 +257,7 @@ public class ItemBridge extends Block{ } } - public void updateTransport(Tilec other){ + public void updateTransport(Building other){ if(uptime >= 0.5f && timer(timerTransport, transportTime)){ Item item = items.take(); if(item != null && other.acceptItem(this, item)){ @@ -314,7 +314,7 @@ public class ItemBridge extends Block{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ if(team != source.team()) return false; Tile other = world.tile(link); @@ -332,12 +332,12 @@ public class ItemBridge extends Block{ } @Override - public boolean canDumpLiquid(Tilec to, Liquid liquid){ + public boolean canDumpLiquid(Building to, Liquid liquid){ return checkDump(to); } @Override - public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){ + public boolean acceptLiquid(Building source, Liquid liquid, float amount){ if(team != source.team() || !hasLiquids) return false; Tile other = world.tile(link); @@ -355,11 +355,11 @@ public class ItemBridge extends Block{ } @Override - public boolean canDump(Tilec to, Item item){ + public boolean canDump(Building to, Item item){ return checkDump(to); } - protected boolean checkDump(Tilec to){ + protected boolean checkDump(Building to){ Tile other = world.tile(link); if(!linkValid(tile, other)){ Tile edge = Edges.getFacingEdge(to.tile(), tile); diff --git a/core/src/mindustry/world/blocks/distribution/Junction.java b/core/src/mindustry/world/blocks/distribution/Junction.java index ba120e3097..4c497d1634 100644 --- a/core/src/mindustry/world/blocks/distribution/Junction.java +++ b/core/src/mindustry/world/blocks/distribution/Junction.java @@ -26,7 +26,7 @@ public class Junction extends Block{ return true; } - public class JunctionEntity extends TileEntity{ + public class JunctionEntity extends Building{ DirectionalItemBuffer buffer = new DirectionalItemBuffer(capacity); @Override @@ -46,7 +46,7 @@ public class Junction extends Block{ if(Time.time() >= time + speed / timeScale || Time.time() < time){ Item item = content.item(BufferItem.item(l)); - Tilec dest = nearby(i); + Building dest = nearby(i); //skip blocks that don't want the item, keep waiting until they do if(dest == null || !dest.acceptItem(this, item) || dest.team() != team){ @@ -62,17 +62,17 @@ public class Junction extends Block{ } @Override - public void handleItem(Tilec source, Item item){ + public void handleItem(Building source, Item item){ int relative = source.relativeTo(tile); buffer.accept(relative, item); } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ int relative = source.relativeTo(tile); if(relative == -1 || !buffer.accepts(relative)) return false; - Tilec to = nearby(relative); + Building to = nearby(relative); return to != null && to.team() == team; } diff --git a/core/src/mindustry/world/blocks/distribution/MassDriver.java b/core/src/mindustry/world/blocks/distribution/MassDriver.java index 3a008a0a75..cbaf9038de 100644 --- a/core/src/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/mindustry/world/blocks/distribution/MassDriver.java @@ -57,7 +57,7 @@ public class MassDriver extends Block{ //check if a mass driver is selected while placing this driver if(!control.input.frag.config.isShown()) return; - Tilec selected = control.input.frag.config.getSelectedTile(); + Building selected = control.input.frag.config.getSelectedTile(); if(selected == null || !(selected.block() instanceof MassDriver) || !(selected.dst(x * tilesize, y * tilesize) <= range)) return; //if so, draw a dotted line towards it while it is in range @@ -85,7 +85,7 @@ public class MassDriver extends Block{ } } - public class MassDriverEntity extends TileEntity{ + public class MassDriverEntity extends Building{ int link = -1; float rotation = 90; float reload = 0f; @@ -98,7 +98,7 @@ public class MassDriver extends Block{ @Override public void updateTile(){ - Tilec link = world.ent(this.link); + Building link = world.ent(this.link); boolean hasLink = linkValid(); //reload regardless of state @@ -212,7 +212,7 @@ public class MassDriver extends Block{ } @Override - public boolean onConfigureTileTapped(Tilec other){ + public boolean onConfigureTileTapped(Building other){ if(this == other){ configure(-1); return false; @@ -230,7 +230,7 @@ public class MassDriver extends Block{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ //mass drivers that ouput only cannot accept items return items.total() < itemCapacity && linkValid(); } @@ -265,7 +265,7 @@ public class MassDriver extends Block{ Effects.shake(shake, shake, this); } - public void handlePayload(Bulletc bullet, DriverBulletData data){ + public void handlePayload(Bullet bullet, DriverBulletData data){ int totalItems = items.total(); //add all the items possible diff --git a/core/src/mindustry/world/blocks/distribution/OverflowGate.java b/core/src/mindustry/world/blocks/distribution/OverflowGate.java index a054e53627..2fa2417c4b 100644 --- a/core/src/mindustry/world/blocks/distribution/OverflowGate.java +++ b/core/src/mindustry/world/blocks/distribution/OverflowGate.java @@ -30,7 +30,7 @@ public class OverflowGate extends Block{ return true; } - public class OverflowGateEntity extends TileEntity{ + public class OverflowGateEntity extends Building{ Item lastItem; Tile lastInput; float time; @@ -62,7 +62,7 @@ public class OverflowGate extends Block{ } time += 1f / speed * Time.delta(); - Tilec target = getTileTarget(lastItem, lastInput, false); + Building target = getTileTarget(lastItem, lastInput, false); if(target != null && (time >= 1f)){ getTileTarget(lastItem, lastInput, true); @@ -74,28 +74,28 @@ public class OverflowGate extends Block{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return team == source.team() && lastItem == null && items.total() == 0; } @Override - public void handleItem(Tilec source, Item item){ + public void handleItem(Building source, Item item){ items.add(item, 1); lastItem = item; time = 0f; lastInput = source.tile(); } - public @Nullable Tilec getTileTarget(Item item, Tile src, boolean flip){ + public @Nullable Building getTileTarget(Item item, Tile src, boolean flip){ int from = relativeToEdge(src); if(from == -1) return null; - Tilec to = nearby((from + 2) % 4); + Building to = nearby((from + 2) % 4); boolean canForward = to != null && to.acceptItem(this, item) && to.team() == team && !(to.block() instanceof OverflowGate); if(!canForward || invert){ - Tilec a = nearby(Mathf.mod(from - 1, 4)); - Tilec b = nearby(Mathf.mod(from + 1, 4)); + Building a = nearby(Mathf.mod(from - 1, 4)); + Building b = nearby(Mathf.mod(from + 1, 4)); boolean ac = a != null && a.acceptItem(this, item) && !(a.block() instanceof OverflowGate) && a.team() == team; boolean bc = b != null && b.acceptItem(this, item) && !(b.block() instanceof OverflowGate) && b.team() == team; diff --git a/core/src/mindustry/world/blocks/distribution/PayloadConveyor.java b/core/src/mindustry/world/blocks/distribution/PayloadConveyor.java index d3035e9997..ff73207c48 100644 --- a/core/src/mindustry/world/blocks/distribution/PayloadConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/PayloadConveyor.java @@ -41,17 +41,17 @@ public class PayloadConveyor extends Block{ super.drawPlace(x, y, rotation, valid); for(int i = 0; i < 4; i++){ - Tilec other = world.ent(x + Geometry.d4x[i] * size, y + Geometry.d4y[i] * size); + Building other = world.ent(x + Geometry.d4x[i] * size, y + Geometry.d4y[i] * size); if(other != null && other.block().outputsPayload && other.block().size == size){ Drawf.selected(other.tileX(), other.tileY(), other.block(), Pal.accent); } } } - public class PayloadConveyorEntity extends TileEntity{ + public class PayloadConveyorEntity extends Building{ public @Nullable Payload item; public float progress, itemRotation, animation; - public @Nullable Tilec next; + public @Nullable Building next; public boolean blocked; public int step = -1, stepAccepted = -1; @@ -66,7 +66,7 @@ public class PayloadConveyor extends Block{ public void onProximityUpdate(){ super.onProximityUpdate(); - Tilec accept = nearby(Geometry.d4(rotation()).x * size, Geometry.d4(rotation()).y * size); + Building accept = nearby(Geometry.d4(rotation()).x * size, Geometry.d4(rotation()).y * size); //next block must be aligned and of the same size if(accept != null && ( //same size @@ -180,13 +180,13 @@ public class PayloadConveyor extends Block{ } @Override - public boolean acceptPayload(Tilec source, Payload payload){ + public boolean acceptPayload(Building source, Payload payload){ //accepting payloads from units isn't supported return this.item == null && progress <= 5f && source != this && payload.fits(); } @Override - public void handlePayload(Tilec source, Payload payload){ + public void handlePayload(Building source, Payload payload){ this.item = payload; this.stepAccepted = curStep(); this.itemRotation = source.angleTo(this); diff --git a/core/src/mindustry/world/blocks/distribution/Router.java b/core/src/mindustry/world/blocks/distribution/Router.java index 7e06328b84..d7b9281831 100644 --- a/core/src/mindustry/world/blocks/distribution/Router.java +++ b/core/src/mindustry/world/blocks/distribution/Router.java @@ -19,7 +19,7 @@ public class Router extends Block{ unloadable = false; } - public class RouterEntity extends TileEntity{ + public class RouterEntity extends Building{ Item lastItem; Tile lastInput; float time; @@ -32,7 +32,7 @@ public class Router extends Block{ if(lastItem != null){ time += 1f / speed * delta(); - Tilec target = getTileTarget(lastItem, lastInput, false); + Building target = getTileTarget(lastItem, lastInput, false); if(target != null && (time >= 1f || !(target.block() instanceof Router))){ getTileTarget(lastItem, lastInput, true); @@ -44,12 +44,12 @@ public class Router extends Block{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return team == source.team() && lastItem == null && items.total() == 0; } @Override - public void handleItem(Tilec source, Item item){ + public void handleItem(Building source, Item item){ items.add(item, 1); lastItem = item; time = 0f; @@ -65,10 +65,10 @@ public class Router extends Block{ return result; } - Tilec getTileTarget(Item item, Tile from, boolean set){ + Building getTileTarget(Item item, Tile from, boolean set){ int counter = tile.rotation(); for(int i = 0; i < proximity.size; i++){ - Tilec other = proximity.get((i + counter) % proximity.size); + Building other = proximity.get((i + counter) % proximity.size); if(set) tile.rotation((byte)((tile.rotation() + 1) % proximity.size)); if(other.tile() == from && from.block() == Blocks.overflowGate) continue; if(other.acceptItem(this, item)){ diff --git a/core/src/mindustry/world/blocks/distribution/Sorter.java b/core/src/mindustry/world/blocks/distribution/Sorter.java index 9b2529856c..bdaf15d101 100644 --- a/core/src/mindustry/world/blocks/distribution/Sorter.java +++ b/core/src/mindustry/world/blocks/distribution/Sorter.java @@ -47,11 +47,11 @@ public class Sorter extends Block{ return tile.ent().sortItem == null ? 0 : tile.ent().sortItem.color.rgba(); } - public class SorterEntity extends TileEntity{ + public class SorterEntity extends Building{ @Nullable Item sortItem; @Override - public void configured(Playerc player, Object value){ + public void configured(Player player, Object value){ super.configured(player, value); if(!headless){ @@ -73,28 +73,28 @@ public class Sorter extends Block{ } @Override - public boolean acceptItem(Tilec source, Item item){ - Tilec to = getTileTarget(item, source, false); + public boolean acceptItem(Building source, Item item){ + Building to = getTileTarget(item, source, false); return to != null && to.acceptItem(this, item) && to.team() == team; } @Override - public void handleItem(Tilec source, Item item){ - Tilec to = getTileTarget(item, source, true); + public void handleItem(Building source, Item item){ + Building to = getTileTarget(item, source, true); to.handleItem(this, item); } - boolean isSame(Tilec other){ + boolean isSame(Building other){ //uncomment comment below to prevent sorter/gate chaining (hacky) return other != null && (other.block() instanceof Sorter/* || other.block() instanceof OverflowGate */); } - Tilec getTileTarget(Item item, Tilec source, boolean flip){ + Building getTileTarget(Item item, Building source, boolean flip){ int dir = source.relativeTo(tile.x, tile.y); if(dir == -1) return null; - Tilec to; + Building to; if((item == sortItem) != invert){ //prevent 3-chains @@ -103,8 +103,8 @@ public class Sorter extends Block{ } to = nearby(dir); }else{ - Tilec a = nearby(Mathf.mod(dir - 1, 4)); - Tilec b = nearby(Mathf.mod(dir + 1, 4)); + Building a = nearby(Mathf.mod(dir - 1, 4)); + Building b = nearby(Mathf.mod(dir + 1, 4)); boolean ac = a != null && !(a.block().instantTransfer && source.block().instantTransfer) && a.acceptItem(this, item); boolean bc = b != null && !(b.block().instantTransfer && source.block().instantTransfer) && @@ -136,7 +136,7 @@ public class Sorter extends Block{ } @Override - public boolean onConfigureTileTapped(Tilec other){ + public boolean onConfigureTileTapped(Building other){ if(this == other){ deselect(); configure(null); diff --git a/core/src/mindustry/world/blocks/distribution/StackConveyor.java b/core/src/mindustry/world/blocks/distribution/StackConveyor.java index 1b70f40a0a..f479765b66 100644 --- a/core/src/mindustry/world/blocks/distribution/StackConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/StackConveyor.java @@ -84,14 +84,14 @@ public class StackConveyor extends Block implements Autotiler{ @Override public boolean rotatedOutput(int x, int y){ - Tilec tile = world.ent(x, y); + Building tile = world.ent(x, y); if(tile instanceof StackConveyorEntity){ return ((StackConveyorEntity)tile).state != stateUnload; } return super.rotatedOutput(x, y); } - public class StackConveyorEntity extends TileEntity{ + public class StackConveyorEntity extends Building{ public int state, blendprox; public int link = -1; @@ -155,7 +155,7 @@ public class StackConveyor extends Block implements Autotiler{ //update other conveyor state when this conveyor's state changes if(state != lastState){ - for(Tilec near : proximity){ + for(Building near : proximity){ if(near instanceof StackConveyorEntity){ near.onProximityUpdate(); } @@ -224,7 +224,7 @@ public class StackConveyor extends Block implements Autotiler{ } @Override - public void handleItem(Tilec source, Item item){ + public void handleItem(Building source, Item item){ if(items.empty()) poofIn(); super.handleItem(source, item); lastItem = item; @@ -247,7 +247,7 @@ public class StackConveyor extends Block implements Autotiler{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ if(this == source) return true; // player threw items if(cooldown > recharge - 1f) return false; // still cooling down return !((state != stateLoad) // not a loading dock diff --git a/core/src/mindustry/world/blocks/experimental/BlockForge.java b/core/src/mindustry/world/blocks/experimental/BlockForge.java index 20036d943f..2c43a8b514 100644 --- a/core/src/mindustry/world/blocks/experimental/BlockForge.java +++ b/core/src/mindustry/world/blocks/experimental/BlockForge.java @@ -56,7 +56,7 @@ public class BlockForge extends PayloadAcceptor{ public float progress, time, heat; @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return items.get(item) < getMaximumAccepted(item); } @@ -70,7 +70,7 @@ public class BlockForge extends PayloadAcceptor{ } @Override - public boolean acceptPayload(Tilec source, Payload payload){ + public boolean acceptPayload(Building source, Payload payload){ return false; } diff --git a/core/src/mindustry/world/blocks/experimental/BlockLoader.java b/core/src/mindustry/world/blocks/experimental/BlockLoader.java index ee152813b9..4b101051ad 100644 --- a/core/src/mindustry/world/blocks/experimental/BlockLoader.java +++ b/core/src/mindustry/world/blocks/experimental/BlockLoader.java @@ -53,7 +53,7 @@ public class BlockLoader extends PayloadAcceptor{ public class BlockLoaderEntity extends PayloadAcceptorEntity{ @Override - public boolean acceptPayload(Tilec source, Payload payload){ + public boolean acceptPayload(Building source, Payload payload){ return super.acceptPayload(source, payload) && (payload instanceof BlockPayload) && ((((BlockPayload)payload).entity.block().hasItems && ((BlockPayload)payload).block().unloadable && ((BlockPayload)payload).block().itemCapacity >= 10)/* || @@ -61,7 +61,7 @@ public class BlockLoader extends PayloadAcceptor{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return items.total() < itemCapacity; } @@ -117,9 +117,9 @@ public class BlockLoader extends PayloadAcceptor{ if(payload.block().hasLiquids && liquids.total() >= 0.001f){ Liquid liq = liquids.current(); float total = liquids.currentAmount(); - float flow = Math.min(Math.min(liquidsLoaded * delta(), payload.block().liquidCapacity - payload.entity.liquids().get(liq) - 0.0001f), total); + float flow = Math.min(Math.min(liquidsLoaded * delta(), payload.block().liquidCapacity - payload.entity.liquids.get(liq) - 0.0001f), total); if(payload.entity.acceptLiquid(payload.entity, liq, flow)){ - payload.entity.liquids().add(liq, flow); + payload.entity.liquids.add(liq, flow); liquids.remove(liq, flow); } }*/ @@ -127,13 +127,13 @@ public class BlockLoader extends PayloadAcceptor{ } public float fraction(){ - return payload == null ? 0f : payload.entity.items().total() / (float)payload.entity.block().itemCapacity; + return payload == null ? 0f : payload.entity.items.total() / (float)payload.entity.block().itemCapacity; } public boolean shouldExport(){ return payload != null && - ((payload.block().hasLiquids && payload.entity.liquids().total() >= payload.block().liquidCapacity - 0.001f) || - (payload.block().hasItems && payload.entity.items().total() >= payload.block().itemCapacity)); + ((payload.block().hasLiquids && payload.entity.liquids.total() >= payload.block().liquidCapacity - 0.001f) || + (payload.block().hasItems && payload.entity.items.total() >= payload.block().itemCapacity)); } } } diff --git a/core/src/mindustry/world/blocks/experimental/BlockUnloader.java b/core/src/mindustry/world/blocks/experimental/BlockUnloader.java index 9f5aa1554e..d9630e0ae1 100644 --- a/core/src/mindustry/world/blocks/experimental/BlockUnloader.java +++ b/core/src/mindustry/world/blocks/experimental/BlockUnloader.java @@ -19,7 +19,7 @@ public class BlockUnloader extends BlockLoader{ public class BlockUnloaderEntity extends BlockLoaderEntity{ @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return false; } @@ -35,9 +35,9 @@ public class BlockUnloader extends BlockLoader{ //load up items a set amount of times for(int j = 0; j < itemsLoaded && !full(); j++){ for(int i = 0; i < items.length(); i++){ - if(payload.entity.items().get(i) > 0){ + if(payload.entity.items.get(i) > 0){ Item item = content.item(i); - payload.entity.items().remove(item, 1); + payload.entity.items.remove(item, 1); items.add(item, 1); break; } @@ -56,12 +56,12 @@ public class BlockUnloader extends BlockLoader{ @Override public float fraction(){ - return payload == null ? 0f : 1f - payload.entity.items().total() / (float)payload.entity.block().itemCapacity; + return payload == null ? 0f : 1f - payload.entity.items.total() / (float)payload.entity.block().itemCapacity; } @Override public boolean shouldExport(){ - return payload != null && (payload.block().hasItems && payload.entity.items().empty()); + return payload != null && (payload.block().hasItems && payload.entity.items.empty()); } } } diff --git a/core/src/mindustry/world/blocks/experimental/ProcessorBlock.java b/core/src/mindustry/world/blocks/experimental/ProcessorBlock.java index 9fa481beba..4d7d4e7df8 100644 --- a/core/src/mindustry/world/blocks/experimental/ProcessorBlock.java +++ b/core/src/mindustry/world/blocks/experimental/ProcessorBlock.java @@ -12,12 +12,12 @@ public class ProcessorBlock extends Block{ configurable = true; } - public class ProcessorEntity extends TileEntity{ + public class ProcessorEntity extends Building{ //all tiles in the block network - does not include itself - Seq network = new Seq<>(); + Seq network = new Seq<>(); @Override - public boolean onConfigureTileTapped(Tilec other){ + public boolean onConfigureTileTapped(Building other){ if(other == this) return true; if(!network.contains(other)){ diff --git a/core/src/mindustry/world/blocks/legacy/LegacyCommandCenter.java b/core/src/mindustry/world/blocks/legacy/LegacyCommandCenter.java index 4fbd663263..0ee076c083 100644 --- a/core/src/mindustry/world/blocks/legacy/LegacyCommandCenter.java +++ b/core/src/mindustry/world/blocks/legacy/LegacyCommandCenter.java @@ -10,7 +10,7 @@ public class LegacyCommandCenter extends LegacyBlock{ update = true; } - public class LegacyCommandCenterEntity extends TileEntity{ + public class LegacyCommandCenterEntity extends Building{ @Override public void read(Reads read, byte revision){ super.read(read, revision); diff --git a/core/src/mindustry/world/blocks/legacy/LegacyMechPad.java b/core/src/mindustry/world/blocks/legacy/LegacyMechPad.java index c0815348ee..d5f51283ce 100644 --- a/core/src/mindustry/world/blocks/legacy/LegacyMechPad.java +++ b/core/src/mindustry/world/blocks/legacy/LegacyMechPad.java @@ -11,7 +11,7 @@ public class LegacyMechPad extends LegacyBlock{ hasPower = true; } - public class LegacyMechPadEntity extends TileEntity{ + public class LegacyMechPadEntity extends Building{ @Override public void read(Reads read, byte revision){ diff --git a/core/src/mindustry/world/blocks/legacy/LegacyUnitFactory.java b/core/src/mindustry/world/blocks/legacy/LegacyUnitFactory.java index 8befde6940..e9bdb7ddee 100644 --- a/core/src/mindustry/world/blocks/legacy/LegacyUnitFactory.java +++ b/core/src/mindustry/world/blocks/legacy/LegacyUnitFactory.java @@ -13,7 +13,7 @@ public class LegacyUnitFactory extends LegacyBlock{ solid = false; } - public class LegacyUnitFactoryEntity extends TileEntity{ + public class LegacyUnitFactoryEntity extends Building{ @Override public void read(Reads read, byte revision){ diff --git a/core/src/mindustry/world/blocks/liquid/ArmoredConduit.java b/core/src/mindustry/world/blocks/liquid/ArmoredConduit.java index 9566dc2032..202877f486 100644 --- a/core/src/mindustry/world/blocks/liquid/ArmoredConduit.java +++ b/core/src/mindustry/world/blocks/liquid/ArmoredConduit.java @@ -25,14 +25,14 @@ public class ArmoredConduit extends Conduit{ super.draw(); // draw the cap when a conduit would normally leak - Tilec next = tile.front(); + Building next = tile.front(); if(next != null && next.team() == team && next.block().hasLiquids) return; Draw.rect(capRegion, x, y, tile.rotdeg()); } @Override - public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){ + public boolean acceptLiquid(Building source, Liquid liquid, float amount){ return super.acceptLiquid(source, liquid, amount) && (source.block() instanceof Conduit) || Edges.getFacingEdge(source.tile(), tile).absoluteRelativeTo(tile.x, tile.y) == tile.rotation(); } } diff --git a/core/src/mindustry/world/blocks/liquid/Conduit.java b/core/src/mindustry/world/blocks/liquid/Conduit.java index 9150dafed3..01ebd077c7 100644 --- a/core/src/mindustry/world/blocks/liquid/Conduit.java +++ b/core/src/mindustry/world/blocks/liquid/Conduit.java @@ -122,7 +122,7 @@ public class Conduit extends LiquidBlock implements Autotiler{ } @Override - public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){ + public boolean acceptLiquid(Building source, Liquid liquid, float amount){ noSleep(); return liquids.get(liquid) + amount < liquidCapacity && (liquids.current() == liquid || liquids.currentAmount() < 0.2f) && ((source.relativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation()); diff --git a/core/src/mindustry/world/blocks/liquid/LiquidBlock.java b/core/src/mindustry/world/blocks/liquid/LiquidBlock.java index 5aca8a9f31..c1e7f3bd65 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidBlock.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidBlock.java @@ -25,7 +25,7 @@ public class LiquidBlock extends Block{ return new TextureRegion[]{bottomRegion, topRegion}; } - public class LiquidBlockEntity extends TileEntity{ + public class LiquidBlockEntity extends Building{ @Override public void draw(){ float rotation = rotate ? rotdeg() : 0; diff --git a/core/src/mindustry/world/blocks/liquid/LiquidBridge.java b/core/src/mindustry/world/blocks/liquid/LiquidBridge.java index 1f128cfc1e..c0eb7d44bd 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidBridge.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidBridge.java @@ -26,7 +26,7 @@ public class LiquidBridge extends ItemBridge{ checkIncoming(); - Tilec other = world.ent(link); + Building other = world.ent(link); if(other == null || !linkValid(tile, other.tile())){ dumpLiquid(liquids.current()); }else{ @@ -54,7 +54,7 @@ public class LiquidBridge extends ItemBridge{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return false; } } diff --git a/core/src/mindustry/world/blocks/liquid/LiquidExtendingBridge.java b/core/src/mindustry/world/blocks/liquid/LiquidExtendingBridge.java index 73e29eb851..538354ded9 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidExtendingBridge.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidExtendingBridge.java @@ -26,7 +26,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{ checkIncoming(); - Tilec other = world.ent(link); + Building other = world.ent(link); if(other == null || !linkValid(tile, other.tile())){ dumpLiquid(liquids.current()); }else{ @@ -49,7 +49,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return false; } } diff --git a/core/src/mindustry/world/blocks/liquid/LiquidJunction.java b/core/src/mindustry/world/blocks/liquid/LiquidJunction.java index 5902a5a834..aa849fd734 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidJunction.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidJunction.java @@ -28,17 +28,17 @@ public class LiquidJunction extends LiquidBlock{ return new TextureRegion[]{region}; } - public class LiquidJunctionEntity extends TileEntity{ + public class LiquidJunctionEntity extends Building{ @Override public void draw(){ Draw.rect(region, x, y); } @Override - public Tilec getLiquidDestination(Tilec source, Liquid liquid){ + public Building getLiquidDestination(Building source, Liquid liquid){ int dir = source.relativeTo(tile.x, tile.y); dir = (dir + 4) % 4; - Tilec next = nearby(dir); + Building next = nearby(dir); if(next == null || (!next.acceptLiquid(this, liquid, 0f) && !(next.block() instanceof LiquidJunction))){ return this; } diff --git a/core/src/mindustry/world/blocks/liquid/LiquidRouter.java b/core/src/mindustry/world/blocks/liquid/LiquidRouter.java index 5a4530613f..4b273369d3 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidRouter.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidRouter.java @@ -18,7 +18,7 @@ public class LiquidRouter extends LiquidBlock{ } @Override - public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){ + public boolean acceptLiquid(Building source, Liquid liquid, float amount){ return liquids.get(liquid) + amount < liquidCapacity && (liquids.current() == liquid || liquids.currentAmount() < 0.2f); } } diff --git a/core/src/mindustry/world/blocks/payloads/BlockPayload.java b/core/src/mindustry/world/blocks/payloads/BlockPayload.java index f9d72b4e1a..4194be3622 100644 --- a/core/src/mindustry/world/blocks/payloads/BlockPayload.java +++ b/core/src/mindustry/world/blocks/payloads/BlockPayload.java @@ -11,13 +11,13 @@ import mindustry.world.*; import static mindustry.Vars.tilesize; public class BlockPayload implements Payload{ - public Tilec entity; + public Building entity; public BlockPayload(Block block, Team team){ this.entity = block.newEntity().create(block, team); } - public BlockPayload(Tilec entity){ + public BlockPayload(Building entity){ this.entity = entity; } diff --git a/core/src/mindustry/world/blocks/payloads/Payload.java b/core/src/mindustry/world/blocks/payloads/Payload.java index 49be536fd4..a63698d09b 100644 --- a/core/src/mindustry/world/blocks/payloads/Payload.java +++ b/core/src/mindustry/world/blocks/payloads/Payload.java @@ -54,7 +54,7 @@ public interface Payload{ return (T)payload; }else if(type == payloadUnit){ byte id = read.b(); - Unitc unit = (Unitc)EntityMapping.map(id).get(); + Unit unit = (Unit)EntityMapping.map(id).get(); unit.read(read); return (T)new UnitPayload(unit); } diff --git a/core/src/mindustry/world/blocks/payloads/UnitPayload.java b/core/src/mindustry/world/blocks/payloads/UnitPayload.java index fe81f4934a..ff4e1d80ef 100644 --- a/core/src/mindustry/world/blocks/payloads/UnitPayload.java +++ b/core/src/mindustry/world/blocks/payloads/UnitPayload.java @@ -9,15 +9,15 @@ import mindustry.graphics.*; import mindustry.ui.*; public class UnitPayload implements Payload{ - public Unitc unit; + public Unit unit; - public UnitPayload(Unitc unit){ + public UnitPayload(Unit unit){ this.unit = unit; } @Override public boolean fits(){ - return unit.hitSize() <= 16f; + return unit.hitSize <= 16f; } @Override @@ -39,7 +39,7 @@ public class UnitPayload implements Payload{ if(Vars.net.client()) return true; //prevents stacking - unit.vel().add(Mathf.range(0.5f), Mathf.range(0.5f)); + unit.vel.add(Mathf.range(0.5f), Mathf.range(0.5f)); unit.add(); return true; @@ -47,7 +47,7 @@ public class UnitPayload implements Payload{ @Override public void draw(){ - Drawf.shadow(unit.x(), unit.y(), 20); - Draw.rect(unit.type().icon(Cicon.full), unit.x(), unit.y(), unit.rotation() - 90); + Drawf.shadow(unit.x, unit.y, 20); + Draw.rect(unit.type().icon(Cicon.full), unit.x, unit.y, unit.rotation - 90); } } diff --git a/core/src/mindustry/world/blocks/power/Battery.java b/core/src/mindustry/world/blocks/power/Battery.java index 03b94961f5..718c5a5ff7 100644 --- a/core/src/mindustry/world/blocks/power/Battery.java +++ b/core/src/mindustry/world/blocks/power/Battery.java @@ -19,7 +19,7 @@ public class Battery extends PowerDistributor{ consumesPower = true; } - public class BatteryEntity extends TileEntity{ + public class BatteryEntity extends Building{ @Override public void draw(){ Draw.color(emptyLightColor, fullLightColor, power.status); diff --git a/core/src/mindustry/world/blocks/power/ConditionalConsumePower.java b/core/src/mindustry/world/blocks/power/ConditionalConsumePower.java index 35e3b08514..780474e3b5 100644 --- a/core/src/mindustry/world/blocks/power/ConditionalConsumePower.java +++ b/core/src/mindustry/world/blocks/power/ConditionalConsumePower.java @@ -6,15 +6,15 @@ import mindustry.world.consumers.ConsumePower; /** A power consumer that only activates sometimes. */ public class ConditionalConsumePower extends ConsumePower{ - private final Boolf consume; + private final Boolf consume; - public ConditionalConsumePower(float usage, Boolf consume){ + public ConditionalConsumePower(float usage, Boolf consume){ super(usage, 0, false); this.consume = consume; } @Override - public float requestedPower(Tilec entity){ + public float requestedPower(Building entity){ return consume.get(entity) ? usage : 0f; } } diff --git a/core/src/mindustry/world/blocks/power/LightBlock.java b/core/src/mindustry/world/blocks/power/LightBlock.java index 7d89bdcdf7..a4a6642bc7 100644 --- a/core/src/mindustry/world/blocks/power/LightBlock.java +++ b/core/src/mindustry/world/blocks/power/LightBlock.java @@ -27,7 +27,7 @@ public class LightBlock extends Block{ config(Integer.class, (LightEntity tile, Integer value) -> tile.color = value); } - public class LightEntity extends TileEntity{ + public class LightEntity extends Building{ public int color = Pal.accent.rgba(); @Override diff --git a/core/src/mindustry/world/blocks/power/PowerDiode.java b/core/src/mindustry/world/blocks/power/PowerDiode.java index 75f74814b8..cdbf612745 100644 --- a/core/src/mindustry/world/blocks/power/PowerDiode.java +++ b/core/src/mindustry/world/blocks/power/PowerDiode.java @@ -38,11 +38,11 @@ public class PowerDiode extends Block{ } // battery % of the graph on either side, defaults to zero - public float bar(Tilec tile){ - return (tile != null && tile.block().hasPower) ? tile.power().graph.getBatteryStored() / tile.power().graph.getTotalBatteryCapacity() : 0f; + public float bar(Building tile){ + return (tile != null && tile.block().hasPower) ? tile.power.graph.getBatteryStored() / tile.power.graph.getTotalBatteryCapacity() : 0f; } - public class PowerDiodeEntity extends TileEntity{ + public class PowerDiodeEntity extends Building{ @Override public void draw(){ Draw.rect(region, x, y, 0); diff --git a/core/src/mindustry/world/blocks/power/PowerGenerator.java b/core/src/mindustry/world/blocks/power/PowerGenerator.java index 804b359f43..056caa3b7e 100644 --- a/core/src/mindustry/world/blocks/power/PowerGenerator.java +++ b/core/src/mindustry/world/blocks/power/PowerGenerator.java @@ -45,7 +45,7 @@ public class PowerGenerator extends PowerDistributor{ return false; } - public class GeneratorEntity extends TileEntity{ + public class GeneratorEntity extends Building{ public float generateTime; /** The efficiency of the producer. An efficiency of 1.0 means 100% */ public float productionEfficiency = 0.0f; diff --git a/core/src/mindustry/world/blocks/power/PowerGraph.java b/core/src/mindustry/world/blocks/power/PowerGraph.java index 9078e56685..302b2a06c1 100644 --- a/core/src/mindustry/world/blocks/power/PowerGraph.java +++ b/core/src/mindustry/world/blocks/power/PowerGraph.java @@ -8,15 +8,15 @@ import mindustry.gen.*; import mindustry.world.consumers.*; public class PowerGraph{ - private final static Queue queue = new Queue<>(); - private final static Seq outArray1 = new Seq<>(); - private final static Seq outArray2 = new Seq<>(); + private final static Queue queue = new Queue<>(); + private final static Seq outArray1 = new Seq<>(); + private final static Seq outArray2 = new Seq<>(); private final static IntSet closedSet = new IntSet(); - private final ObjectSet producers = new ObjectSet<>(); - private final ObjectSet consumers = new ObjectSet<>(); - private final ObjectSet batteries = new ObjectSet<>(); - private final ObjectSet all = new ObjectSet<>(); + private final ObjectSet producers = new ObjectSet<>(); + private final ObjectSet consumers = new ObjectSet<>(); + private final ObjectSet batteries = new ObjectSet<>(); + private final ObjectSet all = new ObjectSet<>(); private final WindowedMean powerBalance = new WindowedMean(60); private float lastPowerProduced, lastPowerNeeded, lastUsageFraction; @@ -61,7 +61,7 @@ public class PowerGraph{ public float getPowerProduced(){ float powerProduced = 0f; - for(Tilec producer : producers){ + for(Building producer : producers){ powerProduced += producer.getPowerProduction() * producer.delta(); } return powerProduced; @@ -69,7 +69,7 @@ public class PowerGraph{ public float getPowerNeeded(){ float powerNeeded = 0f; - for(Tilec consumer : consumers){ + for(Building consumer : consumers){ Consumers consumes = consumer.block().consumes; if(consumes.hasPower()){ ConsumePower consumePower = consumes.getPower(); @@ -83,7 +83,7 @@ public class PowerGraph{ public float getBatteryStored(){ float totalAccumulator = 0f; - for(Tilec battery : batteries){ + for(Building battery : batteries){ Consumers consumes = battery.block().consumes; if(consumes.hasPower()){ totalAccumulator += battery.power().status * consumes.getPower().capacity; @@ -94,7 +94,7 @@ public class PowerGraph{ public float getBatteryCapacity(){ float totalCapacity = 0f; - for(Tilec battery : batteries){ + for(Building battery : batteries){ if(battery.block().consumes.hasPower()){ ConsumePower power = battery.block().consumes.getPower(); totalCapacity += (1f - battery.power().status) * power.capacity; @@ -105,7 +105,7 @@ public class PowerGraph{ public float getTotalBatteryCapacity(){ float totalCapacity = 0f; - for(Tilec battery : batteries){ + for(Building battery : batteries){ if(battery.block().consumes.hasPower()){ totalCapacity += battery.block().consumes.getPower().capacity; } @@ -119,7 +119,7 @@ public class PowerGraph{ float used = Math.min(stored, needed); float consumedPowerPercentage = Math.min(1.0f, needed / stored); - for(Tilec battery : batteries){ + for(Building battery : batteries){ Consumers consumes = battery.block().consumes; if(consumes.hasPower()){ battery.power().status *= (1f-consumedPowerPercentage); @@ -134,7 +134,7 @@ public class PowerGraph{ float chargedPercent = Math.min(excess/capacity, 1f); if(Mathf.equal(capacity, 0f)) return 0f; - for(Tilec battery : batteries){ + for(Building battery : batteries){ Consumers consumes = battery.block().consumes; if(consumes.hasPower()){ ConsumePower consumePower = consumes.getPower(); @@ -149,7 +149,7 @@ public class PowerGraph{ public void distributePower(float needed, float produced){ //distribute even if not needed. this is because some might be requiring power but not using it; it updates consumers float coverage = Mathf.zero(needed) && Mathf.zero(produced) ? 0f : Mathf.zero(needed) ? 1f : Math.min(1, produced / needed); - for(Tilec consumer : consumers){ + for(Building consumer : consumers){ Consumers consumes = consumer.block().consumes; if(consumes.hasPower()){ ConsumePower consumePower = consumes.getPower(); @@ -180,8 +180,8 @@ public class PowerGraph{ return; }else if(!consumers.isEmpty() && consumers.first().cheating()){ //when cheating, just set status to 1 - for(Tilec tile : consumers){ - tile.power().status = 1f; + for(Building tile : consumers){ + tile.power.status = 1f; } lastPowerNeeded = lastPowerProduced = lastUsageFraction = 1f; @@ -221,15 +221,15 @@ public class PowerGraph{ lastUsageFraction = Mathf.zero(rawProduced) ? 1f : Mathf.clamp(powerNeeded / rawProduced); } - public void add(PowerGraph graph){ - for(Tilec tile : graph.all){ + public void addGraph(PowerGraph graph){ + for(Building tile : graph.all){ add(tile); } } - public void add(Tilec tile){ - if(tile == null || tile.power() == null) return; - tile.power().graph = this; + public void add(Building tile){ + if(tile == null || tile.power == null) return; + tile.power.graph = this; all.add(tile); if(tile.block().outputsPower && tile.block().consumesPower && !tile.block().consumes.getPower().buffered){ @@ -244,14 +244,14 @@ public class PowerGraph{ } } - public void reflow(Tilec tile){ + public void reflow(Building tile){ queue.clear(); queue.addLast(tile); closedSet.clear(); while(queue.size > 0){ - Tilec child = queue.removeFirst(); + Building child = queue.removeFirst(); add(child); - for(Tilec next : child.getPowerConnections(outArray2)){ + for(Building next : child.getPowerConnections(outArray2)){ if(!closedSet.contains(next.pos())){ queue.addLast(next); closedSet.add(next.pos()); @@ -260,20 +260,20 @@ public class PowerGraph{ } } - private void removeSingle(Tilec tile){ + private void removeSingle(Building tile){ all.remove(tile); producers.remove(tile); consumers.remove(tile); batteries.remove(tile); } - public void remove(Tilec tile){ + public void remove(Building tile){ removeSingle(tile); //begin by clearing the closed set closedSet.clear(); //go through all the connections of this tile - for(Tilec other : tile.getPowerConnections(outArray1)){ + for(Building other : tile.getPowerConnections(outArray1)){ //a graph has already been assigned to this tile from a previous call, skip it if(other.power().graph != this) continue; @@ -285,13 +285,13 @@ public class PowerGraph{ queue.addLast(other); while(queue.size > 0){ //get child from queue - Tilec child = queue.removeFirst(); + Building child = queue.removeFirst(); //remove it from this graph removeSingle(child); //add it to the new branch graph graph.add(child); //go through connections - for(Tilec next : child.getPowerConnections(outArray2)){ + for(Building next : child.getPowerConnections(outArray2)){ //make sure it hasn't looped back, and that the new graph being assigned hasn't already been assigned //also skip closed tiles if(next != tile && next.power().graph != graph && !closedSet.contains(next.pos())){ @@ -305,7 +305,7 @@ public class PowerGraph{ } } - private boolean otherConsumersAreValid(Tilec tile, Consume consumePower){ + private boolean otherConsumersAreValid(Building tile, Consume consumePower){ for(Consume cons : tile.block().consumes.all()){ if(cons != consumePower && !cons.isOptional() && !cons.valid(tile)){ return false; diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index 911827f247..858408f56c 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -40,8 +40,8 @@ public class PowerNode extends PowerBlock{ consumesPower = false; outputsPower = false; config(Integer.class, (entity, value) -> { - PowerModule power = entity.power(); - Tilec other = world.ent(value); + PowerModule power = entity.power; + Building other = world.ent(value); boolean contains = power.links.contains(value), valid = other != null && other.power() != null; if(contains){ @@ -73,15 +73,15 @@ public class PowerNode extends PowerBlock{ } } - power.graph.add(other.power().graph); + power.graph.addGraph(other.power.graph); } }); config(Point2[].class, (tile, value) -> { - tile.power().links.clear(); + tile.power.links.clear(); for(Point2 p : value){ - if(tile.power().links.size < maxNodes){ - tile.power().links.add(Point2.pack(p.x + tile.tileX(), p.y + tile.tileY())); + if(tile.power.links.size < maxNodes){ + tile.power.links.add(Point2.pack(p.x + tile.tileX(), p.y + tile.tileY())); } } }); @@ -92,15 +92,15 @@ public class PowerNode extends PowerBlock{ super.setBars(); bars.add("power", entity -> new Bar(() -> Core.bundle.format("bar.powerbalance", - ((entity.power().graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.power().graph.getPowerBalance() * 60, 1))), + ((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.power.graph.getPowerBalance() * 60, 1))), () -> Pal.powerBar, - () -> Mathf.clamp(entity.power().graph.getLastPowerProduced() / entity.power().graph.getLastPowerNeeded()))); + () -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded()))); bars.add("batteries", entity -> new Bar(() -> Core.bundle.format("bar.powerstored", - (ui.formatAmount((int)entity.power().graph.getBatteryStored())), ui.formatAmount((int)entity.power().graph.getTotalBatteryCapacity())), + (ui.formatAmount((int)entity.power.graph.getBatteryStored())), ui.formatAmount((int)entity.power.graph.getTotalBatteryCapacity())), () -> Pal.powerBar, - () -> Mathf.clamp(entity.power().graph.getBatteryStored() / entity.power().graph.getTotalBatteryCapacity()))); + () -> Mathf.clamp(entity.power.graph.getBatteryStored() / entity.power.graph.getTotalBatteryCapacity()))); } @Override @@ -157,7 +157,7 @@ public class PowerNode extends PowerBlock{ return Intersector.overlaps(Tmp.cr1.set(srcx, srcy, range), other.getHitbox(Tmp.r1)); } - protected boolean overlaps(Tilec src, Tilec other, float range){ + protected boolean overlaps(Building src, Building other, float range){ return overlaps(src.x(), src.y(), other.tile(), range); } @@ -170,20 +170,20 @@ public class PowerNode extends PowerBlock{ return Intersector.overlaps(Tmp.cr1.set(src.worldx() + offset(), src.worldy() + offset(), laserRange * tilesize), Tmp.r1.setSize(size * tilesize).setCenter(other.worldx() + offset(), other.worldy() + offset())); } - protected void getPotentialLinks(Tile tile, Cons others){ - Boolf valid = other -> other != null && other.tile() != tile && other.power() != null && + protected void getPotentialLinks(Tile tile, Cons others){ + Boolf valid = other -> other != null && other.tile() != tile && other.power() != null && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other.tile(), laserRange * tilesize) && other.team() == player.team() && !other.proximity().contains(e -> e.tile() == tile) && !graphs.contains(other.power().graph); tempTileEnts.clear(); graphs.clear(); - if(tile.entity != null && tile.entity.power() != null){ - graphs.add(tile.entity.power().graph); + if(tile.entity != null && tile.entity.power != null){ + graphs.add(tile.entity.power.graph); } Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> { - Tilec other = world.ent(x, y); + Building other = world.ent(x, y); if(valid.get(other) && !tempTileEnts.contains(other)){ tempTileEnts.add(other); } @@ -219,11 +219,11 @@ public class PowerNode extends PowerBlock{ } } - public boolean linkValid(Tilec tile, Tilec link){ + public boolean linkValid(Building tile, Building link){ return linkValid(tile, link, true); } - public boolean linkValid(Tilec tile, Tilec link, boolean checkMaxNodes){ + public boolean linkValid(Building tile, Building link, boolean checkMaxNodes){ if(tile == link || link == null || !link.block().hasPower || tile.team() != link.team()) return false; if(overlaps(tile, link, laserRange * tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, ((PowerNode)link.block()).laserRange * tilesize))){ @@ -239,7 +239,7 @@ public class PowerNode extends PowerBlock{ return insulated(tile.x, tile.y, other.x, other.y); } - public static boolean insulated(Tilec tile, Tilec other){ + public static boolean insulated(Building tile, Building other){ return insulated(tile.tileX(), tile.tileY(), other.tileX(), other.tileY()); } @@ -249,10 +249,10 @@ public class PowerNode extends PowerBlock{ return returnValue; } - public static void insulators(int x, int y, int x2, int y2, Cons iterator){ + public static void insulators(int x, int y, int x2, int y2, Cons iterator){ world.raycastEach(x, y, x2, y2, (wx, wy) -> { - Tilec tile = world.ent(wx, wy); + Building tile = world.ent(wx, wy); if(tile != null && tile.block().insulated){ iterator.get(tile); } @@ -261,19 +261,19 @@ public class PowerNode extends PowerBlock{ }); } - public class PowerNodeEntity extends TileEntity{ + public class PowerNodeEntity extends Building{ @Override public void placed(){ if(net.client()) return; - Boolf valid = other -> other != null && other != this && ((!other.block().outputsPower && other.block().consumesPower) || + Boolf valid = other -> other != null && other != this && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && linkValid(this, other) && !other.proximity().contains(this) && other.power().graph != power.graph; tempTileEnts.clear(); Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> { - Tilec other = world.ent(x, y); + Building other = world.ent(x, y); if(valid.get(other)){ if(!insulated(this, other)){ tempTileEnts.add(other); @@ -301,7 +301,7 @@ public class PowerNode extends PowerBlock{ } @Override - public boolean onConfigureTileTapped(Tilec other){ + public boolean onConfigureTileTapped(Building other){ if(linkValid(this, other)){ configure(other.pos()); return false; @@ -346,7 +346,7 @@ public class PowerNode extends PowerBlock{ for(int x = (int)(tile.x - laserRange - 2); x <= tile.x + laserRange + 2; x++){ for(int y = (int)(tile.y - laserRange - 2); y <= tile.y + laserRange + 2; y++){ - Tilec link = world.ent(x, y); + Building link = world.ent(x, y); if(link != this && linkValid(this, link, false)){ boolean linked = linked(link); @@ -370,7 +370,7 @@ public class PowerNode extends PowerBlock{ Draw.z(Layer.power); for(int i = 0; i < power.links.size; i++){ - Tilec link = world.ent(power.links.get(i)); + Building link = world.ent(power.links.get(i)); if(!linkValid(this, link)) continue; @@ -382,11 +382,11 @@ public class PowerNode extends PowerBlock{ Draw.reset(); } - protected boolean linked(Tilec other){ + protected boolean linked(Building other){ return power.links.contains(other.pos()); } - protected void drawLaserTo(Tilec target){ + protected void drawLaserTo(Building target){ drawLaser(team, x, y, target.x(), target.y(), power.graph.getSatisfaction(), size, target.block().size); } diff --git a/core/src/mindustry/world/blocks/production/Drill.java b/core/src/mindustry/world/blocks/production/Drill.java index 264f0fa96b..cd827ade21 100644 --- a/core/src/mindustry/world/blocks/production/Drill.java +++ b/core/src/mindustry/world/blocks/production/Drill.java @@ -205,7 +205,7 @@ public class Drill extends Block{ return drops != null && drops.hardness <= tier; } - public class DrillEntity extends TileEntity{ + public class DrillEntity extends Building{ public float progress; public int index; public float warmup; diff --git a/core/src/mindustry/world/blocks/production/GenericCrafter.java b/core/src/mindustry/world/blocks/production/GenericCrafter.java index c70c08973c..33665e3a81 100644 --- a/core/src/mindustry/world/blocks/production/GenericCrafter.java +++ b/core/src/mindustry/world/blocks/production/GenericCrafter.java @@ -79,7 +79,7 @@ public class GenericCrafter extends Block{ return outputItem != null; } - public class GenericCrafterEntity extends TileEntity{ + public class GenericCrafterEntity extends Building{ public float progress; public float totalProgress; public float warmup; diff --git a/core/src/mindustry/world/blocks/production/Incinerator.java b/core/src/mindustry/world/blocks/production/Incinerator.java index 4f0d2c910d..8fc5e660a7 100644 --- a/core/src/mindustry/world/blocks/production/Incinerator.java +++ b/core/src/mindustry/world/blocks/production/Incinerator.java @@ -22,7 +22,7 @@ public class Incinerator extends Block{ solid = true; } - public class IncineratorEntity extends TileEntity{ + public class IncineratorEntity extends Building{ public float heat; @Override @@ -54,26 +54,26 @@ public class Incinerator extends Block{ } @Override - public void handleItem(Tilec source, Item item){ + public void handleItem(Building source, Item item){ if(Mathf.chance(0.3)){ effect.at(x, y); } } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return heat > 0.5f; } @Override - public void handleLiquid(Tilec source, Liquid liquid, float amount){ + public void handleLiquid(Building source, Liquid liquid, float amount){ if(Mathf.chance(0.02)){ effect.at(x, y); } } @Override - public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){ + public boolean acceptLiquid(Building source, Liquid liquid, float amount){ return heat > 0.5f; } } diff --git a/core/src/mindustry/world/blocks/production/PayloadAcceptor.java b/core/src/mindustry/world/blocks/production/PayloadAcceptor.java index 694472734d..52918c3394 100644 --- a/core/src/mindustry/world/blocks/production/PayloadAcceptor.java +++ b/core/src/mindustry/world/blocks/production/PayloadAcceptor.java @@ -26,9 +26,9 @@ public class PayloadAcceptor extends Block{ update = true; } - public static boolean blends(Tilec tile, int direction){ + public static boolean blends(Building tile, int direction){ int size = tile.block().size; - Tilec accept = tile.nearby(Geometry.d4(direction).x * size, Geometry.d4(direction).y * size); + Building accept = tile.nearby(Geometry.d4(direction).x * size, Geometry.d4(direction).y * size); return accept != null && accept.block().outputsPayload && @@ -46,18 +46,18 @@ public class PayloadAcceptor extends Block{ ); } - public class PayloadAcceptorEntity extends TileEntity{ + public class PayloadAcceptorEntity extends Building{ public @Nullable T payload; public Vec2 payVector = new Vec2(); public float payRotation; @Override - public boolean acceptPayload(Tilec source, Payload payload){ + public boolean acceptPayload(Building source, Payload payload){ return this.payload == null; } @Override - public void handlePayload(Tilec source, Payload payload){ + public void handlePayload(Building source, Payload payload){ this.payload = (T)payload; this.payVector.set(source).sub(this).clamp(-size * tilesize / 2f, size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f); this.payRotation = source.angleTo(this); @@ -105,7 +105,7 @@ public class PayloadAcceptor extends Block{ if(payVector.len() >= size * tilesize/2f){ payVector.clamp(-size * tilesize / 2f, size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f); - Tilec front = front(); + Building front = front(); if(front != null && front.block().outputsPayload){ if(movePayload(payload)){ payload = null; diff --git a/core/src/mindustry/world/blocks/production/Separator.java b/core/src/mindustry/world/blocks/production/Separator.java index 1a4c1f0f54..9af39e8685 100644 --- a/core/src/mindustry/world/blocks/production/Separator.java +++ b/core/src/mindustry/world/blocks/production/Separator.java @@ -51,7 +51,7 @@ public class Separator extends Block{ stats.add(BlockStat.productionTime, craftTime / 60f, StatUnit.seconds); } - public class SeparatorEntity extends TileEntity{ + public class SeparatorEntity extends Building{ public float progress; public float totalProgress; public float warmup; @@ -130,7 +130,7 @@ public class Separator extends Block{ } @Override - public boolean canDump(Tilec to, Item item){ + public boolean canDump(Building to, Item item){ return !consumes.itemFilters.get(item.id); } diff --git a/core/src/mindustry/world/blocks/sandbox/ItemSource.java b/core/src/mindustry/world/blocks/sandbox/ItemSource.java index c4fa61590a..96951cdb0b 100644 --- a/core/src/mindustry/world/blocks/sandbox/ItemSource.java +++ b/core/src/mindustry/world/blocks/sandbox/ItemSource.java @@ -44,7 +44,7 @@ public class ItemSource extends Block{ return true; } - public class ItemSourceEntity extends TileEntity{ + public class ItemSourceEntity extends Building{ Item outputItem; @Override @@ -73,7 +73,7 @@ public class ItemSource extends Block{ } @Override - public boolean onConfigureTileTapped(Tilec other){ + public boolean onConfigureTileTapped(Building other){ if(this == other){ deselect(); configure(null); @@ -84,7 +84,7 @@ public class ItemSource extends Block{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return false; } diff --git a/core/src/mindustry/world/blocks/sandbox/ItemVoid.java b/core/src/mindustry/world/blocks/sandbox/ItemVoid.java index 8d36d339b1..8c8bbc75b3 100644 --- a/core/src/mindustry/world/blocks/sandbox/ItemVoid.java +++ b/core/src/mindustry/world/blocks/sandbox/ItemVoid.java @@ -11,12 +11,12 @@ public class ItemVoid extends Block{ update = solid = acceptsItems = true; } - public class ItemVoidEntity extends TileEntity{ + public class ItemVoidEntity extends Building{ @Override - public void handleItem(Tilec source, Item item){} + public void handleItem(Building source, Item item){} @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return true; } } diff --git a/core/src/mindustry/world/blocks/sandbox/LiquidSource.java b/core/src/mindustry/world/blocks/sandbox/LiquidSource.java index 178a41db41..2d46d68da4 100644 --- a/core/src/mindustry/world/blocks/sandbox/LiquidSource.java +++ b/core/src/mindustry/world/blocks/sandbox/LiquidSource.java @@ -41,7 +41,7 @@ public class LiquidSource extends Block{ drawRequestConfigCenter(req, req.config, "center"); } - public class LiquidSourceEntity extends TileEntity{ + public class LiquidSourceEntity extends Building{ public @Nullable Liquid source = null; @Override @@ -71,7 +71,7 @@ public class LiquidSource extends Block{ } @Override - public boolean onConfigureTileTapped(Tilec other){ + public boolean onConfigureTileTapped(Building other){ if(this == other){ deselect(); configure(null); diff --git a/core/src/mindustry/world/blocks/sandbox/LiquidVoid.java b/core/src/mindustry/world/blocks/sandbox/LiquidVoid.java index 49c523f749..2da9b3b7a0 100644 --- a/core/src/mindustry/world/blocks/sandbox/LiquidVoid.java +++ b/core/src/mindustry/world/blocks/sandbox/LiquidVoid.java @@ -19,14 +19,14 @@ public class LiquidVoid extends Block{ bars.remove("liquid"); } - public class LiquidVoidEntity extends TileEntity{ + public class LiquidVoidEntity extends Building{ @Override - public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){ + public boolean acceptLiquid(Building source, Liquid liquid, float amount){ return true; } @Override - public void handleLiquid(Tilec source, Liquid liquid, float amount){ + public void handleLiquid(Building source, Liquid liquid, float amount){ } } diff --git a/core/src/mindustry/world/blocks/storage/CoreBlock.java b/core/src/mindustry/world/blocks/storage/CoreBlock.java index 571a09b8b2..9b2db5e040 100644 --- a/core/src/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/mindustry/world/blocks/storage/CoreBlock.java @@ -49,7 +49,7 @@ public class CoreBlock extends StorageBlock{ } @Remote(called = Loc.server) - public static void onPlayerSpawn(Tile tile, Playerc player){ + public static void onPlayerSpawn(Tile tile, Player player){ if(player == null || tile == null) return; CoreEntity entity = tile.ent(); @@ -57,7 +57,7 @@ public class CoreBlock extends StorageBlock{ Fx.spawn.at(entity); if(!net.client()){ - Unitc unit = block.unitType.create(tile.team()); + Unit unit = block.unitType.create(tile.team()); unit.set(entity); unit.rotation(90f); unit.impulse(0f, 3f); @@ -91,7 +91,7 @@ public class CoreBlock extends StorageBlock{ return false; } - public class CoreEntity extends TileEntity implements ControlBlock{ + public class CoreEntity extends Building implements ControlBlock{ public int storageCapacity; //note that this unit is never actually used for control; the possession handler makes the player respawn when this unit is controlled public @NonNull BlockUnitc unit = Nulls.blockUnit; @@ -103,11 +103,11 @@ public class CoreBlock extends StorageBlock{ } @Override - public Unitc unit(){ - return unit; + public Unit unit(){ + return (Unit)unit; } - public void requestSpawn(Playerc player){ + public void requestSpawn(Player player){ Call.onPlayerSpawn(tile, player); } @@ -126,7 +126,7 @@ public class CoreBlock extends StorageBlock{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return items.get(item) < getMaximumAccepted(item); } @@ -137,7 +137,7 @@ public class CoreBlock extends StorageBlock{ @Override public void onProximityUpdate(){ - for(Tilec other : state.teams.cores(team)){ + for(Building other : state.teams.cores(team)){ if(other.tile() != tile){ items(other.items()); } @@ -150,7 +150,7 @@ public class CoreBlock extends StorageBlock{ ((StorageBlockEntity)t).linkedCore = this; }); - for(Tilec other : state.teams.cores(team)){ + for(Building other : state.teams.cores(team)){ if(other.tile() == tile) continue; storageCapacity += other.block().itemCapacity + other.proximity().sum(e -> isContainer(e) && owns(other, e) ? e.block().itemCapacity : 0); } @@ -169,7 +169,7 @@ public class CoreBlock extends StorageBlock{ @Override public void drawSelect(){ Lines.stroke(1f, Pal.accent); - Cons outline = t -> { + Cons outline = t -> { for(int i = 0; i < 4; i++){ Point2 p = Geometry.d8edge[i]; float offset = -Math.max(t.block().size - 1, 0) / 2f * tilesize; @@ -184,15 +184,15 @@ public class CoreBlock extends StorageBlock{ } - public boolean isContainer(Tilec tile){ + public boolean isContainer(Building tile){ return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == this || ((StorageBlockEntity)tile).linkedCore == null); } - public boolean owns(Tilec tile){ + public boolean owns(Building tile){ return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == this || ((StorageBlockEntity)tile).linkedCore == null); } - public boolean owns(Tilec core, Tilec tile){ + public boolean owns(Building core, Building tile){ return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == core || ((StorageBlockEntity)tile).linkedCore == null); } @@ -237,7 +237,7 @@ public class CoreBlock extends StorageBlock{ } @Override - public void handleItem(Tilec source, Item item){ + public void handleItem(Building source, Item item){ if(net.server() || !net.active()){ super.handleItem(source, item); if(state.rules.tutorial){ diff --git a/core/src/mindustry/world/blocks/storage/MessageBlock.java b/core/src/mindustry/world/blocks/storage/MessageBlock.java index a6adb2e411..61d8fc93fc 100644 --- a/core/src/mindustry/world/blocks/storage/MessageBlock.java +++ b/core/src/mindustry/world/blocks/storage/MessageBlock.java @@ -54,7 +54,7 @@ public class MessageBlock extends Block{ }); } - public class MessageBlockEntity extends TileEntity{ + public class MessageBlockEntity extends Building{ public String message = ""; public String[] lines = {""}; diff --git a/core/src/mindustry/world/blocks/storage/StorageBlock.java b/core/src/mindustry/world/blocks/storage/StorageBlock.java index efa6abdf8a..81f9e47f79 100644 --- a/core/src/mindustry/world/blocks/storage/StorageBlock.java +++ b/core/src/mindustry/world/blocks/storage/StorageBlock.java @@ -20,11 +20,11 @@ public abstract class StorageBlock extends Block{ return false; } - public class StorageBlockEntity extends TileEntity{ - protected @Nullable Tilec linkedCore; + public class StorageBlockEntity extends Building{ + protected @Nullable Building linkedCore; @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return linkedCore != null ? linkedCore.acceptItem(source, item) : items.get(item) < getMaximumAccepted(item); } diff --git a/core/src/mindustry/world/blocks/storage/Unloader.java b/core/src/mindustry/world/blocks/storage/Unloader.java index 2611328563..c6e2fb2132 100644 --- a/core/src/mindustry/world/blocks/storage/Unloader.java +++ b/core/src/mindustry/world/blocks/storage/Unloader.java @@ -42,14 +42,14 @@ public class Unloader extends Block{ bars.remove("items"); } - public class UnloaderEntity extends TileEntity{ + public class UnloaderEntity extends Building{ public Item sortItem = null; - public Tilec dumpingTo; + public Building dumpingTo; @Override public void updateTile(){ if(timer(timerUnload, speed / timeScale())){ - for(Tilec other : proximity){ + for(Building other : proximity){ if(other.interactable(team) && other.block().unloadable && other.block().hasItems && ((sortItem == null && other.items().total() > 0) || (sortItem != null && other.items().has(sortItem)))){ //make sure the item can't be dumped back into this block @@ -86,7 +86,7 @@ public class Unloader extends Block{ } @Override - public boolean onConfigureTileTapped(Tilec other){ + public boolean onConfigureTileTapped(Building other){ if(this == other){ deselect(); configure(null); @@ -97,7 +97,7 @@ public class Unloader extends Block{ } @Override - public boolean canDump(Tilec to, Item item){ + public boolean canDump(Building to, Item item){ return !(to.block() instanceof StorageBlock) && to != dumpingTo; } diff --git a/core/src/mindustry/world/blocks/units/Reconstructor.java b/core/src/mindustry/world/blocks/units/Reconstructor.java index 5783f9f3d6..38e02628d3 100644 --- a/core/src/mindustry/world/blocks/units/Reconstructor.java +++ b/core/src/mindustry/world/blocks/units/Reconstructor.java @@ -71,7 +71,7 @@ public class Reconstructor extends UnitBlock{ } @Override - public boolean acceptPayload(Tilec source, Payload payload){ + public boolean acceptPayload(Building source, Payload payload){ return this.payload == null && relativeTo(source) != rotation() && payload instanceof UnitPayload diff --git a/core/src/mindustry/world/blocks/units/RepairPoint.java b/core/src/mindustry/world/blocks/units/RepairPoint.java index 971a9c6ec6..342e2e8375 100644 --- a/core/src/mindustry/world/blocks/units/RepairPoint.java +++ b/core/src/mindustry/world/blocks/units/RepairPoint.java @@ -59,7 +59,7 @@ public class RepairPoint extends Block{ return new TextureRegion[]{baseRegion, region}; } - public class RepairPointEntity extends TileEntity{ + public class RepairPointEntity extends Building{ public Unitc target; public float strength, rotation = 90; @@ -107,7 +107,7 @@ public class RepairPoint extends Block{ if(timer(timerTarget, 20)){ rect.setSize(repairRadius * 2).setCenter(x, y); - target = Units.closest(team, x, y, repairRadius, Unitc::damaged); + target = Units.closest(team, x, y, repairRadius, Unit::damaged); } } diff --git a/core/src/mindustry/world/blocks/units/ResupplyPoint.java b/core/src/mindustry/world/blocks/units/ResupplyPoint.java index c12a8d49e3..c58847f94c 100644 --- a/core/src/mindustry/world/blocks/units/ResupplyPoint.java +++ b/core/src/mindustry/world/blocks/units/ResupplyPoint.java @@ -33,7 +33,7 @@ public class ResupplyPoint extends Block{ Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.placing); } - public class ResupplyPointEntity extends TileEntity{ + public class ResupplyPointEntity extends Building{ @Override public void drawSelect(){ @@ -50,10 +50,10 @@ public class ResupplyPoint extends Block{ /** Tries to resupply nearby units. * @return whether resupplying was successful. If unit ammo is disabled, always returns false. */ - public static boolean resupply(TileEntity tile, float range, int ammoAmount, Color ammoColor){ + public static boolean resupply(Building tile, float range, int ammoAmount, Color ammoColor){ if(!state.rules.unitAmmo) return false; - Unitc unit = Units.closest(tile.team, tile.x, tile.y, range, u -> u.ammo() <= u.type().ammoCapacity - ammoAmount); + Unit unit = Units.closest(tile.team, tile.x, tile.y, range, u -> u.ammo() <= u.type().ammoCapacity - ammoAmount); if(unit != null){ Fx.itemTransfer.at(tile.x, tile.y, ammoAmount / 2f, ammoColor, unit); unit.ammo(Math.min(unit.ammo() + ammoAmount, unit.type().ammoCapacity)); diff --git a/core/src/mindustry/world/blocks/units/UnitBlock.java b/core/src/mindustry/world/blocks/units/UnitBlock.java index a9d2e863b8..6702bcaa58 100644 --- a/core/src/mindustry/world/blocks/units/UnitBlock.java +++ b/core/src/mindustry/world/blocks/units/UnitBlock.java @@ -40,7 +40,7 @@ public class UnitBlock extends PayloadAcceptor{ Fx.smeltsmoke.at(x + Tmp.v1.x, y + Tmp.v1.y); if(!net.client() && payload != null){ - Unitc unit = payload.unit; + Unit unit = payload.unit; unit.set(x, y); unit.rotation(rotdeg()); unit.vel().trns(rotdeg(), payloadSpeed * 2f).add(Mathf.range(0.3f), Mathf.range(0.3f)); diff --git a/core/src/mindustry/world/blocks/units/UnitFactory.java b/core/src/mindustry/world/blocks/units/UnitFactory.java index 6567054ffd..7b9226df54 100644 --- a/core/src/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/mindustry/world/blocks/units/UnitFactory.java @@ -117,7 +117,7 @@ public class UnitFactory extends UnitBlock{ } @Override - public boolean acceptPayload(Tilec source, Payload payload){ + public boolean acceptPayload(Building source, Payload payload){ return false; } @@ -202,7 +202,7 @@ public class UnitFactory extends UnitBlock{ } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return currentPlan != -1 && items.get(item) < getMaximumAccepted(item) && Structs.contains(plans[currentPlan].requirements, stack -> stack.item == item); } diff --git a/core/src/mindustry/world/consumers/Consume.java b/core/src/mindustry/world/consumers/Consume.java index c37c5ab668..7e0f686018 100644 --- a/core/src/mindustry/world/consumers/Consume.java +++ b/core/src/mindustry/world/consumers/Consume.java @@ -58,16 +58,16 @@ public abstract class Consume{ public abstract ConsumeType type(); - public abstract void build(Tilec tile, Table table); + public abstract void build(Building tile, Table table); /** Called when a consumption is triggered manually. */ - public void trigger(Tilec entity){} + public void trigger(Building entity){} public abstract String getIcon(); - public abstract void update(Tilec entity); + public abstract void update(Building entity); - public abstract boolean valid(Tilec entity); + public abstract boolean valid(Building entity); public abstract void display(BlockStats stats); } diff --git a/core/src/mindustry/world/consumers/ConsumeItemDynamic.java b/core/src/mindustry/world/consumers/ConsumeItemDynamic.java index d85e38ea5d..cc68185fd3 100644 --- a/core/src/mindustry/world/consumers/ConsumeItemDynamic.java +++ b/core/src/mindustry/world/consumers/ConsumeItemDynamic.java @@ -11,10 +11,10 @@ import mindustry.ui.*; import mindustry.world.meta.*; public class ConsumeItemDynamic extends Consume{ - public final @NonNull Func items; + public final @NonNull Func items; - public ConsumeItemDynamic(Func items){ - this.items = (Func)items; + public ConsumeItemDynamic(Func items){ + this.items = (Func)items; } @Override @@ -28,7 +28,7 @@ public class ConsumeItemDynamic extends Consume{ } @Override - public void build(Tilec tile, Table table){ + public void build(Building tile, Table table){ ItemStack[][] current = {items.get(tile)}; table.update(() -> { @@ -41,10 +41,10 @@ public class ConsumeItemDynamic extends Consume{ rebuild(tile, table); } - private void rebuild(Tilec tile, Table table){ + private void rebuild(Building tile, Table table){ for(ItemStack stack : items.get(tile)){ table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount), - () -> tile.items() != null && tile.items().has(stack.item, stack.amount))).size(8 * 4).padRight(6 * Mathf.digits(stack.amount)); + () -> tile.items != null && tile.items.has(stack.item, stack.amount))).size(8 * 4).padRight(6 * Mathf.digits(stack.amount)); } } @@ -54,20 +54,20 @@ public class ConsumeItemDynamic extends Consume{ } @Override - public void update(Tilec entity){ + public void update(Building entity){ } @Override - public void trigger(Tilec entity){ + public void trigger(Building entity){ for(ItemStack stack : items.get(entity)){ - entity.items().remove(stack); + entity.items.remove(stack); } } @Override - public boolean valid(Tilec entity){ - return entity.items() != null && entity.items().has(items.get(entity)); + public boolean valid(Building entity){ + return entity.items != null && entity.items.has(items.get(entity)); } @Override diff --git a/core/src/mindustry/world/consumers/ConsumeItemFilter.java b/core/src/mindustry/world/consumers/ConsumeItemFilter.java index 2ff850f843..a8b3cf1292 100644 --- a/core/src/mindustry/world/consumers/ConsumeItemFilter.java +++ b/core/src/mindustry/world/consumers/ConsumeItemFilter.java @@ -31,10 +31,10 @@ public class ConsumeItemFilter extends Consume{ } @Override - public void build(Tilec tile, Table table){ + public void build(Building tile, Table table){ MultiReqImage image = new MultiReqImage(); content.items().each(i -> filter.get(i) && i.unlockedNow(), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), - () -> tile.items() != null && tile.items().has(item)))); + () -> tile.items != null && tile.items.has(item)))); table.add(image).size(8 * 4); } @@ -45,26 +45,26 @@ public class ConsumeItemFilter extends Consume{ } @Override - public void update(Tilec entity){ + public void update(Building entity){ } @Override - public void trigger(Tilec entity){ + public void trigger(Building entity){ for(int i = 0; i < content.items().size; i++){ Item item = content.item(i); - if(entity.items() != null && entity.items().has(item) && this.filter.get(item)){ - entity.items().remove(item, 1); + if(entity.items != null && entity.items.has(item) && this.filter.get(item)){ + entity.items.remove(item, 1); break; } } } @Override - public boolean valid(Tilec entity){ + public boolean valid(Building entity){ for(int i = 0; i < content.items().size; i++){ Item item = content.item(i); - if(entity.items() != null && entity.items().has(item) && this.filter.get(item)){ + if(entity.items != null && entity.items.has(item) && this.filter.get(item)){ return true; } } diff --git a/core/src/mindustry/world/consumers/ConsumeItems.java b/core/src/mindustry/world/consumers/ConsumeItems.java index bd916b81e4..53eb92ebae 100644 --- a/core/src/mindustry/world/consumers/ConsumeItems.java +++ b/core/src/mindustry/world/consumers/ConsumeItems.java @@ -35,10 +35,10 @@ public class ConsumeItems extends Consume{ } @Override - public void build(Tilec tile, Table table){ + public void build(Building tile, Table table){ for(ItemStack stack : items){ table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount), - () -> tile.items() != null && tile.items().has(stack.item, stack.amount))).size(8 * 4).padRight(Mathf.digits(stack.amount) * 6); + () -> tile.items != null && tile.items.has(stack.item, stack.amount))).size(8 * 4).padRight(Mathf.digits(stack.amount) * 6); } } @@ -48,20 +48,20 @@ public class ConsumeItems extends Consume{ } @Override - public void update(Tilec entity){ + public void update(Building entity){ } @Override - public void trigger(Tilec entity){ + public void trigger(Building entity){ for(ItemStack stack : items){ - entity.items().remove(stack); + entity.items.remove(stack); } } @Override - public boolean valid(Tilec entity){ - return entity.items() != null && entity.items().has(items); + public boolean valid(Building entity){ + return entity.items != null && entity.items.has(items); } @Override diff --git a/core/src/mindustry/world/consumers/ConsumeLiquid.java b/core/src/mindustry/world/consumers/ConsumeLiquid.java index d918a4a812..ae9998db12 100644 --- a/core/src/mindustry/world/consumers/ConsumeLiquid.java +++ b/core/src/mindustry/world/consumers/ConsumeLiquid.java @@ -26,7 +26,7 @@ public class ConsumeLiquid extends ConsumeLiquidBase{ } @Override - public void build(Tilec tile, Table table){ + public void build(Building tile, Table table){ table.add(new ReqImage(liquid.icon(Cicon.medium), () -> valid(tile))).size(8 * 4); } @@ -36,13 +36,13 @@ public class ConsumeLiquid extends ConsumeLiquidBase{ } @Override - public void update(Tilec entity){ - entity.liquids().remove(liquid, Math.min(use(entity), entity.liquids().get(liquid))); + public void update(Building entity){ + entity.liquids.remove(liquid, Math.min(use(entity), entity.liquids.get(liquid))); } @Override - public boolean valid(Tilec entity){ - return entity != null && entity.liquids() != null && entity.liquids().get(liquid) >= use(entity); + public boolean valid(Building entity){ + return entity != null && entity.liquids != null && entity.liquids.get(liquid) >= use(entity); } @Override diff --git a/core/src/mindustry/world/consumers/ConsumeLiquidBase.java b/core/src/mindustry/world/consumers/ConsumeLiquidBase.java index 867d2fe0fd..323a2897ac 100644 --- a/core/src/mindustry/world/consumers/ConsumeLiquidBase.java +++ b/core/src/mindustry/world/consumers/ConsumeLiquidBase.java @@ -22,7 +22,7 @@ public abstract class ConsumeLiquidBase extends Consume{ return ConsumeType.liquid; } - protected float use(Tilec entity){ + protected float use(Building entity){ return Math.min(amount * entity.delta(), entity.block().liquidCapacity); } } diff --git a/core/src/mindustry/world/consumers/ConsumeLiquidFilter.java b/core/src/mindustry/world/consumers/ConsumeLiquidFilter.java index 962986905a..ca57bfa816 100644 --- a/core/src/mindustry/world/consumers/ConsumeLiquidFilter.java +++ b/core/src/mindustry/world/consumers/ConsumeLiquidFilter.java @@ -28,10 +28,10 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{ } @Override - public void build(Tilec tile, Table table){ + public void build(Building tile, Table table){ Seq list = content.liquids().select(l -> !l.isHidden() && filter.get(l)); MultiReqImage image = new MultiReqImage(); - list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.liquids() != null && tile.liquids().get(liquid) >= use(tile)))); + list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.liquids != null && tile.liquids.get(liquid) >= use(tile)))); table.add(image).size(8 * 4); } @@ -42,13 +42,13 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{ } @Override - public void update(Tilec entity){ - entity.liquids().remove(entity.liquids().current(), use(entity)); + public void update(Building entity){ + entity.liquids.remove(entity.liquids.current(), use(entity)); } @Override - public boolean valid(Tilec entity){ - return entity != null && entity.liquids() != null && filter.get(entity.liquids().current()) && entity.liquids().currentAmount() >= use(entity); + public boolean valid(Building entity){ + return entity != null && entity.liquids != null && filter.get(entity.liquids.current()) && entity.liquids.currentAmount() >= use(entity); } @Override diff --git a/core/src/mindustry/world/consumers/ConsumePower.java b/core/src/mindustry/world/consumers/ConsumePower.java index 80e1effb16..5ba9dcf159 100644 --- a/core/src/mindustry/world/consumers/ConsumePower.java +++ b/core/src/mindustry/world/consumers/ConsumePower.java @@ -30,7 +30,7 @@ public class ConsumePower extends Consume{ } @Override - public void build(Tilec tile, Table table){ + public void build(Building tile, Table table){ //No tooltip for power, for now } @@ -40,16 +40,16 @@ public class ConsumePower extends Consume{ } @Override - public void update(Tilec entity){ - // Nothing to do since PowerGraph directly updates entity.power().status + public void update(Building entity){ + // Nothing to do since PowerGraph directly updates entity.power.status } @Override - public boolean valid(Tilec entity){ + public boolean valid(Building entity){ if(buffered){ return true; }else{ - return entity.power().status > 0f; + return entity.power.status > 0f; } } @@ -67,10 +67,10 @@ public class ConsumePower extends Consume{ * @param entity The entity which contains the power module. * @return The amount of power which is requested per tick. */ - public float requestedPower(Tilec entity){ + public float requestedPower(Building entity){ if(entity.tile().entity == null) return 0f; if(buffered){ - return (1f-entity.power().status)*capacity; + return (1f-entity.power.status)*capacity; }else{ try{ return usage * Mathf.num(entity.shouldConsume()); diff --git a/core/src/mindustry/world/consumers/Consumers.java b/core/src/mindustry/world/consumers/Consumers.java index a5aff9f277..febf111f53 100644 --- a/core/src/mindustry/world/consumers/Consumers.java +++ b/core/src/mindustry/world/consumers/Consumers.java @@ -52,7 +52,7 @@ public class Consumers{ } /** Creates a consumer which only consumes power when the condition is met. */ - public ConsumePower powerCond(float usage, Boolf cons){ + public ConsumePower powerCond(float usage, Boolf cons){ return add(new ConditionalConsumePower(usage, cons)); } diff --git a/core/src/mindustry/world/meta/BlockBars.java b/core/src/mindustry/world/meta/BlockBars.java index eb0e3e88a3..d96202ad1d 100644 --- a/core/src/mindustry/world/meta/BlockBars.java +++ b/core/src/mindustry/world/meta/BlockBars.java @@ -6,10 +6,10 @@ import mindustry.gen.*; import mindustry.ui.Bar; public class BlockBars{ - private OrderedMap> bars = new OrderedMap<>(); + private OrderedMap> bars = new OrderedMap<>(); - public void add(String name, Func sup){ - bars.put(name, (Func)sup); + public void add(String name, Func sup){ + bars.put(name, (Func)sup); } public void remove(String name){ @@ -18,7 +18,7 @@ public class BlockBars{ bars.remove(name); } - public Iterable> list(){ + public Iterable> list(){ return bars.values(); } } diff --git a/core/src/mindustry/world/meta/Producers.java b/core/src/mindustry/world/meta/Producers.java index c54a5172f5..56abff88d6 100644 --- a/core/src/mindustry/world/meta/Producers.java +++ b/core/src/mindustry/world/meta/Producers.java @@ -11,6 +11,6 @@ public class Producers{ } interface Produce{ - void add(Tilec entity); + void add(Building entity); } } diff --git a/core/src/mindustry/world/modules/ConsumeModule.java b/core/src/mindustry/world/modules/ConsumeModule.java index fc1936be2a..4d4fc6e522 100644 --- a/core/src/mindustry/world/modules/ConsumeModule.java +++ b/core/src/mindustry/world/modules/ConsumeModule.java @@ -7,9 +7,9 @@ import mindustry.world.meta.*; public class ConsumeModule extends BlockModule{ private boolean valid, optionalValid; - private final Tilec entity; + private final Building entity; - public ConsumeModule(Tilec entity){ + public ConsumeModule(Building entity){ this.entity = entity; } diff --git a/desktop/src/mindustry/desktop/steam/SStats.java b/desktop/src/mindustry/desktop/steam/SStats.java index 4beb269bb5..55fed530fa 100644 --- a/desktop/src/mindustry/desktop/steam/SStats.java +++ b/desktop/src/mindustry/desktop/steam/SStats.java @@ -64,8 +64,8 @@ public class SStats implements SteamUserStatsCallback{ active50Crawlers.complete(); } - for(Tilec entity : player.team().cores()){ - if(!content.items().contains(i -> i.type == ItemType.material && entity.items().get(i) < entity.block().itemCapacity)){ + for(Building entity : player.team().cores()){ + if(!content.items().contains(i -> i.type == ItemType.material && entity.items.get(i) < entity.block().itemCapacity)){ fillCoreAllCampaign.complete(); break; } @@ -79,7 +79,7 @@ public class SStats implements SteamUserStatsCallback{ if(e.unit.team() != Vars.player.team()){ SStat.unitsDestroyed.add(); - if(e.unit instanceof Unitc && ((Unitc)e.unit).isBoss()){ + if(e.unit instanceof Unit && ((Unit)e.unit).isBoss()){ SStat.bossesDefeated.add(); } } diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 5fcb4ceece..aaa61df39d 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -290,7 +290,7 @@ public class ServerControl implements ApplicationListener{ if(Groups.player.size() > 0){ info(" &lyPlayers: @", Groups.player.size()); - for(Playerc p : Groups.player){ + for(Player p : Groups.player){ info(" &y@ / @", p.name(), p.uuid()); } }else{ @@ -577,7 +577,7 @@ public class ServerControl implements ApplicationListener{ return; } - Playerc target = Groups.player.find(p -> p.name().equals(arg[0])); + Player target = Groups.player.find(p -> p.name().equals(arg[0])); if(target != null){ Call.sendMessage("[scarlet] " + target.name() + "[scarlet] has been kicked by the server."); @@ -593,7 +593,7 @@ public class ServerControl implements ApplicationListener{ netServer.admins.banPlayerID(arg[1]); info("Banned."); }else if(arg[0].equals("name")){ - Playerc target = Groups.player.find(p -> p.name().equalsIgnoreCase(arg[1])); + Player target = Groups.player.find(p -> p.name().equalsIgnoreCase(arg[1])); if(target != null){ netServer.admins.banPlayer(target.uuid()); info("Banned."); @@ -607,7 +607,7 @@ public class ServerControl implements ApplicationListener{ err("Invalid type."); } - for(Playerc player : Groups.player){ + for(Player player : Groups.player){ if(netServer.admins.isIDBanned(player.uuid())){ Call.sendMessage("[scarlet] " + player.name() + " has been banned."); player.con().kick(KickReason.banned); @@ -677,7 +677,7 @@ public class ServerControl implements ApplicationListener{ boolean add = arg[0].equals("add"); PlayerInfo target; - Playerc playert = Groups.player.find(p -> p.name().equalsIgnoreCase(arg[1])); + Player playert = Groups.player.find(p -> p.name().equalsIgnoreCase(arg[1])); if(playert != null){ target = playert.getInfo(); }else{ @@ -716,7 +716,7 @@ public class ServerControl implements ApplicationListener{ info("No players are currently in the server."); }else{ info("&lyPlayers: @", Groups.player.size()); - for(Playerc user : Groups.player){ + for(Player user : Groups.player){ PlayerInfo userInfo = user.getInfo(); info(" &lm @ / ID: '@' / IP: '@' / Admin: '@'", userInfo.lastName, userInfo.id, userInfo.lastIP, userInfo.admin); } @@ -879,8 +879,8 @@ public class ServerControl implements ApplicationListener{ private void play(boolean wait, Runnable run){ inExtraRound = true; Runnable r = () -> { - Seq players = new Seq<>(); - for(Playerc p : Groups.player){ + Seq players = new Seq<>(); + for(Player p : Groups.player){ players.add(p); p.clearUnit(); } @@ -892,7 +892,7 @@ public class ServerControl implements ApplicationListener{ state.rules = state.map.applyRules(lastMode); logic.play(); - for(Playerc p : players){ + for(Player p : players){ if(p.con() == null) continue; p.reset(); diff --git a/tests/src/test/java/ApplicationTests.java b/tests/src/test/java/ApplicationTests.java index 1afcce5fa3..9fd4a55f4b 100644 --- a/tests/src/test/java/ApplicationTests.java +++ b/tests/src/test/java/ApplicationTests.java @@ -143,12 +143,12 @@ public class ApplicationTests{ void blockInventories(){ multiblock(); Tile tile = world.tile(4, 4); - tile.entity.items().add(Items.coal, 5); - tile.entity.items().add(Items.titanium, 50); - assertEquals(tile.entity.items().total(), 55); - tile.entity.items().remove(Items.phasefabric, 10); - tile.entity.items().remove(Items.titanium, 10); - assertEquals(tile.entity.items().total(), 45); + tile.entity.items.add(Items.coal, 5); + tile.entity.items.add(Items.titanium, 50); + assertEquals(tile.entity.items.total(), 55); + tile.entity.items.remove(Items.phasefabric, 10); + tile.entity.items.remove(Items.titanium, 10); + assertEquals(tile.entity.items.total(), 45); } @Test @@ -243,8 +243,8 @@ public class ApplicationTests{ updateBlocks(10); - assertTrue(world.tile(2, 1).entity.liquids().currentAmount() >= 1); - assertTrue(world.tile(2, 1).entity.liquids().current() == Liquids.water); + assertTrue(world.tile(2, 1).entity.liquids.currentAmount() >= 1); + assertTrue(world.tile(2, 1).entity.liquids.current() == Liquids.water); } @Test @@ -265,8 +265,8 @@ public class ApplicationTests{ updateBlocks(10); - assertTrue(tank.entity.liquids().currentAmount() >= 1, "Liquid not moved through junction"); - assertTrue(tank.entity.liquids().current() == Liquids.water, "Tank has no water"); + assertTrue(tank.entity.liquids.currentAmount() >= 1, "Liquid not moved through junction"); + assertTrue(tank.entity.liquids.current() == Liquids.water, "Tank has no water"); } @Test @@ -300,9 +300,9 @@ public class ApplicationTests{ //test basic method. Rand r = new Rand(0); - Tilec[] res = {null}; + Building[] res = {null}; - Cons assigner = t -> res[0] = t; + Cons assigner = t -> res[0] = t; int iterations = 100; @@ -369,7 +369,7 @@ public class ApplicationTests{ world.tile(0, 0).setBlock(Blocks.itemSource); world.tile(0, 0).entity.configureAny(Items.copper); - Seq entities = Seq.with(world.tile(0, 0).entity); + Seq entities = Seq.with(world.tile(0, 0).entity); for(int i = 0; i < length; i++){ world.tile(i + 1, 0).setBlock(Blocks.conveyor); @@ -380,29 +380,29 @@ public class ApplicationTests{ world.tile(length + 1, 0).setBlock(new Block("___"){{ hasItems = true; destructible = true; - entityType = () -> new TileEntity(){ + entityType = () -> new Building(){ @Override - public void handleItem(Tilec source, Item item){ + public void handleItem(Building source, Item item){ itemsa[0] ++; } @Override - public boolean acceptItem(Tilec source, Item item){ + public boolean acceptItem(Building source, Item item){ return true; } }; }}); - entities.each(Tilec::updateProximity); + entities.each(Building::updateProximity); //warmup for(int i = 0; i < 100000; i++){ - entities.each(Tilec::update); + entities.each(Building::update); } Time.mark(); for(int i = 0; i < 200000; i++){ - entities.each(Tilec::update); + entities.each(Building::update); } Log.info(Time.elapsed() + "ms to process " + itemsa[0] + " items"); assertNotEquals(0, itemsa[0]); @@ -584,14 +584,14 @@ public class ApplicationTests{ Tile core = world.tile(5, 5); core.setBlock(Blocks.coreShard, Team.sharded, 0); for(Item item : content.items()){ - core.entity.items().set(item, 3000); + core.entity.items.set(item, 3000); } assertEquals(core.entity, state.teams.get(Team.sharded).core()); } void depositTest(Block block, Item item){ - Unitc unit = UnitTypes.spirit.create(Team.derelict); + Unit unit = UnitTypes.spirit.create(Team.derelict); Tile tile = new Tile(0, 0, Blocks.air, Blocks.air, block); int capacity = tile.block().itemCapacity; @@ -601,12 +601,12 @@ public class ApplicationTests{ assertEquals(capacity - 1, deposited); tile.entity.handleStack(item, capacity - 1, unit); - assertEquals(tile.entity.items().get(item), capacity - 1); + assertEquals(tile.entity.items.get(item), capacity - 1); int overflow = tile.entity.acceptStack(item, 10, unit); assertEquals(1, overflow); tile.entity.handleStack(item, 1, unit); - assertEquals(capacity, tile.entity.items().get(item)); + assertEquals(capacity, tile.entity.items.get(item)); } } diff --git a/tests/src/test/java/power/DirectConsumerTests.java b/tests/src/test/java/power/DirectConsumerTests.java index 36770cd951..1b8aa04a8d 100644 --- a/tests/src/test/java/power/DirectConsumerTests.java +++ b/tests/src/test/java/power/DirectConsumerTests.java @@ -28,8 +28,8 @@ public class DirectConsumerTests extends PowerTestFixture{ consumes.power(requestedPower); consumes.items(new ItemStack(Items.silicon, 30), new ItemStack(Items.lead, 30)); }}); - consumerTile.entity.items().add(Items.silicon, siliconAmount); - consumerTile.entity.items().add(Items.lead, leadAmount); + consumerTile.entity.items.add(Items.silicon, siliconAmount); + consumerTile.entity.items.add(Items.lead, leadAmount); Tile producerTile = createFakeTile(2, 0, createFakeProducerBlock(producedPower)); producerTile.ent().productionEfficiency = 1f; @@ -41,6 +41,6 @@ public class DirectConsumerTests extends PowerTestFixture{ consumerTile.entity.update(); graph.update(); - assertEquals(expectedSatisfaction, consumerTile.entity.power().status); + assertEquals(expectedSatisfaction, consumerTile.entity.power.status); }*/ } diff --git a/tests/src/test/java/power/ItemLiquidGeneratorTests.java b/tests/src/test/java/power/ItemLiquidGeneratorTests.java index c2e47f0692..89e730ec63 100644 --- a/tests/src/test/java/power/ItemLiquidGeneratorTests.java +++ b/tests/src/test/java/power/ItemLiquidGeneratorTests.java @@ -88,13 +88,13 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ createGenerator(inputType); assertTrue(entity.acceptLiquid(null, liquid, availableLiquidAmount), inputType + " | " + parameterDescription + ": Liquids which will be declined by the generator don't need to be tested - The code won't be called for those cases."); - entity.liquids().add(liquid, availableLiquidAmount); + entity.liquids.add(liquid, availableLiquidAmount); entity.cons().update(); // Perform an update on the generator once - This should use up any resource up to the maximum liquid usage entity.updateTile(); - assertEquals(expectedRemainingLiquidAmount, entity.liquids().get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch."); + assertEquals(expectedRemainingLiquidAmount, entity.liquids.get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch."); assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch."); } @@ -131,7 +131,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ assertTrue(entity.acceptItem(null, item), inputType + " | " + parameterDescription + ": Items which will be declined by the generator don't need to be tested - The code won't be called for those cases."); if(amount > 0){ - entity.items().add(item, amount); + entity.items.add(item, amount); } entity.cons().update(); @@ -139,7 +139,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ try{ entity.updateTile(); - assertEquals(expectedRemainingItemAmount, entity.items().get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch."); + assertEquals(expectedRemainingItemAmount, entity.items.get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch."); assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch."); }catch(NullPointerException e){ e.printStackTrace(); @@ -163,7 +163,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ createGenerator(inputType); // Burn a single coal and test for the duration - entity.items().add(Items.coal, 1); + entity.items.add(Items.coal, 1); entity.cons().update(); entity.updateTile(); diff --git a/tests/src/test/java/power/PowerTestFixture.java b/tests/src/test/java/power/PowerTestFixture.java index 5307ea9125..5a98ab839d 100644 --- a/tests/src/test/java/power/PowerTestFixture.java +++ b/tests/src/test/java/power/PowerTestFixture.java @@ -58,7 +58,7 @@ public class PowerTestFixture{ protected static Block createFakeDirectConsumer(float powerPerTick){ return new PowerBlock("fakedirectconsumer"){{ - entityType = TileEntity::create; + entityType = Building::create; consumes.power(powerPerTick); }}; } @@ -89,14 +89,14 @@ public class PowerTestFixture{ // Simulate the "changed" method. Calling it through reflections would require half the game to be initialized. tile.entity = block.newEntity().init(tile, Team.sharded, false); if(block.hasPower){ - tile.entity.power().graph = new PowerGraph(){ + tile.entity.power.graph = new PowerGraph(){ //assume there's always something consuming power @Override public float getUsageFraction(){ return 1f; } }; - tile.entity.power().graph.add(tile.entity); + tile.entity.power.graph.add(tile.entity); } // Assign incredibly high health so the block does not get destroyed on e.g. burning Blast Compound diff --git a/tests/src/test/java/power/PowerTests.java b/tests/src/test/java/power/PowerTests.java index d2e7693bcc..a25a163853 100644 --- a/tests/src/test/java/power/PowerTests.java +++ b/tests/src/test/java/power/PowerTests.java @@ -66,7 +66,7 @@ public class PowerTests extends PowerTestFixture{ // Update and check for the expected power status of the consumer powerGraph.update(); - assertEquals(expectedSatisfaction, directConsumerTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match"); + assertEquals(expectedSatisfaction, directConsumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match"); } /** @@ -104,14 +104,14 @@ public class PowerTests extends PowerTestFixture{ } float maxCapacity = 100f; Tile batteryTile = createFakeTile(0, 2, createFakeBattery(maxCapacity)); - batteryTile.entity.power().status = initialBatteryCapacity / maxCapacity; + batteryTile.entity.power.status = initialBatteryCapacity / maxCapacity; powerGraph.add(batteryTile.entity); powerGraph.update(); - assertEquals(expectedBatteryCapacity / maxCapacity, batteryTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Expected battery status did not match"); + assertEquals(expectedBatteryCapacity / maxCapacity, batteryTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Expected battery status did not match"); if(directConsumerTile != null){ - assertEquals(expectedSatisfaction, directConsumerTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match"); + assertEquals(expectedSatisfaction, directConsumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match"); } } @@ -127,13 +127,13 @@ public class PowerTests extends PowerTestFixture{ powerGraph.add(consumerTile.entity); powerGraph.update(); - assertEquals(1.0f, consumerTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR); + assertEquals(1.0f, consumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR); powerGraph.remove(producerTile.entity); powerGraph.add(consumerTile.entity); powerGraph.update(); - assertEquals(0.0f, consumerTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR); + assertEquals(0.0f, consumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR); if(consumerTile.block().consumes.hasPower()){ ConsumePower consumePower = consumerTile.block().consumes.getPower(); assertFalse(consumePower.valid(consumerTile.ent()));