-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd51b5b
commit ea4dc31
Showing
19 changed files
with
299 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:building,type:mindustry.gen.Building},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:building,type:mindustry.gen.Building},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:payloads,type:arc.struct.Seq<mindustry.world.blocks.payloads.Payload>},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:baseRotation,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:payloads,type:arc.struct.Seq<mindustry.world.blocks.payloads.Payload>},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{fields:[{name:abilities,type:"mindustry.entities.abilities.Ability[]"},{name:ammo,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:updateBuilding,type:boolean},{name:vel,type:arc.math.geom.Vec2},{name:x,type:float},{name:y,type:float}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pluginManagement{ | ||
repositories{ | ||
gradlePluginPortal() | ||
maven{url 'https://jitpack.io'} | ||
} | ||
} | ||
|
||
if(JavaVersion.current().ordinal() < JavaVersion.VERSION_17.ordinal()){ | ||
throw new GradleException("JDK 17 is a required minimum version. Yours: ${System.getProperty('java.version')}") | ||
} | ||
|
||
rootProject.name = modName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package fos.io; | ||
|
||
import arc.util.*; | ||
import arc.util.io.*; | ||
import fos.gen.LumoniPlayerc; | ||
import fos.type.abilities.FOSAbility; | ||
import fos.type.content.WeaponSet; | ||
import mindustry.entities.abilities.Ability; | ||
import mindustry.entities.units.WeaponMount; | ||
import mindustry.gen.Unitc; | ||
import mindustry.io.TypeIO; | ||
import mindustry.type.Weapon; | ||
|
||
import java.io.IOException; | ||
|
||
public class FOSTypeIO extends TypeIO { | ||
public static void writeMounts2(Writes writes, Unitc unit) { | ||
writes.i(unit.mounts().length); | ||
|
||
for (WeaponMount mount : unit.mounts()) { | ||
Weapon weapon = mount.weapon; | ||
if (unit instanceof LumoniPlayerc lpu && lpu.isEditedWeapons()) { | ||
writes.bool(true); | ||
|
||
writes.i(lpu.weaponSet().id); | ||
writes.i(lpu.weaponSet().weapons.indexOf(mount.weapon)); | ||
|
||
// write WeaponSet's abilities | ||
for (Ability ability : lpu.weaponSet().abilities) { | ||
if (ability instanceof FOSAbility a) | ||
a.write(writes, unit); | ||
else | ||
writes.f(ability.data); | ||
} | ||
|
||
} else { | ||
writes.bool(false); | ||
writes.str(weapon.name); | ||
} | ||
} | ||
|
||
TypeIO.writeMounts(writes, unit.mounts()); | ||
} | ||
|
||
public static WeaponMount[] readMounts2(Reads reads, Unitc unit) { | ||
WeaponMount[] mounts = new WeaponMount[reads.i()]; | ||
|
||
for (int i = 0; i < mounts.length; i++) { | ||
WeaponMount mount = null; | ||
if (reads.bool()) { | ||
WeaponSet set = WeaponSet.sets.get(reads.i()); | ||
mount = set.getMount(reads.i()); | ||
|
||
unit.abilities(set.abilities.toArray(Ability.class)); | ||
|
||
// read WeaponSet's abilities | ||
for (Ability ability : set.abilities) { | ||
if (ability instanceof FOSAbility a) | ||
a.read(reads, unit); | ||
else | ||
ability.data = reads.f(); | ||
} | ||
} else { | ||
String name = reads.str(); | ||
for (Weapon weapon : unit.type().weapons) { | ||
if (weapon.name.equals(name)) | ||
mount = new WeaponMount(weapon); | ||
} | ||
|
||
if (mount == null) { | ||
Log.err(new IOException(Strings.format("Weapon with name %s not found in %s weapons list.", | ||
name, unit.type()))); | ||
} | ||
} | ||
mounts[i] = mount; | ||
} | ||
|
||
TypeIO.readMounts(reads, mounts); | ||
|
||
return mounts; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fos.net; | ||
|
||
import fos.type.bullets.StickyBulletType; | ||
import mindustry.gen.Player; | ||
import mindustry.net.*; | ||
|
||
public class DetonatePacket extends Packet { | ||
public Player player; | ||
|
||
@Override | ||
public void handleServer(NetConnection con) { | ||
if (con.player == null || con.kicked) return; | ||
|
||
StickyBulletType.detonate(player); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package fos.net; | ||
|
||
import fos.type.blocks.special.UpgradeCenter; | ||
import fos.type.bullets.StickyBulletType; | ||
import mindustry.gen.Player; | ||
import mindustry.net.NetConnection; | ||
import mindustry.world.Tile; | ||
|
||
import static mindustry.Vars.*; | ||
|
||
public class FOSCall { | ||
public static void registerPackets() { | ||
|
||
} | ||
|
||
public static void upgrade(Player player, Tile tile) { | ||
UpgradeCenter.upgrade(player, tile); | ||
if (net.active()) { | ||
UpgradePacket packet = new UpgradePacket(); | ||
if (net.server()) { | ||
packet.player = player; | ||
} | ||
packet.tile = tile; | ||
net.send(packet, false); | ||
} | ||
} | ||
|
||
public static void upgradeForward(NetConnection except, Player player, Tile tile) { | ||
UpgradeCenter.upgrade(player, tile); | ||
if (net.active()) { | ||
UpgradePacket packet = new UpgradePacket(); | ||
if (net.server()) { | ||
packet.player = player; | ||
} | ||
packet.tile = tile; | ||
net.sendExcept(except, packet, false); | ||
} | ||
} | ||
|
||
public static void detonate() { | ||
StickyBulletType.detonate(player); | ||
if (net.client()) { | ||
DetonatePacket packet = new DetonatePacket(); | ||
net.send(packet, false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package fos.net; | ||
|
||
import arc.util.io.*; | ||
import fos.type.blocks.special.UpgradeCenter; | ||
import mindustry.gen.Player; | ||
import mindustry.io.TypeIO; | ||
import mindustry.net.*; | ||
import mindustry.world.Tile; | ||
|
||
import static mindustry.Vars.net; | ||
|
||
public class UpgradePacket extends Packet { | ||
private byte[] DATA = NODATA; | ||
public Player player; | ||
public Tile tile; | ||
|
||
@Override | ||
public void write(Writes write) { | ||
if (net.server()) { | ||
TypeIO.writeEntity(write, player); | ||
} | ||
TypeIO.writeTile(write, tile); | ||
} | ||
|
||
@Override | ||
public void read(Reads read, int length) { | ||
DATA = read.b(length); | ||
} | ||
|
||
@Override | ||
public void handled() { | ||
BAIS.setBytes(DATA); | ||
if (net.client()) { | ||
player = TypeIO.readEntity(READ); | ||
} | ||
tile = TypeIO.readTile(READ); | ||
} | ||
|
||
@Override | ||
public void handleServer(NetConnection con) { | ||
if (con.player == null || con.kicked) return; | ||
|
||
Player player = con.player; | ||
UpgradeCenter.upgrade(player, tile); | ||
FOSCall.upgradeForward(con, player, tile); | ||
} | ||
|
||
@Override | ||
public void handleClient() { | ||
UpgradeCenter.upgrade(player, tile); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package fos.type.units; | ||
|
||
import fos.gen.*; | ||
import mindustry.gen.*; | ||
|
||
import static ent.anno.Annotations.EntityDef; | ||
|
||
class EntityDefs<G> { | ||
@EntityDef({Unitc.class, LumoniPlayerc.class, Legsc.class}) G legsLumoniPlayerUnit; | ||
@EntityDef({Unitc.class, Crawlc.class, Bugc.class}) G bugCrawlUnit; | ||
@EntityDef({Unitc.class, Bugc.class}) G bugUnit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package fos.type.units.comp; | ||
|
||
import arc.util.io.*; | ||
import fos.io.FOSTypeIO; | ||
import fos.type.content.WeaponSet; | ||
import mindustry.entities.abilities.Ability; | ||
import mindustry.entities.units.WeaponMount; | ||
import mindustry.gen.*; | ||
import mindustry.type.UnitType; | ||
|
||
import static ent.anno.Annotations.*; | ||
|
||
@EntityComponent | ||
abstract class LumoniPlayerComp implements Weaponsc, Entityc, Syncc, Unitc { | ||
transient boolean isEditedWeapons = false; | ||
transient WeaponSet weaponSet = null; | ||
@Import WeaponMount[] mounts; | ||
|
||
@Replace | ||
@Override | ||
public void setType(UnitType unitType) { | ||
type(unitType); | ||
maxHealth(type().health); | ||
drag(type().drag); | ||
armor(type().armor); | ||
hitSize(type().hitSize); | ||
hovering(type().hovering); | ||
|
||
if (controller() == null) controller(type().createController(self())); | ||
|
||
if (!isEditedWeapons) { | ||
if (mounts().length != type().weapons.size) setupWeapons(type()); | ||
if (abilities().length != type().abilities.size) { | ||
abilities(new Ability[type().abilities.size]); | ||
for (int i = 0; i < type().abilities.size; i++) { | ||
abilities()[i] = type().abilities.get(i).copy(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void write(Writes write) { | ||
write.bool(isEditedWeapons); | ||
write.i(weaponSet == null ? -1 : weaponSet.id); | ||
FOSTypeIO.writeMounts2(write, this); | ||
} | ||
|
||
@Override | ||
public void read(Reads read) { | ||
isEditedWeapons = read.bool(); | ||
int weaponSetId = read.i(); | ||
weaponSet = weaponSetId == -1 ? null : WeaponSet.sets.get(weaponSetId); | ||
mounts = FOSTypeIO.readMounts2(read, this); | ||
} | ||
|
||
@Override | ||
public void readSync(Reads read) { | ||
isEditedWeapons = read.bool(); | ||
} | ||
|
||
@Override | ||
public void writeSync(Writes write) { | ||
write.bool(isEditedWeapons); | ||
} | ||
} |