This commit is contained in:
Anuken
2020-06-26 14:27:26 -04:00
parent eabc5c15c7
commit fdf7c88083
228 changed files with 1219 additions and 1163 deletions

View File

@@ -136,6 +136,7 @@ public class EntityProcess extends BaseProcessor{
if(!signatures.contains(cname + "()")){ if(!signatures.contains(cname + "()")){
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC) inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
.addAnnotations(Seq.with(field.annotations()).select(a -> a.toString().contains("Null")).map(AnnotationSpec::get)) .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()) .addJavadoc(field.doc() == null ? "" : field.doc())
.returns(field.tname()).build()); .returns(field.tname()).build());
} }
@@ -146,6 +147,7 @@ public class EntityProcess extends BaseProcessor{
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC) inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
.addJavadoc(field.doc() == null ? "" : field.doc()) .addJavadoc(field.doc() == null ? "" : field.doc())
.addParameter(ParameterSpec.builder(field.tname(), field.name()) .addParameter(ParameterSpec.builder(field.tname(), field.name())
//.addAnnotation(Deprecated.class) //TODO undeprecate
.addAnnotations(Seq.with(field.annotations()) .addAnnotations(Seq.with(field.annotations())
.select(a -> a.toString().contains("Null")).map(AnnotationSpec::get)).build()).build()); .select(a -> a.toString().contains("Null")).map(AnnotationSpec::get)).build()).build());
} }
@@ -185,7 +187,7 @@ public class EntityProcess extends BaseProcessor{
} }
//add interfaces //add interfaces
for(Stype type : depends){ for(Stype type : deps){
base.addSuperinterface(tname(packageName, interfaceName(type))); base.addSuperinterface(tname(packageName, interfaceName(type)));
} }
@@ -222,9 +224,13 @@ public class EntityProcess extends BaseProcessor{
return result; return result;
}); });
//representative component type
Stype repr = types.first();
String groupType = repr.annotation(Component.class).base() ? baseName(repr) : interfaceName(repr);
boolean collides = an.collide(); boolean collides = an.collide();
groupDefs.add(new GroupDefinition(group.name().startsWith("g") ? group.name().substring(1) : group.name(), 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<String, Selement> usedNames = new ObjectMap<>(); ObjectMap<String, Selement> usedNames = new ObjectMap<>();
@@ -232,33 +238,9 @@ public class EntityProcess extends BaseProcessor{
//look at each definition //look at each definition
for(Selement<?> type : allDefs){ for(Selement<?> type : allDefs){
EntityDef ann = type.annotation(EntityDef.class); EntityDef ann = type.annotation(EntityDef.class);
boolean isFinal = ann.isFinal(); 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) //all component classes (not interfaces)
Seq<Stype> components = allComponents(type); Seq<Stype> components = allComponents(type);
Seq<GroupDefinition> groups = groupDefs.select(g -> (!g.components.isEmpty() && !g.components.contains(s -> !components.contains(s))) || g.manualInclusions.contains(type)); Seq<GroupDefinition> 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 //whether the main class is the base itself
boolean typeIsBase = baseClassType != null && type.has(Component.class) && type.annotation(Component.class).base(); 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 //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 //all SyncField fields
Seq<Svar> syncedFields = new Seq<>(); Seq<Svar> syncedFields = new Seq<>();
@@ -401,7 +412,7 @@ public class EntityProcess extends BaseProcessor{
//build method using same params/returns //build method using same params/returns
MethodSpec.Builder mbuilder = MethodSpec.methodBuilder(first.name()).addModifiers(first.is(Modifier.PRIVATE) ? Modifier.PRIVATE : Modifier.PUBLIC); 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(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); if(first.is(Modifier.STATIC)) mbuilder.addModifiers(Modifier.STATIC);
mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get)); mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get));
@@ -536,7 +547,7 @@ public class EntityProcess extends BaseProcessor{
.returns(tname(packageName + "." + name)) .returns(tname(packageName + "." + name))
.addStatement(ann.pooled() ? "return Pools.obtain($L.class, " +name +"::new)" : "return new $L()", name).build()); .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 //generate groups
@@ -686,12 +697,12 @@ public class EntityProcess extends BaseProcessor{
//getter //getter
if(!method.isVoid()){ 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 //setter
if(method.isVoid() && !Seq.with(field.annotations).contains(f -> f.type.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){ 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<Smethod> methods = dependencies.flatMap(Stype::methods); Seq<Smethod> methods = dependencies.flatMap(Stype::methods);
methods.sortComparing(Object::toString); 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 //used method signatures
ObjectSet<String> signatures = new ObjectSet<>(); ObjectSet<String> signatures = new ObjectSet<>();
@@ -719,6 +735,7 @@ public class EntityProcess extends BaseProcessor{
.addModifiers(Modifier.FINAL); .addModifiers(Modifier.FINAL);
nullBuilder.addSuperinterface(interf.tname()); nullBuilder.addSuperinterface(interf.tname());
if(superclass != null) nullBuilder.superclass(tname(baseName(superclass)));
for(Smethod method : methods){ for(Smethod method : methods){
String signature = method.toString(); String signature = method.toString();
@@ -726,6 +743,7 @@ public class EntityProcess extends BaseProcessor{
Stype compType = interfaceToComp(method.type()); Stype compType = interfaceToComp(method.type());
MethodSpec.Builder builder = MethodSpec.overriding(method.e).addModifiers(Modifier.PUBLIC, Modifier.FINAL); MethodSpec.Builder builder = MethodSpec.overriding(method.e).addModifiers(Modifier.PUBLIC, Modifier.FINAL);
builder.addAnnotation(OverrideCallSuper.class); //just in case
if(!method.isVoid()){ if(!method.isVoid()){
if(method.name().equals("isNull")){ if(method.name().equals("isNull")){
@@ -749,7 +767,7 @@ public class EntityProcess extends BaseProcessor{
signatures.add(signature); 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); write(nullBuilder);
} }
@@ -775,9 +793,8 @@ public class EntityProcess extends BaseProcessor{
String baseName(Stype comp){ String baseName(Stype comp){
String suffix = "Comp"; String suffix = "Comp";
if(!comp.name().endsWith(suffix)) err("All components must have names that end with 'Comp'", comp.e); 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){ @Nullable Stype interfaceToComp(Stype type){

View File

@@ -5,9 +5,7 @@ import com.squareup.javapoet.*;
import mindustry.annotations.*; import mindustry.annotations.*;
import mindustry.annotations.util.TypeIOResolver.*; import mindustry.annotations.util.TypeIOResolver.*;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import java.lang.reflect.*;
import java.util.*; import java.util.*;
/** Generates code for reading remote invoke packets on the client and server. */ /** Generates code for reading remote invoke packets on the client and server. */
@@ -39,14 +37,8 @@ public class RemoteReadGenerator{
.returns(void.class); .returns(void.class);
if(needsPlayer){ 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<TypeName> cons = TypeName.class.getDeclaredConstructor(String.class);
cons.setAccessible(true);
TypeName playerType = cons.newInstance("mindustry.gen.Playerc");
//add player parameter //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 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){ if(entry.forward && entry.where.isServer && needsPlayer){
//call forwarded method //call forwarded method
readBlock.addStatement(packageName + "." + entry.className + "." + entry.element.getSimpleName() + 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)"); readBlock.nextControlFlow("catch (java.lang.Exception e)");

View File

@@ -81,8 +81,8 @@ public class RemoteWriteGenerator{
return; return;
} }
if(!elem.getParameters().get(0).asType().toString().contains("Playerc")){ if(!elem.getParameters().get(0).asType().toString().contains("Player")){
BaseProcessor.err("Client invoke methods should have a first parameter of type Playerc", elem); BaseProcessor.err("Client invoke methods should have a first parameter of type Player", elem);
return; return;
} }
} }

View File

@@ -17,6 +17,6 @@ public class SerializerResolver{
} }
private static boolean isEntity(TypeMirror mirror){ 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");
} }
} }

View File

@@ -6,15 +6,19 @@ cix=2
draug=3 draug=3
mace=4 mace=4
mindustry.entities.comp.BuildingComp=22 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.DecalComp=6
mindustry.entities.comp.EffectComp=7 mindustry.entities.comp.EffectComp=7
mindustry.entities.comp.EffectInstanceComp=23
mindustry.entities.comp.EffectStateComp=25
mindustry.entities.comp.FireComp=8 mindustry.entities.comp.FireComp=8
mindustry.entities.comp.LaunchCoreComp=21 mindustry.entities.comp.LaunchCoreComp=21
mindustry.entities.comp.PlayerComp=9 mindustry.entities.comp.PlayerComp=9
mindustry.entities.comp.PuddleComp=10 mindustry.entities.comp.PuddleComp=10
mindustry.entities.comp.TileComp=11
mindustry.type.Weather.WeatherComp=12 mindustry.type.Weather.WeatherComp=12
mindustry.type.Weather.WeatherStateComp=26
mindustry.world.blocks.campaign.CoreLauncher.LaunchCoreComp=13 mindustry.world.blocks.campaign.CoreLauncher.LaunchCoreComp=13
mindustry.world.blocks.campaign.LaunchPad.LaunchPayloadComp=14 mindustry.world.blocks.campaign.LaunchPad.LaunchPayloadComp=14
oculon=15 oculon=15

View File

@@ -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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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<mindustry.entities.units.BuildPlan>,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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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<mindustry.entities.units.BuildPlan>,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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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<mindustry.world.blocks.payloads.Payload>,size:-1},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>,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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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<mindustry.entities.units.BuildPlan>,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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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<mindustry.entities.units.BuildPlan>,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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -0,0 +1 @@
{fields:[{name:lifetime,type:float,size:4},{name:stacks,type:arc.struct.Seq<mindustry.type.ItemStack>,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}]}

View File

@@ -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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -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<mindustry.entities.units.StatusEntry>,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}]}

View File

@@ -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}]}

View File

@@ -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}]}

View File

@@ -176,6 +176,7 @@ allprojects{
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
options.encoding = "UTF-8" options.encoding = "UTF-8"
options.compilerArgs += ["-Xlint:deprecation"]
} }
} }

View File

@@ -107,7 +107,7 @@ const BlockBuildBeginEvent = Packages.mindustry.game.EventType.BlockBuildBeginEv
const ResearchEvent = Packages.mindustry.game.EventType.ResearchEvent const ResearchEvent = Packages.mindustry.game.EventType.ResearchEvent
const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent
const StateChangeEvent = Packages.mindustry.game.EventType.StateChangeEvent 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 GameOverEvent = Packages.mindustry.game.EventType.GameOverEvent
const TapConfigEvent = Packages.mindustry.game.EventType.TapConfigEvent const TapConfigEvent = Packages.mindustry.game.EventType.TapConfigEvent
const TapEvent = Packages.mindustry.game.EventType.TapEvent const TapEvent = Packages.mindustry.game.EventType.TapEvent

View File

