Autogeneration of some IO code
This commit is contained in:
@@ -11,8 +11,8 @@ import static mindustry.Vars.*;
|
||||
abstract class BoundedComp implements Velc, Posc, Healthc, Flyingc{
|
||||
static final float warpDst = 180f;
|
||||
|
||||
transient float x, y;
|
||||
transient Vec2 vel;
|
||||
@Import float x, y;
|
||||
@Import Vec2 vel;
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
|
||||
@@ -4,10 +4,9 @@ import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.struct.Queue;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
@@ -27,10 +26,10 @@ import static mindustry.Vars.*;
|
||||
abstract class BuilderComp implements Unitc{
|
||||
static final Vec2[] tmptr = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()};
|
||||
|
||||
transient float x, y, rotation;
|
||||
@Import float x, y, rotation;
|
||||
|
||||
Queue<BuildRequest> requests = new Queue<>();
|
||||
float buildSpeed = 1f;
|
||||
transient float buildSpeed = 1f;
|
||||
//boolean building;
|
||||
|
||||
void updateBuilding(){
|
||||
|
||||
@@ -6,7 +6,7 @@ import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class ChildComp implements Posc{
|
||||
transient float x, y;
|
||||
@Import float x, y;
|
||||
|
||||
@Nullable Posc parent;
|
||||
float offsetX, offsetY;
|
||||
|
||||
@@ -9,7 +9,7 @@ import mindustry.gen.*;
|
||||
@EntityDef(value = {Decalc.class}, pooled = true)
|
||||
@Component
|
||||
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc, DrawLayerFloorc{
|
||||
transient float x, y, rotation;
|
||||
@Import float x, y, rotation;
|
||||
|
||||
Color color = new Color(1, 1, 1, 1);
|
||||
TextureRegion region;
|
||||
|
||||
@@ -7,7 +7,7 @@ import static mindustry.Vars.collisions;
|
||||
|
||||
@Component
|
||||
abstract class ElevationMoveComp implements Velc, Posc, Flyingc, Hitboxc{
|
||||
transient float x, y;
|
||||
@Import float x, y;
|
||||
|
||||
@Replace
|
||||
@Override
|
||||
|
||||
@@ -12,8 +12,8 @@ import static mindustry.Vars.player;
|
||||
@Component
|
||||
@BaseComponent
|
||||
abstract class EntityComp{
|
||||
private boolean added;
|
||||
int id = EntityGroup.nextId();
|
||||
private transient boolean added;
|
||||
transient int id = EntityGroup.nextId();
|
||||
|
||||
boolean isAdded(){
|
||||
return added;
|
||||
@@ -49,6 +49,9 @@ abstract class EntityComp{
|
||||
@InternalImpl
|
||||
abstract int classId();
|
||||
|
||||
@InternalImpl
|
||||
abstract boolean serialize();
|
||||
|
||||
void read(DataInput input) throws IOException{
|
||||
//TODO dynamic io
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import static mindustry.Vars.*;
|
||||
abstract class FireComp implements Timedc, Posc, Firec{
|
||||
private static final float spreadChance = 0.05f, fireballChance = 0.07f;
|
||||
|
||||
transient float time, lifetime, x, y;
|
||||
@Import float time, lifetime, x, y;
|
||||
|
||||
Tile tile;
|
||||
private Block block;
|
||||
|
||||
@@ -12,12 +12,12 @@ import static mindustry.Vars.net;
|
||||
|
||||
@Component
|
||||
abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
transient float x, y;
|
||||
transient Vec2 vel;
|
||||
@Import float x, y;
|
||||
@Import Vec2 vel;
|
||||
|
||||
float elevation;
|
||||
float drownTime;
|
||||
float splashTimer;
|
||||
transient float splashTimer;
|
||||
|
||||
boolean isGrounded(){
|
||||
return elevation < 0.001f;
|
||||
|
||||
@@ -9,7 +9,8 @@ import mindustry.gen.*;
|
||||
abstract class HealthComp implements Entityc{
|
||||
static final float hitDuration = 9f;
|
||||
|
||||
float health, maxHealth = 1f, hitTime;
|
||||
transient float hitTime;
|
||||
float health, maxHealth = 1f;
|
||||
boolean dead;
|
||||
|
||||
boolean isValid(){
|
||||
|
||||
@@ -7,7 +7,7 @@ import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class HitboxComp implements Posc, QuadTreeObject{
|
||||
transient float x, y;
|
||||
@Import float x, y;
|
||||
|
||||
float hitSize;
|
||||
float lastX, lastY;
|
||||
|
||||
@@ -8,7 +8,7 @@ import mindustry.type.*;
|
||||
@Component
|
||||
abstract class ItemsComp implements Posc{
|
||||
@ReadOnly ItemStack stack = new ItemStack();
|
||||
float itemTime;
|
||||
transient float itemTime;
|
||||
|
||||
abstract int itemCapacity();
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc, Unitc, Legsc, ElevationMovec{
|
||||
transient float x, y;
|
||||
@Import float x, y;
|
||||
|
||||
float baseRotation, walkTime;
|
||||
float baseRotation;
|
||||
transient float walkTime;
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
|
||||
@@ -18,9 +18,9 @@ import static mindustry.Vars.*;
|
||||
|
||||
@Component
|
||||
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc{
|
||||
transient float x, y, rotation;
|
||||
@Import float x, y, rotation;
|
||||
|
||||
float mineTimer;
|
||||
transient float mineTimer;
|
||||
@Nullable Tile mineTile;
|
||||
|
||||
abstract boolean canMine(Item item);
|
||||
|
||||
@@ -23,8 +23,7 @@ import static mindustry.Vars.*;
|
||||
@EntityDef({Playerc.class})
|
||||
@Component
|
||||
abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
||||
@NonNull
|
||||
@ReadOnly Unitc unit = Nulls.unit;
|
||||
@NonNull @ReadOnly Unitc unit = Nulls.unit;
|
||||
|
||||
@ReadOnly Team team = Team.sharded;
|
||||
String name = "noname";
|
||||
@@ -33,7 +32,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
||||
Color color = new Color();
|
||||
float mouseX, mouseY;
|
||||
|
||||
@Nullable String lastText;
|
||||
String lastText = "";
|
||||
float textFadeTime;
|
||||
|
||||
public boolean isBuilder(){
|
||||
@@ -51,7 +50,6 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
||||
public void reset(){
|
||||
team = state.rules.defaultTeam;
|
||||
admin = typing = false;
|
||||
lastText = null;
|
||||
textFadeTime = 0f;
|
||||
if(!dead()){
|
||||
unit.controller(unit.type().createController());
|
||||
|
||||
@@ -25,7 +25,7 @@ abstract class PuddleComp implements Posc, DrawLayerFloorOverc{
|
||||
private static final Rect rect2 = new Rect();
|
||||
private static int seeds;
|
||||
|
||||
transient float x, y;
|
||||
@Import float x, y;
|
||||
|
||||
float amount, lastRipple, accepting, updateTime;
|
||||
int generation;
|
||||
|
||||
@@ -7,7 +7,7 @@ import mindustry.net.*;
|
||||
|
||||
@Component
|
||||
abstract class SyncComp implements Posc{
|
||||
transient float x, y;
|
||||
@Import float x, y;
|
||||
|
||||
Interpolator interpolator = new Interpolator();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import static mindustry.Vars.state;
|
||||
|
||||
@Component
|
||||
abstract class TeamComp implements Posc{
|
||||
transient float x, y;
|
||||
@Import float x, y;
|
||||
|
||||
Team team = Team.sharded;
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import static mindustry.Vars.*;
|
||||
@Component
|
||||
abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc,
|
||||
DrawLayerGroundc, DrawLayerFlyingc, DrawLayerGroundShadowsc, DrawLayerFlyingShadowsc{
|
||||
transient float x, y, rotation;
|
||||
@Import float x, y, rotation;
|
||||
|
||||
private UnitController controller;
|
||||
private UnitDef type;
|
||||
private UnitType type;
|
||||
|
||||
@Override
|
||||
public float clipSize(){
|
||||
@@ -52,7 +52,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(UnitDef def, UnitController controller){
|
||||
public void set(UnitType def, UnitController controller){
|
||||
type(type);
|
||||
controller(controller);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
}
|
||||
|
||||
@Override
|
||||
public void type(UnitDef type){
|
||||
public void type(UnitType type){
|
||||
this.type = type;
|
||||
maxHealth(type.health);
|
||||
heal();
|
||||
@@ -86,7 +86,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnitDef type(){
|
||||
public UnitType type(){
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class VelComp implements Posc{
|
||||
transient float x, y;
|
||||
@Import float x, y;
|
||||
|
||||
final Vec2 vel = new Vec2();
|
||||
float drag = 0f;
|
||||
|
||||
@@ -11,7 +11,7 @@ import static mindustry.Vars.collisions;
|
||||
//just a proof of concept
|
||||
@Component
|
||||
abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc{
|
||||
transient float x, y;
|
||||
@Import float x, y;
|
||||
|
||||
@Replace
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,7 @@ import mindustry.type.*;
|
||||
|
||||
@Component
|
||||
abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
||||
transient float x, y, rotation;
|
||||
@Import float x, y, rotation;
|
||||
|
||||
/** minimum cursor distance from player, fixes 'cross-eyed' shooting */
|
||||
static final float minAimDst = 20f;
|
||||
@@ -22,7 +22,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
||||
/** weapon mount array, never null */
|
||||
@ReadOnly WeaponMount[] mounts = {};
|
||||
|
||||
void setupWeapons(UnitDef def){
|
||||
void setupWeapons(UnitType def){
|
||||
mounts = new WeaponMount[def.weapons.size];
|
||||
for(int i = 0; i < mounts.length; i++){
|
||||
mounts[i] = new WeaponMount(def.weapons.get(i));
|
||||
|
||||
Reference in New Issue
Block a user