Skip to content

Commit

Permalink
ok fine (this still doesn't work!)
Browse files Browse the repository at this point in the history
  • Loading branch information
Slotterleet committed Nov 27, 2023
1 parent 3d7b63d commit db7f758
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
20 changes: 20 additions & 0 deletions core/src/fos/FOSTypeIO.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
16 changes: 15 additions & 1 deletion core/src/fos/type/units/comp/LumoniPlayerUnitComp.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,4 +32,5 @@ public void afterRead() {
public void afterSync() {
mounts = syncMounts;
}
*/
}

0 comments on commit db7f758

Please sign in to comment.