@@ -195,7 +195,8 @@ public class Vars implements Loadable{
public static NetServer netServer; public static NetServer netServer;
public static NetClient netClient; public static NetClient netClient;
public static Playerc player; public static
Player player;
@Override @Override
public void loadAsync(){ public void loadAsync(){

View File

@@ -45,7 +45,7 @@ public class BaseAI{
//create AI core unit //create AI core unit
if(!Groups.unit.contains(u -> u.team() == data.team && u.type() == block.unitType)){ 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.set(data.core());
unit.add(); unit.add();
Fx.spawn.at(unit); Fx.spawn.at(unit);

View File

@@ -51,7 +51,7 @@ public class BlockIndexer{
private Seq<Tile> returnArray = new Seq<>(); private Seq<Tile> returnArray = new Seq<>();
public BlockIndexer(){ public BlockIndexer(){
Events.on(TileChangeEvent.class, event -> { Events.on(BuildinghangeEvent.class, event -> {
if(typeMap.get(event.tile.pos()) != null){ if(typeMap.get(event.tile.pos()) != null){
TileIndex index = typeMap.get(event.tile.pos()); TileIndex index = typeMap.get(event.tile.pos());
for(BlockFlag flag : index.flags){ for(BlockFlag flag : index.flags){
@@ -164,11 +164,11 @@ public class BlockIndexer{
return flagMap[team.id][type.ordinal()]; return flagMap[team.id][type.ordinal()];
} }
public boolean eachBlock(Teamc team, float range, Boolf<Tilec> pred, Cons<Tilec> cons){ public boolean eachBlock(Teamc team, float range, Boolf<Building> pred, Cons<Building> cons){
return eachBlock(team.team(), team.getX(), team.getY(), range, pred, cons); return eachBlock(team.team(), team.getX(), team.getY(), range, pred, cons);
} }
public boolean eachBlock(Team team, float wx, float wy, float range, Boolf<Tilec> pred, Cons<Tilec> cons){ public boolean eachBlock(Team team, float wx, float wy, float range, Boolf<Building> pred, Cons<Building> cons){
intSet.clear(); intSet.clear();
int tx = world.toTile(wx); int tx = world.toTile(wx);
@@ -181,7 +181,7 @@ public class BlockIndexer{
for(int y = -tileRange + ty; y <= tileRange + ty; y++){ for(int y = -tileRange + ty; y <= tileRange + ty; y++){
if(!Mathf.within(x * tilesize, y * tilesize, wx, wy, range)) continue; 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; if(other == null) continue;
@@ -211,7 +211,7 @@ public class BlockIndexer{
return returnArray; return returnArray;
} }
public void notifyTileDamaged(Tilec entity){ public void notifyTileDamaged(Building entity){
if(damagedTiles[(int)entity.team().id] == null){ if(damagedTiles[(int)entity.team().id] == null){
damagedTiles[(int)entity.team().id] = new TileArray(); damagedTiles[(int)entity.team().id] = new TileArray();
} }
@@ -220,11 +220,11 @@ public class BlockIndexer{
set.add(entity.tile()); set.add(entity.tile());
} }
public Tilec findEnemyTile(Team team, float x, float y, float range, Boolf<Tilec> pred){ public Building findEnemyTile(Team team, float x, float y, float range, Boolf<Building> pred){
for(Team enemy : activeTeams){ for(Team enemy : activeTeams){
if(!team.isEnemy(enemy)) continue; 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){ if(entity != null){
return entity; return entity;
} }
@@ -233,12 +233,12 @@ public class BlockIndexer{
return null; return null;
} }
public Tilec findTile(Team team, float x, float y, float range, Boolf<Tilec> pred){ public Building findTile(Team team, float x, float y, float range, Boolf<Building> pred){
return findTile(team, x, y, range, pred, false); return findTile(team, x, y, range, pred, false);
} }
public Tilec findTile(Team team, float x, float y, float range, Boolf<Tilec> pred, boolean usePriority){ public Building findTile(Team team, float x, float y, float range, Boolf<Building> pred, boolean usePriority){
Tilec closest = null; Building closest = null;
float dst = 0; float dst = 0;
float range2 = range * range; 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 tx = rx * quadrantSize; tx < (rx + 1) * quadrantSize && tx < world.width(); tx++){
for(int ty = ry * quadrantSize; ty < (ry + 1) * quadrantSize && ty < world.height(); ty++){ 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; if(e == null) continue;
@@ -390,7 +390,7 @@ public class BlockIndexer{
outer: outer:
for(int x = quadrantX * quadrantSize; x < world.width() && x < (quadrantX + 1) * quadrantSize; x++){ 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++){ 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 //when a targetable block is found, mark this quadrant as occupied and stop searching
if(result != null && result.team() == team){ if(result != null && result.team() == team){
bits.set(quadrantX, quadrantY); bits.set(quadrantX, quadrantY);

View File

@@ -63,7 +63,7 @@ public class Pathfinder implements Runnable{
Events.on(ResetEvent.class, event -> stop()); 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. */ /** Packs a tile into its internal representation. */

View File

@@ -48,7 +48,7 @@ public class WaveSpawner{
eachFlyerSpawn((spawnX, spawnY) -> { eachFlyerSpawn((spawnX, spawnY) -> {
for(int i = 0; i < spawned; i++){ 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.set(spawnX + Mathf.range(spread), spawnY + Mathf.range(spread));
unit.add(); unit.add();
} }
@@ -61,7 +61,7 @@ public class WaveSpawner{
for(int i = 0; i < spawned; i++){ for(int i = 0; i < spawned; i++){
Tmp.v1.rnd(spread); 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); unit.set(spawnX + Tmp.v1.x, spawnY + Tmp.v1.y);
Time.run(Math.min(i * 5, 60 * 2), () -> spawnEffect(unit)); 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()){ if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam) && !state.teams.playerCores().isEmpty()){
Tilec firstCore = state.teams.playerCores().first(); Building firstCore = state.teams.playerCores().first();
for(Tilec core : state.rules.waveTeam.cores()){ for(Building core : state.rules.waveTeam.cores()){
Tmp.v1.set(firstCore).sub(core).limit(coreMargin + core.block().size * tilesize); 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); 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)){ 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()); 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); Fx.unitSpawn.at(unit.x(), unit.y(), 0f, unit);
Time.run(30f, () -> { Time.run(30f, () -> {
unit.add(); unit.add();

View File

@@ -8,58 +8,58 @@ import mindustry.entities.units.*;
import mindustry.gen.*; import mindustry.gen.*;
public class FormationAI extends AIController implements FormationMember{ public class FormationAI extends AIController implements FormationMember{
public Unitc leader; public Unit leader;
private Vec3 target = new Vec3(); private Vec3 target = new Vec3();
private @Nullable Formation formation; private @Nullable Formation formation;
public FormationAI(Unitc leader, Formation formation){ public FormationAI(Unit leader, Formation formation){
this.leader = leader; this.leader = leader;
this.formation = formation; this.formation = formation;
} }
@Override @Override
public void init(){ public void init(){
target.set(unit.x(), unit.y(), 0); target.set(unit.x, unit.y, 0);
} }
@Override @Override
public void updateUnit(){ public void updateUnit(){
if(leader.dead()){ if(leader.dead){
unit.resetController(); unit.resetController();
return; return;
} }
unit.controlWeapons(leader.isRotate(), leader.isShooting()); unit.controlWeapons(leader.isRotate(), leader.isShooting);
// unit.moveAt(Tmp.v1.set(deltaX, deltaY).limit(unit.type().speed)); // unit.moveAt(Tmp.v1.set(deltaX, deltaY).limit(unit.type().speed));
if(leader.isShooting()){ if(leader.isShooting){
unit.aimLook(leader.aimX(), leader.aimY()); unit.aimLook(leader.aimX(), leader.aimY());
}else{ }else{
if(!unit.moving()){ if(!unit.moving()){
unit.lookAt(unit.vel().angle()); unit.lookAt(unit.vel.angle());
}else{ }else{
unit.lookAt(leader.rotation()); unit.lookAt(leader.rotation);
} }
} }
Vec2 realtarget = vec.set(target); Vec2 realtarget = vec.set(target);
if(unit.isGrounded() && Vars.world.raycast(unit.tileX(), unit.tileY(), leader.tileX(), leader.tileY(), Vars.world::solid)){ 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)); unit.moveAt(realtarget.sub(unit).limit(unit.type().speed));
} }
@Override @Override
public void removed(Unitc unit){ public void removed(Unit unit){
if(formation != null){ if(formation != null){
formation.removeMember(this); formation.removeMember(this);
} }
} }
@Override @Override
public boolean isBeingControlled(Unitc player){ public boolean isBeingControlled(Unit player){
return leader == player; return leader == player;
} }

View File

@@ -22,7 +22,7 @@ public class GroundAI extends AIController{
targetClosest(); targetClosest();
} }
Tilec core = unit.closestEnemyCore(); Building core = unit.closestEnemyCore();
if(core != null){ if(core != null){
if(unit.within(core,unit.range() / 1.1f)){ if(unit.within(core,unit.range() / 1.1f)){
@@ -81,7 +81,7 @@ public class GroundAI extends AIController{
Tile tile = unit.tileOn(); Tile tile = unit.tileOn();
if(tile == null) return; if(tile == null) return;
Tile targetTile = pathfinder.getTargetTile(tile, enemy, FlagTarget.enemyCores); 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; if(tile == targetTile || core == null || unit.within(core, 120f)) return;

View File

@@ -20,14 +20,14 @@ public class SuicideAI extends GroundAI{
targetClosest(); targetClosest();
} }
Tilec core = unit.closestEnemyCore(); Building core = unit.closestEnemyCore();
boolean rotate = false, shoot = false; boolean rotate = false, shoot = false;
if(!Units.invalidateTarget(target, unit, unit.range())){ if(!Units.invalidateTarget(target, unit, unit.range())){
rotate = true; rotate = true;
shoot = unit.within(target, unit.type().weapons.first().bullet.range() + 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()){ if(unit.type().hasWeapons()){
unit.aimLook(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed)); unit.aimLook(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed));

View File

@@ -9,10 +9,10 @@ import java.util.*;
/** Creates quadtrees per unit team. */ /** Creates quadtrees per unit team. */
public class TeamIndexProcess implements AsyncProcess{ public class TeamIndexProcess implements AsyncProcess{
private QuadTree<Unitc>[] trees = new QuadTree[Team.all.length]; private QuadTree<Unit>[] trees = new QuadTree[Team.all.length];
private int[] counts = new int[Team.all.length]; private int[] counts = new int[Team.all.length];
public QuadTree<Unitc> tree(Team team){ public QuadTree<Unit> tree(Team team){
if(trees[team.uid] == null) trees[team.uid] = new QuadTree<>(Vars.world.getQuadBounds(new Rect())); if(trees[team.uid] == null) trees[team.uid] = new QuadTree<>(Vars.world.getQuadBounds(new Rect()));
return trees[team.uid]; return trees[team.uid];
@@ -43,9 +43,9 @@ public class TeamIndexProcess implements AsyncProcess{
Arrays.fill(counts, 0); Arrays.fill(counts, 0);
for(Unitc unit : Groups.unit){ for(Unit unit : Groups.unit){
tree(unit.team()).insert(unit); tree(unit.team).insert(unit);
counts[unit.team().id] ++; counts[unit.team.id] ++;
} }
} }

View File

@@ -1518,14 +1518,14 @@ public class Blocks implements ContentList{
} }
@Override @Override
public void init(Bulletc b){ public void init(Bullet b){
for(int i = 0; i < rays; i++){ 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); Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), rayLength - Math.abs(i - (rays / 2)) * 20f);
} }
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
super.draw(b); super.draw(b);
Draw.color(Color.white, Pal.lancerLaser, b.fin()); Draw.color(Color.white, Pal.lancerLaser, b.fin());
//Draw.alpha(b.fout()); //Draw.alpha(b.fout());

View File

@@ -390,19 +390,19 @@ public class Bullets implements ContentList{
} }
@Override @Override
public void init(Bulletc b){ public void init(Bullet b){
b.vel().setLength(0.6f + Mathf.random(2f)); b.vel().setLength(0.6f + Mathf.random(2f));
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
Draw.color(Pal.lightFlame, Pal.darkFlame, Color.gray, b.fin()); Draw.color(Pal.lightFlame, Pal.darkFlame, Color.gray, b.fin());
Fill.circle(b.x(), b.y(), 3f * b.fout()); Fill.circle(b.x(), b.y(), 3f * b.fout());
Draw.reset(); Draw.reset();
} }
@Override @Override
public void update(Bulletc b){ public void update(Bullet b){
if(Mathf.chance(0.04 * Time.delta())){ if(Mathf.chance(0.04 * Time.delta())){
Tile tile = world.tileWorld(b.x(), b.y()); Tile tile = world.tileWorld(b.x(), b.y());
if(tile != null){ if(tile != null){
@@ -442,7 +442,7 @@ public class Bullets implements ContentList{
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
} }
}; };
@@ -462,7 +462,7 @@ public class Bullets implements ContentList{
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
} }
}; };
@@ -549,7 +549,7 @@ public class Bullets implements ContentList{
} }
@Override @Override
public void hit(Bulletc b, float x, float y){ public void hit(Bullet b, float x, float y){
super.hit(b, x, y); super.hit(b, x, y);
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){

View File

@@ -26,31 +26,31 @@ public class Fx{
none = new Effect(0, 0f, e -> {}), none = new Effect(0, 0f, e -> {}),
unitSpawn = new Effect(30f, e -> { unitSpawn = new Effect(30f, e -> {
if(!(e.data instanceof Unitc)) return; if(!(e.data instanceof Unit)) return;
alpha(e.fin()); alpha(e.fin());
float scl = 1f + e.fout() * 2f; float scl = 1f + e.fout() * 2f;
Unitc unit = (Unitc)e.data; Unit unit = e.data();
rect(unit.type().region, e.x, e.y, rect(unit.type().region, e.x, e.y,
unit.type().region.getWidth() * Draw.scl * scl, unit.type().region.getHeight() * Draw.scl * scl, 180f); unit.type().region.getWidth() * Draw.scl * scl, unit.type().region.getHeight() * Draw.scl * scl, 180f);
}), }),
unitControl = new Effect(30f, e -> { 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); mixcol(Pal.accent, 1f);
alpha(e.fout()); 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); alpha(1f);
Lines.stroke(e.fslope() * 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.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(); reset();
}), }),
@@ -1256,7 +1256,7 @@ public class Fx{
unitShieldBreak = new Effect(35, e -> { unitShieldBreak = new Effect(35, e -> {
if(!(e.data instanceof Unitc)) return; if(!(e.data instanceof Unitc)) return;
Unitc unit = e.data(); Unit unit = e.data();
float radius = unit.hitSize() * 1.3f; float radius = unit.hitSize() * 1.3f;

View File

@@ -127,7 +127,7 @@ public class UnitTypes implements ContentList{
@Override @Override
public void update(Unitc player){ public void update(Unitc player){
if(player.timer().get(Playerc.timerAbility, healReload)){ if(player.timer().get(Player.timerAbility, healReload)){
wasHealed = false; wasHealed = false;
Units.nearby(player.team(), player.x, player.y, healRange, unit -> { Units.nearby(player.team(), player.x, player.y, healRange, unit -> {
@@ -707,8 +707,8 @@ public class UnitTypes implements ContentList{
} }
@Override @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)){
if(indexer.eachBlock(player, healRange, other -> other.entity.damaged(), other -> { if(indexer.eachBlock(player, healRange, other -> other.entity.damaged(), other -> {
other.entity.heal(other.entity.maxHealth() * healPercent / 100f); other.entity.heal(other.entity.maxHealth() * healPercent / 100f);
Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal); Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal);
@@ -782,9 +782,9 @@ public class UnitTypes implements ContentList{
} }
@Override @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; wasHealed = false;
Units.nearby(player.team(), player.x, player.y, healRange, unit -> { Units.nearby(player.team(), player.x, player.y, healRange, unit -> {
@@ -834,12 +834,12 @@ public class UnitTypes implements ContentList{
} }
@Override @Override
public float getRotationAlpha(Playerc player){ public float getRotationAlpha(Player player){
return 0.6f - player.shootHeat * 0.3f; return 0.6f - player.shootHeat * 0.3f;
} }
@Override @Override
public float spreadX(Playerc player){ public float spreadX(Player player){
return player.shootHeat * 2f; return player.shootHeat * 2f;
} }
@@ -850,18 +850,18 @@ public class UnitTypes implements ContentList{
} }
@Override @Override
public void update(Playerc player){ public void update(Player player){
float scl = 1f - player.shootHeat / 2f*Time.delta(); float scl = 1f - player.shootHeat / 2f*Time.delta();
player.vel().scl(scl); player.vel().scl(scl);
} }
@Override @Override
public float getExtraArmor(Playerc player){ public float getExtraArmor(Player player){
return player.shootHeat * 30f; return player.shootHeat * 30f;
} }
@Override @Override
public void draw(Playerc player){ public void draw(Player player){
if(player.shootHeat <= 0.01f) return; if(player.shootHeat <= 0.01f) return;
Shaders.build.progress = player.shootHeat; Shaders.build.progress = player.shootHeat;
@@ -901,10 +901,10 @@ public class UnitTypes implements ContentList{
} }
@Override @Override
public void update(Playerc player){ public void update(Player player){
super.update(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 -> { Units.nearby(player.team(), player.x, player.y, effectRange, unit -> {
//unit.applyEffect(StatusEffects.overdrive, effectDuration); //unit.applyEffect(StatusEffects.overdrive, effectDuration);
@@ -955,12 +955,12 @@ public class UnitTypes implements ContentList{
} }
@Override @Override
public float getRotationAlpha(Playerc player){ public float getRotationAlpha(Player player){
return 0.5f; return 0.5f;
} }
@Override @Override
public void update(Playerc player){ public void update(Player player){
float scl = scld(player); float scl = scld(player);
if(Mathf.chanceDelta((0.15 * scl))){ if(Mathf.chanceDelta((0.15 * scl))){
Fx.hitLancer.at(Pal.lancerLaser, player.x, player.y); Fx.hitLancer.at(Pal.lancerLaser, player.x, player.y);
@@ -970,7 +970,7 @@ public class UnitTypes implements ContentList{
} }
@Override @Override
public void draw(Playerc player){ public void draw(Player player){
float scl = scld(player); float scl = scld(player);
if(scl < 0.01f) return; if(scl < 0.01f) return;
Draw.color(Pal.lancerLaser); Draw.color(Pal.lancerLaser);
@@ -980,7 +980,7 @@ public class UnitTypes implements ContentList{
Draw.blend(); Draw.blend();
} }
float scld(Playerc player){ float scld(Player player){
return Mathf.clamp((player.vel().len() - minV) / (maxV - minV)); return Mathf.clamp((player.vel().len() - minV) / (maxV - minV));
} }
}; };

View File

@@ -33,7 +33,7 @@ public class Weathers implements ContentList{
} }
@Override @Override
public void drawOver(Weatherc state){ public void drawOver(WeatherState state){
rand.setSeed(0); 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.setCentered(Core.camera.position.x, Core.camera.position.y, Core.graphics.getWidth() / renderer.minScale(), Core.graphics.getHeight() / renderer.minScale());
Tmp.r1.grow(padding); Tmp.r1.grow(padding);
@@ -78,7 +78,7 @@ public class Weathers implements ContentList{
} }
@Override @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.setCentered(Core.camera.position.x, Core.camera.position.y, Core.graphics.getWidth() / renderer.minScale(), Core.graphics.getHeight() / renderer.minScale());
Tmp.r1.grow(padding); Tmp.r1.grow(padding);
Core.camera.bounds(Tmp.r2); Core.camera.bounds(Tmp.r2);
@@ -110,7 +110,7 @@ public class Weathers implements ContentList{
} }
@Override @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.setCentered(Core.camera.position.x, Core.camera.position.y, Core.graphics.getWidth() / renderer.minScale(), Core.graphics.getHeight() / renderer.minScale());
Tmp.r1.grow(padding); Tmp.r1.grow(padding);
Core.camera.bounds(Tmp.r2); Core.camera.bounds(Tmp.r2);
@@ -170,15 +170,15 @@ public class Weathers implements ContentList{
} }
@Override @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()); unit.impulse(force.x * state.intensity(), force.y * state.intensity());
} }
} }
@Override @Override
public void drawOver(Weatherc state){ public void drawOver(WeatherState state){
rand.setSeed(0); 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.setCentered(Core.camera.position.x, Core.camera.position.y, Core.graphics.getWidth() / renderer.minScale(), Core.graphics.getHeight() / renderer.minScale());
Tmp.r1.grow(padding); Tmp.r1.grow(padding);

View File

@@ -74,7 +74,7 @@ public class Control implements ApplicationListener, Loadable{
Events.on(WorldLoadEvent.class, event -> { Events.on(WorldLoadEvent.class, event -> {
if(Mathf.zero(player.x()) && Mathf.zero(player.y())){ 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){ if(core != null){
player.set(core); player.set(core);
camera.position.set(core); camera.position.set(core);
@@ -158,7 +158,7 @@ public class Control implements ApplicationListener, Loadable{
}); });
Events.on(Trigger.newGame, () -> { Events.on(Trigger.newGame, () -> {
Tilec core = player.closestCore(); Building core = player.closestCore();
if(core == null) return; if(core == null) return;
@@ -198,9 +198,9 @@ public class Control implements ApplicationListener, Loadable{
} }
void createPlayer(){ void createPlayer(){
player = PlayerEntity.create(); player = Player.create();
player.name(Core.settings.getString("name")); player.name = Core.settings.getString("name");
player.color().set(Core.settings.getInt("color-0")); player.color.set(Core.settings.getInt("color-0"));
if(mobile){ if(mobile){
input = new MobileInput(); input = new MobileInput();
@@ -243,7 +243,7 @@ public class Control implements ApplicationListener, Loadable{
//TODO move //TODO move
public void handleLaunch(CoreEntity tile){ public void handleLaunch(CoreEntity tile){
LaunchCorec ent = LaunchCoreEntity.create(); LaunchCorec ent = LaunchCore.create();
ent.set(tile); ent.set(tile);
ent.block(Blocks.coreShard); ent.block(Blocks.coreShard);
ent.lifetime(Vars.launchDuration); ent.lifetime(Vars.launchDuration);
@@ -268,7 +268,7 @@ public class Control implements ApplicationListener, Loadable{
if(state.rules.defaultTeam.cores().isEmpty()){ if(state.rules.defaultTeam.cores().isEmpty()){
//kill all friendly units, since they should be dead anwyay //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){ if(unit.team() == state.rules.defaultTeam){
unit.remove(); unit.remove();
} }
@@ -347,12 +347,12 @@ public class Control implements ApplicationListener, Loadable{
zone.rules.get(state.rules); zone.rules.get(state.rules);
//TODO assign zone!! //TODO assign zone!!
//state.rules.zone = zone; //state.rules.zone = zone;
for(Tilec core : state.teams.playerCores()){ for(Building core : state.teams.playerCores()){
for(ItemStack stack : zone.getStartingItems()){ for(ItemStack stack : zone.getStartingItems()){
core.items().add(stack.item, stack.amount); core.items().add(stack.item, stack.amount);
} }
} }
Tilec core = state.teams.playerCores().first(); Building core = state.teams.playerCores().first();
core.items().clear(); core.items().clear();
logic.play(); logic.play();

View File

@@ -33,8 +33,8 @@ public class GameState{
private State state = State.menu; private State state = State.menu;
//TODO optimize //TODO optimize
public Unitc boss(){ public Unit boss(){
return Groups.unit.find(u -> u.isBoss() && u.team() == rules.waveTeam); return Groups.unit.find(u -> u.isBoss() && u.team == rules.waveTeam);
} }
public void set(State astate){ public void set(State astate){

View File

@@ -117,7 +117,7 @@ public class Logic implements ApplicationListener{
if(!state.isCampaign()){ if(!state.isCampaign()){
for(TeamData team : state.teams.getActive()){ for(TeamData team : state.teams.getActive()){
if(team.hasCore()){ if(team.hasCore()){
TileEntity entity = team.core(); Building entity = team.core();
entity.items.clear(); entity.items.clear();
for(ItemStack stack : state.rules.loadout){ for(ItemStack stack : state.rules.loadout){
entity.items.add(stack.item, stack.amount); entity.items.add(stack.item, stack.amount);
@@ -221,7 +221,7 @@ public class Logic implements ApplicationListener{
} }
//TODO core launch effect //TODO core launch effect
for(Tilec tile : state.teams.playerCores()){ for(Building tile : state.teams.playerCores()){
Fx.launch.at(tile); Fx.launch.at(tile);
} }
@@ -234,11 +234,11 @@ public class Logic implements ApplicationListener{
//TODO containers must be launched too //TODO containers must be launched too
Time.runTask(30f, () -> { Time.runTask(30f, () -> {
for(Tilec entity : state.teams.playerCores()){ for(Building entity : state.teams.playerCores()){
for(Item item : content.items()){ for(Item item : content.items()){
//TODO where do the items go? //TODO where do the items go?
//data.addItem(item, entity.items().get(item)); //data.addItem(item, entity.items.get(item));
//Events.fire(new LaunchItemEvent(new ItemStack(item, entity.items().get(item)))); //Events.fire(new LaunchItemEvent(new ItemStack(item, entity.items.get(item))));
} }
entity.tile().remove(); entity.tile().remove();
} }

View File

@@ -153,7 +153,7 @@ public class NetClient implements ApplicationListener{
//called on all clients //called on all clients
@Remote(targets = Loc.server, variants = Variant.both) @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){ if(Vars.ui != null){
Vars.ui.chatfrag.addMessage(message, sender); 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 //called when a server recieves a chat message from a player
@Remote(called = Loc.server, targets = Loc.client) @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){ if(message.length() > maxTextLength){
throw new ValidateException(player, "Player has sent a message above the text limit."); 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){ 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; if(name == null || player == null) return null;
return "[#" + player.color().toString().toUpperCase() + "]" + name; return "[#" + player.color().toString().toUpperCase() + "]" + name;
} }
@@ -238,7 +238,7 @@ public class NetClient implements ApplicationListener{
} }
@Remote(targets = Loc.client) @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); Call.onPingResponse(player.con(), time);
} }
@@ -248,7 +248,7 @@ public class NetClient implements ApplicationListener{
} }
@Remote(variants = Variant.one) @Remote(variants = Variant.one)
public static void onTraceInfo(Playerc player, TraceInfo info){ public static void onTraceInfo(Player player, TraceInfo info){
if(player != null){ if(player != null){
ui.traces.show(player, info); ui.traces.show(player, info);
} }
@@ -458,7 +458,7 @@ public class NetClient implements ApplicationListener{
Tile tile = world.tile(pos); Tile tile = world.tile(pos);
if(tile != null && tile.entity != null){ if(tile != null && tile.entity != null){
tile.entity.items().read(Reads.get(input)); tile.entity.items.read(Reads.get(input));
}else{ }else{
new ItemModule().read(Reads.get(input)); 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++, Call.onClientShapshot(lastSent++,
unit.x(), unit.y(), unit.x, unit.y,
player.unit().aimX(), player.unit().aimY(), player.unit().aimX(), player.unit().aimY(),
unit.rotation(), unit.rotation,
unit instanceof Mechc ? ((Mechc)unit).baseRotation() : 0, unit instanceof Mechc ? ((Mechc)unit).baseRotation() : 0,
unit.vel().x, unit.vel().y, unit.vel.x, unit.vel.y,
player.miner().mineTile(), player.miner().mineTile(),
control.input.isBoosting, control.input.isShooting, ui.chatfrag.shown(), control.input.isBoosting, control.input.isShooting, ui.chatfrag.shown(),
requests, requests,

View File

@@ -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; if((state.rules.waveTeam == data.team && state.rules.waves) || !data.team.active()) return Integer.MAX_VALUE;
int count = 0; int count = 0;
for(Playerc other : players){ for(Player other : players){
if(other.team() == data.team && other != player){ if(other.team() == data.team && other != player){
count++; count++;
} }
@@ -75,7 +75,7 @@ public class NetServer implements ApplicationListener{
/** Data stream for writing player sync data to. */ /** Data stream for writing player sync data to. */
private DataOutputStream dataStream = new DataOutputStream(syncStream); private DataOutputStream dataStream = new DataOutputStream(syncStream);
/** Packet handlers for custom types of messages. */ /** Packet handlers for custom types of messages. */
private ObjectMap<String, Seq<Cons2<Playerc, String>>> customPacketHandlers = new ObjectMap<>(); private ObjectMap<String, Seq<Cons2<Player, String>>> customPacketHandlers = new ObjectMap<>();
public NetServer(){ public NetServer(){
@@ -207,7 +207,7 @@ public class NetServer implements ApplicationListener{
con.modclient = true; con.modclient = true;
} }
Playerc player = PlayerEntity.create(); Player player = Player.create();
player.admin(admins.isAdmin(uuid, packet.usid)); player.admin(admins.isAdmin(uuid, packet.usid));
player.con(con); player.con(con);
player.con().usid = packet.usid; player.con().usid = packet.usid;
@@ -267,7 +267,7 @@ public class NetServer implements ApplicationListener{
} }
private void registerCommands(){ private void registerCommands(){
clientCommands.<Playerc>register("help", "[page]", "Lists all commands.", (args, player) -> { clientCommands.<Player>register("help", "[page]", "Lists all commands.", (args, player) -> {
if(args.length > 0 && !Strings.canParseInt(args[0])){ if(args.length > 0 && !Strings.canParseInt(args[0])){
player.sendMessage("[scarlet]'page' must be a number."); player.sendMessage("[scarlet]'page' must be a number.");
return; return;
@@ -293,7 +293,7 @@ public class NetServer implements ApplicationListener{
player.sendMessage(result.toString()); player.sendMessage(result.toString());
}); });
clientCommands.<Playerc>register("t", "<message...>", "Send a message only to your teammates.", (args, player) -> { clientCommands.<Player>register("t", "<message...>", "Send a message only to your teammates.", (args, player) -> {
String message = admins.filterMessage(player, args[0]); String message = admins.filterMessage(player, args[0]);
if(message != null){ if(message != null){
Groups.player.each(p -> p.team() == player.team(), o -> o.sendMessage(message, player, "[#" + player.team().color.toString() + "]<T>" + NetClient.colorizeName(player.id(), player.name()))); Groups.player.each(p -> p.team() == player.team(), o -> o.sendMessage(message, player, "[#" + player.team().color.toString() + "]<T>" + NetClient.colorizeName(player.id(), player.name())));
@@ -308,13 +308,13 @@ public class NetServer implements ApplicationListener{
int voteCooldown = 60 * 5; int voteCooldown = 60 * 5;
class VoteSession{ class VoteSession{
Playerc target; Player target;
ObjectSet<String> voted = new ObjectSet<>(); ObjectSet<String> voted = new ObjectSet<>();
VoteSession[] map; VoteSession[] map;
Timer.Task task; Timer.Task task;
int votes; int votes;
public VoteSession(VoteSession[] map, Playerc target){ public VoteSession(VoteSession[] map, Player target){
this.target = target; this.target = target;
this.map = map; this.map = map;
this.task = Timer.schedule(() -> { this.task = Timer.schedule(() -> {
@@ -326,7 +326,7 @@ public class NetServer implements ApplicationListener{
}, voteDuration); }, voteDuration);
} }
void vote(Playerc player, int d){ void vote(Player player, int d){
votes += d; votes += d;
voted.addAll(player.uuid(), admins.getInfo(player.uuid()).lastIP); voted.addAll(player.uuid(), admins.getInfo(player.uuid()).lastIP);
@@ -352,7 +352,7 @@ public class NetServer implements ApplicationListener{
//current kick sessions //current kick sessions
VoteSession[] currentlyKicking = {null}; VoteSession[] currentlyKicking = {null};
clientCommands.<Playerc>register("votekick", "[player...]", "Vote to kick a player.", (args, player) -> { clientCommands.<Player>register("votekick", "[player...]", "Vote to kick a player.", (args, player) -> {
if(!Config.enableVotekick.bool()){ if(!Config.enableVotekick.bool()){
player.sendMessage("[scarlet]Vote-kick is disabled on this server."); player.sendMessage("[scarlet]Vote-kick is disabled on this server.");
return; return;
@@ -377,7 +377,7 @@ public class NetServer implements ApplicationListener{
}); });
player.sendMessage(builder.toString()); player.sendMessage(builder.toString());
}else{ }else{
Playerc found; Player found;
if(args[0].length() > 1 && args[0].startsWith("#") && Strings.canParseInt(args[0].substring(1))){ if(args[0].length() > 1 && args[0].startsWith("#") && Strings.canParseInt(args[0].substring(1))){
int id = Strings.parseInt(args[0].substring(1)); int id = Strings.parseInt(args[0].substring(1));
found = Groups.player.find(p -> p.id() == id); found = Groups.player.find(p -> p.id() == id);
@@ -411,7 +411,7 @@ public class NetServer implements ApplicationListener{
} }
}); });
clientCommands.<Playerc>register("vote", "<y/n>", "Vote to kick the current player.", (arg, player) -> { clientCommands.<Player>register("vote", "<y/n>", "Vote to kick the current player.", (arg, player) -> {
if(currentlyKicking[0] == null){ if(currentlyKicking[0] == null){
player.sendMessage("[scarlet]Nobody is being voted on."); player.sendMessage("[scarlet]Nobody is being voted on.");
}else{ }else{
@@ -441,7 +441,7 @@ public class NetServer implements ApplicationListener{
} }
}); });
clientCommands.<Playerc>register("sync", "Re-synchronize world state.", (args, player) -> { clientCommands.<Player>register("sync", "Re-synchronize world state.", (args, player) -> {
if(player.isLocal()){ if(player.isLocal()){
player.sendMessage("[scarlet]Re-synchronizing as the host is pointless."); player.sendMessage("[scarlet]Re-synchronizing as the host is pointless.");
}else{ }else{
@@ -461,15 +461,15 @@ public class NetServer implements ApplicationListener{
return 2 + (Groups.player.size() > 4 ? 1 : 0); return 2 + (Groups.player.size() > 4 ? 1 : 0);
} }
public Team assignTeam(Playerc current){ public Team assignTeam(Player current){
return assigner.assign(current, Groups.player); return assigner.assign(current, Groups.player);
} }
public Team assignTeam(Playerc current, Iterable<Playerc> players){ public Team assignTeam(Player current, Iterable<Player> players){
return assigner.assign(current, players); return assigner.assign(current, players);
} }
public void sendWorldData(Playerc player){ public void sendWorldData(Player player){
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
DeflaterOutputStream def = new FastDeflaterOutputStream(stream); DeflaterOutputStream def = new FastDeflaterOutputStream(stream);
NetworkIO.writeWorld(player, def); NetworkIO.writeWorld(player, def);
@@ -480,15 +480,15 @@ public class NetServer implements ApplicationListener{
Log.debug("Packed @ compressed bytes of world data.", stream.size()); Log.debug("Packed @ compressed bytes of world data.", stream.size());
} }
public void addPacketHandler(String type, Cons2<Playerc, String> handler){ public void addPacketHandler(String type, Cons2<Player, String> handler){
customPacketHandlers.get(type, Seq::new).add(handler); customPacketHandlers.get(type, Seq::new).add(handler);
} }
public Seq<Cons2<Playerc, String>> getPacketHandlers(String type){ public Seq<Cons2<Player, String>> getPacketHandlers(String type){
return customPacketHandlers.get(type, Seq::new); 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 //singleplayer multiplayer wierdness
if(player.con() == null){ if(player.con() == null){
player.remove(); player.remove();
@@ -510,22 +510,22 @@ public class NetServer implements ApplicationListener{
} }
@Remote(targets = Loc.client) @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)){ if(netServer.customPacketHandlers.containsKey(type)){
for(Cons2<Playerc, String> c : netServer.customPacketHandlers.get(type)){ for(Cons2<Player, String> c : netServer.customPacketHandlers.get(type)){
c.get(player, contents); c.get(player, contents);
} }
} }
} }
@Remote(targets = Loc.client, unreliable = true) @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); serverPacketReliable(player, type, contents);
} }
@Remote(targets = Loc.client, unreliable = true) @Remote(targets = Loc.client, unreliable = true)
public static void onClientShapshot( public static void onClientShapshot(
Playerc player, Player player,
int snapshotID, int snapshotID,
float x, float y, float x, float y,
float pointerX, float pointerY, float pointerX, float pointerY,
@@ -599,7 +599,7 @@ public class NetServer implements ApplicationListener{
connection.rejectedRequests.clear(); connection.rejectedRequests.clear();
if(!player.dead()){ if(!player.dead()){
Unitc unit = player.unit(); Unit unit = player.unit();
unit.vel().set(xVelocity, yVelocity).limit(unit.type().speed); unit.vel().set(xVelocity, yVelocity).limit(unit.type().speed);
long elapsed = Time.timeSinceMillis(connection.lastRecievedClientTime); long elapsed = Time.timeSinceMillis(connection.lastRecievedClientTime);
@@ -664,7 +664,7 @@ public class NetServer implements ApplicationListener{
} }
@Remote(targets = Loc.client, called = Loc.server) @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()){ if(!player.admin()){
Log.warn("ACCESS DENIED: Player @ / @ attempted to perform admin action without proper security access.", 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) @Remote(targets = Loc.client)
public static void connectConfirm(Playerc player){ public static void connectConfirm(Player player){
if(player.con() == null || player.con().hasConnected) return; if(player.con() == null || player.con().hasConnected) return;
player.add(); player.add();
@@ -773,7 +773,7 @@ public class NetServer implements ApplicationListener{
syncStream.reset(); syncStream.reset();
short sent = 0; short sent = 0;
for(Tilec entity : Groups.tile){ for(Building entity : Groups.tile){
if(!entity.block().sync) continue; if(!entity.block().sync) continue;
sent ++; 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(); syncStream.reset();
Seq<CoreEntity> cores = state.teams.cores(player.team()); Seq<CoreEntity> cores = state.teams.cores(player.team());
@@ -804,7 +804,7 @@ public class NetServer implements ApplicationListener{
for(CoreEntity entity : cores){ for(CoreEntity entity : cores){
dataStream.writeInt(entity.tile().pos()); dataStream.writeInt(entity.tile().pos());
entity.items().write(Writes.get(dataStream)); entity.items.write(Writes.get(dataStream));
} }
dataStream.close(); dataStream.close();
@@ -925,6 +925,6 @@ public class NetServer implements ApplicationListener{
} }
public interface TeamAssigner{ public interface TeamAssigner{
Team assign(Playerc player, Iterable<Playerc> players); Team assign(Player player, Iterable<Player> players);
} }
} }

View File

@@ -259,7 +259,7 @@ public class Renderer implements ApplicationListener{
private void drawLanding(){ private void drawLanding(){
if(landTime > 0 && player.closestCore() != null){ if(landTime > 0 && player.closestCore() != null){
float fract = landTime / Fx.coreLand.lifetime; float fract = landTime / Fx.coreLand.lifetime;
Tilec entity = player.closestCore(); Building entity = player.closestCore();
TextureRegion reg = entity.block().icon(Cicon.full); TextureRegion reg = entity.block().icon(Cicon.full);
float scl = Scl.scl(4f) / camerascale; float scl = Scl.scl(4f) / camerascale;

View File

@@ -102,7 +102,7 @@ public class World{
} }
@Nullable @Nullable
public Tile tilec(int x, int y){ public Tile Building(int x, int y){
Tile tile = tiles.get(x, y); Tile tile = tiles.get(x, y);
if(tile == null) return null; if(tile == null) return null;
if(tile.entity != null) return tile.entity.tile(); if(tile.entity != null) return tile.entity.tile();
@@ -110,14 +110,14 @@ public class World{
} }
@Nullable @Nullable
public Tilec ent(int x, int y){ public Building ent(int x, int y){
Tile tile = tile(x, y); Tile tile = tile(x, y);
if(tile == null) return null; if(tile == null) return null;
return tile.entity; return tile.entity;
} }
@Nullable @Nullable
public Tilec ent(int pos){ public Building ent(int pos){
Tile tile = tile(pos); Tile tile = tile(pos);
if(tile == null) return null; if(tile == null) return null;
return tile.entity; return tile.entity;
@@ -134,7 +134,7 @@ public class World{
} }
@Nullable @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)); 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. * 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(){ public void beginMapLoad(){
generating = true; generating = true;
@@ -317,7 +317,7 @@ public class World{
public void notifyChanged(Tile tile){ public void notifyChanged(Tile tile){
if(!generating){ if(!generating){
Core.app.post(() -> Events.fire(new TileChangeEvent(tile))); Core.app.post(() -> Events.fire(new BuildinghangeEvent(tile)));
} }
} }

View File

@@ -109,7 +109,7 @@ public class EditorTile extends Tile{
} }
@Override @Override
protected void changeEntity(Team team, Prov<Tilec> entityprov){ protected void changeEntity(Team team, Prov<Building> entityprov){
if(state.isGame()){ if(state.isGame()){
super.changeEntity(team, entityprov); super.changeEntity(team, entityprov);
return; return;

View File

@@ -51,7 +51,7 @@ public class MapGenerateDialog extends BaseDialog{
private CachedTile ctile = new CachedTile(){ private CachedTile ctile = new CachedTile(){
//nothing. //nothing.
@Override @Override
protected void changeEntity(Team team, Prov<Tilec> entityprov){ protected void changeEntity(Team team, Prov<Building> entityprov){
} }
}; };

View File

@@ -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); collideLine(hitter, team, effect, x, y, angle, length, false);
} }
@@ -80,11 +80,11 @@ public class Damage{
* Damages entities in a line. * Damages entities in a line.
* Only enemies of the specified team are damaged. * 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(); collidedBlocks.clear();
tr.trns(angle, length); tr.trns(angle, length);
Intc2 collider = (cx, cy) -> { 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)){ if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.team() != team && tile.collide(hitter)){
tile.collision(hitter); tile.collision(hitter);
collidedBlocks.add(tile.pos()); collidedBlocks.add(tile.pos());
@@ -122,7 +122,7 @@ public class Damage{
rect.width += expand * 2; rect.width += expand * 2;
rect.height += expand * 2; rect.height += expand * 2;
Cons<Unitc> cons = e -> { Cons<Unit> cons = e -> {
e.hitbox(hitrect); e.hitbox(hitrect);
Rect other = hitrect; Rect other = hitrect;
other.y -= expand; other.y -= expand;
@@ -143,8 +143,8 @@ public class Damage{
} }
/** Damages all entities and blocks in a radius that are enemies of the team. */ /** 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<Unitc> predicate, Cons<Unitc> acceptor){ public static void damageUnits(Team team, float x, float y, float size, float damage, Boolf<Unit> predicate, Cons<Unit> acceptor){
Cons<Unitc> cons = entity -> { Cons<Unit> cons = entity -> {
if(!predicate.get(entity)) return; if(!predicate.get(entity)) return;
entity.hitbox(hitrect); entity.hitbox(hitrect);
@@ -180,8 +180,8 @@ public class Damage{
/** Applies a status effect to all enemy units in a range. */ /** 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){ public static void status(Team team, float x, float y, float radius, StatusEffect effect, float duration, boolean air, boolean ground){
Cons<Unitc> cons = entity -> { Cons<Unit> cons = entity -> {
if(entity.team() == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){ if(entity.team == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){
return; return;
} }
@@ -203,15 +203,15 @@ public class Damage{
/** Damages all entities and blocks in a radius that are enemies of the team. */ /** 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){ public static void damage(Team team, float x, float y, float radius, float damage, boolean complete, boolean air, boolean ground){
Cons<Unitc> cons = entity -> { Cons<Unit> cons = entity -> {
if(entity.team() == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){ if(entity.team == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){
return; return;
} }
float amount = calculateDamage(x, y, entity.getX(), entity.getY(), radius, damage); float amount = calculateDamage(x, y, entity.getX(), entity.getY(), radius, damage);
entity.damage(amount); entity.damage(amount);
//TODO better velocity displacement //TODO better velocity displacement
float dst = tr.set(entity.getX() - x, entity.getY() - y).len(); 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()){ if(complete && damage >= 9999999f && entity.isPlayer()){
Events.fire(Trigger.exclusionDeath); Events.fire(Trigger.exclusionDeath);

View File

@@ -42,7 +42,7 @@ public class Effects{
Rect pos = Tmp.r2.setSize(effect.size).setCenter(x, y); Rect pos = Tmp.r2.setSize(effect.size).setCenter(x, y);
if(view.overlaps(pos)){ if(view.overlaps(pos)){
Effectc entity = EffectEntity.create(); EffectState entity = EffectState.create();
entity.effect(effect); entity.effect(effect);
entity.rotation(rotation); entity.rotation(rotation);
entity.data(data); 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){ 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; if(headless || region == null || !Core.atlas.isFound(region)) return;
Decalc decal = DecalEntity.create(); Decal decal = Decal.create();
decal.set(x, y); decal.set(x, y);
decal.rotation(rotation); decal.rotation(rotation);
decal.lifetime(lifetime); decal.lifetime(lifetime);

View File

@@ -13,16 +13,16 @@ import static mindustry.Vars.*;
public class Fires{ public class Fires{
private static final float baseLifetime = 1000f; private static final float baseLifetime = 1000f;
private static final IntMap<Firec> map = new IntMap<>(); private static final IntMap<Fire> map = new IntMap<>();
/** Start a fire on the tile. If there already is a file there, refreshes its lifetime. */ /** Start a fire on the tile. If there already is a file there, refreshes its lifetime. */
public static void create(Tile tile){ public static void create(Tile tile){
if(net.client() || tile == null) return; //not clientside. if(net.client() || tile == null) return; //not clientside.
Firec fire = map.get(tile.pos()); Fire fire = map.get(tile.pos());
if(fire == null){ if(fire == null){
fire = FireEntity.create(); fire = Fire.create();
fire.tile(tile); fire.tile(tile);
fire.lifetime(baseLifetime); fire.lifetime(baseLifetime);
fire.set(tile.worldx(), tile.worldy()); 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)); 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))){ if(!Structs.inBounds(x, y, world.width(), world.height()) || !map.containsKey(Point2.pack(x, y))){
return false; 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; 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){ public static void extinguish(Tile tile, float intensity){
if(tile != null && map.containsKey(tile.pos())){ 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()); fire.time(fire.time() + intensity * Time.delta());
Fx.steam.at(fire); Fx.steam.at(fire);
if(fire.time() >= fire.lifetime()){ if(fire.time() >= fire.lifetime()){
@@ -64,7 +64,7 @@ public class Fires{
map.remove(tile.pos()); map.remove(tile.pos());
} }
public static void register(Firec fire){ public static void register(Fire fire){
map.put(fire.tile().pos(), fire); map.put(fire.tile.pos(), fire);
} }
} }

View File

@@ -11,5 +11,5 @@ class GroupDefs<G>{
@GroupDef(value = Buildingc.class) G tile; @GroupDef(value = Buildingc.class) G tile;
@GroupDef(value = Syncc.class, mapping = true) G sync; @GroupDef(value = Syncc.class, mapping = true) G sync;
@GroupDef(value = Drawc.class) G draw; @GroupDef(value = Drawc.class) G draw;
@GroupDef(value = Weatherc.class) G weather; @GroupDef(value = WeatherStatec.class) G weather;
} }

View File

@@ -10,22 +10,22 @@ import mindustry.type.*;
import mindustry.world.*; import mindustry.world.*;
public class Puddles{ public class Puddles{
private static final IntMap<Puddlec> map = new IntMap<>(); private static final IntMap<Puddle> map = new IntMap<>();
public static final float maxLiquid = 70f; 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){ public static void deposit(Tile tile, Tile source, Liquid liquid, float amount){
deposit(tile, source, liquid, amount, 0); 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){ public static void deposit(Tile tile, Liquid liquid, float amount){
deposit(tile, tile, liquid, amount, 0); deposit(tile, tile, liquid, amount, 0);
} }
/** Returns the Puddlec on the specified tile. May return null. */ /** Returns the Puddle on the specified tile. May return null. */
public static Puddlec get(Tile tile){ public static Puddle get(Tile tile){
return map.get(tile.pos()); return map.get(tile.pos());
} }
@@ -36,7 +36,7 @@ public class Puddles{
reactPuddle(tile.floor().liquidDrop, liquid, amount, tile, reactPuddle(tile.floor().liquidDrop, liquid, amount, tile,
(tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); (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){ 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); 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; return;
} }
Puddlec p = map.get(tile.pos()); Puddle p = map.get(tile.pos());
if(p == null){ if(p == null){
Puddlec puddle = PuddleEntity.create(); Puddle puddle = Puddle.create();
puddle.tile(tile); puddle.tile(tile);
puddle.liquid(liquid); puddle.liquid(liquid);
puddle.amount(amount); puddle.amount(amount);
@@ -73,7 +73,7 @@ public class Puddles{
map.remove(tile.pos()); map.remove(tile.pos());
} }
public static void register(Puddlec puddle){ public static void register(Puddle puddle){
map.put(puddle.tile().pos(), puddle); map.put(puddle.tile().pos(), puddle);
} }
@@ -85,12 +85,12 @@ public class Puddles{
if(Mathf.chance(0.006 * amount)){ if(Mathf.chance(0.006 * amount)){
Call.createBullet(Bullets.fireball, Team.derelict, x, y, Mathf.random(360f), -1f, 1f, 1f); 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)){ if(Mathf.chance(0.5f * amount)){
Fx.steam.at(x, y); Fx.steam.at(x, y);
} }
return -0.1f * amount; 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)){ if(Mathf.chance(0.8f * amount)){
Fx.steam.at(x, y); Fx.steam.at(x, y);
} }

View File

@@ -12,12 +12,12 @@ import static mindustry.Vars.*;
/** Utility class for unit and team interactions.*/ /** Utility class for unit and team interactions.*/
public class Units{ public class Units{
private static Rect hitrect = new Rect(); private static Rect hitrect = new Rect();
private static Unitc result; private static Unit result;
private static float cdist; private static float cdist;
private static boolean boolResult; private static boolean boolResult;
@Remote(called = Loc.server) @Remote(called = Loc.server)
public static void onUnitDeath(Unitc unit){ public static void onUnitDeath(Unit unit){
unit.killed(); 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.*/ /** @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()); return player == null || tile == null || tile.interactable(player.team());
} }
@@ -54,7 +54,7 @@ public class Units{
} }
/** See {@link #invalidateTarget(Posc, Team, float, float, float)} */ /** 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); return invalidateTarget(target, targeter.team(), targeter.x(), targeter.y(), range);
} }
@@ -91,18 +91,18 @@ public class Units{
} }
/** Returns the neareset damaged tile. */ /** 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)); Tile tile = Geometry.findClosest(x, y, indexer.getDamaged(team));
return tile == null ? null : tile.entity; return tile == null ? null : tile.entity;
} }
/** Returns the neareset ally tile in a range. */ /** Returns the neareset ally tile in a range. */
public static Tilec findAllyTile(Team team, float x, float y, float range, Boolf<Tilec> pred){ public static Building findAllyTile(Team team, float x, float y, float range, Boolf<Building> pred){
return indexer.findTile(team, x, y, range, pred); return indexer.findTile(team, x, y, range, pred);
} }
/** Returns the neareset enemy tile in a range. */ /** Returns the neareset enemy tile in a range. */
public static Tilec findEnemyTile(Team team, float x, float y, float range, Boolf<Tilec> pred){ public static Building findEnemyTile(Team team, float x, float y, float range, Boolf<Building> pred){
if(team == Team.derelict) return null; if(team == Team.derelict) return null;
return indexer.findEnemyTile(team, x, y, range, pred); 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. */ /** Returns the closest target enemy. First, units are checked, then tile entities. */
public static Teamc closestTarget(Team team, float x, float y, float range){ 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. */ /** 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<Unitc> unitPred){ public static Teamc closestTarget(Team team, float x, float y, float range, Boolf<Unit> unitPred){
return closestTarget(team, x, y, range, unitPred, t -> true); return closestTarget(team, x, y, range, unitPred, t -> true);
} }
/** Returns the closest target enemy. First, units are checked, then tile entities. */ /** 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<Unitc> unitPred, Boolf<Tilec> tilePred){ public static Teamc closestTarget(Team team, float x, float y, float range, Boolf<Unit> unitPred, Boolf<Building> tilePred){
if(team == Team.derelict) return null; 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){ if(unit != null){
return unit; return unit;
}else{ }else{
@@ -131,7 +131,7 @@ public class Units{
} }
/** Returns the closest enemy of this team. Filter by predicate. */ /** Returns the closest enemy of this team. Filter by predicate. */
public static Unitc closestEnemy(Team team, float x, float y, float range, Boolf<Unitc> predicate){ public static Unit closestEnemy(Team team, float x, float y, float range, Boolf<Unit> predicate){
if(team == Team.derelict) return null; if(team == Team.derelict) return null;
result = null; result = null;
@@ -151,11 +151,11 @@ public class Units{
} }
/** Returns the closest ally of this team. Filter by predicate. No range. */ /** Returns the closest ally of this team. Filter by predicate. No range. */
public static Unitc closest(Team team, float x, float y, Boolf<Unitc> predicate){ public static Unit closest(Team team, float x, float y, Boolf<Unit> predicate){
result = null; result = null;
cdist = 0f; cdist = 0f;
for(Unitc e : Groups.unit){ for(Unit e : Groups.unit){
if(!predicate.get(e) || e.team() != team) continue; if(!predicate.get(e) || e.team() != team) continue;
float dist = e.dst2(x, y); float dist = e.dst2(x, y);
@@ -169,7 +169,7 @@ public class Units{
} }
/** Returns the closest ally of this team. Filter by predicate. */ /** Returns the closest ally of this team. Filter by predicate. */
public static Unitc closest(Team team, float x, float y, float range, Boolf<Unitc> predicate){ public static Unit closest(Team team, float x, float y, float range, Boolf<Unit> predicate){
result = null; result = null;
cdist = 0f; cdist = 0f;
@@ -188,7 +188,7 @@ public class Units{
/** Returns the closest ally of this team. Filter by predicate. /** Returns the closest ally of this team. Filter by predicate.
* Unlike the closest() function, this only guarantees that unit hitboxes overlap the range. */ * 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<Unitc> predicate){ public static Unit closestOverlap(Team team, float x, float y, float range, Boolf<Unit> predicate){
result = null; result = null;
cdist = 0f; cdist = 0f;
@@ -206,12 +206,12 @@ public class Units{
} }
/** Iterates over all units in a rectangle. */ /** Iterates over all units in a rectangle. */
public static void nearby(Team team, float x, float y, float width, float height, Cons<Unitc> cons){ public static void nearby(Team team, float x, float y, float width, float height, Cons<Unit> cons){
teamIndex.tree(team).intersect(x, y, width, height, cons); teamIndex.tree(team).intersect(x, y, width, height, cons);
} }
/** Iterates over all units in a circle around this position. */ /** Iterates over all units in a circle around this position. */
public static void nearby(Team team, float x, float y, float radius, Cons<Unitc> cons){ public static void nearby(Team team, float x, float y, float radius, Cons<Unit> cons){
nearby(team, x - radius, y - radius, radius*2f, radius*2f, unit -> { nearby(team, x - radius, y - radius, radius*2f, radius*2f, unit -> {
if(unit.within(x, y, radius)){ if(unit.within(x, y, radius)){
cons.get(unit); cons.get(unit);
@@ -220,24 +220,24 @@ public class Units{
} }
/** Iterates over all units in a rectangle. */ /** Iterates over all units in a rectangle. */
public static void nearby(float x, float y, float width, float height, Cons<Unitc> cons){ public static void nearby(float x, float y, float width, float height, Cons<Unit> cons){
Groups.unit.intersect(x, y, width, height, cons); Groups.unit.intersect(x, y, width, height, cons);
} }
/** Iterates over all units in a rectangle. */ /** Iterates over all units in a rectangle. */
public static void nearby(Rect rect, Cons<Unitc> cons){ public static void nearby(Rect rect, Cons<Unit> cons){
nearby(rect.x, rect.y, rect.width, rect.height, cons); nearby(rect.x, rect.y, rect.width, rect.height, cons);
} }
/** Iterates over all units that are enemies of this team. */ /** 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<Unitc> cons){ public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons<Unit> cons){
for(Team enemy : state.teams.enemiesOf(team)){ for(Team enemy : state.teams.enemiesOf(team)){
nearby(enemy, x, y, width, height, cons); nearby(enemy, x, y, width, height, cons);
} }
} }
/** Iterates over all units that are enemies of this team. */ /** Iterates over all units that are enemies of this team. */
public static void nearbyEnemies(Team team, Rect rect, Cons<Unitc> cons){ public static void nearbyEnemies(Team team, Rect rect, Cons<Unit> cons){
nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons); nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons);
} }

View File

@@ -24,7 +24,7 @@ public class ArtilleryBulletType extends BasicBulletType{
} }
@Override @Override
public void update(Bulletc b){ public void update(Bullet b){
super.update(b); super.update(b);
if(b.timer(0, 3 + b.fslope() * 2f)){ if(b.timer(0, 3 + b.fslope() * 2f)){
@@ -33,7 +33,7 @@ public class ArtilleryBulletType extends BasicBulletType{
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
float baseScale = 0.7f; float baseScale = 0.7f;
float scale = (baseScale + b.fslope() * (1f - baseScale)); float scale = (baseScale + b.fslope() * (1f - baseScale));

View File

@@ -39,7 +39,7 @@ public class BasicBulletType extends BulletType{
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
float height = this.height * ((1f - shrinkY) + shrinkY * b.fout()); float height = this.height * ((1f - shrinkY) + shrinkY * b.fout());
float width = this.width * ((1f - shrinkX) + shrinkX * b.fout()); float width = this.width * ((1f - shrinkX) + shrinkX * b.fout());

View File

@@ -110,19 +110,19 @@ public abstract class BulletType extends Content{
return speed * lifetime * (1f - drag); return speed * lifetime * (1f - drag);
} }
public boolean collides(Bulletc bullet, Tilec tile){ public boolean collides(Bullet bullet, Building tile){
return true; return true;
} }
public void hitTile(Bulletc b, Tilec tile){ public void hitTile(Bullet b, Building tile){
hit(b); hit(b);
} }
public void hit(Bulletc b){ public void hit(Bullet b){
hit(b, b.getX(), b.getY()); 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); hitEffect.at(x, y, b.rotation(), hitColor);
hitSound.at(b); 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()); despawnEffect.at(b.getX(), b.getY(), b.rotation());
hitSound.at(b); 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); Drawf.light(b.team(), b, lightRadius, lightColor, lightOpacity);
} }
public void init(Bulletc b){ public void init(Bullet b){
if(killShooter && b.owner() instanceof Healthc){ if(killShooter && b.owner() instanceof Healthc){
((Healthc)b.owner()).kill(); ((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){ if(homingPower > 0.0001f){
Teamc target = Units.closestTarget(b.team(), b.getX(), b.getY(), homingRange, e -> (e.isGrounded() && collidesGround) || (e.isFlying() && collidesAir), t -> collidesGround); Teamc target = Units.closestTarget(b.team(), b.getX(), b.getY(), homingRange, e -> (e.isGrounded() && collidesGround) || (e.isFlying() && collidesAir), t -> collidesGround);
if(target != null){ if(target != null){
@@ -197,32 +197,32 @@ public abstract class BulletType extends Content{
return ContentType.bullet; 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); 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); 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); 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); 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); 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); 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){ public Bullet create(@Nullable Entityc owner, Team team, float x, float y, float angle, float damage, float velocityScl, float lifetimeScl, Object data){
Bulletc bullet = BulletEntity.create(); Bullet bullet = Bullet.create();
bullet.type(this); bullet.type(this);
bullet.owner(owner); bullet.owner(owner);
bullet.team(team); bullet.team(team);

View File

@@ -43,7 +43,7 @@ public class ContinuousLaserBulletType extends BulletType{
} }
@Override @Override
public void update(Bulletc b){ public void update(Bullet b){
//TODO possible laser absorption from blocks //TODO possible laser absorption from blocks
//damage every 5 ticks //damage every 5 ticks
@@ -57,7 +57,7 @@ public class ContinuousLaserBulletType extends BulletType{
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
float baseLen = length * b.fout(); float baseLen = length * b.fout();
Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen); Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen);
@@ -77,7 +77,7 @@ public class ContinuousLaserBulletType extends BulletType{
} }
@Override @Override
public void drawLight(Bulletc b){ public void drawLight(Bullet b){
//no light drawn here //no light drawn here
} }

View File

@@ -23,7 +23,7 @@ public class FlakBulletType extends BasicBulletType{
} }
@Override @Override
public void update(Bulletc b){ public void update(Bullet b){
super.update(b); super.update(b);
if(b.data() instanceof Integer) return; if(b.data() instanceof Integer) return;

View File

@@ -28,12 +28,12 @@ public class HealBulletType extends BulletType{
} }
@Override @Override
public boolean collides(Bulletc b, Tilec tile){ public boolean collides(Bullet b, Building tile){
return tile.team() != b.team() || tile.healthf() < 1f; return tile.team() != b.team() || tile.healthf() < 1f;
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
Draw.color(backColor); Draw.color(backColor);
Lines.stroke(bulletWidth); Lines.stroke(bulletWidth);
Lines.lineAngleCenter(b.x(), b.y(), b.rotation(), bulletHeight); Lines.lineAngleCenter(b.x(), b.y(), b.rotation(), bulletHeight);
@@ -43,7 +43,7 @@ public class HealBulletType extends BulletType{
} }
@Override @Override
public void hitTile(Bulletc b, Tilec tile){ public void hitTile(Bullet b, Building tile){
super.hit(b); super.hit(b);
if(tile.team() == b.team() && !(tile.block() instanceof BuildBlock)){ if(tile.team() == b.team() && !(tile.block() instanceof BuildBlock)){

View File

@@ -48,7 +48,7 @@ public class LaserBulletType extends BulletType{
} }
@Override @Override
public void init(Bulletc b){ public void init(Bullet b){
Tmp.v1.trns(b.rotation(), length); Tmp.v1.trns(b.rotation(), length);
furthest = null; furthest = null;
@@ -65,7 +65,7 @@ public class LaserBulletType extends BulletType{
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
float realLength = b.data() == null ? length : (Float)b.data(); float realLength = b.data() == null ? length : (Float)b.data();
float f = Mathf.curve(b.fin(), 0f, 0.2f); float f = Mathf.curve(b.fin(), 0f, 0.2f);
@@ -97,7 +97,7 @@ public class LaserBulletType extends BulletType{
} }
@Override @Override
public void drawLight(Bulletc b){ public void drawLight(Bullet b){
//no light drawn here //no light drawn here
} }
} }

View File

@@ -26,11 +26,11 @@ public class LightningBulletType extends BulletType{
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
} }
@Override @Override
public void init(Bulletc b){ public void init(Bullet b){
Lightning.create(b.team(), lightningColor, damage, b.x(), b.y(), b.rotation(), lightningLength); Lightning.create(b.team(), lightningColor, damage, b.x(), b.y(), b.rotation(), lightningLength);
} }
} }

View File

@@ -44,7 +44,7 @@ public class LiquidBulletType extends BulletType{
} }
@Override @Override
public void update(Bulletc b){ public void update(Bullet b){
super.update(b); super.update(b);
if(liquid.canExtinguish()){ if(liquid.canExtinguish()){
@@ -58,21 +58,21 @@ public class LiquidBulletType extends BulletType{
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
Draw.color(liquid.color, Color.white, b.fout() / 100f); Draw.color(liquid.color, Color.white, b.fout() / 100f);
Fill.circle(b.x(), b.y(), 3f); Fill.circle(b.x(), b.y(), 3f);
} }
@Override @Override
public void despawned(Bulletc b){ public void despawned(Bullet b){
super.despawned(b); super.despawned(b);
hit(b, b.x(), b.y()); hit(b, b.x(), b.y());
} }
@Override @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); hitEffect.at(hitx, hity, liquid.color);
Puddles.deposit(world.tileWorld(hitx, hity), liquid, puddleSize); Puddles.deposit(world.tileWorld(hitx, hity), liquid, puddleSize);

View File

@@ -22,7 +22,7 @@ public class MassDriverBolt extends BulletType{
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bullet b){
float w = 11f, h = 13f; float w = 11f, h = 13f;
Draw.color(Pal.bulletYellowBack); Draw.color(Pal.bulletYellowBack);
@@ -35,7 +35,7 @@ public class MassDriverBolt extends BulletType{
} }
@Override @Override
public void update(Bulletc b){ public void update(Bullet b){
//data MUST be an instance of DriverBulletData //data MUST be an instance of DriverBulletData
if(!(b.data() instanceof DriverBulletData)){ if(!(b.data() instanceof DriverBulletData)){
hit(b); hit(b);
@@ -81,7 +81,7 @@ public class MassDriverBolt extends BulletType{
} }
@Override @Override
public void despawned(Bulletc b){ public void despawned(Bullet b){
super.despawned(b); super.despawned(b);
if(!(b.data() instanceof DriverBulletData)) return; if(!(b.data() instanceof DriverBulletData)) return;
@@ -98,7 +98,7 @@ public class MassDriverBolt extends BulletType{
} }
@Override @Override
public void hit(Bulletc b, float hitx, float hity){ public void hit(Bullet b, float hitx, float hity){
super.hit(b, hitx, hity); super.hit(b, hitx, hity);
despawned(b); despawned(b);
} }

View File

@@ -22,7 +22,7 @@ public class MissileBulletType extends BasicBulletType{
} }
@Override @Override
public void update(Bulletc b){ public void update(Bullet b){
super.update(b); super.update(b);
if(Mathf.chanceDelta(0.2)){ if(Mathf.chanceDelta(0.2)){

View File

@@ -10,9 +10,9 @@ import static mindustry.Vars.tilesize;
abstract class BlockUnitComp implements Unitc{ abstract class BlockUnitComp implements Unitc{
@Import Team team; @Import Team team;
@ReadOnly transient Tilec tile; @ReadOnly transient Building tile;
public void tile(Tilec tile){ public void tile(Building tile){
this.tile = tile; this.tile = tile;
//sets up block stats //sets up block stats

View File

@@ -54,7 +54,7 @@ abstract class BuilderComp implements Unitc{
} }
} }
Tilec core = core(); Building core = core();
//nothing to build. //nothing to build.
if(buildPlan() == null) return; if(buildPlan() == null) return;
@@ -114,9 +114,9 @@ abstract class BuilderComp implements Unitc{
BuildEntity entity = tile.ent(); BuildEntity entity = tile.ent();
if(current.breaking){ 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{ }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){ if(current.hasConfig){
Call.onTileConfig(null, tile.entity, current.config); 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. */ /** @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 //requests that you have at least *started* are considered
if(state.rules.infiniteResources || team().rules().infiniteResources || request.breaking || core == null) return false; if(state.rules.infiniteResources || team().rules().infiniteResources || request.breaking || core == null) return false;
//TODO these are bad criteria //TODO these are bad criteria

View File

@@ -37,11 +37,11 @@ import static mindustry.Vars.*;
@EntityDef(value = {Buildingc.class}, isFinal = false, genio = false, serialize = false) @EntityDef(value = {Buildingc.class}, isFinal = false, genio = false, serialize = false)
@Component(base = true) @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 //region vars and initialization
static final float timeToSleep = 60f * 1; static final float timeToSleep = 60f * 1;
static final ObjectSet<Tilec> tmpTiles = new ObjectSet<>(); static final ObjectSet<Building> tmpTiles = new ObjectSet<>();
static final Seq<Tilec> tempTileEnts = new Seq<>(); static final Seq<Building> tempTileEnts = new Seq<>();
static final Seq<Tile> tempTiles = new Seq<>(); static final Seq<Tile> tempTiles = new Seq<>();
static int sleepingEntities = 0; static int sleepingEntities = 0;
@@ -50,7 +50,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
transient Tile tile; transient Tile tile;
transient Block block; transient Block block;
transient Seq<Tilec> proximity = new Seq<>(8); transient Seq<Building> proximity = new Seq<>(8);
transient boolean updateFlow; transient boolean updateFlow;
transient byte dump; transient byte dump;
@@ -68,7 +68,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
private transient boolean initialized; private transient boolean initialized;
/** Sets this tile entity data to this and adds it if necessary. */ /** 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){ if(!initialized){
create(tile.block(), team); create(tile.block(), team);
} }
@@ -82,11 +82,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
created(); created();
return this; return base();
} }
/** Sets up all the necessary variables, but does not add this entity anywhere. */ /** 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.tile = emptyTile;
this.block = block; this.block = block;
this.team = team; this.team = team;
@@ -99,17 +99,17 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
maxHealth(block.health); maxHealth(block.health);
timer(new Interval(block.timers)); timer(new Interval(block.timers));
cons = new ConsumeModule(this); cons = new ConsumeModule(base());
if(block.hasItems) items = new ItemModule(); if(block.hasItems) items = new ItemModule();
if(block.hasLiquids) liquids = new LiquidModule(); if(block.hasLiquids) liquids = new LiquidModule();
if(block.hasPower){ if(block.hasPower){
power = new PowerModule(); power = new PowerModule();
power.graph.add(this); power.graph.add(base());
} }
initialized = true; initialized = true;
return this; return base();
} }
@Override @Override
@@ -174,17 +174,17 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
public void configure(Object value){ public void configure(Object value){
//save last used config //save last used config
block.lastConfig = value; block.lastConfig = value;
Call.onTileConfig(player, this, value); Call.onTileConfig(player, base(), value);
} }
/** Configure from a server. */ /** Configure from a server. */
public void configureAny(Object value){ public void configureAny(Object value){
Call.onTileConfig(null, this, value); Call.onTileConfig(null, base(), value);
} }
/** Deselect this tile from configuration. */ /** Deselect this tile from configuration. */
public void deselect(){ public void deselect(){
if(!headless && control.input.frag.config.getSelectedTile() == this){ if(!headless && control.input.frag.config.getSelectedTile() == base()){
control.input.frag.config.hideConfig(); control.input.frag.config.hideConfig();
} }
} }
@@ -200,11 +200,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
timeScaleDuration = Math.max(timeScaleDuration, duration); 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); 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 == 0) return world.ent(tile.x + 1, tile.y);
if(rotation == 1) return world.ent(tile.x, tile.y + 1); if(rotation == 1) return world.ent(tile.x, tile.y + 1);
if(rotation == 2) return world.ent(tile.x - 1, tile.y); 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); return relativeTo(tile.x, tile.y);
} }
public byte relativeTo(Tilec tile){ public byte relativeTo(Building tile){
return relativeTo(tile.tile()); return relativeTo(tile.tile());
} }
@@ -229,25 +229,25 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
} }
/** Multiblock front. */ /** Multiblock front. */
public @Nullable Tilec front(){ public @Nullable Building front(){
int trns = block.size/2 + 1; int trns = block.size/2 + 1;
return nearby(Geometry.d4(rotation()).x * trns, Geometry.d4(rotation()).y * trns); return nearby(Geometry.d4(rotation()).x * trns, Geometry.d4(rotation()).y * trns);
} }
/** Multiblock back. */ /** Multiblock back. */
public @Nullable Tilec back(){ public @Nullable Building back(){
int trns = block.size/2 + 1; int trns = block.size/2 + 1;
return nearby(Geometry.d4(rotation() + 2).x * trns, Geometry.d4(rotation() + 2).y * trns); return nearby(Geometry.d4(rotation() + 2).x * trns, Geometry.d4(rotation() + 2).y * trns);
} }
/** Multiblock left. */ /** Multiblock left. */
public @Nullable Tilec left(){ public @Nullable Building left(){
int trns = block.size/2 + 1; int trns = block.size/2 + 1;
return nearby(Geometry.d4(rotation() + 1).x * trns, Geometry.d4(rotation() + 1).y * trns); return nearby(Geometry.d4(rotation() + 1).x * trns, Geometry.d4(rotation() + 1).y * trns);
} }
/** Multiblock right. */ /** Multiblock right. */
public @Nullable Tilec right(){ public @Nullable Building right(){
int trns = block.size/2 + 1; int trns = block.size/2 + 1;
return nearby(Geometry.d4(rotation() + 3).x * trns, Geometry.d4(rotation() + 3).y * trns); 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(){ public byte version(){
return 0; 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. */ /** Returns the amount of items this block can accept. */
public int acceptStack(Item item, int amount, Teamc source){ 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); return Math.min(getMaximumAccepted(item) - items.get(item), amount);
}else{ }else{
return 0; return 0;
@@ -382,11 +382,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
noSleep(); noSleep();
} }
public boolean acceptPayload(Tilec source, Payload payload){ public boolean acceptPayload(Building source, Payload payload){
return false; 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; int trns = block.size/2 + 1;
Tile next = tile.getNearby(Geometry.d4(rotation()).x * trns, Geometry.d4(rotation()).y * trns); 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)){ if(next != null && next.entity != null && next.entity.team() == team && next.entity.acceptPayload(base(), todump)){
next.entity.handlePayload(this, todump); next.entity.handlePayload(base(), todump);
return true; return true;
} }
@@ -419,10 +419,10 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
int dump = this.dump; int dump = this.dump;
for(int i = 0; i < proximity.size; i++){ 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)){ if(other.team() == team && other.acceptPayload(base(), todump)){
other.handlePayload(this, todump); other.handlePayload(base(), todump);
incrementDump(proximity.size); incrementDump(proximity.size);
return true; return true;
} }
@@ -433,19 +433,19 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
return false; return false;
} }
public void handleItem(Tilec source, Item item){ public void handleItem(Building source, Item item){
items.add(item, 1); 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); 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); 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); 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++){ for(int i = 0; i < proximity.size; i++){
incrementDump(proximity.size); incrementDump(proximity.size);
Tilec other = proximity.get((i + dump) % proximity.size); Building other = proximity.get((i + dump) % proximity.size);
other = other.getLiquidDestination(this, liquid); other = other.getLiquidDestination(base(), liquid);
if(other != null && other.team() == team() && other.block().hasLiquids && canDumpLiquid(other, liquid) && other.liquids() != null){ 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 ofract = other.liquids.get(liquid) / other.block.liquidCapacity;
float fract = liquids.get(liquid) / block.liquidCapacity; float fract = liquids.get(liquid) / block.liquidCapacity;
if(ofract < fract) transferLiquid(other, (fract - ofract) * block.liquidCapacity / 2f, liquid); 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; return true;
} }
public void transferLiquid(Tilec next, float amount, Liquid liquid){ public void transferLiquid(Building next, float amount, Liquid liquid){
float flow = Math.min(next.block().liquidCapacity - next.liquids().get(liquid) - 0.001f, amount); float flow = Math.min(next.block.liquidCapacity - next.liquids.get(liquid) - 0.001f, amount);
if(next.acceptLiquid(this, liquid, flow)){ if(next.acceptLiquid(base(), liquid, flow)){
next.handleLiquid(this, liquid, flow); next.handleLiquid(base(), liquid, flow);
liquids.remove(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); return moveLiquid(next.entity, liquid);
}else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){ }else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){
float leakAmount = liquids.get(liquid) / leakResistance; float leakAmount = liquids.get(liquid) / leakResistance;
Puddles.deposit(next, tile(), liquid, leakAmount); Puddles.deposit(next, tile, liquid, leakAmount);
liquids.remove(liquid, leakAmount); liquids.remove(liquid, leakAmount);
} }
return 0; return 0;
} }
public float moveLiquid(Tilec next, Liquid liquid){ public float moveLiquid(Building next, Liquid liquid){
if(next == null) return 0; 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)){ if(next.acceptLiquid(base(), liquid, 0f)){
float ofract = next.liquids().get(liquid) / next.block().liquidCapacity; float ofract = next.liquids().get(liquid) / next.block.liquidCapacity;
float fract = liquids.get(liquid) / block.liquidCapacity * block.liquidPressure; float fract = liquids.get(liquid) / block.liquidCapacity * block.liquidPressure;
float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (block.liquidCapacity), liquids.get(liquid)); 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)){ if(flow > 0f && ofract <= fract && next.acceptLiquid(base(), liquid, flow)){
next.handleLiquid(this, liquid, flow); next.handleLiquid(base(), liquid, flow);
liquids.remove(liquid, flow); liquids.remove(liquid, flow);
return flow; return flow;
}else if(ofract > 0.1f && fract > 0.1f){ }else if(ofract > 0.1f && fract > 0.1f){
//TODO these are incorrect effect positions //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(); Liquid other = next.liquids().current();
if((other.flammability > 0.3f && liquid.temperature > 0.7f) || (liquid.flammability > 0.3f && other.temperature > 0.7f)){ 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; return 0;
} }
public Tilec getLiquidDestination(Tilec from, Liquid liquid){ public Building getLiquidDestination(Building from, Liquid liquid){
return this; return base();
} }
/** Tries to take the payload. Returns null if no payload is present. */ /** 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++){ for(int i = 0; i < proximity.size; i++){
incrementDump(proximity.size); incrementDump(proximity.size);
Tilec other = proximity.get((i + dump) % proximity.size); Building other = proximity.get((i + dump) % proximity.size);
if(other.team() == team() && other.acceptItem(this, item) && canDump(other, item)){ if(other.team() == team && other.acceptItem(base(), item) && canDump(other, item)){
other.handleItem(this, item); other.handleItem(base(), item);
return; 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++){ for(int i = 0; i < proximity.size; i++){
incrementDump(proximity.size); incrementDump(proximity.size);
Tilec other = proximity.get((i + dump) % proximity.size); Building other = proximity.get((i + dump) % proximity.size);
if(other.team() == team() && other.acceptItem(this, item) && canDump(other, item)){ if(other.team() == team && other.acceptItem(base(), item) && canDump(other, item)){
other.handleItem(this, item); other.handleItem(base(), item);
return true; return true;
} }
} }
@@ -598,23 +598,23 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
if(proximity.size == 0) return false; if(proximity.size == 0) return false;
for(int i = 0; i < proximity.size; i++){ 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){ if(todump == null){
for(int ii = 0; ii < content.items().size; ii++){ for(int ii = 0; ii < content.items().size; ii++){
Item item = content.item(ii); Item item = content.item(ii);
if(other.team() == team() && items.has(item) && other.acceptItem(this, item) && canDump(other, item)){ if(other.team() == team && items.has(item) && other.acceptItem(base(), item) && canDump(other, item)){
other.handleItem(this, item); other.handleItem(base(), item);
items.remove(item, 1); items.remove(item, 1);
incrementDump(proximity.size); incrementDump(proximity.size);
return true; return true;
} }
} }
}else{ }else{
if(other.team() == team() && other.acceptItem(this, todump) && canDump(other, todump)){ if(other.team() == team && other.acceptItem(base(), todump) && canDump(other, todump)){
other.handleItem(this, todump); other.handleItem(base(), todump);
items.remove(todump, 1); items.remove(todump, 1);
incrementDump(proximity.size); incrementDump(proximity.size);
return true; return true;
@@ -632,15 +632,15 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
} }
/** Used for dumping items. */ /** Used for dumping items. */
public boolean canDump(Tilec to, Item item){ public boolean canDump(Building to, Item item){
return true; return true;
} }
/** Try offloading an item to a nearby container in its facing direction. Returns true if success. */ /** Try offloading an item to a nearby container in its facing direction. Returns true if success. */
public boolean moveForward(Item item){ public boolean moveForward(Item item){
Tilec other = front(); Building other = front();
if(other != null && other.team() == team() && other.acceptItem(this, item)){ if(other != null && other.team() == team && other.acceptItem(base(), item)){
other.handleItem(this, item); other.handleItem(base(), item);
return true; return true;
} }
return false; return false;
@@ -658,9 +658,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
public void updatePowerGraph(){ public void updatePowerGraph(){
for(Tilec other : getPowerConnections(tempTileEnts)){ for(Building other : getPowerConnections(tempTileEnts)){
if(other.power() != null){ 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; return;
} }
power.graph.remove(this); power.graph.remove(base());
for(int i = 0; i < power.links.size; i++){ for(int i = 0; i < power.links.size; i++){
Tile other = world.tile(power.links.get(i)); Tile other = world.tile(power.links.get(i));
if(other != null && other.entity != null && other.entity.power() != null){ if(other != null && other.entity != null && other.entity.power != null){
other.entity.power().links.removeValue(pos()); other.entity.power.links.removeValue(pos());
} }
} }
} }
public Seq<Tilec> getPowerConnections(Seq<Tilec> out){ public Seq<Building> getPowerConnections(Seq<Building> out){
out.clear(); out.clear();
if(power == null) return out; if(power == null) return out;
for(Tilec other : proximity){ for(Building other : proximity){
if(other != null && other.power() != null 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())){ && !power.links.contains(other.pos())){
out.add(other); 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++){ for(int i = 0; i < power.links.size; i++){
Tile link = world.tile(power.links.get(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; return out;
} }
@@ -731,7 +731,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
int id = pos(); int id = pos();
TextureRegion region = Block.cracks[block.size - 1][Mathf.clamp((int)((1f - healthf()) * Block.crackRegions), 0, Block.crackRegions-1)]; 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.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(); Draw.color();
} }
@@ -793,8 +793,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
int range = 10; int range = 10;
tempTiles.clear(); tempTiles.clear();
Geometry.circle(tileX(), tileY(), range, (x, y) -> { Geometry.circle(tileX(), tileY(), range, (x, y) -> {
Tilec other = world.ent(x, y); Building 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) && if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, base()) && !PowerNode.insulated(other, base())
&& !other.proximity().contains(this.<Building>base()) &&
!(block.outputsPower && proximity.contains(p -> p.power() != null && p.power().graph == other.power().graph))){ !(block.outputsPower && proximity.contains(p -> p.power() != null && p.power().graph == other.power().graph))){
tempTiles.add(other.tile()); 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))); tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile)));
if(!tempTiles.isEmpty()){ if(!tempTiles.isEmpty()){
Tile toLink = tempTiles.first(); Tile toLink = tempTiles.first();
if(!toLink.entity.power().links.contains(pos())){ if(!toLink.entity.power.links.contains(pos())){
toLink.entity.configureAny(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 */ /** 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. */ /** 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. */ /** 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. //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(); 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.*/ /** 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(); table.left();
for(Consume cons : block.consumes.all()){ for(Consume cons : block.consumes.all()){
if(cons.isOptional() && cons.isBoost()) continue; if(cons.isOptional() && cons.isBoost()) continue;
cons.build(this, table); cons.build(base(), table);
} }
} }
public void displayBars(Table table){ public void displayBars(Table table){
for(Func<Tilec, Bar> bar : block.bars.list()){ for(Func<Building, Bar> bar : block.bars.list()){
table.add(bar.get(this)).growX(); table.add(bar.get(base())).growX();
table.row(); table.row();
} }
} }
@@ -999,7 +1000,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
/** Update table alignment after configuring.*/ /** Update table alignment after configuring.*/
public void updateTableAlign(Table table){ 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); 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. * Called when another tile is tapped while this block is selected.
* @return whether or not this block should be deselected. * @return whether or not this block should be deselected.
*/ */
public boolean onConfigureTileTapped(Tilec other){ public boolean onConfigureTileTapped(Building other){
return this != other; return base() != other;
} }
/** Returns whether this config menu should show when the specified player taps it. */ /** 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; return true;
} }
/** Whether this configuration should be hidden now. Called every frame the config is open. */ /** 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; return false;
} }
public void drawConfigure(){ public void drawConfigure(){
Draw.color(Pal.accent); Draw.color(Pal.accent);
Lines.stroke(1f); Lines.stroke(1f);
Lines.square(x, y, block().size * tilesize / 2f + 1f); Lines.square(x, y, block.size * tilesize / 2f + 1f);
Draw.reset(); Draw.reset();
} }
@@ -1042,13 +1043,13 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
return amount; return amount;
} }
public boolean collide(Bulletc other){ public boolean collide(Bullet other){
return true; return true;
} }
/** Handle a bullet collision. /** Handle a bullet collision.
* @return whether the bullet should be removed. */ * @return whether the bullet should be removed. */
public boolean collision(Bulletc other){ public boolean collision(Bullet other){
damage(other.damage() * other.type().tileDamageMultiplier); damage(other.damage() * other.type().tileDamageMultiplier);
return true; return true;
@@ -1060,15 +1061,15 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
Point2[] nearby = Edges.getEdges(block.size); Point2[] nearby = Edges.getEdges(block.size);
for(Point2 point : nearby){ 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 //remove this tile from all nearby tile's proximities
if(other != null){ if(other != null){
tmpTiles.add(other); tmpTiles.add(other);
} }
} }
for(Tilec other : tmpTiles){ for(Building other : tmpTiles){
other.proximity().remove(this, true); other.proximity.remove(base(), true);
other.onProximityUpdate(); other.onProximityUpdate();
} }
} }
@@ -1079,31 +1080,31 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
Point2[] nearby = Edges.getEdges(block.size); Point2[] nearby = Edges.getEdges(block.size);
for(Point2 point : nearby){ 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 //add this tile to proximity of nearby tiles
if(!other.proximity().contains(this, true)){ if(!other.proximity.contains(base(), true)){
other.proximity().add(this); other.proximity.add(base());
} }
tmpTiles.add(other); tmpTiles.add(other);
} }
//using a set to prevent duplicates //using a set to prevent duplicates
for(Tilec tile : tmpTiles){ for(Building tile : tmpTiles){
proximity.add(tile); proximity.add(tile);
} }
for(Tilec other : tmpTiles){ for(Building other : tmpTiles){
other.onProximityUpdate(); other.onProximityUpdate();
} }
onProximityAdded(); onProximityAdded();
onProximityUpdate(); onProximityUpdate();
for(Tilec other : tmpTiles){ for(Building other : tmpTiles){
other.onProximityUpdate(); other.onProximityUpdate();
} }
} }
@@ -1124,7 +1125,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
@Replace @Replace
@Override @Override
public boolean isValid(){ public boolean isValid(){
return tile.entity == this && !dead(); return tile.entity == base() && !dead();
} }
@Override @Override
@@ -1156,7 +1157,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Tilec, Timerc, Quad
} }
if(block.idleSound != Sounds.none && shouldIdleSound()){ if(block.idleSound != Sounds.none && shouldIdleSound()){
loops.play(block.idleSound, this, block.idleSoundVolume); loops.play(block.idleSound, base(), block.idleSoundVolume);
} }
updateTile(); updateTile();

View File

@@ -34,24 +34,24 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@Override @Override
public void drawBullets(){ public void drawBullets(){
type.draw(this); type.draw(base());
} }
@Override @Override
public void add(){ public void add(){
type.init(this); type.init(base());
} }
@Override @Override
public void remove(){ public void remove(){
type.despawned(this); type.despawned(base());
collided.clear(); collided.clear();
} }
@Override @Override
public float damageMultiplier(){ public float damageMultiplier(){
if(owner instanceof Unitc) return ((Unitc)owner).damageMultiplier() * state.rules.unitDamageMultiplier; if(owner instanceof Unit) return ((Unit)owner).damageMultiplier() * state.rules.unitDamageMultiplier;
if(owner instanceof Tilec) return state.rules.blockDamageMultiplier; if(owner instanceof Building) return state.rules.blockDamageMultiplier;
return 1f; return 1f;
} }
@@ -74,7 +74,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@Replace @Replace
@Override @Override
public boolean collides(Hitboxc other){ 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))) && !(other instanceof Flyingc && ((((Flyingc)other).isFlying() && !type.collidesAir) || (((Flyingc)other).isGrounded() && !type.collidesGround)))
&& !(type.pierce && collided.contains(other.id())); //prevent multiple collisions && !(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) @MethodPriority(100)
@Override @Override
public void collision(Hitboxc other, float x, float y){ public void collision(Hitboxc other, float x, float y){
type.hit(this, x, y); type.hit(base(), x, y);
if(other instanceof Healthc){ if(other instanceof Healthc){
Healthc h = (Healthc)other; Healthc h = (Healthc)other;
h.damage(damage); h.damage(damage);
} }
if(other instanceof Unitc){ if(other instanceof Unit){
Unitc unit = (Unitc)other; Unit unit = (Unit)other;
unit.vel().add(Tmp.v3.set(other.x(), other.y()).sub(x, y).setLength(type.knockback / unit.mass())); unit.vel.add(Tmp.v3.set(unit).sub(x, y).setLength(type.knockback / unit.mass()));
unit.apply(type.status, type.statusDuration); unit.apply(type.status, type.statusDuration);
} }
@@ -105,23 +105,23 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@Override @Override
public void update(){ public void update(){
type.update(this); type.update(base());
if(type.collidesTiles && type.collides){ if(type.collidesTiles && type.collides){
world.raycastEach(world.toTile(lastX()), world.toTile(lastY()), tileX(), tileY(), (x, y) -> { 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 == 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; boolean remove = false;
if(tile.team() != team()){ if(tile.team() != team()){
remove = tile.collision(this); remove = tile.collision(base());
} }
if(remove){ if(remove){
type.hitTile(this, tile); type.hitTile(base(), tile);
remove(); remove();
} }
return true; return true;
@@ -136,8 +136,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
public void draw(){ public void draw(){
Draw.z(Layer.bullet); Draw.z(Layer.bullet);
type.draw(this); type.draw(base());
type.drawLight(this); type.drawLight(base());
} }
/** Sets the bullet's rotation in degrees. */ /** Sets the bullet's rotation in degrees. */

View File

@@ -16,7 +16,7 @@ abstract class CommanderComp implements Unitc{
@Import float x, y, rotation; @Import float x, y, rotation;
transient @Nullable Formation formation; transient @Nullable Formation formation;
transient Seq<Unitc> controlling = new Seq<>(); transient Seq<Unit> controlling = new Seq<>();
@Override @Override
public void update(){ public void update(){
@@ -42,12 +42,12 @@ abstract class CommanderComp implements Unitc{
clearCommand(); clearCommand();
} }
void command(Formation formation, Seq<Unitc> units){ void command(Formation formation, Seq<Unit> units){
clearCommand(); clearCommand();
controlling.addAll(units); controlling.addAll(units);
for(Unitc unit : units){ for(Unit unit : units){
unit.controller(new FormationAI(this, formation)); unit.controller(new FormationAI(base(), formation));
} }
this.formation = formation; this.formation = formation;
@@ -67,8 +67,8 @@ abstract class CommanderComp implements Unitc{
void clearCommand(){ void clearCommand(){
//reset controlled units //reset controlled units
for(Unitc unit : controlling){ for(Unit unit : controlling){
if(unit.controller().isBeingControlled(this)){ if(unit.controller().isBeingControlled(base())){
unit.controller(unit.type().createController()); unit.controller(unit.type().createController());
} }
} }

View File

@@ -8,7 +8,7 @@ import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
@EntityDef(value = {Decalc.class}, pooled = true, serialize = false) @EntityDef(value = {Decalc.class}, pooled = true, serialize = false)
@Component @Component(base = true)
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{ abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{
@Import float x, y, rotation; @Import float x, y, rotation;

View File

@@ -5,9 +5,9 @@ import mindustry.annotations.Annotations.*;
import mindustry.entities.*; import mindustry.entities.*;
import mindustry.gen.*; import mindustry.gen.*;
@EntityDef(value = {Effectc.class, Childc.class}, pooled = true, serialize = false) @EntityDef(value = {EffectStatec.class, Childc.class}, pooled = true, serialize = false)
@Component @Component(base = true)
abstract class EffectComp implements Posc, Drawc, Timedc, Rotc, Childc{ abstract class EffectStateComp implements Posc, Drawc, Timedc, Rotc, Childc{
Color color = new Color(Color.white); Color color = new Color(Color.white);
Effect effect; Effect effect;
Object data; Object data;

View File

@@ -36,7 +36,11 @@ abstract class EntityComp{
return false; return false;
} }
<T> T as(Class<T> type){ <T extends Entityc> T base(){
return (T)this;
}
<T> T as(){
return (T)this; return (T)this;
} }

View File

@@ -14,7 +14,7 @@ import mindustry.world.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@EntityDef(value = {Firec.class}, pooled = true) @EntityDef(value = {Firec.class}, pooled = true)
@Component @Component(base = true)
abstract class FireComp implements Timedc, Posc, Firec{ abstract class FireComp implements Timedc, Posc, Firec{
private static final float spreadChance = 0.05f, fireballChance = 0.07f; private static final float spreadChance = 0.05f, fireballChance = 0.07f;
@@ -49,7 +49,7 @@ abstract class FireComp implements Timedc, Posc, Firec{
return; return;
} }
Tilec entity = tile.entity; Building entity = tile.entity;
boolean damage = entity != null; boolean damage = entity != null;
float flammability = baseFlammability + puddleFlammability; float flammability = baseFlammability + puddleFlammability;
@@ -97,6 +97,6 @@ abstract class FireComp implements Timedc, Posc, Firec{
@Override @Override
public void afterRead(){ public void afterRead(){
Fires.register(this); Fires.register(base());
} }
} }

View File

@@ -7,7 +7,7 @@ import mindustry.type.*;
@Component @Component
abstract class ItemsComp implements Posc{ abstract class ItemsComp implements Posc{
@ReadOnly ItemStack stack = new ItemStack(); ItemStack stack = new ItemStack();
transient float itemTime; transient float itemTime;
abstract int itemCapacity(); abstract int itemCapacity();

View File

@@ -35,7 +35,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{
@Override @Override
public void update(){ public void update(){
Tilec core = closestCore(); Building core = closestCore();
if(core != null && mineTile != null && mineTile.drop() != null && !acceptsItem(mineTile.drop()) && dst(core) < mineTransferRange){ if(core != null && mineTile != null && mineTile.drop() != null && !acceptsItem(mineTile.drop()) && dst(core) < mineTransferRange){
int accepted = core.acceptStack(item(), stack().amount, this); int accepted = core.acceptStack(item(), stack().amount, this);

View File

@@ -25,13 +25,13 @@ abstract class PayloadComp implements Posc, Rotc{
payloads.add(load); payloads.add(load);
} }
void pickup(Unitc unit){ void pickup(Unit unit){
unit.remove(); unit.remove();
payloads.add(new UnitPayload(unit)); payloads.add(new UnitPayload(unit));
Fx.unitPickup.at(unit); Fx.unitPickup.at(unit);
} }
void pickup(Tilec tile){ void pickup(Building tile){
tile.tile().remove(); tile.tile().remove();
payloads.add(new BlockPayload(tile)); payloads.add(new BlockPayload(tile));
Fx.unitPickup.at(tile); Fx.unitPickup.at(tile);
@@ -69,10 +69,10 @@ abstract class PayloadComp implements Posc, Rotc{
boolean dropUnit(UnitPayload payload){ boolean dropUnit(UnitPayload payload){
//TODO create an effect here and/or make them be at a lower elevation //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 //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; return false;
} }
@@ -87,11 +87,11 @@ abstract class PayloadComp implements Posc, Rotc{
/** @return whether the tile has been successfully placed. */ /** @return whether the tile has been successfully placed. */
boolean dropBlock(BlockPayload payload){ 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()); int tx = Vars.world.toTile(x - tile.block().offset()), ty = Vars.world.toTile(y - tile.block().offset());
Tile on = Vars.world.tile(tx, ty); Tile on = Vars.world.tile(tx, ty);
if(on != null && Build.validPlace(tile.block(), tile.team(), tx, ty, tile.rotation())){ 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); payload.place(on, rot);
Fx.unitDrop.at(tile); Fx.unitDrop.at(tile);

View File

@@ -31,7 +31,9 @@ import static mindustry.Vars.*;
abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Drawc{ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Drawc{
static final float deathDelay = 30f; 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; transient @Nullable NetConnection con;
@ReadOnly Team team = Team.sharded; @ReadOnly Team team = Team.sharded;
@@ -53,7 +55,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
} }
public @Nullable CoreEntity closestCore(){ public @Nullable CoreEntity closestCore(){
return state.teams.closestCore(x(), y(), team); return state.teams.closestCore(x, y, team);
} }
public @Nullable CoreEntity core(){ public @Nullable CoreEntity core(){
@@ -106,7 +108,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
//update some basic state to sync things //update some basic state to sync things
if(unit.type().canBoost){ if(unit.type().canBoost){
Tile tile = unit.tileOn(); 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){ }else if(core != null){
//have a small delay before death to prevent the camera from jumping around too quickly //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(); deathTimer += Time.delta();
if(deathTimer >= deathDelay){ if(deathTimer >= deathDelay){
//request spawn - this happens serverside only //request spawn - this happens serverside only
core.requestSpawn((Playerc)this); core.requestSpawn(base());
deathTimer = 0; deathTimer = 0;
} }
} }
@@ -132,7 +134,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
unit(Nulls.unit); unit(Nulls.unit);
} }
public Unitc unit(){ public Unit unit(){
return unit; return unit;
} }
@@ -144,7 +146,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
return !(unit instanceof Builderc) ? Nulls.builder : (Builderc)unit; 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(unit == null) throw new IllegalArgumentException("Unit cannot be null. Use clearUnit() instead.");
if(this.unit == unit) return; if(this.unit == unit) return;
if(this.unit != Nulls.unit){ if(this.unit != Nulls.unit){
@@ -157,7 +159,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
unit.controller(this); unit.controller(this);
} }
Events.fire(new UnitChangeEvent((Playerc)this, unit)); Events.fire(new UnitChangeEvent(base(), unit));
} }
boolean dead(){ boolean dead(){
@@ -201,17 +203,17 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
if(!isLocal()){ if(!isLocal()){
Draw.color(0f, 0f, 0f, 0.3f); 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(); Draw.color();
font.setColor(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){ if(admin){
float s = 3f; float s = 3f;
Draw.color(color.r * 0.5f, color.g * 0.5f, color.b * 0.5f, 1f); 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.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); layout.setText(font, text, Color.white, width, Align.bottom, true);
Draw.color(0f, 0f, 0f, 0.3f * (textFadeTime <= 0 || lastText == null ? 1f : visualFadeTime)); 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); 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); font.draw(text, unit.x - width/2f, unit.y + textHeight + layout.height, width, Align.center, true);
} }
Draw.reset(); 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())); 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(isLocal()){
if(ui != null){ if(ui != null){
ui.chatfrag.addMessage(text, fromName); ui.chatfrag.addMessage(text, fromName);

View File

@@ -18,7 +18,7 @@ import static mindustry.Vars.*;
import static mindustry.entities.Puddles.*; import static mindustry.entities.Puddles.*;
@EntityDef(value = {Puddlec.class}, pooled = true) @EntityDef(value = {Puddlec.class}, pooled = true)
@Component @Component(base = true)
abstract class PuddleComp implements Posc, Puddlec, Drawc{ abstract class PuddleComp implements Posc, Puddlec, Drawc{
private static final int maxGeneration = 2; private static final int maxGeneration = 2;
private static final Color tmp = new Color(); private static final Color tmp = new Color();
@@ -128,6 +128,6 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
@Override @Override
public void afterRead(){ public void afterRead(){
Puddles.register(this); Puddles.register(base());
} }
} }

View File

@@ -13,7 +13,7 @@ import mindustry.gen.*;
import mindustry.type.*; import mindustry.type.*;
import mindustry.world.blocks.environment.*; import mindustry.world.blocks.environment.*;
import static mindustry.Vars.content; import static mindustry.Vars.*;
@Component @Component
abstract class StatusComp implements Posc, Flyingc{ abstract class StatusComp implements Posc, Flyingc{
@@ -46,7 +46,7 @@ abstract class StatusComp implements Posc, Flyingc{
return; return;
}else if(entry.effect.reactsWith(effect)){ //find opposite }else if(entry.effect.reactsWith(effect)){ //find opposite
StatusEntry.tmp.effect = entry.effect; 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; entry.time = StatusEntry.tmp.time;
if(StatusEntry.tmp.effect != entry.effect){ if(StatusEntry.tmp.effect != entry.effect){
@@ -128,15 +128,14 @@ abstract class StatusComp implements Posc, Flyingc{
speedMultiplier *= entry.effect.speedMultiplier; speedMultiplier *= entry.effect.speedMultiplier;
armorMultiplier *= entry.effect.armorMultiplier; armorMultiplier *= entry.effect.armorMultiplier;
damageMultiplier *= entry.effect.damageMultiplier; damageMultiplier *= entry.effect.damageMultiplier;
//TODO ugly casting entry.effect.update(base(), entry.time);
entry.effect.update((Unitc)this, entry.time);
} }
} }
} }
public void draw(){ public void draw(){
for(StatusEntry e : statuses){ for(StatusEntry e : statuses){
e.effect.draw((Unitc)this); e.effect.draw(base());
} }
} }

View File

@@ -17,15 +17,15 @@ abstract class TeamComp implements Posc{
return team.rules().cheat; return team.rules().cheat;
} }
public @Nullable Tilec core(){ public @Nullable Building core(){
return team.core(); return team.core();
} }
public @Nullable Tilec closestCore(){ public @Nullable Building closestCore(){
return state.teams.closestCore(x, y, team); return state.teams.closestCore(x, y, team);
} }
public @Nullable Tilec closestEnemyCore(){ public @Nullable Building closestEnemyCore(){
return state.teams.closestEnemyCore(x, y, team); return state.teams.closestEnemyCore(x, y, team);
} }
} }

View File

@@ -11,6 +11,7 @@ import mindustry.content.*;
import mindustry.entities.*; import mindustry.entities.*;
import mindustry.entities.units.*; import mindustry.entities.units.*;
import mindustry.game.EventType.*; import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.type.*; 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 float x, y, rotation, elevation, maxHealth, drag, armor, hitSize, health;
@Import boolean dead; @Import boolean dead;
@Import Team team;
private UnitController controller; private UnitController controller;
private UnitType type; private UnitType type;
@@ -60,13 +62,13 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override @Override
public float bounds(){ public float bounds(){
return hitSize() * 2f; return hitSize * 2f;
} }
@Override @Override
public void controller(UnitController next){ public void controller(UnitController next){
this.controller = next; this.controller = next;
if(controller.unit() != this) controller.unit(this); if(controller.unit() != base()) controller.unit(base());
} }
@Override @Override
@@ -128,7 +130,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
public void afterSync(){ public void afterSync(){
//set up type info after reading //set up type info after reading
setStats(this.type); setStats(this.type);
controller.unit(this); controller.unit(base());
} }
@Override @Override
@@ -140,13 +142,13 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override @Override
public void add(){ public void add(){
teamIndex.updateCount(team(), 1); teamIndex.updateCount(team, 1);
} }
@Override @Override
public void remove(){ public void remove(){
teamIndex.updateCount(team(), -1); teamIndex.updateCount(team, -1);
controller.removed(this); controller.removed(base());
} }
@Override @Override
@@ -155,17 +157,17 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
Effects.shake(type.landShake, type.landShake, this); Effects.shake(type.landShake, type.landShake, this);
} }
type.landed(this); type.landed(base());
} }
@Override @Override
public void update(){ public void update(){
type.update(this); type.update(base());
drag(type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f)); drag(type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f));
//apply knockback based on spawns //apply knockback based on spawns
if(team() != state.rules.waveTeam){ if(team != state.rules.waveTeam){
float relativeSize = state.rules.dropZoneRadius + bounds()/2f + 1f; float relativeSize = state.rules.dropZoneRadius + bounds()/2f + 1f;
for(Tile spawn : spawner.getSpawns()){ for(Tile spawn : spawner.getSpawns()){
if(within(spawn.worldx(), spawn.worldy(), relativeSize)){ 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()){ if(tile != null && isGrounded()){
//unit block update //unit block update
if(tile.entity != null){ if(tile.entity != null){
tile.entity.unitOn(this); tile.entity.unitOn(base());
} }
//kill when stuck in wall //kill when stuck in wall
@@ -208,7 +210,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override @Override
public void display(Table table){ public void display(Table table){
type.display(this, table); type.display(base(), table);
} }
@Override @Override
@@ -218,17 +220,17 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override @Override
public void draw(){ public void draw(){
type.draw(this); type.draw(base());
} }
@Override @Override
public boolean isPlayer(){ public boolean isPlayer(){
return controller instanceof Playerc; return controller instanceof Player;
} }
@Nullable @Nullable
public Playerc getPlayer(){ public Player getPlayer(){
return isPlayer() ? (Playerc)controller : null; return isPlayer() ? (Player)controller : null;
} }
@Override @Override
@@ -240,12 +242,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
float flammability = item().flammability * stack().amount; float flammability = item().flammability * stack().amount;
Damage.dynamicExplosion(x, y, flammability, explosiveness, 0f, bounds() / 2f, Pal.darkFlame); 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); Fx.explosion.at(this);
Effects.shake(2f, 2f, this); Effects.shake(2f, 2f, this);
type.deathSound.at(this); type.deathSound.at(this);
Events.fire(new UnitDestroyEvent(this)); Events.fire(new UnitDestroyEvent(base()));
if(explosiveness > 7f && isLocal()){ if(explosiveness > 7f && isLocal()){
Events.fire(Trigger.suicideBomb); Events.fire(Trigger.suicideBomb);
@@ -260,7 +262,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
if(dead || net.client()) return; if(dead || net.client()) return;
//deaths are synced; this calls killed() //deaths are synced; this calls killed()
Call.onUnitDeath(this); Call.onUnitDeath(base());
} }
@Override @Override

View File

@@ -14,7 +14,7 @@ public class AIController implements UnitController{
protected static final Vec2 vec = new Vec2(); protected static final Vec2 vec = new Vec2();
protected static final int timerTarget = 0; protected static final int timerTarget = 0;
protected Unitc unit; protected Unit unit;
protected Teamc target; protected Teamc target;
protected Interval timer = new Interval(4); protected Interval timer = new Interval(4);
@@ -23,12 +23,12 @@ public class AIController implements UnitController{
} }
protected void targetClosestAllyFlag(BlockFlag flag){ 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; if(target != null) this.target = target.entity;
} }
protected void targetClosestEnemyFlag(BlockFlag flag){ 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; if(target != null) this.target = target.entity;
} }
@@ -37,7 +37,7 @@ public class AIController implements UnitController{
} }
protected void targetClosest(){ 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){ if(newTarget != null){
target = newTarget; target = newTarget;
} }
@@ -48,7 +48,7 @@ public class AIController implements UnitController{
} }
@Override @Override
public void unit(Unitc unit){ public void unit(Unit unit){
if(this.unit == unit) return; if(this.unit == unit) return;
this.unit = unit; this.unit = unit;
@@ -56,7 +56,7 @@ public class AIController implements UnitController{
} }
@Override @Override
public Unitc unit(){ public Unit unit(){
return unit; return unit;
} }
} }

View File

@@ -3,8 +3,8 @@ package mindustry.entities.units;
import mindustry.gen.*; import mindustry.gen.*;
public interface UnitController{ public interface UnitController{
void unit(Unitc unit); void unit(Unit unit);
Unitc unit(); Unit unit();
default void command(UnitCommand command){ 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; return false;
} }
} }

View File

@@ -69,20 +69,20 @@ public class EventType{
public static class CommandIssueEvent{ public static class CommandIssueEvent{
public final Tilec tile; public final Building tile;
public final UnitCommand command; public final UnitCommand command;
public CommandIssueEvent(Tilec tile, UnitCommand command){ public CommandIssueEvent(Building tile, UnitCommand command){
this.tile = tile; this.tile = tile;
this.command = command; this.command = command;
} }
} }
public static class PlayerChatEvent{ public static class PlayerChatEvent{
public final Playerc player; public final Player player;
public final String message; public final String message;
public PlayerChatEvent(Playerc player, String message){ public PlayerChatEvent(Player player, String message){
this.player = player; this.player = player;
this.message = message; this.message = message;
} }
@@ -120,12 +120,12 @@ public class EventType{
/** Called when the player withdraws items from a block. */ /** Called when the player withdraws items from a block. */
public static class WithdrawEvent{ public static class WithdrawEvent{
public final Tilec tile; public final Building tile;
public final Playerc player; public final Player player;
public final Item item; public final Item item;
public final int amount; 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.tile = tile;
this.player = player; this.player = player;
this.item = item; this.item = item;
@@ -135,12 +135,12 @@ public class EventType{
/** Called when a player deposits items to a block.*/ /** Called when a player deposits items to a block.*/
public static class DepositEvent{ public static class DepositEvent{
public final Tilec tile; public final Building tile;
public final Playerc player; public final Player player;
public final Item item; public final Item item;
public final int amount; 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.tile = tile;
this.player = player; this.player = player;
this.item = item; this.item = item;
@@ -150,10 +150,10 @@ public class EventType{
/** Called when the player taps a block. */ /** Called when the player taps a block. */
public static class TapEvent{ public static class TapEvent{
public final Tilec tile; public final Building tile;
public final Playerc player; public final Player player;
public TapEvent(Tilec tile, Playerc player){ public TapEvent(Building tile, Player player){
this.tile = tile; this.tile = tile;
this.player = player; this.player = player;
} }
@@ -161,11 +161,11 @@ public class EventType{
/** Called when the player sets a specific block. */ /** Called when the player sets a specific block. */
public static class TapConfigEvent{ public static class TapConfigEvent{
public final Tilec tile; public final Building tile;
public final Playerc player; public final Player player;
public final Object value; public final Object value;
public TapConfigEvent(Tilec tile, Playerc player, Object value){ public TapConfigEvent(Building tile, Player player, Object value){
this.tile = tile; this.tile = tile;
this.player = player; this.player = player;
this.value = value; this.value = value;
@@ -181,10 +181,10 @@ public class EventType{
} }
/** Called from the logic thread. Do not access graphics here! */ /** Called from the logic thread. Do not access graphics here! */
public static class TileChangeEvent{ public static class BuildinghangeEvent{
public final Tile tile; public final Tile tile;
public TileChangeEvent(Tile tile){ public BuildinghangeEvent(Tile tile){
this.tile = tile; this.tile = tile;
} }
} }
@@ -233,10 +233,10 @@ public class EventType{
public static class BlockBuildEndEvent{ public static class BlockBuildEndEvent{
public final Tile tile; public final Tile tile;
public final Team team; public final Team team;
public final @Nullable Unitc unit; public final @Nullable Unit unit;
public final boolean breaking; 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.tile = tile;
this.team = team; this.team = team;
this.unit = unit; this.unit = unit;
@@ -273,26 +273,26 @@ public class EventType{
} }
public static class UnitDestroyEvent{ public static class UnitDestroyEvent{
public final Unitc unit; public final Unit unit;
public UnitDestroyEvent(Unitc unit){ public UnitDestroyEvent(Unit unit){
this.unit = unit; this.unit = unit;
} }
} }
public static class UnitCreateEvent{ public static class UnitCreateEvent{
public final Unitc unit; public final Unit unit;
public UnitCreateEvent(Unitc unit){ public UnitCreateEvent(Unit unit){
this.unit = unit; this.unit = unit;
} }
} }
public static class UnitChangeEvent{ public static class UnitChangeEvent{
public final Playerc player; public final Player player;
public final Unitc unit; public final Unit unit;
public UnitChangeEvent(Playerc player, Unitc unit){ public UnitChangeEvent(Player player, Unit unit){
this.player = player; this.player = player;
this.unit = unit; this.unit = unit;
} }
@@ -300,42 +300,42 @@ public class EventType{
/** Called after connecting; when a player recieves world data and is ready to play.*/ /** Called after connecting; when a player recieves world data and is ready to play.*/
public static class PlayerJoin{ public static class PlayerJoin{
public final Playerc player; public final Player player;
public PlayerJoin(Playerc player){ public PlayerJoin(Player player){
this.player = player; this.player = player;
} }
} }
/** Called when a player connects, but has not joined the game yet.*/ /** Called when a player connects, but has not joined the game yet.*/
public static class PlayerConnect{ public static class PlayerConnect{
public final Playerc player; public final Player player;
public PlayerConnect(Playerc player){ public PlayerConnect(Player player){
this.player = player; this.player = player;
} }
} }
public static class PlayerLeave{ public static class PlayerLeave{
public final Playerc player; public final Player player;
public PlayerLeave(Playerc player){ public PlayerLeave(Player player){
this.player = player; this.player = player;
} }
} }
public static class PlayerBanEvent{ public static class PlayerBanEvent{
public final Playerc player; public final Player player;
public PlayerBanEvent(Playerc player){ public PlayerBanEvent(Player player){
this.player = player; this.player = player;
} }
} }
public static class PlayerUnbanEvent{ public static class PlayerUnbanEvent{
public final Playerc player; public final Player player;
public PlayerUnbanEvent(Playerc player){ public PlayerUnbanEvent(Player player){
this.player = player; this.player = player;
} }
} }

Some files were not shown because too many files have changed in this diff Show More