diff --git a/core/src/fos/FOSTypeIO.java b/core/src/fos/FOSTypeIO.java index 07b0f554..f8a104d6 100644 --- a/core/src/fos/FOSTypeIO.java +++ b/core/src/fos/FOSTypeIO.java @@ -1,8 +1,28 @@ package fos; +import arc.util.io.Reads; import mindustry.annotations.Annotations; +import mindustry.entities.units.WeaponMount; import mindustry.io.TypeIO; @Annotations.TypeIOHandler public class FOSTypeIO extends TypeIO { + public static WeaponMount[] readMounts(Reads read) { + WeaponMount[] mounts = new WeaponMount[read.b()]; + + for(int i = 0; i < mounts.length; i++){ + byte state = read.b(); + float ax = read.f(), ay = read.f(); + + if(i <= mounts.length - 1){ + WeaponMount m = mounts[i]; + m.aimX = ax; + m.aimY = ay; + m.shoot = (state & 1) != 0; + m.rotate = (state & 2) != 0; + } + } + + return mounts; + } } diff --git a/core/src/fos/type/units/comp/LumoniPlayerUnitComp.java b/core/src/fos/type/units/comp/LumoniPlayerUnitComp.java index 490568fe..fa3e6ed4 100644 --- a/core/src/fos/type/units/comp/LumoniPlayerUnitComp.java +++ b/core/src/fos/type/units/comp/LumoniPlayerUnitComp.java @@ -1,15 +1,28 @@ package fos.type.units.comp; +import arc.util.io.*; +import fos.FOSTypeIO; import mindustry.annotations.Annotations; import mindustry.entities.units.WeaponMount; import mindustry.gen.*; +import mindustry.io.TypeIO; // FIXME mounts @Annotations.Component public abstract class LumoniPlayerUnitComp implements Weaponsc, Entityc, Syncc { @Annotations.Import WeaponMount[] mounts; - WeaponMount[] syncMounts; + @Override + public void write(Writes write) { + TypeIO.writeMounts(write, mounts); + } + + @Override + public void read(Reads read) { + mounts = FOSTypeIO.readMounts(read); + } + +/* @Override public void afterRead() { mounts = syncMounts; @@ -19,4 +32,5 @@ public void afterRead() { public void afterSync() { mounts = syncMounts; } +*/ }