From a7b39e56bd313c8091f9dcc3c69b909743204096 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 4 Feb 2020 18:00:32 -0500 Subject: [PATCH] Cleanup continues --- .../annotations/impl/EntityProcess.java | 3 +- .../annotations/remote/RemoteProcess.java | 4 +- .../src/main/resources/classids.properties | 5 +- .../java/main/mindustry/gen/Call.java | 603 +----- core/src/mindustry/Vars.java | 2 +- core/src/mindustry/ai/WaveSpawner.java | 27 +- core/src/mindustry/content/Blocks.java | 31 +- core/src/mindustry/content/Bullets.java | 30 +- core/src/mindustry/content/Fx.java | 1678 ++++++++--------- core/src/mindustry/content/Mechs.java | 461 ----- core/src/mindustry/content/StatusEffects.java | 2 +- core/src/mindustry/content/UnitTypes.java | 443 ++++- core/src/mindustry/core/ContentLoader.java | 2 +- core/src/mindustry/core/Control.java | 12 +- core/src/mindustry/core/GameState.java | 6 +- core/src/mindustry/core/Logic.java | 15 +- core/src/mindustry/core/NetClient.java | 71 +- core/src/mindustry/core/NetServer.java | 174 +- core/src/mindustry/core/Renderer.java | 28 +- core/src/mindustry/ctype/ContentType.java | 6 +- .../src/mindustry/editor/MapEditorDialog.java | 2 +- core/src/mindustry/entities/Damage.java | 12 +- core/src/mindustry/entities/Effect.java | 14 + core/src/mindustry/entities/Effects.java | 17 +- core/src/mindustry/entities/Units.java | 18 +- .../entities/bullet/ArtilleryBulletType.java | 6 +- .../entities/bullet/BasicBulletType.java | 4 +- .../mindustry/entities/bullet/BulletType.java | 2 +- .../entities/bullet/FlakBulletType.java | 2 +- .../entities/bullet/HealBulletType.java | 4 +- .../entities/bullet/LaserBulletType.java | 14 +- .../entities/bullet/LightningBulletType.java | 2 +- .../entities/bullet/LiquidBulletType.java | 4 +- .../entities/bullet/MassDriverBolt.java | 8 +- .../entities/bullet/MissileBulletType.java | 4 +- .../mindustry/entities/def/EntityComps.java | 167 +- .../mindustry/entities/def/EntityDefs.java | 3 + .../entities/def/EntityGroupDefs.java | 12 +- .../entities/effect/GroundEffectEntity.java | 89 - .../mindustry/entities/effect/Lightning.java | 2 +- .../src/mindustry/entities/effect/Puddle.java | 2 +- core/src/mindustry/entities/type/Player.java | 914 --------- .../entities/type/base/BaseDrone.java | 68 - .../entities/type/base/BuilderDrone.java | 238 --- .../entities/type/base/FlyingUnit.java | 255 --- .../entities/type/base/GroundUnit.java | 259 --- .../entities/type/base/HoverUnit.java | 34 - .../entities/type/base/MinerDrone.java | 178 -- .../entities/type/base/RepairDrone.java | 73 - core/src/mindustry/game/EventType.java | 50 +- core/src/mindustry/game/SpawnGroup.java | 14 +- core/src/mindustry/game/Tutorial.java | 2 +- .../mindustry/graphics/MinimapRenderer.java | 6 +- .../mindustry/graphics/OverlayRenderer.java | 4 +- core/src/mindustry/graphics/Pixelator.java | 6 +- core/src/mindustry/input/DesktopInput.java | 2 + core/src/mindustry/input/InputHandler.java | 206 +- core/src/mindustry/input/MobileInput.java | 2 + core/src/mindustry/input/Placement.java | 2 +- core/src/mindustry/io/TypeIO.java | 100 +- .../io/versions/LegacyTypeTable.java | 8 +- core/src/mindustry/maps/Map.java | 2 +- .../maps/generators/BasicGenerator.java | 2 +- core/src/mindustry/mod/ContentParser.java | 4 +- core/src/mindustry/net/Administration.java | 22 +- core/src/mindustry/net/CrashSender.java | 2 +- core/src/mindustry/net/NetConnection.java | 16 +- core/src/mindustry/net/NetworkIO.java | 8 +- core/src/mindustry/net/ValidateException.java | 6 +- core/src/mindustry/type/UnitDef.java | 6 +- core/src/mindustry/type/Weather.java | 2 +- .../mindustry/ui/dialogs/AdminsDialog.java | 2 +- core/src/mindustry/ui/dialogs/JoinDialog.java | 2 +- .../src/mindustry/ui/dialogs/TraceDialog.java | 6 +- .../ui/fragments/BlockInventoryFragment.java | 4 +- .../mindustry/ui/fragments/HudFragment.java | 14 +- .../ui/fragments/PlayerListFragment.java | 8 +- core/src/mindustry/world/Block.java | 10 +- .../mindustry/world/blocks/BuildBlock.java | 10 +- .../mindustry/world/blocks/RespawnBlock.java | 7 +- .../world/blocks/defense/DeflectorWall.java | 6 +- .../mindustry/world/blocks/defense/Door.java | 5 +- .../world/blocks/defense/SurgeWall.java | 2 +- .../blocks/defense/turrets/ItemTurret.java | 2 +- .../distribution/BufferedItemBridge.java | 4 +- .../world/blocks/distribution/ItemBridge.java | 8 +- .../world/blocks/distribution/MassDriver.java | 18 +- .../world/blocks/distribution/Sorter.java | 4 +- .../world/blocks/logic/MessageBlock.java | 3 +- .../world/blocks/power/LightBlock.java | 3 +- .../world/blocks/power/PowerNode.java | 4 +- .../world/blocks/production/Cultivator.java | 2 +- .../world/blocks/sandbox/ItemSource.java | 8 +- .../world/blocks/sandbox/LiquidSource.java | 4 +- .../world/blocks/storage/CoreBlock.java | 62 +- .../world/blocks/storage/Unloader.java | 18 +- .../world/blocks/units/CommandCenter.java | 4 +- .../mindustry/world/blocks/units/MechPad.java | 23 +- .../world/blocks/units/UnitFactory.java | 42 +- .../world/consumers/ConsumeItemFilter.java | 6 +- .../world/consumers/ConsumeItems.java | 4 +- .../world/consumers/ConsumeLiquid.java | 2 +- .../src/mindustry/desktop/steam/SStats.java | 4 +- .../src/mindustry/server/ServerControl.java | 20 +- tests/src/test/java/ApplicationTests.java | 2 +- .../test/java/power/DirectConsumerTests.java | 4 +- 106 files changed, 2266 insertions(+), 4543 deletions(-) delete mode 100644 core/src/mindustry/content/Mechs.java delete mode 100644 core/src/mindustry/entities/effect/GroundEffectEntity.java delete mode 100644 core/src/mindustry/entities/type/Player.java delete mode 100644 core/src/mindustry/entities/type/base/BaseDrone.java delete mode 100644 core/src/mindustry/entities/type/base/BuilderDrone.java delete mode 100644 core/src/mindustry/entities/type/base/FlyingUnit.java delete mode 100644 core/src/mindustry/entities/type/base/GroundUnit.java delete mode 100644 core/src/mindustry/entities/type/base/HoverUnit.java delete mode 100644 core/src/mindustry/entities/type/base/MinerDrone.java delete mode 100644 core/src/mindustry/entities/type/base/RepairDrone.java diff --git a/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java b/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java index 6768fb906d..8554d3453c 100644 --- a/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java +++ b/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java @@ -287,10 +287,11 @@ public class EntityProcess extends BaseProcessor{ //get interface for each component for(Stype comp : def.components){ + //implement the interface Stype inter = interfaces.find(i -> i.name().equals(interfaceName(comp))); if(inter == null){ - err("Failed to generate interface for component. Interfaces are " + interfaces + "\nComponent", comp); + err("Failed to generate interface for", comp); return; } diff --git a/annotations/src/main/java/mindustry/annotations/remote/RemoteProcess.java b/annotations/src/main/java/mindustry/annotations/remote/RemoteProcess.java index 8abd0b82b8..f405f44a07 100644 --- a/annotations/src/main/java/mindustry/annotations/remote/RemoteProcess.java +++ b/annotations/src/main/java/mindustry/annotations/remote/RemoteProcess.java @@ -72,12 +72,12 @@ public class RemoteProcess extends BaseProcessor{ //check for static if(!element.getModifiers().contains(Modifier.STATIC) || !element.getModifiers().contains(Modifier.PUBLIC)){ - BaseProcessor.messager.printMessage(Kind.ERROR, "All @Remote methods must be public and static: ", element); + err("All @Remote methods must be public and static: ", element); } //can't generate none methods if(annotation.targets() == Loc.none){ - BaseProcessor.messager.printMessage(Kind.ERROR, "A @Remote method's targets() cannot be equal to 'none':", element); + err("A @Remote method's targets() cannot be equal to 'none':", element); } //get and create class entry if needed diff --git a/annotations/src/main/resources/classids.properties b/annotations/src/main/resources/classids.properties index c1984fdd69..c7296a4017 100644 --- a/annotations/src/main/resources/classids.properties +++ b/annotations/src/main/resources/classids.properties @@ -1,7 +1,8 @@ #Maps entity names to IDs. Autogenerated. -#Tue Feb 04 13:56:56 EST 2020 +#Tue Feb 04 17:41:17 EST 2020 mindustry.entities.def.EntityDefs.DecalDef=1 mindustry.entities.def.EntityDefs.EffectDef=2 mindustry.entities.def.EntityDefs.TileDef=3 -mindustry.entities.def.EntityDefs.BulletDef=0 \ No newline at end of file +mindustry.entities.def.EntityDefs.BulletDef=0 +mindustry.entities.def.EntityDefs.PlayerDef=4 \ No newline at end of file diff --git a/core/build/generated/sources/annotationProcessor/java/main/mindustry/gen/Call.java b/core/build/generated/sources/annotationProcessor/java/main/mindustry/gen/Call.java index 569750ab53..81a185067b 100644 --- a/core/build/generated/sources/annotationProcessor/java/main/mindustry/gen/Call.java +++ b/core/build/generated/sources/annotationProcessor/java/main/mindustry/gen/Call.java @@ -4,11 +4,8 @@ import arc.graphics.Color; import java.lang.String; import java.nio.ByteBuffer; import mindustry.entities.bullet.BulletType; -import mindustry.entities.type.Player; -import mindustry.entities.units.BuildRequest; import mindustry.game.Rules; import mindustry.game.Team; -import mindustry.net.Administration; import mindustry.net.NetConnection; import mindustry.net.Packets; import mindustry.type.Item; @@ -59,18 +56,6 @@ public class Call { } } - public static synchronized void connectConfirm() { - if(mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)2; - TEMP_BUFFER.position(0); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - public static synchronized void createBullet(BulletType type, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl) { if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { @@ -118,22 +103,6 @@ public class Call { } } - public static synchronized void dropItem(float angle) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.input.InputHandler.dropItem(mindustry.Vars.player, angle); - } - if(mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)5; - TEMP_BUFFER.position(0); - TEMP_BUFFER.putFloat(angle); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - public static synchronized void launchZone() { mindustry.core.Logic.launchZone(); if(mindustry.Vars.net.server()) { @@ -147,23 +116,6 @@ public class Call { } } - public static synchronized void onAdminRequest(Player other, Packets.AdminAction action) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.core.NetServer.onAdminRequest(mindustry.Vars.player, other, action); - } - if(mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)7; - TEMP_BUFFER.position(0); - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, other); - mindustry.io.TypeIO.writeAction(TEMP_BUFFER, action); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - public static synchronized void onBlockSnapshot(short amount, short dataLen, byte[] data) { if(mindustry.Vars.net.server()) { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); @@ -195,40 +147,6 @@ public class Call { } } - public static synchronized void onClientShapshot(int snapshotID, float x, float y, float pointerX, - float pointerY, float rotation, float baseRotation, float xVelocity, float yVelocity, - Tile mining, boolean boosting, boolean shooting, boolean chatting, boolean building, - BuildRequest[] requests, float viewX, float viewY, float viewWidth, float viewHeight) { - if(mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)9; - TEMP_BUFFER.position(0); - TEMP_BUFFER.putInt(snapshotID); - TEMP_BUFFER.putFloat(x); - TEMP_BUFFER.putFloat(y); - TEMP_BUFFER.putFloat(pointerX); - TEMP_BUFFER.putFloat(pointerY); - TEMP_BUFFER.putFloat(rotation); - TEMP_BUFFER.putFloat(baseRotation); - TEMP_BUFFER.putFloat(xVelocity); - TEMP_BUFFER.putFloat(yVelocity); - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, mining); - TEMP_BUFFER.put(boosting ? (byte)1 : 0); - TEMP_BUFFER.put(shooting ? (byte)1 : 0); - TEMP_BUFFER.put(chatting ? (byte)1 : 0); - TEMP_BUFFER.put(building ? (byte)1 : 0); - mindustry.io.TypeIO.writeRequests(TEMP_BUFFER, requests); - TEMP_BUFFER.putFloat(viewX); - TEMP_BUFFER.putFloat(viewY); - TEMP_BUFFER.putFloat(viewWidth); - TEMP_BUFFER.putFloat(viewHeight); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.udp); - } - } - public static synchronized void onConnect(NetConnection playerConnection, String ip, int port) { if(mindustry.Vars.net.client() || !mindustry.Vars.net.active()) { mindustry.core.NetClient.onConnect(ip, port); @@ -286,33 +204,14 @@ public class Call { } } - public static synchronized void onDoorToggle(Player player, Tile tile, boolean open) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.world.blocks.defense.Door.onDoorToggle(player, tile, open); - } - if(mindustry.Vars.net.server()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)13; - TEMP_BUFFER.position(0); - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - TEMP_BUFFER.put(open ? (byte)1 : 0); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - public static synchronized void onEntitySnapshot(NetConnection playerConnection, byte groupID, - short amount, short dataLen, byte[] data) { + public static synchronized void onEntitySnapshot(NetConnection playerConnection, short amount, + short dataLen, byte[] data) { if(mindustry.Vars.net.server()) { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)2; packet.type = (byte)14; TEMP_BUFFER.position(0); - TEMP_BUFFER.put(groupID); TEMP_BUFFER.putShort(amount); TEMP_BUFFER.putShort(dataLen); mindustry.io.TypeIO.writeBytes(TEMP_BUFFER, data); @@ -361,7 +260,8 @@ public class Call { } } - public static synchronized void onInfoToast(String message, float duration) { + public static synchronized void onInfoPopup(String message, float duration, int align, int top, + int left, int bottom, int right) { if(mindustry.Vars.net.server()) { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; @@ -370,6 +270,45 @@ public class Call { TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeString(TEMP_BUFFER, message); TEMP_BUFFER.putFloat(duration); + TEMP_BUFFER.putInt(align); + TEMP_BUFFER.putInt(top); + TEMP_BUFFER.putInt(left); + TEMP_BUFFER.putInt(bottom); + TEMP_BUFFER.putInt(right); + packet.writeLength = TEMP_BUFFER.position(); + mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); + } + } + + public static synchronized void onInfoPopup(NetConnection playerConnection, String message, + float duration, int align, int top, int left, int bottom, int right) { + if(mindustry.Vars.net.server()) { + mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); + packet.writeBuffer = TEMP_BUFFER; + packet.priority = (byte)0; + packet.type = (byte)17; + TEMP_BUFFER.position(0); + mindustry.io.TypeIO.writeString(TEMP_BUFFER, message); + TEMP_BUFFER.putFloat(duration); + TEMP_BUFFER.putInt(align); + TEMP_BUFFER.putInt(top); + TEMP_BUFFER.putInt(left); + TEMP_BUFFER.putInt(bottom); + TEMP_BUFFER.putInt(right); + packet.writeLength = TEMP_BUFFER.position(); + playerConnection.send(packet, mindustry.net.Net.SendMode.tcp); + } + } + + public static synchronized void onInfoToast(String message, float duration) { + if(mindustry.Vars.net.server()) { + mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); + packet.writeBuffer = TEMP_BUFFER; + packet.priority = (byte)0; + packet.type = (byte)18; + TEMP_BUFFER.position(0); + mindustry.io.TypeIO.writeString(TEMP_BUFFER, message); + TEMP_BUFFER.putFloat(duration); packet.writeLength = TEMP_BUFFER.position(); mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); } @@ -381,7 +320,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)17; + packet.type = (byte)18; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeString(TEMP_BUFFER, message); TEMP_BUFFER.putFloat(duration); @@ -395,7 +334,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)1; - packet.type = (byte)18; + packet.type = (byte)19; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeString(TEMP_BUFFER, reason); packet.writeLength = TEMP_BUFFER.position(); @@ -409,7 +348,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)1; - packet.type = (byte)19; + packet.type = (byte)20; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeKick(TEMP_BUFFER, reason); packet.writeLength = TEMP_BUFFER.position(); @@ -417,49 +356,50 @@ public class Call { } } + public static synchronized void onLabel(String info, float duration, float worldx, float worldy) { + if(mindustry.Vars.net.server()) { + mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); + packet.writeBuffer = TEMP_BUFFER; + packet.priority = (byte)0; + packet.type = (byte)21; + TEMP_BUFFER.position(0); + mindustry.io.TypeIO.writeString(TEMP_BUFFER, info); + TEMP_BUFFER.putFloat(duration); + TEMP_BUFFER.putFloat(worldx); + TEMP_BUFFER.putFloat(worldy); + packet.writeLength = TEMP_BUFFER.position(); + mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); + } + } + + public static synchronized void onLabel(NetConnection playerConnection, String info, + float duration, float worldx, float worldy) { + if(mindustry.Vars.net.server()) { + mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); + packet.writeBuffer = TEMP_BUFFER; + packet.priority = (byte)0; + packet.type = (byte)21; + TEMP_BUFFER.position(0); + mindustry.io.TypeIO.writeString(TEMP_BUFFER, info); + TEMP_BUFFER.putFloat(duration); + TEMP_BUFFER.putFloat(worldx); + TEMP_BUFFER.putFloat(worldy); + packet.writeLength = TEMP_BUFFER.position(); + playerConnection.send(packet, mindustry.net.Net.SendMode.tcp); + } + } + public static synchronized void onMechFactoryDone(Tile tile) { if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { mindustry.world.blocks.units.MechPad.onMechFactoryDone(tile); } if(mindustry.Vars.net.server()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)20; - TEMP_BUFFER.position(0); - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - public static synchronized void onMechFactoryTap(Player player, Tile tile) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.world.blocks.units.MechPad.onMechFactoryTap(player, tile); - } - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)21; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - public static synchronized void onPing(long time) { - if(mindustry.Vars.net.client()) { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; packet.type = (byte)22; TEMP_BUFFER.position(0); - TEMP_BUFFER.putLong(time); + mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); packet.writeLength = TEMP_BUFFER.position(); mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); } @@ -470,7 +410,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)23; + packet.type = (byte)25; TEMP_BUFFER.position(0); TEMP_BUFFER.putLong(time); packet.writeLength = TEMP_BUFFER.position(); @@ -478,28 +418,12 @@ public class Call { } } - public static synchronized void onPlayerDeath(Player player) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.entities.type.Player.onPlayerDeath(player); - } - if(mindustry.Vars.net.server()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)24; - TEMP_BUFFER.position(0); - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - public static synchronized void onPlayerDisconnect(int playerid) { if(mindustry.Vars.net.server()) { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)25; + packet.type = (byte)26; TEMP_BUFFER.position(0); TEMP_BUFFER.putInt(playerid); packet.writeLength = TEMP_BUFFER.position(); @@ -512,7 +436,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)26; + packet.type = (byte)27; TEMP_BUFFER.position(0); TEMP_BUFFER.putFloat(x); TEMP_BUFFER.putFloat(y); @@ -529,7 +453,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)27; + packet.type = (byte)28; TEMP_BUFFER.position(0); TEMP_BUFFER.putInt(puddleid); packet.writeLength = TEMP_BUFFER.position(); @@ -542,7 +466,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)28; + packet.type = (byte)29; TEMP_BUFFER.position(0); TEMP_BUFFER.putInt(fid); packet.writeLength = TEMP_BUFFER.position(); @@ -555,7 +479,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)29; + packet.type = (byte)30; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeRules(TEMP_BUFFER, rules); packet.writeLength = TEMP_BUFFER.position(); @@ -568,7 +492,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)29; + packet.type = (byte)30; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeRules(TEMP_BUFFER, rules); packet.writeLength = TEMP_BUFFER.position(); @@ -582,7 +506,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)2; - packet.type = (byte)30; + packet.type = (byte)31; TEMP_BUFFER.position(0); TEMP_BUFFER.putFloat(waveTime); TEMP_BUFFER.putInt(wave); @@ -594,42 +518,6 @@ public class Call { } } - public static synchronized void onTileConfig(Player player, Tile tile, int value) { - mindustry.input.InputHandler.onTileConfig(player, tile, value); - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)31; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - TEMP_BUFFER.putInt(value); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - static synchronized void onTileConfig__forward(NetConnection exceptConnection, Player player, - Tile tile, int value) { - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)31; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - TEMP_BUFFER.putInt(value); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.sendExcept(exceptConnection, packet, mindustry.net.Net.SendMode.tcp); - } - } - public static synchronized void onTileDamage(Tile tile, float health) { if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { mindustry.world.Tile.onTileDamage(tile, health); @@ -638,7 +526,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)32; + packet.type = (byte)33; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); TEMP_BUFFER.putFloat(health); @@ -652,89 +540,21 @@ public class Call { mindustry.world.Tile.onTileDestroyed(tile); } if(mindustry.Vars.net.server()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)33; - TEMP_BUFFER.position(0); - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - public static synchronized void onTileTapped(Player player, Tile tile) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.input.InputHandler.onTileTapped(player, tile); - } - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; packet.type = (byte)34; TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); packet.writeLength = TEMP_BUFFER.position(); mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); } } - static synchronized void onTileTapped__forward(NetConnection exceptConnection, Player player, - Tile tile) { - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)34; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - public static synchronized void onTraceInfo(NetConnection playerConnection, Player player, - Administration.TraceInfo info) { - if(mindustry.Vars.net.server()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)35; - TEMP_BUFFER.position(0); - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - mindustry.io.TypeIO.writeTraceInfo(TEMP_BUFFER, info); - packet.writeLength = TEMP_BUFFER.position(); - playerConnection.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - public static synchronized void onUnitFactorySpawn(Tile tile, int spawns) { if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { mindustry.world.blocks.units.UnitFactory.onUnitFactorySpawn(tile, spawns); } - if(mindustry.Vars.net.server()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)36; - TEMP_BUFFER.position(0); - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - TEMP_BUFFER.putInt(spawns); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - public static synchronized void onUnitRespawn(Tile tile, Player player) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.world.blocks.storage.CoreBlock.onUnitRespawn(tile, player); - } if(mindustry.Vars.net.server()) { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; @@ -742,7 +562,7 @@ public class Call { packet.type = (byte)37; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); + TEMP_BUFFER.putInt(spawns); packet.writeLength = TEMP_BUFFER.position(); mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); } @@ -753,7 +573,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)38; + packet.type = (byte)39; TEMP_BUFFER.position(0); packet.writeLength = TEMP_BUFFER.position(); mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); @@ -765,7 +585,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)38; + packet.type = (byte)39; TEMP_BUFFER.position(0); packet.writeLength = TEMP_BUFFER.position(); playerConnection.send(packet, mindustry.net.Net.SendMode.tcp); @@ -778,7 +598,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)39; + packet.type = (byte)40; TEMP_BUFFER.position(0); TEMP_BUFFER.putInt(x); TEMP_BUFFER.putInt(y); @@ -796,7 +616,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)40; + packet.type = (byte)41; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); packet.writeLength = TEMP_BUFFER.position(); @@ -804,117 +624,10 @@ public class Call { } } - public static synchronized void requestItem(Player player, Tile tile, Item item, int amount) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.ui.fragments.BlockInventoryFragment.requestItem(player, tile, item, amount); - } - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)42; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - mindustry.io.TypeIO.writeItem(TEMP_BUFFER, item); - TEMP_BUFFER.putInt(amount); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - static synchronized void requestItem__forward(NetConnection exceptConnection, Player player, - Tile tile, Item item, int amount) { - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)42; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - mindustry.io.TypeIO.writeItem(TEMP_BUFFER, item); - TEMP_BUFFER.putInt(amount); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - public static synchronized void rotateBlock(Player player, Tile tile, boolean direction) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.input.InputHandler.rotateBlock(player, tile, direction); - } - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)43; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - TEMP_BUFFER.put(direction ? (byte)1 : 0); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.udp); - } - } - - static synchronized void rotateBlock__forward(NetConnection exceptConnection, Player player, - Tile tile, boolean direction) { - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)43; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - TEMP_BUFFER.put(direction ? (byte)1 : 0); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.udp); - } - } - - public static synchronized void sendChatMessage(String message) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.core.NetClient.sendChatMessage(mindustry.Vars.player, message); - } - if(mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)44; - TEMP_BUFFER.position(0); - mindustry.io.TypeIO.writeString(TEMP_BUFFER, message); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - public static synchronized void sendMessage(String message) { if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { mindustry.core.NetClient.sendMessage(message); } - if(mindustry.Vars.net.server()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)45; - TEMP_BUFFER.position(0); - mindustry.io.TypeIO.writeString(TEMP_BUFFER, message); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - public static synchronized void sendMessage(String message, String sender, Player playersender) { if(mindustry.Vars.net.server()) { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; @@ -922,99 +635,11 @@ public class Call { packet.type = (byte)46; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeString(TEMP_BUFFER, message); - mindustry.io.TypeIO.writeString(TEMP_BUFFER, sender); - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, playersender); packet.writeLength = TEMP_BUFFER.position(); mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); } } - public static synchronized void sendMessage(NetConnection playerConnection, String message, - String sender, Player playersender) { - if(mindustry.Vars.net.server()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)46; - TEMP_BUFFER.position(0); - mindustry.io.TypeIO.writeString(TEMP_BUFFER, message); - mindustry.io.TypeIO.writeString(TEMP_BUFFER, sender); - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, playersender); - packet.writeLength = TEMP_BUFFER.position(); - playerConnection.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - public static synchronized void setMessageBlockText(Player player, Tile tile, String text) { - mindustry.world.blocks.logic.MessageBlock.setMessageBlockText(player, tile, text); - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)47; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - mindustry.io.TypeIO.writeString(TEMP_BUFFER, text); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - static synchronized void setMessageBlockText__forward(NetConnection exceptConnection, - Player player, Tile tile, String text) { - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)47; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - mindustry.io.TypeIO.writeString(TEMP_BUFFER, text); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.sendExcept(exceptConnection, packet, mindustry.net.Net.SendMode.tcp); - } - } - - public static synchronized void setPlayerTeamEditor(Player player, Team team) { - mindustry.ui.fragments.HudFragment.setPlayerTeamEditor(player, team); - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)48; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTeam(TEMP_BUFFER, team); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - static synchronized void setPlayerTeamEditor__forward(NetConnection exceptConnection, - Player player, Team team) { - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)48; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTeam(TEMP_BUFFER, team); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.sendExcept(exceptConnection, packet, mindustry.net.Net.SendMode.tcp); - } - } - public static synchronized void setTile(Tile tile, Block block, Team team, int rotation) { if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { mindustry.world.Tile.setTile(tile, block, team, rotation); @@ -1023,7 +648,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)49; + packet.type = (byte)50; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); mindustry.io.TypeIO.writeBlock(TEMP_BUFFER, block); @@ -1034,42 +659,6 @@ public class Call { } } - public static synchronized void transferInventory(Player player, Tile tile) { - if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { - mindustry.input.InputHandler.transferInventory(player, tile); - } - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)51; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - - static synchronized void transferInventory__forward(NetConnection exceptConnection, Player player, - Tile tile) { - if(mindustry.Vars.net.server() || mindustry.Vars.net.client()) { - mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); - packet.writeBuffer = TEMP_BUFFER; - packet.priority = (byte)0; - packet.type = (byte)51; - TEMP_BUFFER.position(0); - if(mindustry.Vars.net.server()) { - mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player); - } - mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile); - packet.writeLength = TEMP_BUFFER.position(); - mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp); - } - } - public static synchronized void transferItemTo(Item item, int amount, float x, float y, Tile tile) { if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) { @@ -1079,7 +668,7 @@ public class Call { mindustry.net.Packets.InvokePacket packet = arc.util.pooling.Pools.obtain(mindustry.net.Packets.InvokePacket.class, mindustry.net.Packets.InvokePacket::new); packet.writeBuffer = TEMP_BUFFER; packet.priority = (byte)0; - packet.type = (byte)53; + packet.type = (byte)54; TEMP_BUFFER.position(0); mindustry.io.TypeIO.writeItem(TEMP_BUFFER, item); TEMP_BUFFER.putInt(amount); diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index 897db14689..22567e38a1 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -174,7 +174,7 @@ public class Vars implements Loadable{ public static NetServer netServer; public static NetClient netClient; - public static Unitc player; + public static Playerc player; @Override public void loadAsync(){ diff --git a/core/src/mindustry/ai/WaveSpawner.java b/core/src/mindustry/ai/WaveSpawner.java index fe25fa96f4..ada260a51b 100644 --- a/core/src/mindustry/ai/WaveSpawner.java +++ b/core/src/mindustry/ai/WaveSpawner.java @@ -9,6 +9,7 @@ import mindustry.content.*; import mindustry.entities.*; import mindustry.game.EventType.*; import mindustry.game.*; +import mindustry.gen.*; import mindustry.world.*; import static mindustry.Vars.*; @@ -34,7 +35,7 @@ public class WaveSpawner{ /** @return true if the player is near a ground spawn point. */ public boolean playerNear(){ - return groundSpawns.contains(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, player.x, player.y) < state.rules.dropZoneRadius && player.team() != state.rules.waveTeam); + return groundSpawns.contains(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, player.x(), player.y()) < state.rules.dropZoneRadius && player.team() != state.rules.waveTeam); } public void spawnEnemies(){ @@ -48,9 +49,10 @@ public class WaveSpawner{ eachFlyerSpawn((spawnX, spawnY) -> { for(int i = 0; i < spawned; i++){ - BaseUnit unit = group.createUnit(state.rules.waveTeam); - unit.set(spawnX + Mathf.range(spread), spawnY + Mathf.range(spread)); - unit.add(); + //TODO + //Unitc unit = group.createUnit(state.rules.waveTeam); + //unit.set(spawnX + Mathf.range(spread), spawnY + Mathf.range(spread)); + //unit.add(); } }); }else{ @@ -61,10 +63,11 @@ public class WaveSpawner{ for(int i = 0; i < spawned; i++){ Tmp.v1.rnd(spread); - BaseUnit unit = group.createUnit(state.rules.waveTeam); - unit.set(spawnX + Tmp.v1.x, spawnY + Tmp.v1.y); + //TODO + //Unitc unit = group.createUnit(state.rules.waveTeam); + //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)); } }); } @@ -88,8 +91,8 @@ public class WaveSpawner{ if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam) && !state.teams.playerCores().isEmpty()){ Tilec firstCore = state.teams.playerCores().first(); for(Tilec core : state.rules.waveTeam.cores()){ - Tmp.v1.set(firstCore).sub(core.x, core.y).limit(coreMargin + core.block.size*tilesize); - cons.accept(core.x + Tmp.v1.x, core.y + Tmp.v1.y, false); + 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); } } } @@ -104,7 +107,7 @@ public class WaveSpawner{ if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam)){ for(Tilec core : state.teams.get(state.rules.waveTeam).cores){ - cons.get(core.x, core.y); + cons.get(core.x(), core.y()); } } } @@ -136,8 +139,8 @@ public class WaveSpawner{ flySpawns.add(fspawn); } - private void spawnEffect(BaseUnit unit){ - Fx.unitSpawn.at(unit.x, unit.y, 0f, unit); + private void spawnEffect(Unitc unit){ + Fx.unitSpawn.at(unit.x(), unit.y(), 0f, unit); Time.run(30f, () -> { unit.add(); Fx.spawn.at(unit); diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index b22e72ea21..1d8b65cbca 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -1281,7 +1281,6 @@ public class Blocks implements ContentList{ health = 1100; itemCapacity = 4000; size = 3; - mech = Mechs.vanguard; }}; coreFoundation = new CoreBlock("core-foundation"){{ @@ -1290,7 +1289,6 @@ public class Blocks implements ContentList{ health = 2000; itemCapacity = 9000; size = 4; - mech = Mechs.vanguard; }}; coreNucleus = new CoreBlock("core-nucleus"){{ @@ -1299,7 +1297,6 @@ public class Blocks implements ContentList{ health = 4000; itemCapacity = 13000; size = 5; - mech = Mechs.vanguard; }}; vault = new Vault("vault"){{ @@ -1548,7 +1545,7 @@ public class Blocks implements ContentList{ @Override public void init(Bulletc b){ for(int i = 0; i < rays; i++){ - Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rot(), 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); } } @@ -1558,13 +1555,13 @@ public class Blocks implements ContentList{ Draw.color(Color.white, Pal.lancerLaser, b.fin()); //Draw.alpha(b.fout()); for(int i = 0; i < 7; i++){ - Tmp.v1.trns(b.rot(), i * 8f); + Tmp.v1.trns(b.rotation(), i * 8f); float sl = Mathf.clamp(b.fout() - 0.5f) * (80f - i * 10); - Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() + 90); - Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() - 90); + Drawf.tri(b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, 4f, sl, b.rotation() + 90); + Drawf.tri(b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, 4f, sl, b.rotation() - 90); } - Drawf.tri(b.x, b.y, 20f * b.fout(), (rayLength + 50), b.rot()); - Drawf.tri(b.x, b.y, 20f * b.fout(), 10f, b.rot() + 180f); + Drawf.tri(b.x(), b.y(), 20f * b.fout(), (rayLength + 50), b.rotation()); + Drawf.tri(b.x(), b.y(), 20f * b.fout(), 10f, b.rotation() + 180f); Draw.reset(); } }); @@ -1783,56 +1780,56 @@ public class Blocks implements ContentList{ dartPad = new MechPad("dart-ship-pad"){{ requirements(Category.upgrade, ItemStack.with(Items.lead, 100, Items.graphite, 50, Items.copper, 75)); - mech = Mechs.dart; + mech = UnitTypes.dart; size = 2; consumes.power(0.5f); }}; alphaPad = new MechPad("alpha-mech-pad"){{ requirements(Category.upgrade, ItemStack.with(Items.lead, 100, Items.graphite, 50, Items.copper, 75)); - mech = Mechs.alpha; + mech = UnitTypes.alpha; size = 2; consumes.power(0.5f); }}; deltaPad = new MechPad("delta-mech-pad"){{ requirements(Category.upgrade, ItemStack.with(Items.lead, 175, Items.titanium, 175, Items.copper, 200, Items.silicon, 225, Items.thorium, 150)); - mech = Mechs.delta; + mech = UnitTypes.delta; size = 2; consumes.power(0.7f); }}; tauPad = new MechPad("tau-mech-pad"){{ requirements(Category.upgrade, ItemStack.with(Items.lead, 125, Items.titanium, 125, Items.copper, 125, Items.silicon, 125)); - mech = Mechs.tau; + mech = UnitTypes.tau; size = 2; consumes.power(1f); }}; omegaPad = new MechPad("omega-mech-pad"){{ requirements(Category.upgrade, ItemStack.with(Items.lead, 225, Items.graphite, 275, Items.silicon, 325, Items.thorium, 300, Items.surgealloy, 120)); - mech = Mechs.omega; + mech = UnitTypes.omega; size = 3; consumes.power(1.2f); }}; javelinPad = new MechPad("javelin-ship-pad"){{ requirements(Category.upgrade, ItemStack.with(Items.lead, 175, Items.silicon, 225, Items.titanium, 250, Items.plastanium, 200, Items.phasefabric, 100)); - mech = Mechs.javelin; + mech = UnitTypes.javelin; size = 2; consumes.power(0.8f); }}; tridentPad = new MechPad("trident-ship-pad"){{ requirements(Category.upgrade, ItemStack.with(Items.lead, 125, Items.copper, 125, Items.silicon, 125, Items.titanium, 150, Items.plastanium, 100)); - mech = Mechs.trident; + mech = UnitTypes.trident; size = 2; consumes.power(1f); }}; glaivePad = new MechPad("glaive-ship-pad"){{ requirements(Category.upgrade, ItemStack.with(Items.lead, 225, Items.silicon, 325, Items.titanium, 350, Items.plastanium, 300, Items.surgealloy, 100)); - mech = Mechs.glaive; + mech = UnitTypes.glaive; size = 3; consumes.power(1.2f); }}; diff --git a/core/src/mindustry/content/Bullets.java b/core/src/mindustry/content/Bullets.java index 23bdfe4646..798076a2f4 100644 --- a/core/src/mindustry/content/Bullets.java +++ b/core/src/mindustry/content/Bullets.java @@ -4,11 +4,10 @@ import arc.graphics.*; import arc.graphics.g2d.*; import arc.math.*; import arc.util.*; -import mindustry.ctype.ContentList; +import mindustry.ctype.*; import mindustry.entities.*; import mindustry.entities.bullet.*; import mindustry.entities.effect.*; -import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.world.*; @@ -412,31 +411,31 @@ public class Bullets implements ContentList{ @Override public void init(Bulletc b){ - b.velocity().setLength(0.6f + Mathf.random(2f)); + b.vel().setLength(0.6f + Mathf.random(2f)); } @Override public void draw(Bulletc b){ 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(); } @Override public void update(Bulletc b){ 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){ Fire.create(tile); } } if(Mathf.chance(0.1 * Time.delta())){ - Fx.fireballsmoke.at(b.x, b.y); + Fx.fireballsmoke.at(b.x(), b.y()); } if(Mathf.chance(0.1 * Time.delta())){ - Fx.ballfire.at(b.x, b.y); + Fx.ballfire.at(b.x(), b.y()); } } }; @@ -512,15 +511,15 @@ public class Bullets implements ContentList{ @Override public void update(Bulletc b){ - if(b.timer.get(1, 5f)){ - Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rot(), length, true); + if(b.timer(1, 5f)){ + Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), length, true); } - Effects.shake(1f, 1f, b.x, b.y); + Effects.shake(1f, 1f, b.x(), b.y()); } @Override public void hit(Bulletc b, float hitx, float hity){ - hitEffect.at(colors[2], hitx, hity); + hitEffect.at(hitx, hity, colors[2]); if(Mathf.chance(0.4)){ Fire.create(world.tileWorld(hitx + Mathf.range(5f), hity + Mathf.range(5f))); } @@ -530,13 +529,13 @@ public class Bullets implements ContentList{ public void draw(Bulletc b){ float baseLen = (length) * b.fout(); - Lines.lineAngle(b.x, b.y, b.rot(), baseLen); + Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen); for(int s = 0; s < colors.length; s++){ Draw.color(tmpColor.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f))); for(int i = 0; i < tscales.length; i++){ - Tmp.v1.trns(b.rot() + 180f, (lenscales[i] - 1f) * 35f); + Tmp.v1.trns(b.rotation() + 180f, (lenscales[i] - 1f) * 35f); Lines.stroke((9f + Mathf.absin(Time.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]); - Lines.lineAngle(b.x + Tmp.v1.x, b.y + Tmp.v1.y, b.rot(), baseLen * lenscales[i], CapStyle.none); + Lines.lineAngle(b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, b.rotation(), baseLen * lenscales[i], CapStyle.none); } } Draw.reset(); @@ -587,7 +586,8 @@ public class Bullets implements ContentList{ @Override public void init(Bulletc b){ - Lightning.create(b.team(), Pal.lancerLaser, damage * (b.getOwner() instanceof Player ? state.rules.playerDamageMultiplier : 1f), b.x, b.y, b.rot(), 30); + //TODO owners are never players... + Lightning.create(b.team(), Pal.lancerLaser, damage * (b.owner() instanceof Playerc ? state.rules.playerDamageMultiplier : 1f), b.x(), b.y(), b.rotation(), 30); } }; diff --git a/core/src/mindustry/content/Fx.java b/core/src/mindustry/content/Fx.java index e5ae6fc142..31a5b883e1 100644 --- a/core/src/mindustry/content/Fx.java +++ b/core/src/mindustry/content/Fx.java @@ -5,1110 +5,1104 @@ import arc.graphics.*; import arc.graphics.g2d.*; import arc.math.*; import arc.util.*; -import mindustry.ctype.ContentList; import mindustry.entities.*; -import mindustry.entities.effect.GroundEffectEntity.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; -import mindustry.ui.Cicon; +import mindustry.ui.*; +import static arc.graphics.g2d.Draw.*; +import static arc.graphics.g2d.Lines.*; +import static arc.math.Angles.*; import static mindustry.Vars.*; -public class Fx implements ContentList{ - public static Effect +public class Fx{ + public static final Effect + + none = new Effect(0, 0f, e -> {}), + + unitSpawn = new Effect(30f, e -> { + if(!(e.data instanceof Unitc)) return; + + alpha(e.fin()); + + float scl = 1f + e.fout() * 2f; + + Unitc unit = (Unitc)e.data; + rect(unit.type().region, e.x, e.y, + unit.type().region.getWidth() * Draw.scl * scl, unit.type().region.getHeight() * Draw.scl * scl, 180f); + + }), + + commandSend = new Effect(28, e -> { + color(Pal.command); + stroke(e.fout() * 2f); + Lines.circle(e.x, e.y, 4f + e.finpow() * 120f); + }), + + placeBlock = new Effect(16, e -> { + color(Pal.accent); + stroke(3f - e.fin() * 2f); + Lines.square(e.x, e.y, tilesize / 2f * e.rotation + e.fin() * 3f); + }), + + tapBlock = new Effect(12, e -> { + color(Pal.accent); + stroke(3f - e.fin() * 2f); + Lines.circle(e.x, e.y, 4f + (tilesize / 1.5f * e.rotation) * e.fin()); + }), + + breakBlock = new Effect(12, e -> { + color(Pal.remove); + stroke(3f - e.fin() * 2f); + Lines.square(e.x, e.y, tilesize / 2f * e.rotation + e.fin() * 3f); + + randLenVectors(e.id, 3 + (int)(e.rotation * 3), e.rotation * 2f + (tilesize * e.rotation) * e.finpow(), (x, y) -> { + Fill.square(e.x + x, e.y + y, 1f + e.fout() * (3f + e.rotation)); + }); + }), + + select = new Effect(23, e -> { + color(Pal.accent); + stroke(e.fout() * 3f); + Lines.circle(e.x, e.y, 3f + e.fin() * 14f); + }), - none, placeBlock, breakBlock, smoke, spawn, tapBlock, select, - vtolHover, unitDrop, unitPickup, unitLand, pickup, healWave, heal, landShock, reactorsmoke, nuclearsmoke, nuclearcloud, - redgeneratespark, generatespark, fuelburn, plasticburn, pulverize, pulverizeRed, pulverizeRedder, pulverizeSmall, pulverizeMedium, - producesmoke, smeltsmoke, formsmoke, blastsmoke, lava, doorclose, dooropen, dooropenlarge, doorcloselarge, purify, purifyoil, purifystone, generate, - mine, mineBig, mineHuge, smelt, teleportActivate, teleport, teleportOut, ripple, bubble, launch, - healBlock, healBlockFull, healWaveMend, overdriveWave, overdriveBlockFull, shieldBreak, hitBulletSmall, hitFuse, - hitBulletBig, hitFlameSmall, hitLiquid, hitLaser, hitYellowLaser, hitLancer, hitMeltdown, despawn, flakExplosion, blastExplosion, - plasticExplosion, artilleryTrail, incendTrail, missileTrail, absorb, flakExplosionBig, plasticExplosionFlak, burning, fire, - fireSmoke, steam, fireballsmoke, ballfire, freezing, melting, wet, oily, overdriven, dropItem, shockwave, - bigShockwave, nuclearShockwave, explosion, blockExplosion, blockExplosionSmoke, shootSmall, shootHeal, shootHealYellow, shootSmallSmoke, shootBig, shootBig2, shootBigSmoke, - shootBigSmoke2, shootSmallFlame, shootPyraFlame, shootLiquid, shellEjectSmall, shellEjectMedium, - shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot, - unitSpawn, spawnShockwave, magmasmoke, impactShockwave, impactcloud, impactsmoke, dynamicExplosion, padlaunch, commandSend, coreLand; + smoke = new Effect(100, e -> { + color(Color.gray, Pal.darkishGray, e.fin()); + Fill.circle(e.x, e.y, (7f - e.fin() * 7f)/2f); + }), - @Override - public void load(){ + magmasmoke = new Effect(110, e -> { + color(Color.gray); + Fill.circle(e.x, e.y, e.fslope() * 6f); + }), - none = new Effect(0, 0f, e -> {}); + spawn = new Effect(30, e -> { + stroke(2f * e.fout()); + color(Pal.accent); + Lines.poly(e.x, e.y, 4, 5f + e.fin() * 12f); + }), - unitSpawn = new Effect(30f, e -> { - if(!(e.data instanceof BaseUnit)) return; + padlaunch = new Effect(10, e -> { + stroke(4f * e.fout()); + color(Pal.accent); + Lines.poly(e.x, e.y, 4, 5f + e.fin() * 60f); + }), - Draw.alpha(e.fin()); + vtolHover = new Effect(40f, e -> { + float len = e.finpow() * 10f; + float ang = e.rotation + Mathf.randomSeedRange(e.id, 30f); + color(Pal.lightFlame, Pal.lightOrange, e.fin()); + Fill.circle(e.x + trnsx(ang, len), e.y + trnsy(ang, len), 2f * e.fout()); + }), - float scl = 1f + e.fout() * 2f; - - BaseUnit unit = (BaseUnit)e.data; - Draw.rect(unit.getIconRegion(), e.x, e.y, - unit.getIconRegion().getWidth() * Draw.scl * scl, unit.getIconRegion().getWidth() * Draw.scl * scl, 180f); - - }); - - commandSend = new Effect(28, e -> { - Draw.color(Pal.command); - Lines.stroke(e.fout() * 2f); - Lines.circle(e.x, e.y, 4f + e.finpow() * 120f); + unitDrop = new Effect(30, e -> { + color(Pal.lightishGray); + randLenVectors(e.id, 9, 3 + 20f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.4f); }); + }).ground(), - placeBlock = new Effect(16, e -> { - Draw.color(Pal.accent); - Lines.stroke(3f - e.fin() * 2f); - Lines.square(e.x, e.y, tilesize / 2f * e.rotation + e.fin() * 3f); + unitLand = new Effect(30, e -> { + color(Tmp.c1.set(e.color).mul(1.1f)); + randLenVectors(e.id, 6, 17f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.3f); }); + }).ground(), - tapBlock = new Effect(12, e -> { - Draw.color(Pal.accent); - Lines.stroke(3f - e.fin() * 2f); - Lines.circle(e.x, e.y, 4f + (tilesize / 1.5f * e.rotation) * e.fin()); - }); + unitPickup = new Effect(18, e -> { + color(Pal.lightishGray); + stroke(e.fin() * 2f); + Lines.poly(e.x, e.y, 4, 13f * e.fout()); + }).ground(), - breakBlock = new Effect(12, e -> { - Draw.color(Pal.remove); - Lines.stroke(3f - e.fin() * 2f); - Lines.square(e.x, e.y, tilesize / 2f * e.rotation + e.fin() * 3f); + landShock = new Effect(12, e -> { + color(Pal.lancerLaser); + stroke(e.fout() * 3f); + Lines.poly(e.x, e.y, 12, 20f * e.fout()); + }).ground(), - Angles.randLenVectors(e.id, 3 + (int)(e.rotation * 3), e.rotation * 2f + (tilesize * e.rotation) * e.finpow(), (x, y) -> { - Fill.square(e.x + x, e.y + y, 1f + e.fout() * (3f + e.rotation)); - }); - }); + pickup = new Effect(18, e -> { + color(Pal.lightishGray); + stroke(e.fout() * 2f); + Lines.spikes(e.x, e.y, 1f + e.fin() * 6f, e.fout() * 4f, 6); + }), - select = new Effect(23, e -> { - Draw.color(Pal.accent); - Lines.stroke(e.fout() * 3f); - Lines.circle(e.x, e.y, 3f + e.fin() * 14f); - }); + healWave = new Effect(22, e -> { + color(Pal.heal); + stroke(e.fout() * 2f); + Lines.circle(e.x, e.y, 4f + e.finpow() * 60f); + }), - smoke = new Effect(100, e -> { - Draw.color(Color.gray, Pal.darkishGray, e.fin()); - float size = 7f - e.fin() * 7f; - Draw.rect("circle", e.x, e.y, size, size); - }); + heal = new Effect(11, e -> { + color(Pal.heal); + stroke(e.fout() * 2f); + Lines.circle(e.x, e.y, 2f + e.finpow() * 7f); + }), - magmasmoke = new Effect(110, e -> { - Draw.color(Color.gray); - Fill.circle(e.x, e.y, e.fslope() * 6f); - }); + hitBulletSmall = new Effect(14, e -> { + color(Color.white, Pal.lightOrange, e.fin()); - spawn = new Effect(30, e -> { - Lines.stroke(2f * e.fout()); - Draw.color(Pal.accent); - Lines.poly(e.x, e.y, 4, 5f + e.fin() * 12f); + e.scaled(7f, s -> { + stroke(0.5f + s.fout()); + Lines.circle(e.x, e.y, s.fin() * 5f); }); - padlaunch = new Effect(10, e -> { - Lines.stroke(4f * e.fout()); - Draw.color(Pal.accent); - Lines.poly(e.x, e.y, 4, 5f + e.fin() * 60f); - }); + stroke(0.5f + e.fout()); - vtolHover = new Effect(40f, e -> { - float len = e.finpow() * 10f; - float ang = e.rotation + Mathf.randomSeedRange(e.id, 30f); - Draw.color(Pal.lightFlame, Pal.lightOrange, e.fin()); - Fill.circle(e.x + Angles.trnsx(ang, len), e.y + Angles.trnsy(ang, len), 2f * e.fout()); + randLenVectors(e.id, 5, e.fin() * 15f, (x, y) -> { + float ang = Mathf.angle(x, y); + lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f); }); + }), - unitDrop = new GroundEffect(30, e -> { - Draw.color(Pal.lightishGray); - Angles.randLenVectors(e.id, 9, 3 + 20f * e.finpow(), (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.4f); - }); - }); + hitFuse = new Effect(14, e -> { + color(Color.white, Pal.surge, e.fin()); - unitLand = new GroundEffect(30, e -> { - Draw.color(Tmp.c1.set(e.color).mul(1.1f)); - Angles.randLenVectors(e.id, 6, 17f * e.finpow(), (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.3f); - }); + e.scaled(7f, s -> { + stroke(0.5f + s.fout()); + Lines.circle(e.x, e.y, s.fin() * 7f); }); - unitPickup = new GroundEffect(18, e -> { - Draw.color(Pal.lightishGray); - Lines.stroke(e.fin() * 2f); - Lines.poly(e.x, e.y, 4, 13f * e.fout()); - }); + stroke(0.5f + e.fout()); - landShock = new GroundEffect(12, e -> { - Draw.color(Pal.lancerLaser); - Lines.stroke(e.fout() * 3f); - Lines.poly(e.x, e.y, 12, 20f * e.fout()); + randLenVectors(e.id, 6, e.fin() * 15f, (x, y) -> { + float ang = Mathf.angle(x, y); + lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f); }); - pickup = new Effect(18, e -> { - Draw.color(Pal.lightishGray); - Lines.stroke(e.fout() * 2f); - Lines.spikes(e.x, e.y, 1f + e.fin() * 6f, e.fout() * 4f, 6); - }); + }), - healWave = new Effect(22, e -> { - Draw.color(Pal.heal); - Lines.stroke(e.fout() * 2f); - Lines.circle(e.x, e.y, 4f + e.finpow() * 60f); - }); + hitBulletBig = new Effect(13, e -> { + color(Color.white, Pal.lightOrange, e.fin()); + stroke(0.5f + e.fout() * 1.5f); - heal = new Effect(11, e -> { - Draw.color(Pal.heal); - Lines.stroke(e.fout() * 2f); - Lines.circle(e.x, e.y, 2f + e.finpow() * 7f); + randLenVectors(e.id, 8, e.finpow() * 30f, e.rotation, 50f, (x, y) -> { + float ang = Mathf.angle(x, y); + lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1.5f); }); - hitBulletSmall = new Effect(14, e -> { - Draw.color(Color.white, Pal.lightOrange, e.fin()); - - e.scaled(7f, s -> { - Lines.stroke(0.5f + s.fout()); - Lines.circle(e.x, e.y, s.fin() * 5f); - }); - - - Lines.stroke(0.5f + e.fout()); + }), - Angles.randLenVectors(e.id, 5, e.fin() * 15f, (x, y) -> { - float ang = Mathf.angle(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f); - }); + hitFlameSmall = new Effect(14, e -> { + color(Pal.lightFlame, Pal.darkFlame, e.fin()); + stroke(0.5f + e.fout()); + randLenVectors(e.id, 2, e.fin() * 15f, e.rotation, 50f, (x, y) -> { + float ang = Mathf.angle(x, y); + lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f); }); - hitFuse = new Effect(14, e -> { - Draw.color(Color.white, Pal.surge, e.fin()); - - e.scaled(7f, s -> { - Lines.stroke(0.5f + s.fout()); - Lines.circle(e.x, e.y, s.fin() * 7f); - }); + }), + hitLiquid = new Effect(16, e -> { + color(e.color); - Lines.stroke(0.5f + e.fout()); - - Angles.randLenVectors(e.id, 6, e.fin() * 15f, (x, y) -> { - float ang = Mathf.angle(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f); - }); - + randLenVectors(e.id, 5, e.fin() * 15f, e.rotation + 180f, 60f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 2f); }); - hitBulletBig = new Effect(13, e -> { - Draw.color(Color.white, Pal.lightOrange, e.fin()); - Lines.stroke(0.5f + e.fout() * 1.5f); + }), - Angles.randLenVectors(e.id, 8, e.finpow() * 30f, e.rotation, 50f, (x, y) -> { - float ang = Mathf.angle(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1.5f); - }); + hitLancer = new Effect(12, e -> { + color(Color.white); + stroke(e.fout() * 1.5f); + randLenVectors(e.id, 8, e.finpow() * 17f, e.rotation, 360f, (x, y) -> { + float ang = Mathf.angle(x, y); + lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f); }); - hitFlameSmall = new Effect(14, e -> { - Draw.color(Pal.lightFlame, Pal.darkFlame, e.fin()); - Lines.stroke(0.5f + e.fout()); + }), - Angles.randLenVectors(e.id, 2, e.fin() * 15f, e.rotation, 50f, (x, y) -> { - float ang = Mathf.angle(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f); - }); + hitMeltdown = new Effect(12, e -> { + color(Pal.meltdownHit); + stroke(e.fout() * 2f); + randLenVectors(e.id, 6, e.finpow() * 18f, e.rotation, 360f, (x, y) -> { + float ang = Mathf.angle(x, y); + lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f); }); - hitLiquid = new Effect(16, e -> { - Draw.color(e.color); - - Angles.randLenVectors(e.id, 5, e.fin() * 15f, e.rotation + 180f, 60f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 2f); - }); + }), - }); + hitLaser = new Effect(8, e -> { + color(Color.white, Pal.heal, e.fin()); + stroke(0.5f + e.fout()); + Lines.circle(e.x, e.y, e.fin() * 5f); + }), - hitLancer = new Effect(12, e -> { - Draw.color(Color.white); - Lines.stroke(e.fout() * 1.5f); + hitYellowLaser = new Effect(8, e -> { + color(Color.white, Pal.lightTrail, e.fin()); + stroke(0.5f + e.fout()); + Lines.circle(e.x, e.y, e.fin() * 5f); + }), - Angles.randLenVectors(e.id, 8, e.finpow() * 17f, e.rotation, 360f, (x, y) -> { - float ang = Mathf.angle(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f); - }); + despawn = new Effect(12, e -> { + color(Pal.lighterOrange, Color.gray, e.fin()); + stroke(e.fout()); + randLenVectors(e.id, 7, e.fin() * 7f, e.rotation, 40f, (x, y) -> { + float ang = Mathf.angle(x, y); + lineAngle(e.x + x, e.y + y, ang, e.fout() * 2 + 1f); }); - hitMeltdown = new Effect(12, e -> { - Draw.color(Pal.meltdownHit); - Lines.stroke(e.fout() * 2f); + }), - Angles.randLenVectors(e.id, 6, e.finpow() * 18f, e.rotation, 360f, (x, y) -> { - float ang = Mathf.angle(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f); - }); + flakExplosion = new Effect(20, e -> { + color(Pal.bulletYellow); + e.scaled(6, i -> { + stroke(3f * i.fout()); + Lines.circle(e.x, e.y, 3f + i.fin() * 10f); }); - hitLaser = new Effect(8, e -> { - Draw.color(Color.white, Pal.heal, e.fin()); - Lines.stroke(0.5f + e.fout()); - Lines.circle(e.x, e.y, e.fin() * 5f); - }); + color(Color.gray); - hitYellowLaser = new Effect(8, e -> { - Draw.color(Color.white, Pal.lightTrail, e.fin()); - Lines.stroke(0.5f + e.fout()); - Lines.circle(e.x, e.y, e.fin() * 5f); - Draw.reset(); + randLenVectors(e.id, 5, 2f + 23f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 3f + 0.5f); }); - despawn = new Effect(12, e -> { - Draw.color(Pal.lighterOrange, Color.gray, e.fin()); - Lines.stroke(e.fout()); - - Angles.randLenVectors(e.id, 7, e.fin() * 7f, e.rotation, 40f, (x, y) -> { - float ang = Mathf.angle(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 2 + 1f); - }); + color(Pal.lighterOrange); + stroke(1f * e.fout()); + randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - flakExplosion = new Effect(20, e -> { + }), - Draw.color(Pal.bulletYellow); - e.scaled(6, i -> { - Lines.stroke(3f * i.fout()); - Lines.circle(e.x, e.y, 3f + i.fin() * 10f); - }); + plasticExplosion = new Effect(24, e -> { - Draw.color(Color.gray); + color(Pal.plastaniumFront); + e.scaled(7, i -> { + stroke(3f * i.fout()); + Lines.circle(e.x, e.y, 3f + i.fin() * 24f); + }); - Angles.randLenVectors(e.id, 5, 2f + 23f * e.finpow(), (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 3f + 0.5f); - }); + color(Color.gray); - Draw.color(Pal.lighterOrange); - Lines.stroke(1f * e.fout()); + randLenVectors(e.id, 7, 2f + 28f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.5f); + }); - Angles.randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); - }); + color(Pal.plastaniumBack); + stroke(1f * e.fout()); + randLenVectors(e.id + 1, 4, 1f + 25f * e.finpow(), (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - plasticExplosion = new Effect(24, e -> { + }), - Draw.color(Pal.plastaniumFront); - e.scaled(7, i -> { - Lines.stroke(3f * i.fout()); - Lines.circle(e.x, e.y, 3f + i.fin() * 24f); - }); + plasticExplosionFlak = new Effect(28, e -> { - Draw.color(Color.gray); + color(Pal.plastaniumFront); + e.scaled(7, i -> { + stroke(3f * i.fout()); + Lines.circle(e.x, e.y, 3f + i.fin() * 34f); + }); - Angles.randLenVectors(e.id, 7, 2f + 28f * e.finpow(), (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.5f); - }); + color(Color.gray); - Draw.color(Pal.plastaniumBack); - Lines.stroke(1f * e.fout()); + randLenVectors(e.id, 7, 2f + 30f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.5f); + }); - Angles.randLenVectors(e.id + 1, 4, 1f + 25f * e.finpow(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); - }); + color(Pal.plastaniumBack); + stroke(1f * e.fout()); + randLenVectors(e.id + 1, 4, 1f + 30f * e.finpow(), (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - plasticExplosionFlak = new Effect(28, e -> { + }), - Draw.color(Pal.plastaniumFront); - e.scaled(7, i -> { - Lines.stroke(3f * i.fout()); - Lines.circle(e.x, e.y, 3f + i.fin() * 34f); - }); + blastExplosion = new Effect(22, e -> { - Draw.color(Color.gray); + color(Pal.missileYellow); + e.scaled(6, i -> { + stroke(3f * i.fout()); + Lines.circle(e.x, e.y, 3f + i.fin() * 15f); + }); - Angles.randLenVectors(e.id, 7, 2f + 30f * e.finpow(), (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.5f); - }); + color(Color.gray); - Draw.color(Pal.plastaniumBack); - Lines.stroke(1f * e.fout()); + randLenVectors(e.id, 5, 2f + 23f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.5f); + }); - Angles.randLenVectors(e.id + 1, 4, 1f + 30f * e.finpow(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); - }); + color(Pal.missileYellowBack); + stroke(1f * e.fout()); + randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - blastExplosion = new Effect(22, e -> { + }), - Draw.color(Pal.missileYellow); - e.scaled(6, i -> { - Lines.stroke(3f * i.fout()); - Lines.circle(e.x, e.y, 3f + i.fin() * 15f); - }); + artilleryTrail = new Effect(50, e -> { + color(e.color); + Fill.circle(e.x, e.y, e.rotation * e.fout()); + }), - Draw.color(Color.gray); + incendTrail = new Effect(50, e -> { + color(Pal.lightOrange); + Fill.circle(e.x, e.y, e.rotation * e.fout()); + }), - Angles.randLenVectors(e.id, 5, 2f + 23f * e.finpow(), (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.5f); - }); + missileTrail = new Effect(50, e -> { + color(e.color); + Fill.circle(e.x, e.y, e.rotation * e.fout()); + }), - Draw.color(Pal.missileYellowBack); - Lines.stroke(1f * e.fout()); + absorb = new Effect(12, e -> { + color(Pal.accent); + stroke(2f * e.fout()); + Lines.circle(e.x, e.y, 5f * e.fout()); + }), - Angles.randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); - }); + flakExplosionBig = new Effect(30, e -> { + color(Pal.bulletYellowBack); + e.scaled(6, i -> { + stroke(3f * i.fout()); + Lines.circle(e.x, e.y, 3f + i.fin() * 25f); }); - artilleryTrail = new Effect(50, e -> { - Draw.color(e.color); - Fill.circle(e.x, e.y, e.rotation * e.fout()); - }); + color(Color.gray); - incendTrail = new Effect(50, e -> { - Draw.color(Pal.lightOrange); - Fill.circle(e.x, e.y, e.rotation * e.fout()); + randLenVectors(e.id, 6, 2f + 23f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.5f); }); - missileTrail = new Effect(50, e -> { - Draw.color(e.color); - Fill.circle(e.x, e.y, e.rotation * e.fout()); - }); + color(Pal.bulletYellow); + stroke(1f * e.fout()); - absorb = new Effect(12, e -> { - Draw.color(Pal.accent); - Lines.stroke(2f * e.fout()); - Lines.circle(e.x, e.y, 5f * e.fout()); + randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - flakExplosionBig = new Effect(30, e -> { - - Draw.color(Pal.bulletYellowBack); - e.scaled(6, i -> { - Lines.stroke(3f * i.fout()); - Lines.circle(e.x, e.y, 3f + i.fin() * 25f); - }); + }), - Draw.color(Color.gray); - - Angles.randLenVectors(e.id, 6, 2f + 23f * e.finpow(), (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.5f); - }); - - Draw.color(Pal.bulletYellow); - Lines.stroke(1f * e.fout()); - - Angles.randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); - }); + burning = new Effect(35f, e -> { + color(Pal.lightFlame, Pal.darkFlame, e.fin()); + randLenVectors(e.id, 3, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.1f + e.fout() * 1.4f); }); + }), - burning = new Effect(35f, e -> { - Draw.color(Pal.lightFlame, Pal.darkFlame, e.fin()); - - Angles.randLenVectors(e.id, 3, 2f + e.fin() * 7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.1f + e.fout() * 1.4f); - }); + fire = new Effect(50f, e -> { + color(Pal.lightFlame, Pal.darkFlame, e.fin()); + randLenVectors(e.id, 2, 2f + e.fin() * 9f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); }); - fire = new Effect(50f, e -> { - Draw.color(Pal.lightFlame, Pal.darkFlame, e.fin()); + color(); - Angles.randLenVectors(e.id, 2, 2f + e.fin() * 9f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); - }); + renderer.lights.add(e.x, e.y, 20f * e.fslope(), Pal.lightFlame, 0.5f); + }), - Draw.color(); + fireSmoke = new Effect(35f, e -> { + color(Color.gray); - renderer.lights.add(e.x, e.y, 20f * e.fslope(), Pal.lightFlame, 0.5f); + randLenVectors(e.id, 1, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); }); - fireSmoke = new Effect(35f, e -> { - Draw.color(Color.gray); + }), - Angles.randLenVectors(e.id, 1, 2f + e.fin() * 7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); - }); + steam = new Effect(35f, e -> { + color(Color.lightGray); + randLenVectors(e.id, 2, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); }); - steam = new Effect(35f, e -> { - Draw.color(Color.lightGray); + }), - Angles.randLenVectors(e.id, 2, 2f + e.fin() * 7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); - }); + fireballsmoke = new Effect(25f, e -> { + color(Color.gray); + randLenVectors(e.id, 1, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f); }); - fireballsmoke = new Effect(25f, e -> { - Draw.color(Color.gray); + }), - Angles.randLenVectors(e.id, 1, 2f + e.fin() * 7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f); - }); + ballfire = new Effect(25f, e -> { + color(Pal.lightFlame, Pal.darkFlame, e.fin()); + randLenVectors(e.id, 2, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f); }); - ballfire = new Effect(25f, e -> { - Draw.color(Pal.lightFlame, Pal.darkFlame, e.fin()); + }), - Angles.randLenVectors(e.id, 2, 2f + e.fin() * 7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f); - }); + freezing = new Effect(40f, e -> { + color(Liquids.cryofluid.color); + randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1.2f); }); - freezing = new Effect(40f, e -> { - Draw.color(Liquids.cryofluid.color); + }), - Angles.randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 1.2f); - }); + melting = new Effect(40f, e -> { + color(Liquids.slag.color, Color.white, e.fout() / 5f + Mathf.randomSeedRange(e.id, 0.12f)); + randLenVectors(e.id, 2, 1f + e.fin() * 3f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, .2f + e.fout() * 1.2f); }); - melting = new Effect(40f, e -> { - Draw.color(Liquids.slag.color, Color.white, e.fout() / 5f + Mathf.randomSeedRange(e.id, 0.12f)); + }), - Angles.randLenVectors(e.id, 2, 1f + e.fin() * 3f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, .2f + e.fout() * 1.2f); - }); + wet = new Effect(40f, e -> { + color(Liquids.water.color); + randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1f); }); - wet = new Effect(40f, e -> { - Draw.color(Liquids.water.color); + }), - Angles.randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 1f); - }); + oily = new Effect(42f, e -> { + color(Liquids.oil.color); + randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1f); }); - oily = new Effect(42f, e -> { - Draw.color(Liquids.oil.color); + }), - Angles.randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 1f); - }); + overdriven = new Effect(20f, e -> { + color(Pal.accent); + randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { + Fill.square(e.x + x, e.y + y, e.fout() * 2.3f + 0.5f); }); - overdriven = new Effect(20f, e -> { - Draw.color(Pal.accent); + }), - Angles.randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { - Fill.square(e.x + x, e.y + y, e.fout() * 2.3f + 0.5f); - }); + dropItem = new Effect(20f, e -> { + float length = 20f * e.finpow(); + float size = 7f * e.fout(); - }); + rect(((Item)e.data).icon(Cicon.medium), e.x + trnsx(e.rotation, length), e.y + trnsy(e.rotation, length), size, size); + }), - dropItem = new Effect(20f, e -> { - float length = 20f * e.finpow(); - float size = 7f * e.fout(); + shockwave = new Effect(10f, 80f, e -> { + color(Color.white, Color.lightGray, e.fin()); + stroke(e.fout() * 2f + 0.2f); + Lines.circle(e.x, e.y, e.fin() * 28f); + }), - Draw.rect(((Item)e.data).icon(Cicon.medium), e.x + Angles.trnsx(e.rotation, length), e.y + Angles.trnsy(e.rotation, length), size, size); - }); + bigShockwave = new Effect(10f, 80f, e -> { + color(Color.white, Color.lightGray, e.fin()); + stroke(e.fout() * 3f); + Lines.circle(e.x, e.y, e.fin() * 50f); + }), + nuclearShockwave = new Effect(10f, 200f, e -> { + color(Color.white, Color.lightGray, e.fin()); + stroke(e.fout() * 3f + 0.2f); + Lines.circle(e.x, e.y, e.fin() * 140f); + }), - shockwave = new Effect(10f, 80f, e -> { - Draw.color(Color.white, Color.lightGray, e.fin()); - Lines.stroke(e.fout() * 2f + 0.2f); - Lines.circle(e.x, e.y, e.fin() * 28f); - }); + impactShockwave = new Effect(13f, 300f, e -> { + color(Pal.lighterOrange, Color.lightGray, e.fin()); + stroke(e.fout() * 4f + 0.2f); + Lines.circle(e.x, e.y, e.fin() * 200f); + }), - bigShockwave = new Effect(10f, 80f, e -> { - Draw.color(Color.white, Color.lightGray, e.fin()); - Lines.stroke(e.fout() * 3f); - Lines.circle(e.x, e.y, e.fin() * 50f); - }); + spawnShockwave = new Effect(20f, 400f, e -> { + color(Color.white, Color.lightGray, e.fin()); + stroke(e.fout() * 3f + 0.5f); + Lines.circle(e.x, e.y, e.fin() * (e.rotation + 50f)); + }), - nuclearShockwave = new Effect(10f, 200f, e -> { - Draw.color(Color.white, Color.lightGray, e.fin()); - Lines.stroke(e.fout() * 3f + 0.2f); - Lines.circle(e.x, e.y, e.fin() * 140f); + explosion = new Effect(30, e -> { + e.scaled(7, i -> { + stroke(3f * i.fout()); + Lines.circle(e.x, e.y, 3f + i.fin() * 10f); }); - impactShockwave = new Effect(13f, 300f, e -> { - Draw.color(Pal.lighterOrange, Color.lightGray, e.fin()); - Lines.stroke(e.fout() * 4f + 0.2f); - Lines.circle(e.x, e.y, e.fin() * 200f); - }); + color(Color.gray); - spawnShockwave = new Effect(20f, 400f, e -> { - Draw.color(Color.white, Color.lightGray, e.fin()); - Lines.stroke(e.fout() * 3f + 0.5f); - Lines.circle(e.x, e.y, e.fin() * (e.rotation + 50f)); + randLenVectors(e.id, 6, 2f + 19f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 3f + 0.5f); + Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f); }); - explosion = new Effect(30, e -> { - e.scaled(7, i -> { - Lines.stroke(3f * i.fout()); - Lines.circle(e.x, e.y, 3f + i.fin() * 10f); - }); - - Draw.color(Color.gray); - - Angles.randLenVectors(e.id, 6, 2f + 19f * e.finpow(), (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 3f + 0.5f); - Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f); - }); - - Draw.color(Pal.lighterOrange, Pal.lightOrange, Color.gray, e.fin()); - Lines.stroke(1.5f * e.fout()); - - Angles.randLenVectors(e.id + 1, 8, 1f + 23f * e.finpow(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); - }); + color(Pal.lighterOrange, Pal.lightOrange, Color.gray, e.fin()); + stroke(1.5f * e.fout()); + randLenVectors(e.id + 1, 8, 1f + 23f * e.finpow(), (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); + }), - dynamicExplosion = new Effect(30, e -> { - float intensity = e.rotation; - - e.scaled(5 + intensity * 2, i -> { - Lines.stroke(3.1f * i.fout()); - Lines.circle(e.x, e.y, (3f + i.fin() * 14f) * intensity); - }); - - Draw.color(Color.gray); - - Angles.randLenVectors(e.id, e.finpow(), (int)(6 * intensity), 21f * intensity, (x, y, in, out) -> { - Fill.circle(e.x + x, e.y + y, out * (2f + intensity) * 3 + 0.5f); - Fill.circle(e.x + x / 2f, e.y + y / 2f, out * (intensity) * 3); - }); - - Draw.color(Pal.lighterOrange, Pal.lightOrange, Color.gray, e.fin()); - Lines.stroke((1.7f * e.fout()) * (1f + (intensity - 1f) / 2f)); - - Angles.randLenVectors(e.id + 1, e.finpow(), (int)(9 * intensity), 40f * intensity, (x, y, in, out) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + out * 4 * (3f + intensity)); - }); + dynamicExplosion = new Effect(30, e -> { + float intensity = e.rotation; + e.scaled(5 + intensity * 2, i -> { + stroke(3.1f * i.fout()); + Lines.circle(e.x, e.y, (3f + i.fin() * 14f) * intensity); }); - blockExplosion = new Effect(30, e -> { - e.scaled(7, i -> { - Lines.stroke(3.1f * i.fout()); - Lines.circle(e.x, e.y, 3f + i.fin() * 14f); - }); - - Draw.color(Color.gray); - - Angles.randLenVectors(e.id, 6, 2f + 19f * e.finpow(), (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 3f + 0.5f); - Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f); - }); - - Draw.color(Pal.lighterOrange, Pal.lightOrange, Color.gray, e.fin()); - Lines.stroke(1.7f * e.fout()); - - Angles.randLenVectors(e.id + 1, 9, 1f + 23f * e.finpow(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); - }); + color(Color.gray); + randLenVectors(e.id, e.finpow(), (int)(6 * intensity), 21f * intensity, (x, y, in, out) -> { + Fill.circle(e.x + x, e.y + y, out * (2f + intensity) * 3 + 0.5f); + Fill.circle(e.x + x / 2f, e.y + y / 2f, out * (intensity) * 3); }); - blockExplosionSmoke = new Effect(30, e -> { - Draw.color(Color.gray); + color(Pal.lighterOrange, Pal.lightOrange, Color.gray, e.fin()); + stroke((1.7f * e.fout()) * (1f + (intensity - 1f) / 2f)); - Angles.randLenVectors(e.id, 6, 4f + 30f * e.finpow(), (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 3f); - Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f); - }); + randLenVectors(e.id + 1, e.finpow(), (int)(9 * intensity), 40f * intensity, (x, y, in, out) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + out * 4 * (3f + intensity)); + }); + }), + blockExplosion = new Effect(30, e -> { + e.scaled(7, i -> { + stroke(3.1f * i.fout()); + Lines.circle(e.x, e.y, 3f + i.fin() * 14f); }); + color(Color.gray); - shootSmall = new Effect(8, e -> { - Draw.color(Pal.lighterOrange, Pal.lightOrange, e.fin()); - float w = 1f + 5 * e.fout(); - Drawf.tri(e.x, e.y, w, 15f * e.fout(), e.rotation); - Drawf.tri(e.x, e.y, w, 3f * e.fout(), e.rotation + 180f); + randLenVectors(e.id, 6, 2f + 19f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 3f + 0.5f); + Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f); }); - shootHeal = new Effect(8, e -> { - Draw.color(Pal.heal); - float w = 1f + 5 * e.fout(); - Drawf.tri(e.x, e.y, w, 17f * e.fout(), e.rotation); - Drawf.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f); - }); + color(Pal.lighterOrange, Pal.lightOrange, Color.gray, e.fin()); + stroke(1.7f * e.fout()); - shootHealYellow = new Effect(8, e -> { - Draw.color(Pal.lightTrail); - float w = 1f + 5 * e.fout(); - Drawf.tri(e.x, e.y, w, 17f * e.fout(), e.rotation); - Drawf.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f); - Draw.reset(); + randLenVectors(e.id + 1, 9, 1f + 23f * e.finpow(), (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - shootSmallSmoke = new Effect(20f, e -> { - Draw.color(Pal.lighterOrange, Color.lightGray, Color.gray, e.fin()); + }), - Angles.randLenVectors(e.id, 5, e.finpow() * 6f, e.rotation, 20f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 1.5f); - }); + blockExplosionSmoke = new Effect(30, e -> { + color(Color.gray); + randLenVectors(e.id, 6, 4f + 30f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 3f); + Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f); }); - shootBig = new Effect(9, e -> { - Draw.color(Pal.lighterOrange, Pal.lightOrange, e.fin()); - float w = 1.2f + 7 * e.fout(); - Drawf.tri(e.x, e.y, w, 25f * e.fout(), e.rotation); - Drawf.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f); - }); + }), - shootBig2 = new Effect(10, e -> { - Draw.color(Pal.lightOrange, Color.gray, e.fin()); - float w = 1.2f + 8 * e.fout(); - Drawf.tri(e.x, e.y, w, 29f * e.fout(), e.rotation); - Drawf.tri(e.x, e.y, w, 5f * e.fout(), e.rotation + 180f); - }); + shootSmall = new Effect(8, e -> { + color(Pal.lighterOrange, Pal.lightOrange, e.fin()); + float w = 1f + 5 * e.fout(); + Drawf.tri(e.x, e.y, w, 15f * e.fout(), e.rotation); + Drawf.tri(e.x, e.y, w, 3f * e.fout(), e.rotation + 180f); + }), - shootBigSmoke = new Effect(17f, e -> { - Draw.color(Pal.lighterOrange, Color.lightGray, Color.gray, e.fin()); + shootHeal = new Effect(8, e -> { + color(Pal.heal); + float w = 1f + 5 * e.fout(); + Drawf.tri(e.x, e.y, w, 17f * e.fout(), e.rotation); + Drawf.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f); + }), - Angles.randLenVectors(e.id, 8, e.finpow() * 19f, e.rotation, 10f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 2f + 0.2f); - }); + shootHealYellow = new Effect(8, e -> { + color(Pal.lightTrail); + float w = 1f + 5 * e.fout(); + Drawf.tri(e.x, e.y, w, 17f * e.fout(), e.rotation); + Drawf.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f); + }), - }); + shootSmallSmoke = new Effect(20f, e -> { + color(Pal.lighterOrange, Color.lightGray, Color.gray, e.fin()); - shootBigSmoke2 = new Effect(18f, e -> { - Draw.color(Pal.lightOrange, Color.lightGray, Color.gray, e.fin()); + randLenVectors(e.id, 5, e.finpow() * 6f, e.rotation, 20f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1.5f); + }); - Angles.randLenVectors(e.id, 9, e.finpow() * 23f, e.rotation, 20f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 2.4f + 0.2f); - }); + }), - }); + shootBig = new Effect(9, e -> { + color(Pal.lighterOrange, Pal.lightOrange, e.fin()); + float w = 1.2f + 7 * e.fout(); + Drawf.tri(e.x, e.y, w, 25f * e.fout(), e.rotation); + Drawf.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f); + }), - shootSmallFlame = new Effect(32f, e -> { - Draw.color(Pal.lightFlame, Pal.darkFlame, Color.gray, e.fin()); + shootBig2 = new Effect(10, e -> { + color(Pal.lightOrange, Color.gray, e.fin()); + float w = 1.2f + 8 * e.fout(); + Drawf.tri(e.x, e.y, w, 29f * e.fout(), e.rotation); + Drawf.tri(e.x, e.y, w, 5f * e.fout(), e.rotation + 180f); + }), - Angles.randLenVectors(e.id, 8, e.finpow() * 60f, e.rotation, 10f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.5f); - }); + shootBigSmoke = new Effect(17f, e -> { + color(Pal.lighterOrange, Color.lightGray, Color.gray, e.fin()); + randLenVectors(e.id, 8, e.finpow() * 19f, e.rotation, 10f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 2f + 0.2f); }); - shootPyraFlame = new Effect(33f, e -> { - Draw.color(Pal.lightPyraFlame, Pal.darkPyraFlame, Color.gray, e.fin()); + }), - Angles.randLenVectors(e.id, 10, e.finpow() * 70f, e.rotation, 10f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.6f); - }); + shootBigSmoke2 = new Effect(18f, e -> { + color(Pal.lightOrange, Color.lightGray, Color.gray, e.fin()); + randLenVectors(e.id, 9, e.finpow() * 23f, e.rotation, 20f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 2.4f + 0.2f); }); - shootLiquid = new Effect(40f, e -> { - Draw.color(e.color, Color.white, e.fout() / 6f + Mathf.randomSeedRange(e.id, 0.1f)); + }), - Angles.randLenVectors(e.id, 6, e.finpow() * 60f, e.rotation, 11f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.5f + e.fout() * 2.5f); - }); + shootSmallFlame = new Effect(32f, e -> { + color(Pal.lightFlame, Pal.darkFlame, Color.gray, e.fin()); + randLenVectors(e.id, 8, e.finpow() * 60f, e.rotation, 10f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.5f); }); - shellEjectSmall = new GroundEffect(30f, 400f, e -> { - Draw.color(Pal.lightOrange, Color.lightGray, Pal.lightishGray, e.fin()); - float rot = Math.abs(e.rotation) + 90f; + }), - int i = Mathf.sign(e.rotation); - - float len = (2f + e.finpow() * 6f) * i; - float lr = rot + e.fin() * 30f * i; - Fill.rect(e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), - e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), - 1f, 2f, rot + e.fin() * 50f * i); + shootPyraFlame = new Effect(33f, e -> { + color(Pal.lightPyraFlame, Pal.darkPyraFlame, Color.gray, e.fin()); + randLenVectors(e.id, 10, e.finpow() * 70f, e.rotation, 10f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.6f); }); - shellEjectMedium = new GroundEffect(34f, 400f, e -> { - Draw.color(Pal.lightOrange, Color.lightGray, Pal.lightishGray, e.fin()); - float rot = e.rotation + 90f; - for(int i : Mathf.signs){ - float len = (2f + e.finpow() * 10f) * i; - float lr = rot + e.fin() * 20f * i; - Draw.rect(Core.atlas.find("casing"), - e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), - e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), - 2f, 3f, rot); - } - - Draw.color(Color.lightGray, Color.gray, e.fin()); + }), - for(int i : Mathf.signs){ - float ex = e.x, ey = e.y, fout = e.fout(); - Angles.randLenVectors(e.id, 4, 1f + e.finpow() * 11f, e.rotation + 90f * i, 20f, (x, y) -> { - Fill.circle(ex + x, ey + y, fout * 1.5f); - }); - } + shootLiquid = new Effect(40f, e -> { + color(e.color, Color.white, e.fout() / 6f + Mathf.randomSeedRange(e.id, 0.1f)); + randLenVectors(e.id, 6, e.finpow() * 60f, e.rotation, 11f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.5f + e.fout() * 2.5f); }); - shellEjectBig = new GroundEffect(22f, 400f, e -> { - Draw.color(Pal.lightOrange, Color.lightGray, Pal.lightishGray, e.fin()); - float rot = e.rotation + 90f; - for(int i : Mathf.signs){ - float len = (4f + e.finpow() * 8f) * i; - float lr = rot + Mathf.randomSeedRange(e.id + i + 6, 20f * e.fin()) * i; - Draw.rect(Core.atlas.find("casing"), - e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), - e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), - 2.5f, 4f, - rot + e.fin() * 30f * i + Mathf.randomSeedRange(e.id + i + 9, 40f * e.fin())); - } - - Draw.color(Color.lightGray); + }), - for(int i : Mathf.signs){ - float ex = e.x, ey = e.y, fout = e.fout(); - Angles.randLenVectors(e.id, 4, -e.finpow() * 15f, e.rotation + 90f * i, 25f, (x, y) -> { - Fill.circle(ex + x, ey + y, fout * 2f); - }); - } + shellEjectSmall = new Effect(30f, e -> { + color(Pal.lightOrange, Color.lightGray, Pal.lightishGray, e.fin()); + float rot = Math.abs(e.rotation) + 90f; - }); + int i = Mathf.sign(e.rotation); - lancerLaserShoot = new Effect(21f, e -> { - Draw.color(Pal.lancerLaser); + float len = (2f + e.finpow() * 6f) * i; + float lr = rot + e.fin() * 30f * i; + Fill.rect(e.x + trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), + e.y + trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), + 1f, 2f, rot + e.fin() * 50f * i); - for(int i : Mathf.signs){ - Drawf.tri(e.x, e.y, 4f * e.fout(), 29f, e.rotation + 90f * i); - } + }).ground(400f), - }); + shellEjectMedium = new Effect(34f, e -> { + color(Pal.lightOrange, Color.lightGray, Pal.lightishGray, e.fin()); + float rot = e.rotation + 90f; + for(int i : Mathf.signs){ + float len = (2f + e.finpow() * 10f) * i; + float lr = rot + e.fin() * 20f * i; + rect(Core.atlas.find("casing"), + e.x + trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), + e.y + trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), + 2f, 3f, rot); + } - lancerLaserShootSmoke = new Effect(26f, e -> { - Draw.color(Color.white); + color(Color.lightGray, Color.gray, e.fin()); - Angles.randLenVectors(e.id, 7, 70f, e.rotation, 0f, (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fout() * 9f); + for(int i : Mathf.signs){ + float ex = e.x, ey = e.y, fout = e.fout(); + randLenVectors(e.id, 4, 1f + e.finpow() * 11f, e.rotation + 90f * i, 20f, (x, y) -> { + Fill.circle(ex + x, ey + y, fout * 1.5f); }); + } - }); + }).ground(400f), - lancerLaserCharge = new Effect(38f, e -> { - Draw.color(Pal.lancerLaser); + shellEjectBig = new Effect(22f, e -> { + color(Pal.lightOrange, Color.lightGray, Pal.lightishGray, e.fin()); + float rot = e.rotation + 90f; + for(int i : Mathf.signs){ + float len = (4f + e.finpow() * 8f) * i; + float lr = rot + Mathf.randomSeedRange(e.id + i + 6, 20f * e.fin()) * i; + rect(Core.atlas.find("casing"), + e.x + trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), + e.y + trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), + 2.5f, 4f, + rot + e.fin() * 30f * i + Mathf.randomSeedRange(e.id + i + 9, 40f * e.fin())); + } - Angles.randLenVectors(e.id, 2, 1f + 20f * e.fout(), e.rotation, 120f, (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fslope() * 3f + 1f); + color(Color.lightGray); + + for(int i : Mathf.signs){ + float ex = e.x, ey = e.y, fout = e.fout(); + randLenVectors(e.id, 4, -e.finpow() * 15f, e.rotation + 90f * i, 25f, (x, y) -> { + Fill.circle(ex + x, ey + y, fout * 2f); }); + } - }); + }).ground(400f), - lancerLaserChargeBegin = new Effect(60f, e -> { - Draw.color(Pal.lancerLaser); - Fill.circle(e.x, e.y, e.fin() * 3f); + lancerLaserShoot = new Effect(21f, e -> { + color(Pal.lancerLaser); - Draw.color(); - Fill.circle(e.x, e.y, e.fin() * 2f); - }); + for(int i : Mathf.signs){ + Drawf.tri(e.x, e.y, 4f * e.fout(), 29f, e.rotation + 90f * i); + } - lightningCharge = new Effect(38f, e -> { - Draw.color(Pal.lancerLaser); + }), - Angles.randLenVectors(e.id, 2, 1f + 20f * e.fout(), e.rotation, 120f, (x, y) -> { - Drawf.tri(e.x + x, e.y + y, e.fslope() * 3f + 1, e.fslope() * 3f + 1, Mathf.angle(x, y)); - }); + lancerLaserShootSmoke = new Effect(26f, e -> { + color(Color.white); + randLenVectors(e.id, 7, 70f, e.rotation, 0f, (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fout() * 9f); }); - lightningShoot = new Effect(12f, e -> { - Draw.color(Color.white, Pal.lancerLaser, e.fin()); - Lines.stroke(e.fout() * 1.2f + 0.5f); + }), - Angles.randLenVectors(e.id, 7, 25f * e.finpow(), e.rotation, 50f, (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 5f + 2f); - }); + lancerLaserCharge = new Effect(38f, e -> { + color(Pal.lancerLaser); + randLenVectors(e.id, 2, 1f + 20f * e.fout(), e.rotation, 120f, (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fslope() * 3f + 1f); }); + }), - reactorsmoke = new Effect(17, e -> { - Angles.randLenVectors(e.id, 4, e.fin() * 8f, (x, y) -> { - float size = 1f + e.fout() * 5f; - Draw.color(Color.lightGray, Color.gray, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); - }); - }); - nuclearsmoke = new Effect(40, e -> { - Angles.randLenVectors(e.id, 4, e.fin() * 13f, (x, y) -> { - float size = e.fslope() * 4f; - Draw.color(Color.lightGray, Color.gray, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); - }); - }); - nuclearcloud = new Effect(90, 200f, e -> { - Angles.randLenVectors(e.id, 10, e.finpow() * 90f, (x, y) -> { - float size = e.fout() * 14f; - Draw.color(Color.lime, Color.gray, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); - }); - }); - impactsmoke = new Effect(60, e -> { - Angles.randLenVectors(e.id, 7, e.fin() * 20f, (x, y) -> { - float size = e.fslope() * 4f; - Draw.color(Color.lightGray, Color.gray, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); - }); - }); - impactcloud = new Effect(140, 400f, e -> { - Angles.randLenVectors(e.id, 20, e.finpow() * 160f, (x, y) -> { - float size = e.fout() * 15f; - Draw.color(Pal.lighterOrange, Color.lightGray, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); - }); - }); - redgeneratespark = new Effect(18, e -> { - Angles.randLenVectors(e.id, 5, e.fin() * 8f, (x, y) -> { - float len = e.fout() * 4f; - Draw.color(Pal.redSpark, Color.gray, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, len, len); - }); - }); - generatespark = new Effect(18, e -> { - Angles.randLenVectors(e.id, 5, e.fin() * 8f, (x, y) -> { - float len = e.fout() * 4f; - Draw.color(Pal.orangeSpark, Color.gray, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, len, len); - }); - }); - fuelburn = new Effect(23, e -> { - Angles.randLenVectors(e.id, 5, e.fin() * 9f, (x, y) -> { - float len = e.fout() * 4f; - Draw.color(Color.lightGray, Color.gray, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, len, len); - }); - }); - plasticburn = new Effect(40, e -> { - Angles.randLenVectors(e.id, 5, 3f + e.fin() * 5f, (x, y) -> { - Draw.color(Color.valueOf("e9ead3"), Color.gray, e.fin()); - Fill.circle(e.x + x, e.y + y, e.fout() * 1f); - }); - }); - pulverize = new Effect(40, e -> { - Angles.randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> { - Draw.color(Pal.stoneGray); - Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.5f, 45); - }); - }); - pulverizeRed = new Effect(40, e -> { - Angles.randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> { - Draw.color(Pal.redDust, Pal.stoneGray, e.fin()); - Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.5f, 45); - }); - }); - pulverizeRedder = new Effect(40, e -> { - Angles.randLenVectors(e.id, 5, 3f + e.fin() * 9f, (x, y) -> { - Draw.color(Pal.redderDust, Pal.stoneGray, e.fin()); - Fill.square(e.x + x, e.y + y, e.fout() * 2.5f + 0.5f, 45); - }); - }); - pulverizeSmall = new Effect(30, e -> { - Angles.randLenVectors(e.id, 3, e.fin() * 5f, (x, y) -> { - Draw.color(Pal.stoneGray); - Fill.square(e.x + x, e.y + y, e.fout() * 1f + 0.5f, 45); - }); - }); - pulverizeMedium = new Effect(30, e -> { - Angles.randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> { - Draw.color(Pal.stoneGray); - Fill.square(e.x + x, e.y + y, e.fout() * 1f + 0.5f, 45); - }); - }); - producesmoke = new Effect(12, e -> { - Angles.randLenVectors(e.id, 8, 4f + e.fin() * 18f, (x, y) -> { - Draw.color(Color.white, Pal.accent, e.fin()); - Fill.square(e.x + x, e.y + y, 1f + e.fout() * 3f, 45); - }); - }); - smeltsmoke = new Effect(15, e -> { - Angles.randLenVectors(e.id, 6, 4f + e.fin() * 5f, (x, y) -> { - Draw.color(Color.white, e.color, e.fin()); - Fill.square(e.x + x, e.y + y, 0.5f + e.fout() * 2f, 45); - }); - }); - formsmoke = new Effect(40, e -> { - Angles.randLenVectors(e.id, 6, 5f + e.fin() * 8f, (x, y) -> { - Draw.color(Pal.plasticSmoke, Color.lightGray, e.fin()); - Fill.square(e.x + x, e.y + y, 0.2f + e.fout() * 2f, 45); - }); - }); - blastsmoke = new Effect(26, e -> { - Angles.randLenVectors(e.id, 12, 1f + e.fin() * 23f, (x, y) -> { - float size = 2f + e.fout() * 6f; - Draw.color(Color.lightGray, Color.darkGray, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); - }); - }); - lava = new Effect(18, e -> { - Angles.randLenVectors(e.id, 3, 1f + e.fin() * 10f, (x, y) -> { - float size = e.fslope() * 4f; - Draw.color(Color.orange, Color.gray, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); - }); - }); - dooropen = new Effect(10, e -> { - Lines.stroke(e.fout() * 1.6f); - Lines.square(e.x, e.y, tilesize / 2f + e.fin() * 2f); - }); - doorclose = new Effect(10, e -> { - Lines.stroke(e.fout() * 1.6f); - Lines.square(e.x, e.y, tilesize / 2f + e.fout() * 2f); - }); - dooropenlarge = new Effect(10, e -> { - Lines.stroke(e.fout() * 1.6f); - Lines.square(e.x, e.y, tilesize + e.fin() * 2f); - }); - doorcloselarge = new Effect(10, e -> { - Lines.stroke(e.fout() * 1.6f); - Lines.square(e.x, e.y, tilesize + e.fout() * 2f); - }); - purify = new Effect(10, e -> { - Draw.color(Color.royal, Color.gray, e.fin()); - Lines.stroke(2f); - Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); - }); - purifyoil = new Effect(10, e -> { - Draw.color(Color.black, Color.gray, e.fin()); - Lines.stroke(2f); - Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); - }); - purifystone = new Effect(10, e -> { - Draw.color(Color.orange, Color.gray, e.fin()); - Lines.stroke(2f); - Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); - }); - generate = new Effect(11, e -> { - Draw.color(Color.orange, Color.yellow, e.fin()); - Lines.stroke(1f); - Lines.spikes(e.x, e.y, e.fin() * 5f, 2, 8); - }); - mine = new Effect(20, e -> { - Angles.randLenVectors(e.id, 6, 3f + e.fin() * 6f, (x, y) -> { - Draw.color(e.color, Color.lightGray, e.fin()); - Fill.square(e.x + x, e.y + y, e.fout() * 2f, 45); - }); - }); - mineBig = new Effect(30, e -> { - Angles.randLenVectors(e.id, 6, 4f + e.fin() * 8f, (x, y) -> { - Draw.color(e.color, Color.lightGray, e.fin()); - Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.2f, 45); - }); - }); - mineHuge = new Effect(40, e -> { - Angles.randLenVectors(e.id, 8, 5f + e.fin() * 10f, (x, y) -> { - Draw.color(e.color, Color.lightGray, e.fin()); - Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.5f, 45); - }); - }); - smelt = new Effect(20, e -> { - Angles.randLenVectors(e.id, 6, 2f + e.fin() * 5f, (x, y) -> { - Draw.color(Color.white, e.color, e.fin()); - Fill.square(e.x + x, e.y + y, 0.5f + e.fout() * 2f, 45); - }); - }); - teleportActivate = new Effect(50, e -> { - Draw.color(e.color); + lancerLaserChargeBegin = new Effect(60f, e -> { + color(Pal.lancerLaser); + Fill.circle(e.x, e.y, e.fin() * 3f); - e.scaled(8f, e2 -> { - Lines.stroke(e2.fout() * 4f); - Lines.circle(e2.x, e2.y, 4f + e2.fin() * 27f); - }); + color(); + Fill.circle(e.x, e.y, e.fin() * 2f); + }), - Lines.stroke(e.fout() * 2f); - - Angles.randLenVectors(e.id, 30, 4f + 40f * e.fin(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 4f + 1f); - }); + lightningCharge = new Effect(38f, e -> { + color(Pal.lancerLaser); + randLenVectors(e.id, 2, 1f + 20f * e.fout(), e.rotation, 120f, (x, y) -> { + Drawf.tri(e.x + x, e.y + y, e.fslope() * 3f + 1, e.fslope() * 3f + 1, Mathf.angle(x, y)); }); - teleport = new Effect(60, e -> { - Draw.color(e.color); - Lines.stroke(e.fin() * 2f); - Lines.circle(e.x, e.y, 7f + e.fout() * 8f); - - Angles.randLenVectors(e.id, 20, 6f + 20f * e.fout(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 4f + 1f); - }); - }); - teleportOut = new Effect(20, e -> { - Draw.color(e.color); - Lines.stroke(e.fout() * 2f); - Lines.circle(e.x, e.y, 7f + e.fin() * 8f); + }), - Angles.randLenVectors(e.id, 20, 4f + 20f * e.fin(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fslope() * 4f + 1f); - }); + lightningShoot = new Effect(12f, e -> { + color(Color.white, Pal.lancerLaser, e.fin()); + stroke(e.fout() * 1.2f + 0.5f); - }); - ripple = new GroundEffect(false, 30, e -> { - Draw.color(Tmp.c1.set(e.color).mul(1.2f)); - Lines.stroke(e.fout() + 0.4f); - Lines.circle(e.x, e.y, 2f + e.fin() * 4f); + randLenVectors(e.id, 7, 25f * e.finpow(), e.rotation, 50f, (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 5f + 2f); }); - bubble = new Effect(20, e -> { - Draw.color(Tmp.c1.set(e.color).shiftValue(0.1f)); - Lines.stroke(e.fout() + 0.2f); - Angles.randLenVectors(e.id, 2, 8f, (x, y) -> { - Lines.circle(e.x + x, e.y + y, 1f + e.fin() * 3f); - }); - }); + }), - launch = new Effect(28, e -> { - Draw.color(Pal.command); - Lines.stroke(e.fout() * 2f); - Lines.circle(e.x, e.y, 4f + e.finpow() * 120f); + reactorsmoke = new Effect(17, e -> { + randLenVectors(e.id, 4, e.fin() * 8f, (x, y) -> { + float size = 1f + e.fout() * 5f; + color(Color.lightGray, Color.gray, e.fin()); + Fill.circle(e.x + x, e.y + y, size/2f); }); + }), - healWaveMend = new Effect(40, e -> { - Draw.color(e.color); - Lines.stroke(e.fout() * 2f); - Lines.circle(e.x, e.y, e.finpow() * e.rotation); + nuclearsmoke = new Effect(40, e -> { + randLenVectors(e.id, 4, e.fin() * 13f, (x, y) -> { + float size = e.fslope() * 4f; + color(Color.lightGray, Color.gray, e.fin()); + Fill.circle(e.x + x, e.y + y, size/2f); }); + }), - overdriveWave = new Effect(50, e -> { - Draw.color(e.color); - Lines.stroke(e.fout() * 1f); - Lines.circle(e.x, e.y, e.finpow() * e.rotation); + nuclearcloud = new Effect(90, 200f, e -> { + randLenVectors(e.id, 10, e.finpow() * 90f, (x, y) -> { + float size = e.fout() * 14f; + color(Color.lime, Color.gray, e.fin()); + Fill.circle(e.x + x, e.y + y, size/2f); }); + }), - healBlock = new Effect(20, e -> { - Draw.color(Pal.heal); - Lines.stroke(2f * e.fout() + 0.5f); - Lines.square(e.x, e.y, 1f + (e.fin() * e.rotation * tilesize / 2f - 1f)); + impactsmoke = new Effect(60, e -> { + randLenVectors(e.id, 7, e.fin() * 20f, (x, y) -> { + float size = e.fslope() * 4f; + color(Color.lightGray, Color.gray, e.fin()); + Fill.circle(e.x + x, e.y + y, size/2f); }); + }), - healBlockFull = new Effect(20, e -> { - Draw.color(e.color); - Draw.alpha(e.fout()); - Fill.square(e.x, e.y, e.rotation * tilesize / 2f); + impactcloud = new Effect(140, 400f, e -> { + randLenVectors(e.id, 20, e.finpow() * 160f, (x, y) -> { + float size = e.fout() * 15f; + color(Pal.lighterOrange, Color.lightGray, e.fin()); + Fill.circle(e.x + x, e.y + y, size/2f); }); + }), - overdriveBlockFull = new Effect(60, e -> { - Draw.color(e.color); - Draw.alpha(e.fslope() * 0.4f); - Fill.square(e.x, e.y, e.rotation * tilesize); + redgeneratespark = new Effect(18, e -> { + randLenVectors(e.id, 5, e.fin() * 8f, (x, y) -> { + float len = e.fout() * 4f; + color(Pal.redSpark, Color.gray, e.fin()); + Fill.circle(e.x + x, e.y + y, len/2f); }); + }), - shieldBreak = new Effect(40, e -> { - Draw.color(Pal.accent); - Lines.stroke(3f * e.fout()); - Lines.poly(e.x, e.y, 6, e.rotation + e.fin(), 90); - }); + generatespark = new Effect(18, e -> { + randLenVectors(e.id, 5, e.fin() * 8f, (x, y) -> { + float len = e.fout() * 4f; + color(Pal.orangeSpark, Color.gray, e.fin()); + Fill.circle(e.x + x, e.y + y, len/2f); + }); + }), + + fuelburn = new Effect(23, e -> { + randLenVectors(e.id, 5, e.fin() * 9f, (x, y) -> { + float len = e.fout() * 4f; + color(Color.lightGray, Color.gray, e.fin()); + Fill.circle(e.x + x, e.y + y, len/2f); + }); + }), + + plasticburn = new Effect(40, e -> { + randLenVectors(e.id, 5, 3f + e.fin() * 5f, (x, y) -> { + color(Color.valueOf("e9ead3"), Color.gray, e.fin()); + Fill.circle(e.x + x, e.y + y, e.fout() * 1f); + }); + }), + + pulverize = new Effect(40, e -> { + randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> { + color(Pal.stoneGray); + Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.5f, 45); + }); + }), + + pulverizeRed = new Effect(40, e -> { + randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> { + color(Pal.redDust, Pal.stoneGray, e.fin()); + Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.5f, 45); + }); + }), + + pulverizeRedder = new Effect(40, e -> { + randLenVectors(e.id, 5, 3f + e.fin() * 9f, (x, y) -> { + color(Pal.redderDust, Pal.stoneGray, e.fin()); + Fill.square(e.x + x, e.y + y, e.fout() * 2.5f + 0.5f, 45); + }); + }), + + pulverizeSmall = new Effect(30, e -> { + randLenVectors(e.id, 3, e.fin() * 5f, (x, y) -> { + color(Pal.stoneGray); + Fill.square(e.x + x, e.y + y, e.fout() * 1f + 0.5f, 45); + }); + }), + + pulverizeMedium = new Effect(30, e -> { + randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> { + color(Pal.stoneGray); + Fill.square(e.x + x, e.y + y, e.fout() * 1f + 0.5f, 45); + }); + }), + + producesmoke = new Effect(12, e -> { + randLenVectors(e.id, 8, 4f + e.fin() * 18f, (x, y) -> { + color(Color.white, Pal.accent, e.fin()); + Fill.square(e.x + x, e.y + y, 1f + e.fout() * 3f, 45); + }); + }), + + smeltsmoke = new Effect(15, e -> { + randLenVectors(e.id, 6, 4f + e.fin() * 5f, (x, y) -> { + color(Color.white, e.color, e.fin()); + Fill.square(e.x + x, e.y + y, 0.5f + e.fout() * 2f, 45); + }); + }), + + formsmoke = new Effect(40, e -> { + randLenVectors(e.id, 6, 5f + e.fin() * 8f, (x, y) -> { + color(Pal.plasticSmoke, Color.lightGray, e.fin()); + Fill.square(e.x + x, e.y + y, 0.2f + e.fout() * 2f, 45); + }); + }), + + blastsmoke = new Effect(26, e -> { + randLenVectors(e.id, 12, 1f + e.fin() * 23f, (x, y) -> { + float size = 2f + e.fout() * 6f; + color(Color.lightGray, Color.darkGray, e.fin()); + Fill.circle(e.x + x, e.y + y, size/2f); + }); + }), + + lava = new Effect(18, e -> { + randLenVectors(e.id, 3, 1f + e.fin() * 10f, (x, y) -> { + float size = e.fslope() * 4f; + color(Color.orange, Color.gray, e.fin()); + Fill.circle(e.x + x, e.y + y, size/2f); + }); + }), + + dooropen = new Effect(10, e -> { + stroke(e.fout() * 1.6f); + Lines.square(e.x, e.y, tilesize / 2f + e.fin() * 2f); + }), + + doorclose = new Effect(10, e -> { + stroke(e.fout() * 1.6f); + Lines.square(e.x, e.y, tilesize / 2f + e.fout() * 2f); + }), + dooropenlarge = new Effect(10, e -> { + stroke(e.fout() * 1.6f); + Lines.square(e.x, e.y, tilesize + e.fin() * 2f); + }), + doorcloselarge = new Effect(10, e -> { + stroke(e.fout() * 1.6f); + Lines.square(e.x, e.y, tilesize + e.fout() * 2f); + }), + purify = new Effect(10, e -> { + color(Color.royal, Color.gray, e.fin()); + stroke(2f); + Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); + }), + purifyoil = new Effect(10, e -> { + color(Color.black, Color.gray, e.fin()); + stroke(2f); + Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); + }), + purifystone = new Effect(10, e -> { + color(Color.orange, Color.gray, e.fin()); + stroke(2f); + Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); + }), + generate = new Effect(11, e -> { + color(Color.orange, Color.yellow, e.fin()); + stroke(1f); + Lines.spikes(e.x, e.y, e.fin() * 5f, 2, 8); + }), + mine = new Effect(20, e -> { + randLenVectors(e.id, 6, 3f + e.fin() * 6f, (x, y) -> { + color(e.color, Color.lightGray, e.fin()); + Fill.square(e.x + x, e.y + y, e.fout() * 2f, 45); + }); + }), + mineBig = new Effect(30, e -> { + randLenVectors(e.id, 6, 4f + e.fin() * 8f, (x, y) -> { + color(e.color, Color.lightGray, e.fin()); + Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.2f, 45); + }); + }), + + mineHuge = new Effect(40, e -> { + randLenVectors(e.id, 8, 5f + e.fin() * 10f, (x, y) -> { + color(e.color, Color.lightGray, e.fin()); + Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.5f, 45); + }); + }), + smelt = new Effect(20, e -> { + randLenVectors(e.id, 6, 2f + e.fin() * 5f, (x, y) -> { + color(Color.white, e.color, e.fin()); + Fill.square(e.x + x, e.y + y, 0.5f + e.fout() * 2f, 45); + }); + }), + teleportActivate = new Effect(50, e -> { + color(e.color); + + e.scaled(8f, e2 -> { + stroke(e2.fout() * 4f); + Lines.circle(e2.x, e2.y, 4f + e2.fin() * 27f); + }); + + stroke(e.fout() * 2f); + + randLenVectors(e.id, 30, 4f + 40f * e.fin(), (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 4f + 1f); + }); + + }), + teleport = new Effect(60, e -> { + color(e.color); + stroke(e.fin() * 2f); + Lines.circle(e.x, e.y, 7f + e.fout() * 8f); + + randLenVectors(e.id, 20, 6f + 20f * e.fout(), (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 4f + 1f); + }); + + }), + teleportOut = new Effect(20, e -> { + color(e.color); + stroke(e.fout() * 2f); + Lines.circle(e.x, e.y, 7f + e.fin() * 8f); + + randLenVectors(e.id, 20, 4f + 20f * e.fin(), (x, y) -> { + lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fslope() * 4f + 1f); + }); + + }), + + //TODO fix false in constructor + ripple = new Effect(30, e -> { + color(Tmp.c1.set(e.color).mul(1.2f)); + stroke(e.fout() + 0.4f); + Lines.circle(e.x, e.y, 2f + e.fin() * 4f); + }).ground(), + + bubble = new Effect(20, e -> { + color(Tmp.c1.set(e.color).shiftValue(0.1f)); + stroke(e.fout() + 0.2f); + randLenVectors(e.id, 2, 8f, (x, y) -> { + Lines.circle(e.x + x, e.y + y, 1f + e.fin() * 3f); + }); + }), + + launch = new Effect(28, e -> { + color(Pal.command); + stroke(e.fout() * 2f); + Lines.circle(e.x, e.y, 4f + e.finpow() * 120f); + }), + + healWaveMend = new Effect(40, e -> { + color(e.color); + stroke(e.fout() * 2f); + Lines.circle(e.x, e.y, e.finpow() * e.rotation); + }), + + overdriveWave = new Effect(50, e -> { + color(e.color); + stroke(e.fout() * 1f); + Lines.circle(e.x, e.y, e.finpow() * e.rotation); + }), + + healBlock = new Effect(20, e -> { + color(Pal.heal); + stroke(2f * e.fout() + 0.5f); + Lines.square(e.x, e.y, 1f + (e.fin() * e.rotation * tilesize / 2f - 1f)); + }), + + healBlockFull = new Effect(20, e -> { + color(e.color); + alpha(e.fout()); + Fill.square(e.x, e.y, e.rotation * tilesize / 2f); + }), + + overdriveBlockFull = new Effect(60, e -> { + color(e.color); + alpha(e.fslope() * 0.4f); + Fill.square(e.x, e.y, e.rotation * tilesize); + }), + + shieldBreak = new Effect(40, e -> { + color(Pal.accent); + stroke(3f * e.fout()); + Lines.poly(e.x, e.y, 6, e.rotation + e.fin(), 90); + }), - coreLand = new Effect(120f, e -> { - }); - } + coreLand = new Effect(120f, e -> { + }); } diff --git a/core/src/mindustry/content/Mechs.java b/core/src/mindustry/content/Mechs.java deleted file mode 100644 index 0e3e9f211e..0000000000 --- a/core/src/mindustry/content/Mechs.java +++ /dev/null @@ -1,461 +0,0 @@ -package mindustry.content; - -import arc.*; -import arc.graphics.*; -import arc.graphics.g2d.*; -import arc.math.*; -import arc.util.*; -import mindustry.*; -import mindustry.ctype.*; -import mindustry.entities.*; -import mindustry.entities.bullet.*; -import mindustry.entities.effect.*; -import mindustry.entities.type.*; -import mindustry.gen.*; -import mindustry.graphics.*; -import mindustry.type.*; - -import static mindustry.Vars.indexer; - -public class Mechs implements ContentList{ - public static UnitDef vanguard, alpha, delta, tau, omega, dart, javelin, trident, glaive; - - public static UnitDef starter; - - @Override - public void load(){ - - vanguard = new UnitDef("vanguard-ship"){ - float healRange = 60f; - float healReload = 200f; - float healPercent = 10f; - - { - flying = true; - drillTier = 1; - minePower = 4f; - speed = 0.49f; - drag = 0.09f; - health = 200f; - weaponOffsetX = -1; - engineSize = 2.3f; - weaponOffsetY = -1; - engineColor = Pal.lightTrail; - cellTrnsY = 1f; - buildPower = 1.2f; - weapon = new Weapon("vanguard-blaster"){{ - length = 1.5f; - reload = 30f; - alternate = true; - inaccuracy = 6f; - velocityRnd = 0.1f; - ejectEffect = Fx.none; - bullet = new HealBulletType(){{ - healPercent = 3f; - backColor = engineColor; - homingPower = 20f; - bulletHeight = 4f; - bulletWidth = 1.5f; - damage = 3f; - speed = 4f; - lifetime = 40f; - shootEffect = Fx.shootHealYellow; - smokeEffect = hitEffect = despawnEffect = Fx.hitYellowLaser; - }}; - }}; - } - - @Override - public boolean alwaysUnlocked(){ - return true; - } - - @Override - public void update(Player player){ - if(player.timer.get(Player.timerAbility, healReload)){ - if(indexer.eachBlock(player, healRange, other -> other.entity.damaged(), other -> { - other.entity.healBy(other.entity.maxHealth() * healPercent / 100f); - Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal); - })){ - Fx.healWave.at(player); - } - } - } - }; - - alpha = new UnitDef("alpha-mech", false){ - { - drillTier = -1; - speed = 0.5f; - boostSpeed = 0.95f; - itemCapacity = 15; - mass = 0.9f; - health = 150f; - buildPower = 0.9f; - weaponOffsetX = 1; - weaponOffsetY = -1; - engineColor = Pal.heal; - - weapon = new Weapon("shockgun"){{ - shake = 2f; - length = 0.5f; - reload = 70f; - alternate = true; - recoil = 4f; - width = 5f; - shootSound = Sounds.laser; - - bullet = new LaserBulletType(){{ - damage = 20f; - recoil = 1f; - sideAngle = 45f; - sideWidth = 1f; - sideLength = 70f; - colors = new Color[]{Pal.heal.cpy().a(0.4f), Pal.heal, Color.white}; - }}; - }}; - } - - @Override - public void update(Player player){ - player.healBy(Time.delta() * 0.09f); - } - - }; - - delta = new UnitDef("delta-mech", false){ - { - drillPower = 1; - mineSpeed = 1.5f; - mass = 1.2f; - speed = 0.5f; - itemCapacity = 40; - boostSpeed = 0.95f; - buildPower = 1.2f; - engineColor = Color.valueOf("ffd37f"); - health = 250f; - weaponOffsetX = 4f; - - weapon = new Weapon("flamethrower"){{ - length = 1.5f; - reload = 30f; - width = 4f; - alternate = true; - shots = 3; - inaccuracy = 40f; - shootSound = Sounds.spark; - bullet = new LightningBulletType(){{ - damage = 5; - lightningLength = 10; - lightningColor = Pal.lightFlame; - }}; - }}; - } - }; - - tau = new UnitDef("tau-mech", false){ - float healRange = 60f; - float healAmount = 10f; - float healReload = 160f; - boolean wasHealed; - - { - drillPower = 4; - mineSpeed = 3f; - itemCapacity = 70; - weaponOffsetY = -1; - weaponOffsetX = 1; - mass = 1.75f; - speed = 0.44f; - drag = 0.35f; - boostSpeed = 0.8f; - canHeal = true; - health = 200f; - buildPower = 1.6f; - engineColor = Pal.heal; - - weapon = new Weapon("heal-blaster"){{ - length = 1.5f; - reload = 24f; - alternate = false; - ejectEffect = Fx.none; - recoil = 2f; - bullet = Bullets.healBullet; - shootSound = Sounds.pew; - }}; - } - - @Override - public void update(Player player){ - - if(player.timer.get(Player.timerAbility, healReload)){ - wasHealed = false; - - Units.nearby(player.team(), player.x, player.y, healRange, unit -> { - if(unit.health < unit.maxHealth()){ - Fx.heal.at(unit); - wasHealed = true; - } - unit.healBy(healAmount); - }); - - if(wasHealed){ - Fx.healWave.at(player); - } - } - } - }; - - omega = new UnitDef("omega-mech", false){ - protected TextureRegion armorRegion; - - { - drillPower = 2; - mineSpeed = 1.5f; - itemCapacity = 80; - speed = 0.36f; - boostSpeed = 0.6f; - mass = 4f; - shake = 4f; - weaponOffsetX = 1; - weaponOffsetY = 0; - engineColor = Color.valueOf("feb380"); - health = 350f; - buildPower = 1.5f; - weapon = new Weapon("swarmer"){{ - length = 1.5f; - recoil = 4f; - reload = 38f; - shots = 4; - spacing = 8f; - inaccuracy = 8f; - alternate = true; - ejectEffect = Fx.none; - shake = 3f; - bullet = Bullets.missileSwarm; - shootSound = Sounds.shootBig; - }}; - } - - @Override - public float getRotationAlpha(Player player){ - return 0.6f - player.shootHeat * 0.3f; - } - - @Override - public float spreadX(Player player){ - return player.shootHeat * 2f; - } - - @Override - public void load(){ - super.load(); - armorRegion = Core.atlas.find(name + "-armor"); - } - - @Override - public void update(Player player){ - float scl = 1f - player.shootHeat / 2f*Time.delta(); - player.velocity().scl(scl); - } - - @Override - public float getExtraArmor(Player player){ - return player.shootHeat * 30f; - } - - @Override - public void draw(Player player){ - if(player.shootHeat <= 0.01f) return; - - Shaders.build.progress = player.shootHeat; - Shaders.build.region = armorRegion; - Shaders.build.time = Time.time() / 10f; - Shaders.build.color.set(Pal.accent).a = player.shootHeat; - Draw.shader(Shaders.build); - Draw.rect(armorRegion, player.x, player.y, player.rotation); - Draw.shader(); - } - }; - - dart = new UnitDef("dart-ship"){ - float effectRange = 60f; - float effectReload = 60f * 5; - float effectDuration = 60f * 10f; - - { - flying = true; - drillPower = 1; - mineSpeed = 2f; - speed = 0.5f; - drag = 0.09f; - health = 200f; - weaponOffsetX = -1; - weaponOffsetY = -1; - engineColor = Pal.lightTrail; - cellTrnsY = 1f; - buildPower = 1.1f; - weapon = new Weapon("blaster"){{ - length = 1.5f; - reload = 15f; - alternate = true; - ejectEffect = Fx.shellEjectSmall; - bullet = Bullets.standardCopper; - }}; - } - - @Override - public void update(Player player){ - super.update(player); - - if(player.timer.get(Player.timerAbility, effectReload)){ - - Units.nearby(player.team(), player.x, player.y, effectRange, unit -> { - //unit.applyEffect(StatusEffects.overdrive, effectDuration); - }); - - indexer.eachBlock(player, effectRange, other -> other.entity.damaged(), other -> { - other.entity.applyBoost(1.5f, effectDuration); - Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal); - }); - - Fx.overdriveWave.at(player); - } - } - }; - - javelin = new UnitDef("javelin-ship"){ - float minV = 3.6f; - float maxV = 6f; - TextureRegion shield; - - { - flying = true; - drillPower = -1; - speed = 0.11f; - drag = 0.01f; - mass = 2f; - health = 170f; - engineColor = Color.valueOf("d3ddff"); - cellTrnsY = 1f; - weapon = new Weapon("missiles"){{ - length = 1.5f; - reload = 70f; - shots = 4; - inaccuracy = 2f; - alternate = true; - ejectEffect = Fx.none; - velocityRnd = 0.2f; - spacing = 1f; - bullet = Bullets.missileJavelin; - shootSound = Sounds.missile; - }}; - } - - @Override - public void load(){ - super.load(); - shield = Core.atlas.find(name + "-shield"); - } - - @Override - public float getRotationAlpha(Player player){ - return 0.5f; - } - - @Override - public void update(Player player){ - float scl = scld(player); - if(Mathf.chance(Time.delta() * (0.15 * scl))){ - Fx.hitLancer.at(Pal.lancerLaser, player.x, player.y); - Lightning.create(player.team(), Pal.lancerLaser, 10f * Vars.state.rules.playerDamageMultiplier, - player.x + player.velocity().x, player.y + player.velocity().y, player.rotation, 14); - } - } - - @Override - public void draw(Player player){ - float scl = scld(player); - if(scl < 0.01f) return; - Draw.color(Pal.lancerLaser); - Draw.alpha(scl / 2f); - Draw.blend(Blending.additive); - Draw.rect(shield, player.x + Mathf.range(scl / 2f), player.y + Mathf.range(scl / 2f), player.rotation - 90); - Draw.blend(); - } - - float scld(Player player){ - return Mathf.clamp((player.velocity().len() - minV) / (maxV - minV)); - } - }; - - trident = new UnitDef("trident-ship"){ - { - flying = true; - drillPower = 2; - speed = 0.15f; - drag = 0.034f; - mass = 2.5f; - turnCursor = false; - health = 250f; - itemCapacity = 30; - engineColor = Color.valueOf("84f491"); - cellTrnsY = 1f; - buildPower = 2.5f; - weapon = new Weapon("bomber"){{ - length = 0f; - width = 2f; - reload = 25f; - shots = 2; - shotDelay = 1f; - shots = 8; - alternate = true; - ejectEffect = Fx.none; - velocityRnd = 1f; - inaccuracy = 20f; - ignoreRotation = true; - bullet = new BombBulletType(16f, 25f, "shell"){{ - bulletWidth = 10f; - bulletHeight = 14f; - hitEffect = Fx.flakExplosion; - shootEffect = Fx.none; - smokeEffect = Fx.none; - shootSound = Sounds.artillery; - }}; - }}; - } - - @Override - public boolean canShoot(Player player){ - return player.velocity().len() > 1.2f; - } - }; - - glaive = new UnitDef("glaive-ship"){ - { - flying = true; - drillPower = 4; - mineSpeed = 1.3f; - speed = 0.32f; - drag = 0.06f; - mass = 3f; - health = 240f; - itemCapacity = 60; - engineColor = Color.valueOf("feb380"); - cellTrnsY = 1f; - buildPower = 1.2f; - - weapon = new Weapon("bomber"){{ - length = 1.5f; - reload = 13f; - alternate = true; - ejectEffect = Fx.shellEjectSmall; - bullet = Bullets.standardGlaive; - shootSound = Sounds.shootSnap; - }}; - } - }; - - starter = vanguard; - } -} diff --git a/core/src/mindustry/content/StatusEffects.java b/core/src/mindustry/content/StatusEffects.java index 7f60d54979..f0cb039a01 100644 --- a/core/src/mindustry/content/StatusEffects.java +++ b/core/src/mindustry/content/StatusEffects.java @@ -23,7 +23,7 @@ public class StatusEffects implements ContentList{ opposite(wet,freezing); trans(tarred, ((unit, time, newTime, result) -> { unit.damage(1f); - Fx.burning.at(unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f)); + Fx.burning.at(unit.x() + Mathf.range(unit.bounds() / 2f), unit.y() + Mathf.range(unit.bounds() / 2f)); result.set(this, Math.min(time + newTime, 300f)); })); }); diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 9c97dc9475..069a196214 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -1,10 +1,6 @@ package mindustry.content; -import arc.struct.*; import mindustry.ctype.*; -import mindustry.entities.bullet.*; -import mindustry.entities.type.base.*; -import mindustry.gen.*; import mindustry.type.*; public class UnitTypes implements ContentList{ @@ -13,8 +9,12 @@ public class UnitTypes implements ContentList{ wraith, ghoul, revenant, lich, reaper, dagger, crawler, titan, fortress, eruptor, chaosArray, eradicator; + public static UnitDef vanguard, alpha, delta, tau, omega, dart, javelin, trident, glaive; + public static UnitDef starter; + @Override public void load(){ + /* draug = new UnitDef("draug", MinerDrone::new){{ flying = true; drag = 0.01f; @@ -372,5 +372,440 @@ public class UnitTypes implements ContentList{ shootSound = Sounds.shootBig; }}; }}; + + + /* + vanguard = new UnitDef("vanguard-ship"){ + float healRange = 60f; + float healReload = 200f; + float healPercent = 10f; + + { + flying = true; + drillTier = 1; + minePower = 4f; + speed = 0.49f; + drag = 0.09f; + health = 200f; + weaponOffsetX = -1; + engineSize = 2.3f; + weaponOffsetY = -1; + engineColor = Pal.lightTrail; + cellTrnsY = 1f; + buildPower = 1.2f; + weapon = new Weapon("vanguard-blaster"){{ + length = 1.5f; + reload = 30f; + alternate = true; + inaccuracy = 6f; + velocityRnd = 0.1f; + ejectEffect = Fx.none; + bullet = new HealBulletType(){{ + healPercent = 3f; + backColor = engineColor; + homingPower = 20f; + bulletHeight = 4f; + bulletWidth = 1.5f; + damage = 3f; + speed = 4f; + lifetime = 40f; + shootEffect = Fx.shootHealYellow; + smokeEffect = hitEffect = despawnEffect = Fx.hitYellowLaser; + }}; + }}; + } + + @Override + public boolean alwaysUnlocked(){ + return true; + } + + @Override + public void update(Playerc player){ + if(player.timer.get(Playerc.timerAbility, healReload)){ + if(indexer.eachBlock(player, healRange, other -> other.entity.damaged(), other -> { + other.entity.healBy(other.entity.maxHealth() * healPercent / 100f); + Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal); + })){ + Fx.healWave.at(player); + } + } + } + }; + + alpha = new UnitDef("alpha-mech", false){ + { + drillTier = -1; + speed = 0.5f; + boostSpeed = 0.95f; + itemCapacity = 15; + mass = 0.9f; + health = 150f; + buildPower = 0.9f; + weaponOffsetX = 1; + weaponOffsetY = -1; + engineColor = Pal.heal; + + weapon = new Weapon("shockgun"){{ + shake = 2f; + length = 0.5f; + reload = 70f; + alternate = true; + recoil = 4f; + width = 5f; + shootSound = Sounds.laser; + + bullet = new LaserBulletType(){{ + damage = 20f; + recoil = 1f; + sideAngle = 45f; + sideWidth = 1f; + sideLength = 70f; + colors = new Color[]{Pal.heal.cpy().a(0.4f), Pal.heal, Color.white}; + }}; + }}; + } + + @Override + public void update(Playerc player){ + player.healBy(Time.delta() * 0.09f); + } + + }; + + delta = new UnitDef("delta-mech", false){ + { + drillPower = 1; + mineSpeed = 1.5f; + mass = 1.2f; + speed = 0.5f; + itemCapacity = 40; + boostSpeed = 0.95f; + buildPower = 1.2f; + engineColor = Color.valueOf("ffd37f"); + health = 250f; + weaponOffsetX = 4f; + + weapon = new Weapon("flamethrower"){{ + length = 1.5f; + reload = 30f; + width = 4f; + alternate = true; + shots = 3; + inaccuracy = 40f; + shootSound = Sounds.spark; + bullet = new LightningBulletType(){{ + damage = 5; + lightningLength = 10; + lightningColor = Pal.lightFlame; + }}; + }}; + } + }; + + tau = new UnitDef("tau-mech", false){ + float healRange = 60f; + float healAmount = 10f; + float healReload = 160f; + boolean wasHealed; + + { + drillPower = 4; + mineSpeed = 3f; + itemCapacity = 70; + weaponOffsetY = -1; + weaponOffsetX = 1; + mass = 1.75f; + speed = 0.44f; + drag = 0.35f; + boostSpeed = 0.8f; + canHeal = true; + health = 200f; + buildPower = 1.6f; + engineColor = Pal.heal; + + weapon = new Weapon("heal-blaster"){{ + length = 1.5f; + reload = 24f; + alternate = false; + ejectEffect = Fx.none; + recoil = 2f; + bullet = Bullets.healBullet; + shootSound = Sounds.pew; + }}; + } + + @Override + public void update(Playerc player){ + + if(player.timer.get(Playerc.timerAbility, healReload)){ + wasHealed = false; + + Units.nearby(player.team(), player.x, player.y, healRange, unit -> { + if(unit.health < unit.maxHealth()){ + Fx.heal.at(unit); + wasHealed = true; + } + unit.healBy(healAmount); + }); + + if(wasHealed){ + Fx.healWave.at(player); + } + } + } + }; + + omega = new UnitDef("omega-mech", false){ + protected TextureRegion armorRegion; + + { + drillPower = 2; + mineSpeed = 1.5f; + itemCapacity = 80; + speed = 0.36f; + boostSpeed = 0.6f; + mass = 4f; + shake = 4f; + weaponOffsetX = 1; + weaponOffsetY = 0; + engineColor = Color.valueOf("feb380"); + health = 350f; + buildPower = 1.5f; + weapon = new Weapon("swarmer"){{ + length = 1.5f; + recoil = 4f; + reload = 38f; + shots = 4; + spacing = 8f; + inaccuracy = 8f; + alternate = true; + ejectEffect = Fx.none; + shake = 3f; + bullet = Bullets.missileSwarm; + shootSound = Sounds.shootBig; + }}; + } + + @Override + public float getRotationAlpha(Playerc player){ + return 0.6f - player.shootHeat * 0.3f; + } + + @Override + public float spreadX(Playerc player){ + return player.shootHeat * 2f; + } + + @Override + public void load(){ + super.load(); + armorRegion = Core.atlas.find(name + "-armor"); + } + + @Override + public void update(Playerc player){ + float scl = 1f - player.shootHeat / 2f*Time.delta(); + player.vel().scl(scl); + } + + @Override + public float getExtraArmor(Playerc player){ + return player.shootHeat * 30f; + } + + @Override + public void draw(Playerc player){ + if(player.shootHeat <= 0.01f) return; + + Shaders.build.progress = player.shootHeat; + Shaders.build.region = armorRegion; + Shaders.build.time = Time.time() / 10f; + Shaders.build.color.set(Pal.accent).a = player.shootHeat; + Draw.shader(Shaders.build); + Draw.rect(armorRegion, player.x, player.y, player.rotation); + Draw.shader(); + } + }; + + dart = new UnitDef("dart-ship"){ + float effectRange = 60f; + float effectReload = 60f * 5; + float effectDuration = 60f * 10f; + + { + flying = true; + drillPower = 1; + mineSpeed = 2f; + speed = 0.5f; + drag = 0.09f; + health = 200f; + weaponOffsetX = -1; + weaponOffsetY = -1; + engineColor = Pal.lightTrail; + cellTrnsY = 1f; + buildPower = 1.1f; + weapon = new Weapon("blaster"){{ + length = 1.5f; + reload = 15f; + alternate = true; + ejectEffect = Fx.shellEjectSmall; + bullet = Bullets.standardCopper; + }}; + } + + @Override + public void update(Playerc player){ + super.update(player); + + if(player.timer.get(Playerc.timerAbility, effectReload)){ + + Units.nearby(player.team(), player.x, player.y, effectRange, unit -> { + //unit.applyEffect(StatusEffects.overdrive, effectDuration); + }); + + indexer.eachBlock(player, effectRange, other -> other.entity.damaged(), other -> { + other.entity.applyBoost(1.5f, effectDuration); + Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal); + }); + + Fx.overdriveWave.at(player); + } + } + }; + + javelin = new UnitDef("javelin-ship"){ + float minV = 3.6f; + float maxV = 6f; + TextureRegion shield; + + { + flying = true; + drillPower = -1; + speed = 0.11f; + drag = 0.01f; + mass = 2f; + health = 170f; + engineColor = Color.valueOf("d3ddff"); + cellTrnsY = 1f; + weapon = new Weapon("missiles"){{ + length = 1.5f; + reload = 70f; + shots = 4; + inaccuracy = 2f; + alternate = true; + ejectEffect = Fx.none; + velocityRnd = 0.2f; + spacing = 1f; + bullet = Bullets.missileJavelin; + shootSound = Sounds.missile; + }}; + } + + @Override + public void load(){ + super.load(); + shield = Core.atlas.find(name + "-shield"); + } + + @Override + public float getRotationAlpha(Playerc player){ + return 0.5f; + } + + @Override + public void update(Playerc player){ + float scl = scld(player); + if(Mathf.chance(Time.delta() * (0.15 * scl))){ + Fx.hitLancer.at(Pal.lancerLaser, player.x, player.y); + Lightning.create(player.team(), Pal.lancerLaser, 10f * Vars.state.rules.playerDamageMultiplier, + player.x + player.vel().x, player.y + player.vel().y, player.rotation, 14); + } + } + + @Override + public void draw(Playerc player){ + float scl = scld(player); + if(scl < 0.01f) return; + Draw.color(Pal.lancerLaser); + Draw.alpha(scl / 2f); + Draw.blend(Blending.additive); + Draw.rect(shield, player.x + Mathf.range(scl / 2f), player.y + Mathf.range(scl / 2f), player.rotation - 90); + Draw.blend(); + } + + float scld(Playerc player){ + return Mathf.clamp((player.vel().len() - minV) / (maxV - minV)); + } + }; + + trident = new UnitDef("trident-ship"){ + { + flying = true; + drillPower = 2; + speed = 0.15f; + drag = 0.034f; + mass = 2.5f; + turnCursor = false; + health = 250f; + itemCapacity = 30; + engineColor = Color.valueOf("84f491"); + cellTrnsY = 1f; + buildPower = 2.5f; + weapon = new Weapon("bomber"){{ + length = 0f; + width = 2f; + reload = 25f; + shots = 2; + shotDelay = 1f; + shots = 8; + alternate = true; + ejectEffect = Fx.none; + velocityRnd = 1f; + inaccuracy = 20f; + ignoreRotation = true; + bullet = new BombBulletType(16f, 25f, "shell"){{ + bulletWidth = 10f; + bulletHeight = 14f; + hitEffect = Fx.flakExplosion; + shootEffect = Fx.none; + smokeEffect = Fx.none; + shootSound = Sounds.artillery; + }}; + }}; + } + + @Override + public boolean canShoot(Playerc player){ + return player.vel().len() > 1.2f; + } + }; + + glaive = new UnitDef("glaive-ship"){ + { + flying = true; + drillPower = 4; + mineSpeed = 1.3f; + speed = 0.32f; + drag = 0.06f; + mass = 3f; + health = 240f; + itemCapacity = 60; + engineColor = Color.valueOf("feb380"); + cellTrnsY = 1f; + buildPower = 1.2f; + + weapon = new Weapon("bomber"){{ + length = 1.5f; + reload = 13f; + alternate = true; + ejectEffect = Fx.shellEjectSmall; + bullet = Bullets.standardGlaive; + shootSound = Sounds.shootSnap; + }}; + } + }; + + starter = vanguard;*/ } } diff --git a/core/src/mindustry/core/ContentLoader.java b/core/src/mindustry/core/ContentLoader.java index a2c54d9051..2a7c1c45bc 100644 --- a/core/src/mindustry/core/ContentLoader.java +++ b/core/src/mindustry/core/ContentLoader.java @@ -263,7 +263,7 @@ public class ContentLoader{ return getBy(ContentType.zone); } - public Array units(){ + public Array units(){ return getBy(ContentType.unit); } } diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index b988dc969a..14c7ea47a9 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -13,7 +13,7 @@ import arc.util.*; import mindustry.content.*; import mindustry.core.GameState.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.game.*; @@ -63,7 +63,7 @@ public class Control implements ApplicationListener, Loadable{ }); Events.on(PlayEvent.class, event -> { - player.team(netServer.assignTeam(player, playerGroup.all())); + player.team(netServer.assignTeam(player, Groups.player.all())); player.dead(true); player.add(); @@ -204,10 +204,10 @@ public class Control implements ApplicationListener, Loadable{ } void createPlayer(){ - player = new Player(); + player = new Playerc(); player.name = Core.settings.getString("name"); player.color.set(Core.settings.getInt("color-0")); - player.isLocal = true; + player.isLocal() = true; player.isMobile = mobile; if(mobile){ @@ -304,14 +304,14 @@ public class Control implements ApplicationListener, Loadable{ } } - Geometry.circle(coreb.x, coreb.y, 10, (cx, cy) -> { + Geometry.circle(coreb.x(), coreb.y(), 10, (cx, cy) -> { Tile tile = world.ltile(cx, cy); if(tile != null && tile.getTeam() == state.rules.defaultTeam && !(tile.block() instanceof CoreBlock)){ tile.remove(); } }); - Geometry.circle(coreb.x, coreb.y, 5, (cx, cy) -> world.tile(cx, cy).clearOverlay()); + Geometry.circle(coreb.x(), coreb.y(), 5, (cx, cy) -> world.tile(cx, cy).clearOverlay()); world.endMapLoad(); diff --git a/core/src/mindustry/core/GameState.java b/core/src/mindustry/core/GameState.java index 2b233789eb..f546a933f1 100644 --- a/core/src/mindustry/core/GameState.java +++ b/core/src/mindustry/core/GameState.java @@ -1,9 +1,9 @@ package mindustry.core; import arc.*; -import mindustry.entities.type.*; import mindustry.game.EventType.*; import mindustry.game.*; +import mindustry.gen.*; import static mindustry.Vars.*; @@ -25,8 +25,8 @@ public class GameState{ /** Current game state. */ private State state = State.menu; - public BaseUnit boss(){ - return unitGroup.find(u -> u.isBoss() && u.getTeam() == rules.waveTeam); + public Unitc boss(){ + return Groups.unit.find(u -> u.isBoss() && u.team() == rules.waveTeam); } public void set(State astate){ diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 65f7084ff2..02cc46f814 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -6,7 +6,6 @@ import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.core.GameState.*; import mindustry.ctype.*; -import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.game.*; @@ -79,7 +78,7 @@ public class Logic implements ApplicationListener{ while(it.hasNext()){ BrokenBlock b = it.next(); Block block = content.block(b.block); - if(event.tile.block().bounds(event.tile.x, event.tile.y, Tmp.r1).overlaps(block.bounds(b.x, b.y, Tmp.r2))){ + if(event.tile.block().bounds(event.tile.x, event.tile.y, Tmp.r1).overlaps(block.bounds(b.x(), b.y(), Tmp.r2))){ it.remove(); } } @@ -206,7 +205,7 @@ public class Logic implements ApplicationListener{ if(!state.is(State.menu)){ if(!net.client()){ //TODO - //state.enemies = unitGroup.count(b -> b.getTeam() == state.rules.waveTeam && b.countsAsEnemy()); + //state.enemies = Groups.unit.count(b -> b.getTeam() == state.rules.waveTeam && b.countsAsEnemy()); } if(!state.isPaused()){ @@ -230,7 +229,7 @@ public class Logic implements ApplicationListener{ } if(!state.isEditor()){ - unitGroup.update(); + Groups.unit.update(); puddleGroup.update(); shieldGroup.update(); bulletGroup.update(); @@ -238,12 +237,12 @@ public class Logic implements ApplicationListener{ fireGroup.update(); weatherGroup.update(); }else{ - unitGroup.updateEvents(); - collisions.updatePhysics(unitGroup); + Groups.unit.updateEvents(); + collisions.updatePhysics(Groups.unit); } - playerGroup.update(); + Groups.player.update(); //effect group only contains item transfers in the headless version, update it! if(headless){ @@ -252,7 +251,7 @@ public class Logic implements ApplicationListener{ if(!state.isEditor()){ //bulletGroup - collisions.collideGroups(bulletGroup, unitGroup); + collisions.collideGroups(bulletGroup, Groups.unit); }*/ } diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index 5e3f257877..a6f281f0a8 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -13,7 +13,7 @@ import mindustry.annotations.Annotations.*; import mindustry.core.GameState.*; import mindustry.ctype.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.game.EventType.*; import mindustry.game.*; @@ -60,7 +60,7 @@ public class NetClient implements ApplicationListener{ net.handleClient(Connect.class, packet -> { Log.info("Connecting to server: {0}", packet.addressTCP); - player.isAdmin = false; + player.admin(false); reset(); @@ -75,11 +75,11 @@ public class NetClient implements ApplicationListener{ }); ConnectPacket c = new ConnectPacket(); - c.name = player.name; + c.name = player.name(); c.mods = mods.getModStrings(); c.mobile = mobile; c.versionType = Version.type; - c.color = Color.rgba8888(player.color); + c.color = Color.rgba8888(player.color()); c.usid = getUsid(packet.addressTCP); c.uuid = platform.getUUID(); @@ -133,14 +133,14 @@ public class NetClient implements ApplicationListener{ //called on all clients @Remote(targets = Loc.server, variants = Variant.both) - public static void sendMessage(String message, String sender, Player playersender){ + public static void sendMessage(String message, String sender, Playerc playersender){ if(Vars.ui != null){ Vars.ui.chatfrag.addMessage(message, sender); } if(playersender != null){ - playersender.lastText = message; - playersender.textFadeTime = 1f; + playersender.lastText(message); + playersender.textFadeTime(1f); } } @@ -154,7 +154,7 @@ public class NetClient implements ApplicationListener{ //called when a server recieves a chat message from a player @Remote(called = Loc.server, targets = Loc.client) - public static void sendChatMessage(Player player, String message){ + public static void sendChatMessage(Playerc player, String message){ if(message.length() > maxTextLength){ throw new ValidateException(player, "Player has sent a message above the text limit."); } @@ -172,18 +172,18 @@ public class NetClient implements ApplicationListener{ //special case; graphical server needs to see its message if(!headless){ - sendMessage(message, colorizeName(player.id, player.name), player); + sendMessage(message, colorizeName(player.id(), player.name()), player); } //server console logging - Log.info("&y{0}: &lb{1}", player.name, message); + Log.info("&y{0}: &lb{1}", player.name(), message); //invoke event for all clients but also locally //this is required so other clients get the correct name even if they don't know who's sending it yet - Call.sendMessage(message, colorizeName(player.id, player.name), player); + Call.sendMessage(message, colorizeName(player.id(), player.name()), player); }else{ //log command to console but with brackets - Log.info("<&y{0}: &lm{1}&lg>", player.name, message); + Log.info("<&y{0}: &lm{1}&lg>", player.name(), message); //a command was sent, now get the output if(response.type != ResponseType.valid){ @@ -204,9 +204,9 @@ public class NetClient implements ApplicationListener{ } public static String colorizeName(int id, String name){ - Player player = playerGroup.getByID(id); + Playerc player = Groups.player.getByID(id); if(name == null || player == null) return null; - return "[#" + player.color.toString().toUpperCase() + "]" + name; + return "[#" + player.color().toString().toUpperCase() + "]" + name; } @Remote(called = Loc.client, variants = Variant.one) @@ -219,8 +219,8 @@ public class NetClient implements ApplicationListener{ } @Remote(targets = Loc.client) - public static void onPing(Player player, long time){ - Call.onPingResponse(player.con, time); + public static void onPing(Playerc player, long time){ + Call.onPingResponse(player.con(), time); } @Remote(variants = Variant.one) @@ -229,7 +229,7 @@ public class NetClient implements ApplicationListener{ } @Remote(variants = Variant.one) - public static void onTraceInfo(Player player, TraceInfo info){ + public static void onTraceInfo(Playerc player, TraceInfo info){ if(player != null){ ui.traces.show(player, info); } @@ -265,9 +265,6 @@ public class NetClient implements ApplicationListener{ ui.showText("", message); } - //TODO these are commented out to enforce compatibility with 103! uncomment before 104 release - /* - @Remote(variants = Variant.both) public static void onInfoPopup(String message, float duration, int align, int top, int left, int bottom, int right){ ui.showInfoPopup(message, duration, align, top, left, bottom, right); @@ -278,14 +275,15 @@ public class NetClient implements ApplicationListener{ ui.showLabel(info, duration, worldx, worldy); } + /* @Remote(variants = Variant.both, unreliable = true) public static void onEffect(Effect effect, float x, float y, float rotation, Color color){ - effect.at(color, x, y, rotation); + effect.at(x, y, rotation, color); } @Remote(variants = Variant.both) public static void onEffectReliable(Effect effect, float x, float y, float rotation, Color color){ - effect.at(color, x, y, rotation); + effect.at(x, y, rotation, color); }*/ @Remote(variants = Variant.both) @@ -323,35 +321,33 @@ public class NetClient implements ApplicationListener{ @Remote public static void onPlayerDisconnect(int playerid){ - playerGroup.removeByID(playerid); + Groups.player.removeByID(playerid); } @Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true) - public static void onEntitySnapshot(byte groupID, short amount, short dataLen, byte[] data){ + public static void onEntitySnapshot(short amount, short dataLen, byte[] data){ try{ netClient.byteStream.setBytes(net.decompressSnapshot(data, dataLen)); DataInputStream input = netClient.dataStream; - EntityGroup group = entities.get(groupID); - //go through each entity for(int j = 0; j < amount; j++){ int id = input.readInt(); byte typeID = input.readByte(); - SyncTrait entity = group == null ? null : (SyncTrait)group.getByID(id); + Syncc entity = Groups.sync.getByID(id); boolean add = false, created = false; - if(entity == null && id == player.id){ + if(entity == null && id == player.id()){ entity = player; add = true; } //entity must not be added yet, so create it if(entity == null){ - entity = (SyncTrait)content.getByID(ContentType.typeid, typeID).constructor.get(); - entity.resetID(id); - if(!netClient.isEntityUsed(entity.getID())){ + entity = (Syncc)ClassMapping.map(typeID).get(); + entity.id(id); + if(!netClient.isEntityUsed(entity.id())){ add = true; } created = true; @@ -360,17 +356,14 @@ public class NetClient implements ApplicationListener{ //read the entity entity.read(input); - if(created && entity.getInterpolator() != null && entity.getInterpolator().target != null){ + if(created && entity.interpolator().target != null){ //set initial starting position - entity.setNet(entity.getInterpolator().target.x, entity.getInterpolator().target.y); - if(entity instanceof Unitc && entity.getInterpolator().targets.length > 0){ - ((Unitc)entity).rotation = entity.getInterpolator().targets[0]; - } + entity.setNet(entity.interpolator().target.x, entity.interpolator().target.y); } if(add){ entity.add(); - netClient.addRemovedEntity(entity.getID()); + netClient.addRemovedEntity(entity.id()); } } }catch(IOException e){ @@ -391,7 +384,7 @@ public class NetClient implements ApplicationListener{ Log.warn("Missing entity at {0}. Skipping block snapshot.", tile); break; } - tile.entity.read(input, tile.entity.version()); + tile.entity.read(input); } }catch(Exception e){ e.printStackTrace(); @@ -525,7 +518,7 @@ public class NetClient implements ApplicationListener{ Call.onClientShapshot(lastSent++, player.x, player.y, player.pointerX, player.pointerY, player.rotation, player.baseRotation, - player.velocity().x, player.velocity().y, + player.vel().x, player.vel().y, player.getMineTile(), player.isBoosting, player.isShooting, ui.chatfrag.shown(), player.isBuilding, requests, diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index ec4217bb1b..4535490800 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -12,7 +12,7 @@ import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.core.GameState.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.net.Administration; @@ -48,7 +48,7 @@ public class NetServer implements ApplicationListener{ //find team with minimum amount of players and auto-assign player to that. TeamData re = state.teams.getActive().min(data -> { int count = 0; - for(Player other : players){ + for(Playerc other : players){ if(other.team() == data.team && other != player){ count++; } @@ -120,7 +120,7 @@ public class NetServer implements ApplicationListener{ return; } - if(admins.getPlayerLimit() > 0 && playerGroup.size() >= admins.getPlayerLimit()){ + if(admins.getPlayerLimit() > 0 && Groups.player.size() >= admins.getPlayerLimit()){ con.kick(KickReason.playerLimit); return; } @@ -161,7 +161,7 @@ public class NetServer implements ApplicationListener{ boolean preventDuplicates = headless && netServer.admins.getStrict(); if(preventDuplicates){ - for(Player player : playerGroup.all()){ + for(Playerc player : Groups.player.all()){ if(player.name.trim().equalsIgnoreCase(packet.name.trim())){ con.kick(KickReason.nameInUse); return; @@ -194,7 +194,7 @@ public class NetServer implements ApplicationListener{ con.modclient = true; } - Player player = new Player(); + Playerc player = new Playerc(); player.isAdmin = admins.isAdmin(uuid, packet.usid); player.con = con; player.usid = packet.usid; @@ -218,7 +218,7 @@ public class NetServer implements ApplicationListener{ con.player = player; //playing in pvp mode automatically assigns players to teams - player.team(assignTeam(player, playerGroup.all())); + player.team(assignTeam(player, Groups.player.all())); sendWorldData(player); @@ -252,7 +252,7 @@ public class NetServer implements ApplicationListener{ } private void registerCommands(){ - clientCommands.register("help", "[page]", "Lists all commands.", (args, player) -> { + clientCommands.register("help", "[page]", "Lists all commands.", (args, player) -> { if(args.length > 0 && !Strings.canParseInt(args[0])){ player.sendMessage("[scarlet]'page' must be a number."); return; @@ -278,8 +278,8 @@ public class NetServer implements ApplicationListener{ player.sendMessage(result.toString()); }); - clientCommands.register("t", "", "Send a message only to your teammates.", (args, player) -> { - playerGroup.all().each(p -> p.getTeam() == player.team(), o -> o.sendMessage(args[0], player, "[#" + player.team().color.toString() + "]" + NetClient.colorizeName(player.id, player.name))); + clientCommands.register("t", "", "Send a message only to your teammates.", (args, player) -> { + Groups.player.all().each(p -> p.getTeam() == player.team(), o -> o.sendMessage(args[0], player, "[#" + player.team().color.toString() + "]" + NetClient.colorizeName(player.id, player.name()))); }); //duration of a a kick in seconds @@ -290,13 +290,13 @@ public class NetServer implements ApplicationListener{ int voteCooldown = 60 * 1; class VoteSession{ - Player target; + Playerc target; ObjectSet voted = new ObjectSet<>(); VoteSession[] map; Timer.Task task; int votes; - public VoteSession(VoteSession[] map, Player target){ + public VoteSession(VoteSession[] map, Playerc target){ this.target = target; this.map = map; this.task = Timer.schedule(() -> { @@ -308,19 +308,19 @@ public class NetServer implements ApplicationListener{ }, voteDuration); } - void vote(Player player, int d){ + void vote(Playerc player, int d){ votes += d; voted.addAll(player.uuid, admins.getInfo(player.uuid).lastIP); Call.sendMessage(Strings.format("[orange]{0}[lightgray] has voted to kick[orange] {1}[].[accent] ({2}/{3})\n[lightgray]Type[orange] /vote [] to agree.", - player.name, target.name, votes, votesRequired())); + player.name(), target.name, votes, votesRequired())); } boolean checkPass(){ if(votes >= votesRequired()){ Call.sendMessage(Strings.format("[orange]Vote passed.[scarlet] {0}[orange] will be banned from the server for {1} minutes.", target.name, (kickDuration/60))); target.getInfo().lastKicked = Time.millis() + kickDuration*1000; - playerGroup.all().each(p -> p.uuid != null && p.uuid.equals(target.uuid), p -> p.con.kick(KickReason.vote)); + Groups.player.all().each(p -> p.uuid != null && p.uuid.equals(target.uuid), p -> p.con.kick(KickReason.vote)); map[0] = null; task.cancel(); return true; @@ -333,18 +333,18 @@ public class NetServer implements ApplicationListener{ //current kick sessions VoteSession[] currentlyKicking = {null}; - clientCommands.register("votekick", "[player...]", "Vote to kick a player, with a cooldown.", (args, player) -> { + clientCommands.register("votekick", "[player...]", "Vote to kick a player, with a cooldown.", (args, player) -> { if(!Config.enableVotekick.bool()){ player.sendMessage("[scarlet]Vote-kick is disabled on this server."); return; } - if(playerGroup.size() < 3){ + if(Groups.player.size() < 3){ player.sendMessage("[scarlet]At least 3 players are needed to start a votekick."); return; } - if(player.isLocal){ + if(player.isLocal()){ player.sendMessage("[scarlet]Just kick them yourself if you're the host."); return; } @@ -352,19 +352,19 @@ public class NetServer implements ApplicationListener{ if(args.length == 0){ StringBuilder builder = new StringBuilder(); builder.append("[orange]Players to kick: \n"); - for(Player p : playerGroup.all()){ + for(Playerc p : Groups.player.all()){ if(p.isAdmin || p.con == null || p == player) continue; builder.append("[lightgray] ").append(p.name).append("[accent] (#").append(p.id).append(")\n"); } player.sendMessage(builder.toString()); }else{ - Player found; + Playerc found; if(args[0].length() > 1 && args[0].startsWith("#") && Strings.canParseInt(args[0].substring(1))){ int id = Strings.parseInt(args[0].substring(1)); - found = playerGroup.find(p -> p.id == id); + found = Groups.player.find(p -> p.id == id); }else{ - found = playerGroup.find(p -> p.name.equalsIgnoreCase(args[0])); + found = Groups.player.find(p -> p.name.equalsIgnoreCase(args[0])); } if(found != null){ @@ -391,11 +391,11 @@ public class NetServer implements ApplicationListener{ } }); - clientCommands.register("vote", "", "Vote to kick the current player.", (arg, player) -> { + clientCommands.register("vote", "", "Vote to kick the current player.", (arg, player) -> { if(currentlyKicking[0] == null){ player.sendMessage("[scarlet]Nobody is being voted on."); }else{ - if(player.isLocal){ + if(player.isLocal()){ player.sendMessage("Local players can't vote. Kick the player yourself instead."); return; } @@ -422,8 +422,8 @@ public class NetServer implements ApplicationListener{ }); - clientCommands.register("sync", "Re-synchronize world state.", (args, player) -> { - if(player.isLocal){ + clientCommands.register("sync", "Re-synchronize world state.", (args, player) -> { + if(player.isLocal()){ player.sendMessage("[scarlet]Re-synchronizing as the host is pointless."); }else{ if(Time.timeSinceMillis(player.getInfo().lastSyncTime) < 1000 * 5){ @@ -439,14 +439,14 @@ public class NetServer implements ApplicationListener{ } public int votesRequired(){ - return 2 + (playerGroup.size() > 4 ? 1 : 0); + return 2 + (Groups.player.size() > 4 ? 1 : 0); } - public Team assignTeam(Player current, Iterable players){ + public Team assignTeam(Playerc current, Iterable players){ return assigner.assign(current, players); } - public void sendWorldData(Player player){ + public void sendWorldData(Playerc player){ ByteArrayOutputStream stream = new ByteArrayOutputStream(); DeflaterOutputStream def = new FastDeflaterOutputStream(stream); NetworkIO.writeWorld(player, def); @@ -457,7 +457,7 @@ public class NetServer implements ApplicationListener{ Log.debug("Packed {0} compressed bytes of world data.", stream.size()); } - public static void onDisconnect(Player player, String reason){ + public static void onDisconnect(Playerc player, String reason){ //singleplayer multiplayer wierdness if(player.con == null){ player.remove(); @@ -471,7 +471,7 @@ public class NetServer implements ApplicationListener{ Call.onPlayerDisconnect(player.id); } - if(Config.showConnectMessages.bool()) Log.info("&lm[{1}] &lc{0} has disconnected. &lg&fi({2})", player.name, player.uuid, reason); + if(Config.showConnectMessages.bool()) Log.info("&lm[{1}] &lc{0} has disconnected. &lg&fi({2})", player.name(), player.uuid, reason); } player.remove(); @@ -480,7 +480,7 @@ public class NetServer implements ApplicationListener{ @Remote(targets = Loc.client, unreliable = true) public static void onClientShapshot( - Player player, + Playerc player, int snapshotID, float x, float y, float pointerX, float pointerY, @@ -508,8 +508,8 @@ public class NetServer implements ApplicationListener{ float maxSpeed = boosting && !player.mech.flying ? player.mech.compoundSpeedBoost : player.mech.compoundSpeed; float maxMove = elapsed / 1000f * 60f * Math.min(maxSpeed, player.mech.maxSpeed) * 1.2f; - player.pointerX = pointerX; - player.pointerY = pointerY; + player.mouseX(pointerX); + player.mouseY(pointerY); player.setMineTile(mining); player.isTyping = chatting; player.isBoosting = boosting; @@ -571,23 +571,23 @@ public class NetServer implements ApplicationListener{ //set interpolator target to *new* position so it moves toward it player.getInterpolator().read(player.x, player.y, newx, newy, rotation, baseRotation); - player.velocity().set(xVelocity, yVelocity); //only for visual calculation purposes, doesn't actually update the player + player.vel().set(xVelocity, yVelocity); //only for visual calculation purposes, doesn't actually update the player connection.lastRecievedClientSnapshot = snapshotID; connection.lastRecievedClientTime = Time.millis(); } @Remote(targets = Loc.client, called = Loc.server) - public static void onAdminRequest(Player player, Player other, AdminAction action){ + public static void onAdminRequest(Playerc player, Playerc other, AdminAction action){ - if(!player.isAdmin){ + if(!player.admin()){ Log.warn("ACCESS DENIED: Player {0} / {1} attempted to perform admin action without proper security access.", - player.name, player.con.address); + player.name(), player.con().address); return; } - if(other == null || ((other.isAdmin && !player.isLocal) && other != player)){ - Log.warn("{0} attempted to perform admin action on nonexistant or admin player.", player.name); + if(other == null || ((other.admin() && !player.isLocal()) && other != player)){ + Log.warn("{0} attempted to perform admin action on nonexistant or admin player.", player.name()); return; } @@ -596,32 +596,32 @@ public class NetServer implements ApplicationListener{ //not a real issue, because server owners may want to do just that state.wavetime = 0f; }else if(action == AdminAction.ban){ - netServer.admins.banPlayerIP(other.con.address); - other.con.kick(KickReason.banned); - Log.info("&lc{0} has banned {1}.", player.name, other.name); + netServer.admins.banPlayerIP(other.con().address); + other.kick(KickReason.banned); + Log.info("&lc{0} has banned {1}.", player.name(), other.name()); }else if(action == AdminAction.kick){ - other.con.kick(KickReason.kick); - Log.info("&lc{0} has kicked {1}.", player.name, other.name); + other.kick(KickReason.kick); + Log.info("&lc{0} has kicked {1}.", player.name(), other.name()); }else if(action == AdminAction.trace){ - TraceInfo info = new TraceInfo(other.con.address, other.uuid, other.con.modclient, other.con.mobile); - if(player.con != null){ - Call.onTraceInfo(player.con, other, info); + TraceInfo info = new TraceInfo(other.con().address, other.uuid(), other.con().modclient, other.con.mobile); + if(player.con() != null){ + Call.onTraceInfo(player.con(), other, info); }else{ NetClient.onTraceInfo(other, info); } - Log.info("&lc{0} has requested trace info of {1}.", player.name, other.name); + Log.info("&lc{0} has requested trace info of {1}.", player.name(), other.name()); } } @Remote(targets = Loc.client) - public static void connectConfirm(Player player){ - if(player.con == null || player.con.hasConnected) return; + public static void connectConfirm(Playerc player){ + if(player.con() == null || player.con().hasConnected) return; player.add(); - player.con.hasConnected = true; + player.con().hasConnected = true; if(Config.showConnectMessages.bool()){ - Call.sendMessage("[accent]" + player.name + "[accent] has connected."); - Log.info("&lm[{1}] &y{0} has connected. ", player.name, player.uuid); + Call.sendMessage("[accent]" + player.name() + "[accent] has connected."); + Log.info("&lm[{1}] &y{0} has connected. ", player.name(), player.uuid()); } if(!Config.motd.string().equalsIgnoreCase("off")){ @@ -635,7 +635,7 @@ public class NetServer implements ApplicationListener{ if(state.rules.pvp){ int used = 0; for(TeamData t : state.teams.getActive()){ - if(playerGroup.count(p -> p.getTeam() == t.team) > 0){ + if(Groups.player.count(p -> p.getTeam() == t.team) > 0){ used++; } } @@ -710,14 +710,14 @@ public class NetServer implements ApplicationListener{ } } - public void writeEntitySnapshot(Player player) throws IOException{ + public void writeEntitySnapshot(Playerc player) throws IOException{ syncStream.reset(); Array cores = state.teams.cores(player.team()); dataStream.writeByte(cores.size); for(CoreEntity entity : cores){ - dataStream.writeInt(entity.tile.pos()); + dataStream.writeInt(entity.tile().pos()); entity.items().write(dataStream); } @@ -730,44 +730,42 @@ public class NetServer implements ApplicationListener{ viewport.setSize(player.con.viewWidth, player.con.viewHeight).setCenter(player.con.viewX, player.con.viewY); //check for syncable groups - for(EntityGroup group : entities.all()){ - if(group.isEmpty() || !(group.all().get(0) instanceof SyncTrait)) continue; - //make sure mapping is enabled for this group - if(!group.mappingEnabled()){ - throw new RuntimeException("Entity group '" + group.getType() + "' contains SyncTrait entities, yet mapping is not enabled. In order for syncing to work, you must enable mapping for this group."); - } + //make sure mapping is enabled for this group + if(!group.mappingEnabled()){ + throw new RuntimeException("Entity group '" + group.getType() + "' contains SyncTrait entities, yet mapping is not enabled. In order for syncing to work, you must enable mapping for this group."); + } - syncStream.reset(); + syncStream.reset(); - int sent = 0; + int sent = 0; - for(Entity entity : group.all()){ - SyncTrait sync = (SyncTrait)entity; + for(Entity entity : group.all()){ + SyncTrait sync = (SyncTrait)entity; - //write all entities now - dataStream.writeInt(entity.getID()); //write id - dataStream.writeByte(sync.getTypeID().id); //write type ID - sync.write(dataStream); //write entity + //write all entities now + dataStream.writeInt(entity.getID()); //write id + dataStream.writeByte(sync.getTypeID().id); //write type ID + sync.write(dataStream); //write entity - sent++; + sent++; - if(syncStream.size() > maxSnapshotSize){ - dataStream.close(); - byte[] syncBytes = syncStream.toByteArray(); - Call.onEntitySnapshot(player.con, (byte)group.getID(), (short)sent, (short)syncBytes.length, net.compressSnapshot(syncBytes)); - sent = 0; - syncStream.reset(); - } - } - - if(sent > 0){ + if(syncStream.size() > maxSnapshotSize){ dataStream.close(); - byte[] syncBytes = syncStream.toByteArray(); Call.onEntitySnapshot(player.con, (byte)group.getID(), (short)sent, (short)syncBytes.length, net.compressSnapshot(syncBytes)); + sent = 0; + syncStream.reset(); } } + + if(sent > 0){ + dataStream.close(); + + byte[] syncBytes = syncStream.toByteArray(); + Call.onEntitySnapshot(player.con, (byte)group.getID(), (short)sent, (short)syncBytes.length, net.compressSnapshot(syncBytes)); + } + } String fixName(String name){ @@ -824,9 +822,9 @@ public class NetServer implements ApplicationListener{ try{ //iterate through each player - for(int i = 0; i < playerGroup.size(); i++){ - Player player = playerGroup.all().get(i); - if(player.isLocal) continue; + for(int i = 0; i < Groups.player.size(); i++){ + Playerc player = Groups.player.all().get(i); + if(player.isLocal()) continue; if(player.con == null || !player.con.isConnected()){ onDisconnect(player, "disappeared"); @@ -835,12 +833,12 @@ public class NetServer implements ApplicationListener{ NetConnection connection = player.con; - if(!player.timer.get(Player.timerSync, serverSyncTime) || !connection.hasConnected) continue; + if(!player.timer.get(Playerc.timerSync, serverSyncTime) || !connection.hasConnected) continue; writeEntitySnapshot(player); } - if(playerGroup.size() > 0 && Core.settings.getBool("blocksync") && timer.get(timerBlockSync, blockSyncTime)){ + if(Groups.player.size() > 0 && Core.settings.getBool("blocksync") && timer.get(timerBlockSync, blockSyncTime)){ writeBlockSnapshots(); } @@ -850,6 +848,6 @@ public class NetServer implements ApplicationListener{ } public interface TeamAssigner{ - Team assign(Player player, Iterable players); + Team assign(Playerc player, Iterable players); } } diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index aefd832988..ab98ad05c9 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -12,7 +12,7 @@ import arc.scene.ui.layout.*; import arc.util.*; import mindustry.content.*; import mindustry.core.GameState.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.gen.*; import mindustry.graphics.*; @@ -242,7 +242,7 @@ public class Renderer implements ApplicationListener{ } overlays.drawBottom(); - playerGroup.draw(p -> p.isLocal, Player::drawBuildRequests); + Groups.player.draw(p -> p.isLocal, Playerc::drawBuildRequests); if(shieldGroup.countInBounds() > 0){ if(settings.getBool("animatedshields") && Shaders.shield != null){ @@ -265,7 +265,7 @@ public class Renderer implements ApplicationListener{ overlays.drawTop(); - playerGroup.draw(p -> !p.isDead(), Player::drawName); + Groups.player.draw(p -> !p.isDead(), Playerc::drawName); if(state.rules.lighting){ lights.draw(); @@ -311,10 +311,10 @@ public class Renderer implements ApplicationListener{ Draw.rect("circle-shadow", u.x, u.y, size * rad, size * rad); }; - unitGroup.draw(unit -> !unit.isDead(), draw::get); + Groups.unit.draw(unit -> !unit.isDead(), draw::get); - if(!playerGroup.isEmpty()){ - playerGroup.draw(unit -> !unit.isDead(), draw::get); + if(!Groups.player.isEmpty()){ + Groups.player.draw(unit -> !unit.isDead(), draw::get); } Draw.color(); @@ -324,21 +324,21 @@ public class Renderer implements ApplicationListener{ float trnsX = -12, trnsY = -13; Draw.color(0, 0, 0, 0.22f); - unitGroup.draw(unit -> unit.isFlying() && !unit.isDead(), baseUnit -> baseUnit.drawShadow(trnsX, trnsY)); - playerGroup.draw(unit -> unit.isFlying() && !unit.isDead(), player -> player.drawShadow(trnsX, trnsY)); + Groups.unit.draw(unit -> unit.isFlying() && !unit.isDead(), baseUnit -> baseUnit.drawShadow(trnsX, trnsY)); + Groups.player.draw(unit -> unit.isFlying() && !unit.isDead(), player -> player.drawShadow(trnsX, trnsY)); Draw.color(); } private void drawAllTeams(boolean flying){ - unitGroup.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawUnder); - playerGroup.draw(p -> p.isFlying() == flying && !p.isDead(), Unitc::drawUnder); + Groups.unit.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawUnder); + Groups.player.draw(p -> p.isFlying() == flying && !p.isDead(), Unitc::drawUnder); - unitGroup.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawAll); - playerGroup.draw(p -> p.isFlying() == flying, Unitc::drawAll); + Groups.unit.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawAll); + Groups.player.draw(p -> p.isFlying() == flying, Unitc::drawAll); - unitGroup.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawOver); - playerGroup.draw(p -> p.isFlying() == flying, Unitc::drawOver); + Groups.unit.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawOver); + Groups.player.draw(p -> p.isFlying() == flying, Unitc::drawOver); } public void scaleCamera(float amount){ diff --git a/core/src/mindustry/ctype/ContentType.java b/core/src/mindustry/ctype/ContentType.java index 31061e256b..de80c859bd 100644 --- a/core/src/mindustry/ctype/ContentType.java +++ b/core/src/mindustry/ctype/ContentType.java @@ -10,10 +10,10 @@ public enum ContentType{ status, unit, weather, - effect, + effect_UNUSED, zone, - loadout, - typeid, + loadout_UNUSED, + typeid_UNUSED, error, planet; diff --git a/core/src/mindustry/editor/MapEditorDialog.java b/core/src/mindustry/editor/MapEditorDialog.java index fd50dc57f4..e64b3a8857 100644 --- a/core/src/mindustry/editor/MapEditorDialog.java +++ b/core/src/mindustry/editor/MapEditorDialog.java @@ -176,7 +176,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ } platform.publish(map); - }).padTop(-3).size(swidth * 2f + 10, 60f).update(b -> b.setText(editor.getTags().containsKey("steamid") ? editor.getTags().get("author").equals(player.name) ? "$workshop.listing" : "$view.workshop" : "$editor.publish.workshop")); + }).padTop(-3).size(swidth * 2f + 10, 60f).update(b -> b.setText(editor.getTags().containsKey("steamid") ? editor.getTags().get("author").equals(player.name()) ? "$workshop.listing" : "$view.workshop" : "$editor.publish.workshop")); menu.cont.row(); } diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index 78a5859cf5..a54d6db301 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -73,7 +73,7 @@ public class Damage{ } } - public static void collideLine(Bullet hitter, Team team, Effect effect, float x, float y, float angle, float length){ + public static void collideLine(Bulletc hitter, Team team, Effect effect, float x, float y, float angle, float length){ collideLine(hitter, team, effect, x, y, angle, length, false); } @@ -81,7 +81,7 @@ public class Damage{ * Damages entities in a line. * Only enemies of the specified team are damaged. */ - public static void collideLine(Bullet hitter, Team team, Effect effect, float x, float y, float angle, float length, boolean large){ + public static void collideLine(Bulletc hitter, Team team, Effect effect, float x, float y, float angle, float length, boolean large){ collidedBlocks.clear(); tr.trns(angle, length); Intc2 collider = (cx, cy) -> { @@ -89,7 +89,7 @@ public class Damage{ if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.entity != null && tile.getTeamID() != team.id && tile.entity.collide(hitter)){ tile.entity.collision(hitter); collidedBlocks.add(tile.pos()); - hitter.getBulletType().hit(hitter, tile.worldx(), tile.worldy()); + hitter.type().hit(hitter, tile.worldx(), tile.worldy()); } }; @@ -184,7 +184,7 @@ public class Damage{ entity.damage(amount); //TODO better velocity displacement float dst = tr.set(entity.getX() - x, entity.getY() - y).len(); - entity.velocity().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 == player){ Events.fire(Trigger.exclusionDeath); @@ -235,8 +235,8 @@ public class Damage{ //apply damage to entity if needed if(tile.entity != null && tile.getTeam() != team){ - int health = (int)tile.entity.health; - if(tile.entity.health > 0){ + int health = (int)tile.entity.health(); + if(tile.entity.health() > 0){ tile.entity.damage(scaledDamage); scaledDamage -= health; diff --git a/core/src/mindustry/entities/Effect.java b/core/src/mindustry/entities/Effect.java index a09e0c81ca..971e9804de 100644 --- a/core/src/mindustry/entities/Effect.java +++ b/core/src/mindustry/entities/Effect.java @@ -16,6 +16,9 @@ public class Effect{ /** Clip size. */ public float size; + public boolean ground; + public float groundDuration; + public Effect(float life, float clipsize, Cons renderer){ this.id = lastid++; this.lifetime = life; @@ -27,6 +30,17 @@ public class Effect{ this(life, 28f, renderer); } + public Effect ground(){ + ground = true; + return this; + } + + public Effect ground(float duration){ + ground = true; + this.groundDuration = duration; + return this; + } + public void at(Position pos){ Effects.createEffect(this, pos.getX(), pos.getY(), 0, Color.white, null); } diff --git a/core/src/mindustry/entities/Effects.java b/core/src/mindustry/entities/Effects.java index 08b9a4d445..02c41452a6 100644 --- a/core/src/mindustry/entities/Effects.java +++ b/core/src/mindustry/entities/Effects.java @@ -5,9 +5,7 @@ import arc.graphics.*; import arc.math.*; import arc.math.geom.*; import arc.util.*; -import arc.util.pooling.*; import mindustry.content.*; -import mindustry.entities.type.*; import static mindustry.Vars.*; @@ -40,13 +38,14 @@ public class Effects{ Rect pos = Tmp.r2.setSize(effect.size).setCenter(x, y); if(view.overlaps(pos)){ - EffectEntity entity = Pools.obtain(EffectEntity.class, EffectEntity::new); - entity.effect = effect; - entity.color.set(color); - entity.rotation = rotation; - entity.data = data; - entity.id++; - entity.set(x, y); + //TODO implement create() method here. + //EffectEntity entity = Pools.obtain(EffectEntity.class, EffectEntity::new); + //entity.effect = effect; + //entity.color.set(color); + //entity.rotation = rotation; + //entity.data = data; + //entity.id++; + //entity.set(x, y); //if(data instanceof Entity){ // entity.setParent((Entity)data); //} diff --git a/core/src/mindustry/entities/Units.java b/core/src/mindustry/entities/Units.java index 98f068a87e..53dbd60696 100644 --- a/core/src/mindustry/entities/Units.java +++ b/core/src/mindustry/entities/Units.java @@ -3,7 +3,7 @@ package mindustry.entities; import arc.func.*; import arc.math.*; import arc.math.geom.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.world.*; @@ -18,7 +18,7 @@ public class Units{ private static boolean boolResult; /** @return whether this player can interact with a specific tile. if either of these are null, returns true.*/ - public static boolean canInteract(Player player, Tile tile){ + public static boolean canInteract(Playerc player, Tile tile){ return player == null || tile == null || tile.interactable(player.team()); } @@ -148,7 +148,7 @@ public class Units{ /** Iterates over all units in a rectangle. */ public static void nearby(Team team, float x, float y, float width, float height, Cons cons){ - unitGroup.intersect(x, y, width, height, u -> { + Groups.unit.intersect(x, y, width, height, u -> { if(u.getTeam() == team){ cons.get(u); } @@ -157,7 +157,7 @@ public class Units{ /** Iterates over all units in a circle around this position. */ public static void nearby(Team team, float x, float y, float radius, Cons cons){ - unitGroup.intersect(x - radius, y - radius, radius*2f, radius*2f, unit -> { + Groups.unit.intersect(x - radius, y - radius, radius*2f, radius*2f, unit -> { if(unit.getTeam() == team && unit.withinDst(x, y, radius)){ cons.get(unit); } @@ -166,7 +166,7 @@ public class Units{ /** Iterates over all units in a rectangle. */ public static void nearby(float x, float y, float width, float height, Cons cons){ - unitGroup.intersect(x, y, width, height, cons); + Groups.unit.intersect(x, y, width, height, cons); } /** Iterates over all units in a rectangle. */ @@ -176,7 +176,7 @@ public class Units{ /** 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 cons){ - unitGroup.intersect(x, y, width, height, u -> { + Groups.unit.intersect(x, y, width, height, u -> { if(team.isEnemy(u.getTeam())){ cons.get(u); } @@ -190,11 +190,11 @@ public class Units{ /** Iterates over all units. */ public static void all(Cons cons){ - unitGroup.all().each(cons); + Groups.unit.all().each(cons); } - public static void each(Team team, Cons cons){ - unitGroup.all().each(t -> t.getTeam() == team, cons); + public static void each(Team team, Cons cons){ + Groups.unit.all().each(t -> t.getTeam() == team, cons); } } diff --git a/core/src/mindustry/entities/bullet/ArtilleryBulletType.java b/core/src/mindustry/entities/bullet/ArtilleryBulletType.java index 18888ad538..de97b5395d 100644 --- a/core/src/mindustry/entities/bullet/ArtilleryBulletType.java +++ b/core/src/mindustry/entities/bullet/ArtilleryBulletType.java @@ -27,7 +27,7 @@ public class ArtilleryBulletType extends BasicBulletType{ super.update(b); if(b.timer.get(0, 3 + b.fslope() * 2f)){ - trailEffect.at(b.x, b.y, b.fslope() * 4f, backColor); + trailEffect.at(b.x(), b.y(), b.fslope() * 4f, backColor); } } @@ -39,9 +39,9 @@ public class ArtilleryBulletType extends BasicBulletType{ float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout()); Draw.color(backColor); - Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale, b.rot() - 90); + Draw.rect(backRegion, b.x(), b.y(), bulletWidth * scale, height * scale, b.rotation() - 90); Draw.color(frontColor); - Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale, b.rot() - 90); + Draw.rect(frontRegion, b.x(), b.y(), bulletWidth * scale, height * scale, b.rotation() - 90); Draw.color(); } } diff --git a/core/src/mindustry/entities/bullet/BasicBulletType.java b/core/src/mindustry/entities/bullet/BasicBulletType.java index 6a71cd9538..f4edaf3924 100644 --- a/core/src/mindustry/entities/bullet/BasicBulletType.java +++ b/core/src/mindustry/entities/bullet/BasicBulletType.java @@ -38,9 +38,9 @@ public class BasicBulletType extends BulletType{ float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout()); Draw.color(backColor); - Draw.rect(backRegion, b.x, b.y, bulletWidth, height, b.rot() - 90); + Draw.rect(backRegion, b.x(), b.y(), bulletWidth, height, b.rotation() - 90); Draw.color(frontColor); - Draw.rect(frontRegion, b.x, b.y, bulletWidth, height, b.rot() - 90); + Draw.rect(frontRegion, b.x(), b.y(), bulletWidth, height, b.rotation() - 90); Draw.color(); } } diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 2a363ce18c..e048052d8d 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -210,7 +210,7 @@ public abstract class BulletType extends Content{ bullet.velocity.set(0, type.speed).setAngle(angle).scl(velocityScl); if(type.keepVelocity){ - bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait)owner).velocity() : Vec2.ZERO); + bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait)owner).vel() : Vec2.ZERO); } bullet.team = team; diff --git a/core/src/mindustry/entities/bullet/FlakBulletType.java b/core/src/mindustry/entities/bullet/FlakBulletType.java index 8b7217f7f8..f12a85e4ed 100644 --- a/core/src/mindustry/entities/bullet/FlakBulletType.java +++ b/core/src/mindustry/entities/bullet/FlakBulletType.java @@ -29,7 +29,7 @@ public class FlakBulletType extends BasicBulletType{ if(b.getData() instanceof Integer) return; if(b.timer.get(2, 6)){ - Units.nearbyEnemies(b.team(), rect.setSize(explodeRange * 2f).setCenter(b.x, b.y), unit -> { + Units.nearbyEnemies(b.team(), rect.setSize(explodeRange * 2f).setCenter(b.x(), b.y()), unit -> { if(b.getData() instanceof Float) return; if(unit.dst(b) < explodeRange){ diff --git a/core/src/mindustry/entities/bullet/HealBulletType.java b/core/src/mindustry/entities/bullet/HealBulletType.java index 71a3febf63..53004b8ec5 100644 --- a/core/src/mindustry/entities/bullet/HealBulletType.java +++ b/core/src/mindustry/entities/bullet/HealBulletType.java @@ -36,9 +36,9 @@ public class HealBulletType extends BulletType{ public void draw(Bulletc b){ Draw.color(backColor); Lines.stroke(bulletWidth); - Lines.lineAngleCenter(b.x, b.y, b.rot(), bulletHeight); + Lines.lineAngleCenter(b.x(), b.y(), b.rotation(), bulletHeight); Draw.color(frontColor); - Lines.lineAngleCenter(b.x, b.y, b.rot(), bulletHeight / 2f); + Lines.lineAngleCenter(b.x(), b.y(), b.rotation(), bulletHeight / 2f); Draw.reset(); } diff --git a/core/src/mindustry/entities/bullet/LaserBulletType.java b/core/src/mindustry/entities/bullet/LaserBulletType.java index 31058d0481..c556e0aca1 100644 --- a/core/src/mindustry/entities/bullet/LaserBulletType.java +++ b/core/src/mindustry/entities/bullet/LaserBulletType.java @@ -41,7 +41,7 @@ public class LaserBulletType extends BulletType{ @Override public void init(Bulletc b){ - Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rot(), length); + Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), length); } @Override @@ -51,18 +51,18 @@ public class LaserBulletType extends BulletType{ float cwidth = width; float compound = 1f; - Lines.lineAngle(b.x, b.y, b.rot(), baseLen); + Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen); Lines.precise(true); for(Color color : colors){ Draw.color(color); Lines.stroke((cwidth *= lengthFalloff) * b.fout()); - Lines.lineAngle(b.x, b.y, b.rot(), baseLen, CapStyle.none); - Tmp.v1.trns(b.rot(), baseLen); - Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, Lines.getStroke() * 1.22f, cwidth * 2f + width / 2f, b.rot()); + Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen, CapStyle.none); + Tmp.v1.trns(b.rotation(), baseLen); + Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, Lines.getStroke() * 1.22f, cwidth * 2f + width / 2f, b.rotation()); - Fill.circle(b.x, b.y, 1f * cwidth * b.fout()); + Fill.circle(b.x(), b.y(), 1f * cwidth * b.fout()); for(int i : Mathf.signs){ - Drawf.tri(b.x, b.y, sideWidth * b.fout() * cwidth, sideLength * compound, b.rot() + sideAngle * i); + Drawf.tri(b.x(), b.y(), sideWidth * b.fout() * cwidth, sideLength * compound, b.rotation() + sideAngle * i); } compound *= lengthFalloff; diff --git a/core/src/mindustry/entities/bullet/LightningBulletType.java b/core/src/mindustry/entities/bullet/LightningBulletType.java index dcf34101a4..91504d76b4 100644 --- a/core/src/mindustry/entities/bullet/LightningBulletType.java +++ b/core/src/mindustry/entities/bullet/LightningBulletType.java @@ -25,6 +25,6 @@ public class LightningBulletType extends BulletType{ @Override public void init(Bulletc b){ - Lightning.create(b.team(), lightningColor, damage, b.x, b.y, b.rot(), lightningLength); + Lightning.create(b.team(), lightningColor, damage, b.x(), b.y(), b.rotation(), lightningLength); } } diff --git a/core/src/mindustry/entities/bullet/LiquidBulletType.java b/core/src/mindustry/entities/bullet/LiquidBulletType.java index d73d0d90ad..cb7ac09bc3 100644 --- a/core/src/mindustry/entities/bullet/LiquidBulletType.java +++ b/core/src/mindustry/entities/bullet/LiquidBulletType.java @@ -48,7 +48,7 @@ public class LiquidBulletType extends BulletType{ super.update(b); if(liquid.canExtinguish()){ - Tile tile = world.tileWorld(b.x, b.y); + Tile tile = world.tileWorld(b.x(), b.y()); if(tile != null && Fire.has(tile.x, tile.y)){ Fire.extinguish(tile, 100f); b.remove(); @@ -61,7 +61,7 @@ public class LiquidBulletType extends BulletType{ public void draw(Bulletc b){ Draw.color(liquid.color, Color.white, b.fout() / 100f); - Fill.circle(b.x, b.y, 0.5f + b.fout() * 2.5f); + Fill.circle(b.x(), b.y(), 0.5f + b.fout() * 2.5f); } @Override diff --git a/core/src/mindustry/entities/bullet/MassDriverBolt.java b/core/src/mindustry/entities/bullet/MassDriverBolt.java index 3316c86bb1..8f41524c62 100644 --- a/core/src/mindustry/entities/bullet/MassDriverBolt.java +++ b/core/src/mindustry/entities/bullet/MassDriverBolt.java @@ -27,10 +27,10 @@ public class MassDriverBolt extends BulletType{ float w = 11f, h = 13f; Draw.color(Pal.bulletYellowBack); - Draw.rect("shell-back", b.x, b.y, w, h, b.rot() + 90); + Draw.rect("shell-back", b.x(), b.y(), w, h, b.rotation() + 90); Draw.color(Pal.bulletYellow); - Draw.rect("shell", b.x, b.y, w, h, b.rot() + 90); + Draw.rect("shell", b.x(), b.y(), w, h, b.rotation() + 90); Draw.reset(); } @@ -92,8 +92,8 @@ public class MassDriverBolt extends BulletType{ for(int i = 0; i < data.items.length; i++){ int amountDropped = Mathf.random(0, data.items[i]); if(amountDropped > 0){ - float angle = b.rot() + Mathf.range(100f); - Fx.dropItem.at(b.x, b.y, angle, Color.white, content.item(i)); + float angle = b.rotation() + Mathf.range(100f); + Fx.dropItem.at(b.x(), b.y(), angle, Color.white, content.item(i)); } } } diff --git a/core/src/mindustry/entities/bullet/MissileBulletType.java b/core/src/mindustry/entities/bullet/MissileBulletType.java index 81a35982b3..1e3699dd13 100644 --- a/core/src/mindustry/entities/bullet/MissileBulletType.java +++ b/core/src/mindustry/entities/bullet/MissileBulletType.java @@ -30,11 +30,11 @@ public class MissileBulletType extends BasicBulletType{ super.update(b); if(Mathf.chance(Time.delta() * 0.2)){ - Fx.missileTrail.at(b.x, b.y, 2f, trailColor); + Fx.missileTrail.at(b.x(), b.y(), 2f, trailColor); } if(weaveMag > 0){ - b.velocity().rotate(Mathf.sin(Time.time() + b.id * 4422, weaveScale, weaveMag) * Time.delta()); + b.vel().rotate(Mathf.sin(Time.time() + b.id * 4422, weaveScale, weaveMag) * Time.delta()); } } } diff --git a/core/src/mindustry/entities/def/EntityComps.java b/core/src/mindustry/entities/def/EntityComps.java index ba7d3d8182..2222deb0c0 100644 --- a/core/src/mindustry/entities/def/EntityComps.java +++ b/core/src/mindustry/entities/def/EntityComps.java @@ -16,6 +16,7 @@ import arc.util.pooling.*; import mindustry.*; import mindustry.annotations.Annotations.*; import mindustry.content.*; +import mindustry.core.*; import mindustry.ctype.*; import mindustry.entities.*; import mindustry.entities.bullet.*; @@ -25,7 +26,9 @@ import mindustry.game.EventType.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; +import mindustry.net.Administration.*; import mindustry.net.*; +import mindustry.net.Packets.*; import mindustry.type.*; import mindustry.ui.*; import mindustry.world.*; @@ -179,6 +182,11 @@ public class EntityComps{ Object data; BulletType type; + Interval timer = new Interval(6); + + public boolean timer(int index, float time){ + return timer.get(index, time); + } @Override public float getDamage(){ @@ -662,6 +670,136 @@ public class EntityComps{ } } + @Component + abstract class PlayerComp implements UnitController, Entityc, Syncc{ + @Nullable Unitc unit; + + @ReadOnly Team team = Team.sharded; + String name = "noname"; + @Nullable NetConnection con; + boolean admin, typing; + Color color = new Color(); + float mouseX, mouseY; + + @Nullable String lastText; + float textFadeTime; + + public void update(){ + if(unit != null){ + x(unit.x()); + y(unit.y()); + unit.team(team); + } + textFadeTime -= Time.delta() / (60 * 5); + } + + public void team(Team team){ + if(unit != null){ + unit.team(team); + } + } + + public void unit(Unitc unit){ + this.unit = unit; + unit.team(team); + } + + String uuid(){ + return con == null ? "AAAAAAAA" : con.uuid; + } + + String usid(){ + return con == null ? "AAAAAAAA" : con.usid; + } + + void kick(KickReason reason){ + con.kick(reason); + } + + void kick(String reason){ + con.kick(reason); + } + + void drawName(){ + BitmapFont font = Fonts.def; + GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new); + final float nameHeight = 11; + final float textHeight = 15; + + boolean ints = font.usesIntegerPositions(); + font.setUseIntegerPositions(false); + font.getData().setScale(0.25f / Scl.scl(1f)); + layout.setText(font, name); + + if(!isLocal()){ + Draw.color(0f, 0f, 0f, 0.3f); + Fill.rect(unit.x(), unit.y() + nameHeight - layout.height / 2, layout.width + 2, layout.height + 3); + Draw.color(); + font.setColor(color); + font.draw(name, unit.x(), unit.y() + nameHeight, 0, Align.center, false); + + if(admin){ + float s = 3f; + 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.color(color); + Draw.rect(Icon.adminSmall.getRegion(), unit.x() + layout.width / 2f + 2 + 1, unit.y() + nameHeight - 1f, s, s); + } + } + + if(Core.settings.getBool("playerchat") && ((textFadeTime > 0 && lastText != null) || typing)){ + String text = textFadeTime <= 0 || lastText == null ? "[LIGHT_GRAY]" + Strings.animated(Time.time(), 4, 15f, ".") : lastText; + float width = 100f; + float visualFadeTime = 1f - Mathf.curve(1f - textFadeTime, 0.9f); + font.setColor(1f, 1f, 1f, textFadeTime <= 0 || lastText == null ? 1f : visualFadeTime); + + layout.setText(font, text, Color.white, width, Align.bottom, true); + + 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); + font.draw(text, unit.x() - width/2f, unit.y() + textHeight + layout.height, width, Align.center, true); + } + + Draw.reset(); + Pools.free(layout); + font.getData().setScale(1f); + font.setColor(Color.white); + font.setUseIntegerPositions(ints); + } + + void sendMessage(String text){ + if(isLocal()){ + if(ui != null){ + ui.chatfrag.addMessage(text, null); + } + }else{ + Call.sendMessage(con, text, null, null); + } + } + + void sendMessage(String text, Playerc from){ + sendMessage(text, from, NetClient.colorizeName(from.id(), from.name())); + } + + void sendMessage(String text, Playerc from, String fromName){ + if(isLocal()){ + if(ui != null){ + ui.chatfrag.addMessage(text, fromName); + } + }else{ + Call.sendMessage(con, text, fromName, from); + } + } + + PlayerInfo getInfo(){ + if(isLocal()){ + throw new IllegalArgumentException("Local players cannot be traced and do not have info."); + }else{ + return netServer.admins.getInfo(uuid()); + } + } + } + @Component abstract class TeamComp implements Posc, Healthc{ transient float x, y; @@ -1194,6 +1332,25 @@ public class EntityComps{ current.progress = entity.progress; } + + /** Draw all current build requests. Does not draw the beam effect, only the positions. */ + void drawBuildRequests(){ + + for(BuildRequest request : requests){ + if(request.progress > 0.01f || (buildRequest() == request && request.initialized && (dst(request.x * tilesize, request.y * tilesize) <= placeDistance || state.isEditor()))) continue; + + request.animScale = 1f; + if(request.breaking){ + control.input.drawBreaking(request); + }else{ + request.block.drawRequest(request, control.input.allRequests(), + Build.validPlace(team(), request.x, request.y, request.block, request.rotation) || control.input.requestMatches(request)); + } + } + + Draw.reset(); + } + /** @return whether this request should be skipped, in favor of the next one. */ boolean shouldSkip(BuildRequest request, @Nullable Tilec core){ //requests that you have at least *started* are considered @@ -1557,7 +1714,7 @@ public class EntityComps{ } boolean isLocal(){ - return this == Vars.player; + return this instanceof Unitc && ((Unitc)this).controller() == player || this == player; } T as(Class type){ @@ -1566,5 +1723,13 @@ public class EntityComps{ @InternalImpl abstract int classId(); + + void read(DataInput input) throws IOException{ + //TODO dynamic io + } + + void write(DataOutput output) throws IOException{ + //TODO dynamic io + } } } diff --git a/core/src/mindustry/entities/def/EntityDefs.java b/core/src/mindustry/entities/def/EntityDefs.java index 1c3c90a209..c4ad565a17 100644 --- a/core/src/mindustry/entities/def/EntityDefs.java +++ b/core/src/mindustry/entities/def/EntityDefs.java @@ -16,4 +16,7 @@ class EntityDefs{ @EntityDef({DecalComp.class}) class DecalDef{} + + @EntityDef({PlayerComp.class}) + class PlayerDef{} } diff --git a/core/src/mindustry/entities/def/EntityGroupDefs.java b/core/src/mindustry/entities/def/EntityGroupDefs.java index c49d1108c4..dc0e4c69a3 100644 --- a/core/src/mindustry/entities/def/EntityGroupDefs.java +++ b/core/src/mindustry/entities/def/EntityGroupDefs.java @@ -5,6 +5,11 @@ import mindustry.entities.def.EntityComps.*; public class EntityGroupDefs{ + @GroupDef(PlayerComp.class) + void player(){ + + } + @GroupDef(UnitComp.class) void unit(){ @@ -16,7 +21,12 @@ public class EntityGroupDefs{ } @GroupDef(DrawComp.class) - void drawers(){ + void drawer(){ + + } + + @GroupDef(SyncComp.class) + void sync(){ } } diff --git a/core/src/mindustry/entities/effect/GroundEffectEntity.java b/core/src/mindustry/entities/effect/GroundEffectEntity.java deleted file mode 100644 index 3e15448c6e..0000000000 --- a/core/src/mindustry/entities/effect/GroundEffectEntity.java +++ /dev/null @@ -1,89 +0,0 @@ -package mindustry.entities.effect; - -import arc.math.Mathf; -import arc.util.Time; -import mindustry.Vars; -import mindustry.entities.Effects; -import mindustry.entities.*; -import mindustry.entities.Effects.EffectRenderer; -import mindustry.world.Tile; - -/** - * A ground effect contains an effect that is rendered on the ground layer as opposed to the top layer. - */ -public class GroundEffectEntity extends EffectEntity{ - private boolean once; - - @Override - public void update(){ - GroundEffect effect = (GroundEffect)this.effect; - - if(effect.isStatic){ - time += Time.delta(); - - time = Mathf.clamp(time, 0, effect.staticLife); - - if(!once && time >= lifetime()){ - once = true; - time = 0f; - Tile tile = Vars.world.tileWorld(x, y); - if(tile != null && tile.floor().isLiquid){ - remove(); - } - }else if(once && time >= effect.staticLife){ - remove(); - } - }else{ - super.update(); - } - } - - @Override - public void draw(){ - GroundEffect effect = (GroundEffect)this.effect; - - if(once && effect.isStatic) - Effects.renderEffect(id, effect, color, lifetime(), rotation, x, y, data); - else - Effects.renderEffect(id, effect, color, time, rotation, x, y, data); - } - - @Override - public void reset(){ - super.reset(); - once = false; - } - - /** - * An effect that is rendered on the ground layer as opposed to the top layer. - */ - public static class GroundEffect extends Effect{ - /** - * How long this effect stays on the ground when static. - */ - public final float staticLife; - /** - * If true, this effect will stop and lie on the ground for a specific duration, - * after its initial lifetime is over. - */ - public final boolean isStatic; - - public GroundEffect(float life, float staticLife, EffectRenderer draw){ - super(life, draw); - this.staticLife = staticLife; - this.isStatic = true; - } - - public GroundEffect(boolean isStatic, float life, EffectRenderer draw){ - super(life, draw); - this.staticLife = 0f; - this.isStatic = isStatic; - } - - public GroundEffect(float life, EffectRenderer draw){ - super(life, draw); - this.staticLife = 0f; - this.isStatic = false; - } - } -} diff --git a/core/src/mindustry/entities/effect/Lightning.java b/core/src/mindustry/entities/effect/Lightning.java index 58049df9ca..ae1c2dfda9 100644 --- a/core/src/mindustry/entities/effect/Lightning.java +++ b/core/src/mindustry/entities/effect/Lightning.java @@ -9,7 +9,7 @@ import arc.util.pooling.*; import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; diff --git a/core/src/mindustry/entities/effect/Puddle.java b/core/src/mindustry/entities/effect/Puddle.java index ac1b68f0b3..bfd5110894 100644 --- a/core/src/mindustry/entities/effect/Puddle.java +++ b/core/src/mindustry/entities/effect/Puddle.java @@ -201,7 +201,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai unit.applyEffect(liquid.effect, 60 * 2); - if(unit.velocity().len() > 0.1){ + if(unit.vel().len() > 0.1){ Fx.ripple.at(liquid.color, unit.x, unit.y); } }); diff --git a/core/src/mindustry/entities/type/Player.java b/core/src/mindustry/entities/type/Player.java deleted file mode 100644 index 2fc06012df..0000000000 --- a/core/src/mindustry/entities/type/Player.java +++ /dev/null @@ -1,914 +0,0 @@ -package mindustry.entities.type; - -import arc.*; -import mindustry.annotations.Annotations.*; -import arc.struct.*; -import arc.graphics.*; -import arc.graphics.g2d.*; -import arc.math.*; -import arc.math.geom.*; -import arc.scene.ui.*; -import arc.scene.ui.layout.*; -import arc.util.*; -import arc.util.ArcAnnotate.*; -import arc.util.pooling.*; -import mindustry.*; -import mindustry.content.*; -import mindustry.core.*; -import mindustry.ctype.ContentType; -import mindustry.entities.*; -import mindustry.entities.units.*; -import mindustry.game.*; -import mindustry.gen.*; -import mindustry.input.*; -import mindustry.io.*; -import mindustry.net.Administration.*; -import mindustry.net.*; -import mindustry.type.*; -import mindustry.ui.*; -import mindustry.world.*; -import mindustry.world.blocks.*; - -import java.io.*; - -import static mindustry.Vars.*; - -public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ - public static final int timerSync = 2; - public static final int timerAbility = 3; - private static final float liftoffBoost = 0.2f; - - private static final Rect rect = new Rect(); - - //region instance variables - - public float baseRotation; - public float pointerX, pointerY; - public String name = "noname"; - public @Nullable String uuid, usid; - public boolean isAdmin, isTransferring, isShooting, isBoosting, isMobile, isTyping, isBuilding = true; - public boolean buildWasAutoPaused = false; - public float boostHeat, shootHeat, destructTime; - public boolean achievedFlight; - public Color color = new Color(); - public UnitDef mech = Mechs.starter; - public SpawnerTrait spawner, lastSpawner; - public int respawns; - - public @Nullable NetConnection con; - public boolean isLocal = false; - public Interval timer = new Interval(6); - public Teamc target; - public Teamc moveTarget; - - public @Nullable String lastText; - public float textFadeTime; - - private float walktime, itemtime; - private Queue placeQueue = new Queue<>(); - private Tile mining; - private Vec2 movement = new Vec2(); - private boolean moved; - - //endregion - - //region unit and event overrides, utility methods - - @Remote(targets = Loc.server, called = Loc.server) - public static void onPlayerDeath(Player player){ - if(player == null) return; - - player.dead = true; - player.placeQueue.clear(); - player.onDeath(); - } - - @Override - public float getDamageMultipler(){ - return status.getDamageMultiplier() * state.rules.playerDamageMultiplier; - } - - @Override - public void onRespawn(Tile tile){ - velocity.setZero(); - boostHeat = 1f; - achievedFlight = true; - rotation = 90f; - baseRotation = 90f; - dead = false; - spawner = null; - respawns --; - Sounds.respawn.at(tile); - - setNet(tile.drawx(), tile.drawy()); - clearItem(); - heal(); - } - - @Override - public boolean offloadImmediately(){ - return true; - } - - @Override - public TypeID getTypeID(){ - return TypeIDs.player; - } - - @Override - public UnitDef type(){ - return mech; - } - - @Override - public Weapons getWeapons(){ - return null; - } - - @Override - public void move(float x, float y){ - if(!mech.flying){ - collisions.move(this, x, y); - }else{ - moveBy(x, y); - } - } - - @Override - public float getMinePower(){ - return mech.minePower; - } - - @Override - public TextureRegion getIconRegion(){ - return mech.icon(Cicon.full); - } - - @Override - public void interpolate(){ - super.interpolate(); - - if(interpolator.values.length > 1){ - baseRotation = interpolator.values[1]; - } - - if(interpolator.target.dst(interpolator.last) > 1f){ - walktime += Time.delta(); - } - } - - @Override - public float getBuildPower(Tile tile){ - return mech.buildPower; - } - - @Override - public float maxHealth(){ - return mech.health * state.rules.playerHealthMultiplier; - } - - @Override - public Tile getMineTile(){ - return mining; - } - - @Override - public void setMineTile(Tile tile){ - this.mining = tile; - } - - @Override - public boolean canMine(Item item){ - return item.hardness <= mech.drillTier; - } - - @Override - public float calculateDamage(float amount){ - return amount * Mathf.clamp(1f - (status.getArmorMultiplier() + mech.getExtraArmor(this)) / 100f); - } - - @Override - public void added(){ - baseRotation = 90f; - } - - @Override - public float mass(){ - return mech.mass; - } - - @Override - public boolean isFlying(){ - return mech.flying || boostHeat > liftoffBoost; - } - - @Override - public void damage(float amount){ - hitTime = hitDuration; - if(!net.client()){ - health -= calculateDamage(amount); - } - - if(health <= 0 && !dead){ - Call.onPlayerDeath(this); - } - } - - @Override - public void set(float x, float y){ - this.x = x; - this.y = y; - } - - @Override - public Queue buildQueue(){ - return placeQueue; - } - - @Override - public String toString(){ - return "Player{" + name + ", mech=" + mech.name + ", id=" + id + ", local=" + isLocal + ", " + x + ", " + y + "}"; - } - - @Override - public EntityGroup targetGroup(){ - return playerGroup; - } - - public void team(Team team){ - this.team = team; - } - - //endregion - - //region draw methods - - @Override - public float drawSize(){ - return isLocal ? Float.MAX_VALUE : 40 + placeDistance; - } - - @Override - public void drawShadow(float offsetX, float offsetY){ - float scl = mech.flying ? 1f : boostHeat / 2f; - - Draw.rect(getIconRegion(), x + offsetX * scl, y + offsetY * scl, rotation - 90); - } - - @Override - public void draw(){ - if(dead) return; - - if(!movement.isZero() && moved && !state.isPaused()){ - walktime += movement.len() * getFloorOn().speedMultiplier * 2f; - baseRotation = Mathf.slerpDelta(baseRotation, movement.angle(), 0.13f); - } - - float ft = Mathf.sin(walktime, 6f, 2f) * (1f - boostHeat); - - Floor floor = getFloorOn(); - - Draw.color(); - Draw.mixcol(Color.white, hitTime / hitDuration); - - if(!mech.flying){ - if(floor.isLiquid){ - Draw.color(Color.white, floor.color, 0.5f); - } - - float boostTrnsY = -boostHeat * 3f; - float boostTrnsX = boostHeat * 3f; - float boostAng = boostHeat * 40f; - - float light = 0.2f; - - for(int i : Mathf.signs){ - Draw.colorl(1f-light + Mathf.clamp(ft * i, 0, 1) *light); - Draw.rect(mech.legRegion, - x + Angles.trnsx(baseRotation, ft * i + boostTrnsY, -boostTrnsX * i), - y + Angles.trnsy(baseRotation, ft * i + boostTrnsY, -boostTrnsX * i), - mech.legRegion.getWidth() * i * Draw.scl, - (mech.legRegion.getHeight() - Mathf.clamp(ft * i, 0, 2)) * Draw.scl, - baseRotation - 90 + boostAng * i); - } - Draw.color(); - - Draw.rect(mech.baseRegion, x, y, baseRotation - 90); - } - - if(floor.isLiquid){ - Draw.color(Color.white, floor.color, drownTime); - }else{ - Draw.color(Color.white); - } - - Draw.rect(mech.region, x, y, rotation - 90); - - mech.draw(this); - weapons.draw(this); - Draw.reset(); - } - - public void drawBackItems(){ - drawBackItems(itemtime, isLocal); - } - - @Override - public void drawStats(){ - mech.drawStats(this); - } - - @Override - public void drawOver(){ - if(dead) return; - - if(isBuilding() && isBuilding){ - if(!state.isPaused()){ - drawBuilding(); - } - }else{ - drawMining(); - } - } - - @Override - public void drawUnder(){ - if(dead) return; - - float size = mech.engineSize * (mech.flying ? 1f : boostHeat); - Draw.color(mech.engineColor); - Fill.circle(x + Angles.trnsx(rotation + 180, mech.engineOffset), y + Angles.trnsy(rotation + 180, mech.engineOffset), - size + Mathf.absin(Time.time(), 2f, size / 4f)); - - Draw.color(Color.white); - Fill.circle(x + Angles.trnsx(rotation + 180, mech.engineOffset - 1f), y + Angles.trnsy(rotation + 180, mech.engineOffset - 1f), - (size + Mathf.absin(Time.time(), 2f, size / 4f)) / 2f); - Draw.color(); - } - - public void drawName(){ - BitmapFont font = Fonts.def; - GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new); - final float nameHeight = 11; - final float textHeight = 15; - - boolean ints = font.usesIntegerPositions(); - font.setUseIntegerPositions(false); - font.getData().setScale(0.25f / Scl.scl(1f)); - layout.setText(font, name); - - if(!isLocal){ - Draw.color(0f, 0f, 0f, 0.3f); - Fill.rect(x, y + nameHeight - layout.height / 2, layout.width + 2, layout.height + 3); - Draw.color(); - font.setColor(color); - font.draw(name, x, y + nameHeight, 0, Align.center, false); - - if(isAdmin){ - float s = 3f; - Draw.color(color.r * 0.5f, color.g * 0.5f, color.b * 0.5f, 1f); - Draw.rect(Icon.adminSmall.getRegion(), x + layout.width / 2f + 2 + 1, y + nameHeight - 1.5f, s, s); - Draw.color(color); - Draw.rect(Icon.adminSmall.getRegion(), x + layout.width / 2f + 2 + 1, y + nameHeight - 1f, s, s); - } - } - - if(Core.settings.getBool("playerchat") && ((textFadeTime > 0 && lastText != null) || isTyping)){ - String text = textFadeTime <= 0 || lastText == null ? "[LIGHT_GRAY]" + Strings.animated(Time.time(), 4, 15f, ".") : lastText; - float width = 100f; - float visualFadeTime = 1f - Mathf.curve(1f - textFadeTime, 0.9f); - font.setColor(1f, 1f, 1f, textFadeTime <= 0 || lastText == null ? 1f : visualFadeTime); - - layout.setText(font, text, Color.white, width, Align.bottom, true); - - Draw.color(0f, 0f, 0f, 0.3f * (textFadeTime <= 0 || lastText == null ? 1f : visualFadeTime)); - Fill.rect(x, y + textHeight + layout.height - layout.height/2f, layout.width + 2, layout.height + 3); - font.draw(text, x - width/2f, y + textHeight + layout.height, width, Align.center, true); - } - - Draw.reset(); - Pools.free(layout); - font.getData().setScale(1f); - font.setColor(Color.white); - font.setUseIntegerPositions(ints); - } - - /** Draw all current build requests. Does not draw the beam effect, only the positions. */ - public void drawBuildRequests(){ - if(!isLocal) return; - - for(BuildRequest request : buildQueue()){ - if(request.progress > 0.01f || (buildRequest() == request && request.initialized && (dst(request.x * tilesize, request.y * tilesize) <= placeDistance || state.isEditor()))) continue; - - request.animScale = 1f; - if(request.breaking){ - control.input.drawBreaking(request); - }else{ - request.block.drawRequest(request, control.input.allRequests(), - Build.validPlace(team(), request.x, request.y, request.block, request.rotation) || control.input.requestMatches(request)); - } - } - - Draw.reset(); - } - - //endregion - - //region update methods - - @Override - public void updateMechanics(){ - if(isBuilding){ - updateBuilding(); - } - - //mine only when not building - if(buildRequest() == null || !isBuilding){ - updateMining(); - } - } - - @Override - public void update(){ - hitTime -= Time.delta(); - textFadeTime -= Time.delta() / (60 * 5); - itemtime = Mathf.lerpDelta(itemtime, Mathf.num(item.amount > 0), 0.1f); - - if(Float.isNaN(x) || Float.isNaN(y)){ - velocity.set(0f, 0f); - x = 0; - y = 0; - dead(true); - } - - if(netServer.isWaitingForPlayers()){ - dead(true); - } - - if(!dead() && isOutOfBounds()){ - destructTime += Time.delta(); - - if(destructTime >= boundsCountdown){ - kill(); - } - }else{ - destructTime = 0f; - } - - if(!dead() && isFlying()){ - loops.play(Sounds.thruster, this, Mathf.clamp(velocity.len() * 2f) * 0.3f); - } - - BuildRequest request = buildRequest(); - if(isBuilding() && isBuilding && request.tile() != null && (request.tile().withinDst(x, y, placeDistance) || state.isEditor())){ - loops.play(Sounds.build, request.tile(), 0.75f); - } - - if(dead()){ - isBoosting = false; - boostHeat = 0f; - if(respawns > 0 || !state.rules.limitedRespawns){ - updateRespawning(); - } - return; - }else{ - spawner = null; - } - - if(isLocal || net.server()){ - avoidOthers(); - } - - Tile tile = world.tileWorld(x, y); - - boostHeat = Mathf.lerpDelta(boostHeat, (tile != null && tile.solid()) || (isBoosting && ((!movement.isZero() && moved) || !isLocal)) ? 1f : 0f, 0.08f); - shootHeat = Mathf.lerpDelta(shootHeat, isShooting() ? 1f : 0f, 0.06f); - mech.update(this); //updated regardless - - if(boostHeat > liftoffBoost + 0.1f){ - achievedFlight = true; - } - - if(boostHeat <= liftoffBoost + 0.05f && achievedFlight && !mech.flying){ - if(tile != null){ - Fx.unitLand.at(x, y, tile.floor().isLiquid ? 1f : 0.5f, tile.floor().color); - } - mech.onLand(this); - achievedFlight = false; - } - - if(!isLocal){ - interpolate(); - updateMechanics(); //building happens even with non-locals - status.update(this); //status effect updating also happens with non locals for effect purposes - updateVelocityStatus(); //velocity too, for visual purposes - - if(net.server()){ - updateShooting(); //server simulates player shooting - } - return; - }else if(world.isZone()){ - //unlock mech when used - data.unlockContent(mech); - } - - if(control.input instanceof MobileInput){ - updateTouch(); - }else{ - updateKeyboard(); - } - - isTyping = ui.chatfrag.shown(); - - updateMechanics(); - - if(!mech.flying){ - clampPosition(); - } - } - - protected void updateKeyboard(){ - Tile tile = world.tileWorld(x, y); - boolean canMove = !Core.scene.hasKeyboard() || ui.minimapfrag.shown(); - - isBoosting = Core.input.keyDown(Binding.dash) && !mech.flying; - - //if player is in solid block - if(tile != null && tile.solid()){ - isBoosting = true; - } - - float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed; - - if(mech.flying){ - //prevent strafing backwards, have a penalty for doing so - float penalty = 0.2f; //when going 180 degrees backwards, reduce speed to 0.2x - speed *= Mathf.lerp(1f, penalty, Angles.angleDist(rotation, velocity.angle()) / 180f); - } - - movement.setZero(); - - float xa = Core.input.axis(Binding.move_x); - float ya = Core.input.axis(Binding.move_y); - if(!(Core.scene.getKeyboardFocus() instanceof TextField)){ - movement.y += ya * speed; - movement.x += xa * speed; - } - - if(Core.input.keyDown(Binding.mouse_move)){ - movement.x += Mathf.clamp((Core.input.mouseX() - Core.graphics.getWidth() / 2f) * 0.005f, -1, 1) * speed; - movement.y += Mathf.clamp((Core.input.mouseY() - Core.graphics.getHeight() / 2f) * 0.005f, -1, 1) * speed; - } - - Vec2 vec = Core.input.mouseWorld(control.input.getMouseX(), control.input.getMouseY()); - pointerX = vec.x; - pointerY = vec.y; - updateShooting(); - - movement.limit(speed).scl(Time.delta()); - - if(canMove){ - velocity.add(movement.x, movement.y); - }else{ - isShooting = false; - } - float prex = x, prey = y; - updateVelocityStatus(); - moved = dst(prex, prey) > 0.001f; - - if(canMove){ - float baseLerp = mech.getRotationAlpha(this); - if(!isShooting() || !mech.faceTarget){ - if(!movement.isZero()){ - rotation = Mathf.slerpDelta(rotation, mech.flying ? velocity.angle() : movement.angle(), 0.13f * baseLerp); - } - }else{ - float angle = control.input.mouseAngle(x, y); - this.rotation = Mathf.slerpDelta(this.rotation, angle, 0.1f * baseLerp); - } - } - } - - protected void updateShooting(){ - if(!state.isEditor() && isShooting() && mech.canShoot(this)){ - weapons.update(this); - //if(!mech.turnCursor){ - //shoot forward ignoring cursor - //mech.weapon.update(this, x + Angles.trnsx(rotation, mech.weapon.targetDistance), y + Angles.trnsy(rotation, mech.weapon.targetDistance)); - //}else{ - //mech.weapon.update(this, pointerX, pointerY); - //} - } - } - - protected void updateTouch(){ - if(Units.invalidateTarget(target, this) && - !(target instanceof Tilec && ((Tilec)target).damaged() && target.isValid() && target.team() == team && mech.canHeal && dst(target) < mech.range && !(((Tilec)target).block instanceof BuildBlock))){ - target = null; - } - - if(state.isEditor()){ - target = null; - } - - float targetX = Core.camera.position.x, targetY = Core.camera.position.y; - float attractDst = 15f; - float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed; - - if(moveTarget != null && !moveTarget.dead()){ - targetX = moveTarget.getX(); - targetY = moveTarget.getY(); - boolean tapping = moveTarget instanceof Tilec && moveTarget.team() == team; - attractDst = 0f; - - if(tapping){ - velocity.setAngle(angleTo(moveTarget)); - } - - if(dst(moveTarget) <= 2f * Time.delta()){ - if(tapping && !dead()){ - Tile tile = ((Tilec)moveTarget).tile; - tile.block().tapped(tile, this); - } - - moveTarget = null; - } - }else{ - moveTarget = null; - } - - movement.set((targetX - x) / Time.delta(), (targetY - y) / Time.delta()).limit(speed); - movement.setAngle(Mathf.slerp(movement.angle(), velocity.angle(), 0.05f)); - - if(dst(targetX, targetY) < attractDst){ - movement.setZero(); - } - - float expansion = 3f; - - hitbox(rect); - rect.x -= expansion; - rect.y -= expansion; - rect.width += expansion * 2f; - rect.height += expansion * 2f; - - isBoosting = collisions.overlapsTile(rect) || dst(targetX, targetY) > 85f; - - velocity.add(movement.scl(Time.delta())); - - if(velocity.len() <= 0.2f && mech.flying){ - rotation += Mathf.sin(Time.time() + id * 99, 10f, 1f); - }else if(target == null){ - rotation = Mathf.slerpDelta(rotation, velocity.angle(), velocity.len() / 10f); - } - - float lx = x, ly = y; - updateVelocityStatus(); - moved = dst(lx, ly) > 0.001f; - - if(mech.flying){ - //hovering effect - x += Mathf.sin(Time.time() + id * 999, 25f, 0.08f); - y += Mathf.cos(Time.time() + id * 999, 25f, 0.08f); - } - - //update shooting if not building, not mining and there's ammo left - if(!isBuilding() && getMineTile() == null){ - - //autofire - if(target == null){ - isShooting = false; - if(Core.settings.getBool("autotarget")){ - target = Units.closestTarget(team, x, y, mech.range, u -> u.team() != Team.derelict, u -> u.getTeam() != Team.derelict); - - if(mech.canHeal && target == null){ - target = Geometry.findClosest(x, y, indexer.getDamaged(Team.sharded)); - if(target != null && dst(target) > mech.range){ - target = null; - }else if(target != null){ - target = ((Tile)target).entity; - } - } - - if(target != null){ - setMineTile(null); - } - } - }else if(target.isValid() || (target instanceof Tilec && ((Tilec)target).damaged() && target.team() == team && mech.canHeal && dst(target) < mech.range)){ - //rotate toward and shoot the target - if(mech.faceTarget){ - rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f); - } - - Vec2 intercept = Predict.intercept(this, target, getWeapon().bullet.speed); - - pointerX = intercept.x; - pointerY = intercept.y; - - updateShooting(); - isShooting = true; - } - - } - } - - //endregion - - //region utility methods - - public void sendMessage(String text){ - if(isLocal){ - if(Vars.ui != null){ - Vars.ui.chatfrag.addMessage(text, null); - } - }else{ - Call.sendMessage(con, text, null, null); - } - } - - public void sendMessage(String text, Player from){ - sendMessage(text, from, NetClient.colorizeName(from.id, from.name)); - } - - public void sendMessage(String text, Player from, String fromName){ - if(isLocal){ - if(Vars.ui != null){ - Vars.ui.chatfrag.addMessage(text, fromName); - } - }else{ - Call.sendMessage(con, text, fromName, from); - } - } - - public PlayerInfo getInfo(){ - if(uuid == null){ - throw new IllegalArgumentException("Local players cannot be traced and do not have info."); - }else{ - return netServer.admins.getInfo(uuid); - } - } - - /** Resets all values of the player. */ - public void reset(){ - resetNoAdd(); - - add(); - } - - public void resetNoAdd(){ - status.clear(); - team = Team.sharded; - item.amount = 0; - placeQueue.clear(); - dead = true; - lastText = null; - isBuilding = true; - textFadeTime = 0f; - target = null; - moveTarget = null; - isShooting = isBoosting = isTransferring = isTyping = false; - spawner = lastSpawner = null; - health = maxHealth(); - mining = null; - boostHeat = drownTime = hitTime = 0f; - mech = Mechs.starter; - placeQueue.clear(); - respawns = state.rules.respawns; - } - - public boolean isShooting(){ - return isShooting && (boostHeat < 0.1f || mech.flying) && mining == null; - } - - public void updateRespawning(){ - - if(state.isEditor()){ - //instant respawn at center of map. - set(world.width() * tilesize/2f, world.height() * tilesize/2f); - dead(false); - }else if(spawner != null && spawner.isValid()){ - spawner.updateSpawning(this); - }else if(!netServer.isWaitingForPlayers()){ - if(!net.client()){ - if(lastSpawner != null && lastSpawner.isValid()){ - this.spawner = lastSpawner; - }else if(closestCore() != null){ - this.spawner = (SpawnerTrait)closestCore(); - } - } - }else if(closestCore() != null){ - set(closestCore().getX(), closestCore().getY()); - } - } - - public void beginRespawning(SpawnerTrait spawner){ - this.spawner = spawner; - this.lastSpawner = spawner; - this.dead = true; - setNet(spawner.getX(), spawner.getY()); - spawner.updateSpawning(this); - } - - //endregion - - //region read and write methods - - @Override - public byte version(){ - return 0; - } - - @Override - public void writeSave(DataOutput stream) throws IOException{ - stream.writeBoolean(isLocal); - - if(isLocal){ - stream.writeByte(mech.id); - stream.writeInt(lastSpawner == null ? noSpawner : lastSpawner.getTile().pos()); - super.writeSave(stream, false); - } - } - - @Override - public void readSave(DataInput stream, byte version) throws IOException{ - boolean local = stream.readBoolean(); - - if(local){ - byte mechid = stream.readByte(); - int spawner = stream.readInt(); - Tile stile = world.tile(spawner); - Player player = headless ? this : Vars.player; - player.readSaveSuper(stream, version); - player.mech = content.getByID(ContentType.mech, mechid); - player.dead = false; - if(stile != null && stile.entity instanceof SpawnerTrait){ - player.lastSpawner = (SpawnerTrait)stile.entity; - } - } - } - - private void readSaveSuper(DataInput stream, byte version) throws IOException{ - super.readSave(stream, version); - - add(); - } - - @Override - public void write(DataOutput buffer) throws IOException{ - super.writeSave(buffer, !isLocal); - TypeIO.writeStringData(buffer, name); - buffer.writeByte(Pack.byteValue(isAdmin) | (Pack.byteValue(dead) << 1) | (Pack.byteValue(isBoosting) << 2) | (Pack.byteValue(isTyping) << 3)| (Pack.byteValue(isBuilding) << 4)); - buffer.writeInt(Color.rgba8888(color)); - buffer.writeByte(mech.id); - buffer.writeInt(mining == null ? noSpawner : mining.pos()); - buffer.writeInt(spawner == null || !spawner.hasUnit(this) ? noSpawner : spawner.getTile().pos()); - buffer.writeShort((short)(baseRotation * 2)); - - writeBuilding(buffer); - } - - @Override - public void read(DataInput buffer) throws IOException{ - float lastx = x, lasty = y, lastrot = rotation, lastvx = velocity.x, lastvy = velocity.y; - - super.readSave(buffer, version()); - - name = TypeIO.readStringData(buffer); - byte bools = buffer.readByte(); - isAdmin = (bools & 1) != 0; - dead = (bools & 2) != 0; - boolean boosting = (bools & 4) != 0; - isTyping = (bools & 8) != 0; - boolean building = (bools & 16) != 0; - color.set(buffer.readInt()); - mech = content.getByID(ContentType.mech, buffer.readByte()); - int mine = buffer.readInt(); - int spawner = buffer.readInt(); - float baseRotation = buffer.readShort() / 2f; - - readBuilding(buffer, !isLocal); - - interpolator.read(lastx, lasty, x, y, rotation, baseRotation); - rotation = lastrot; - x = lastx; - y = lasty; - - if(isLocal){ - velocity.x = lastvx; - velocity.y = lastvy; - }else{ - mining = world.tile(mine); - isBuilding = building; - isBoosting = boosting; - } - - Tile tile = world.tile(spawner); - if(tile != null && tile.entity instanceof SpawnerTrait){ - this.spawner = (SpawnerTrait)tile.entity; - }else{ - this.spawner = null; - } - } - - //endregion -} diff --git a/core/src/mindustry/entities/type/base/BaseDrone.java b/core/src/mindustry/entities/type/base/BaseDrone.java deleted file mode 100644 index 87b140b7a9..0000000000 --- a/core/src/mindustry/entities/type/base/BaseDrone.java +++ /dev/null @@ -1,68 +0,0 @@ -package mindustry.entities.type.base; - -import arc.math.Mathf; -import arc.math.geom.Geometry; -import mindustry.entities.units.*; -import mindustry.world.Tile; -import mindustry.world.meta.BlockFlag; - -import static mindustry.Vars.*; - -public abstract class BaseDrone extends FlyingUnit{ - public final StateMachine.UnitState retreat = new StateMachine.UnitState(){ - public void entered(){ - target = null; - } - - public void update(){ - if(health >= maxHealth()){ - state.set(getStartState()); - }else if(!targetHasFlag(BlockFlag.repair)){ - if(retarget()){ - Tile repairPoint = Geometry.findClosest(x, y, indexer.getAllied(team, BlockFlag.repair)); - if(repairPoint != null){ - target = repairPoint; - }else{ - setState(getStartState()); - } - } - }else{ - circle(40f); - } - } - }; - - @Override - public boolean countsAsEnemy(){ - return false; - } - - @Override - public void onCommand(UnitCommand command){ - //do nothing, normal commands are not applicable here - } - - @Override - protected void updateRotation(){ - if(target != null && shouldRotate() && target.dst(this) < type.range){ - rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.3f); - }else{ - rotation = Mathf.slerpDelta(rotation, velocity.angle(), 0.3f); - } - } - - @Override - public void behavior(){ - if(health <= maxHealth() * type.retreatPercent && !state.is(retreat) && Geometry.findClosest(x, y, indexer.getAllied(team, BlockFlag.repair)) != null){ - setState(retreat); - } - } - - public boolean shouldRotate(){ - return state.is(getStartState()); - } - - @Override - public abstract StateMachine.UnitState getStartState(); - -} diff --git a/core/src/mindustry/entities/type/base/BuilderDrone.java b/core/src/mindustry/entities/type/base/BuilderDrone.java deleted file mode 100644 index 886ecc02f2..0000000000 --- a/core/src/mindustry/entities/type/base/BuilderDrone.java +++ /dev/null @@ -1,238 +0,0 @@ -package mindustry.entities.type.base; - -import arc.*; -import arc.math.*; -import arc.struct.*; -import arc.util.*; -import mindustry.entities.*; -import mindustry.entities.type.*; -import mindustry.entities.units.*; -import mindustry.game.EventType.*; -import mindustry.game.Teams.*; -import mindustry.world.*; -import mindustry.world.blocks.*; -import mindustry.world.blocks.BuildBlock.*; - -import java.io.*; - -import static mindustry.Vars.*; - -public class BuilderDrone extends BaseDrone implements BuilderTrait{ - private static final StaticReset reset = new StaticReset(); - private static final IntIntMap totals = new IntIntMap(); - - protected Queue placeQueue = new Queue<>(); - protected BuildRequest lastFound; - protected boolean isBreaking; - protected Player playerTarget; - - public final StateMachine.UnitState - - build = new StateMachine.UnitState(){ - - public void entered(){ - if(!(target instanceof BuildEntity)){ - target = null; - } - } - - public void update(){ - BuildEntity entity = (BuildEntity)target; - Tilec core = getClosestCore(); - - if(isBuilding() && entity == null && canRebuild()){ - target = world.tile(buildRequest().x, buildRequest().y); - circle(placeDistance * 0.7f); - target = null; - - BuildRequest request = buildRequest(); - - if(world.tile(request.x, request.y).entity instanceof BuildEntity){ - target = world.tile(request.x, request.y).entity; - } - }else if(entity != null && core != null && (entity.progress < 1f || entity.progress > 0f) && entity.tile.block() instanceof BuildBlock){ //building is valid - if(!isBuilding() && dst(target) < placeDistance * 0.9f){ //within distance, begin placing - if(isBreaking){ - buildQueue().addLast(new BuildRequest(entity.tile.x, entity.tile.y)); - }else{ - buildQueue().addLast(new BuildRequest(entity.tile.x, entity.tile.y, entity.tile.rotation(), entity.cblock)); - if(lastFound != null && lastFound.hasConfig){ - buildQueue().last().configure(lastFound.config); - } - } - } - - circle(placeDistance * 0.7f); - velocity.scl(0.74f); - }else{ //else, building isn't valid, follow a player - target = null; - - if(playerTarget == null || playerTarget.team() != team || !playerTarget.isValid()){ - playerTarget = null; - - if(retarget()){ - float minDst = Float.POSITIVE_INFINITY; - int minDrones = Integer.MAX_VALUE; - - //find player with min amount of drones - for(Player player : playerGroup.all()){ - if(player.team() == team){ - int drones = getDrones(player); - float dst = dst2(player); - - if(playerTarget == null || drones < minDrones || (drones == minDrones && dst < minDst)){ - minDrones = drones; - minDst = dst; - playerTarget = player; - } - } - } - } - - if(getSpawner() != null){ - target = getSpawner(); - circle(40f); - target = null; - } - }else{ - incDrones(playerTarget); - Teamc prev = target; - target = playerTarget; - float dst = 90f + (id % 10)*3; - float tdst = dst(target); - float scale = (Mathf.lerp(1f, 0.2f, 1f - Mathf.clamp((tdst - dst) / dst))); - circle(dst); - velocity.scl(scale); - target = prev; - } - } - } - }; - - public BuilderDrone(){ - if(reset.check()){ - Events.on(BuildSelectEvent.class, event -> { - if(!(event.tile.entity instanceof BuildEntity)) return; - - for(BaseUnit unit : unitGroup.all()){ - if(unit instanceof BuilderDrone && unit.getTeam() == getTeam()){ - BuilderDrone drone = (BuilderDrone)unit; - if(drone.isBuilding()){ - //stop building if opposite building begins. - BuildRequest req = drone.buildRequest(); - if(req.breaking != event.breaking && req.x == event.tile.x && req.y == event.tile.y){ - drone.clearBuilding(); - drone.target = null; - } - } - } - } - }); - } - } - - int getDrones(Player player){ - return Pack.leftShort(totals.get(player.id, 0)); - } - - void incDrones(Player player){ - int num = totals.get(player.id, 0); - int amount = Pack.leftShort(num), frame = Pack.rightShort(num); - short curFrame = (short)(Core.graphics.getFrameId() % Short.MAX_VALUE); - - if(frame != curFrame){ - totals.put(player.id, Pack.shortInt((short)1, curFrame)); - }else{ - totals.put(player.id, Pack.shortInt((short)(amount + 1), curFrame)); - } - } - - boolean canRebuild(){ - return true; - } - - @Override - public float getBuildPower(Tile tile){ - return type.buildPower; - } - - @Override - public Queue buildQueue(){ - return placeQueue; - } - - @Override - public void update(){ - super.update(); - - if(!isBuilding() && timer.get(timerTarget2, 15)){ - for(Player player : playerGroup.all()){ - if(player.team() == team && player.buildRequest() != null){ - BuildRequest req = player.buildRequest(); - Tile tile = world.tile(req.x, req.y); - if(tile != null && tile.entity instanceof BuildEntity){ - BuildEntity b = tile.ent(); - float dist = Math.min(b.dst(x, y) - placeDistance, 0); - if(dist / type.maxVelocity < b.buildCost * 0.9f){ - lastFound = req; - target = b; - this.isBreaking = req.breaking; - setState(build); - break; - } - } - } - } - - if(timer.get(timerTarget, 80) && Units.closestEnemy(getTeam(), x, y, 100f, u -> !(u instanceof BaseDrone)) == null && !isBuilding()){ - TeamData data = team.data(); - if(!data.brokenBlocks.isEmpty()){ - BrokenBlock block = data.brokenBlocks.removeLast(); - if(Build.validPlace(getTeam(), block.x, block.y, content.block(block.block), block.rotation)){ - placeQueue.addFirst(new BuildRequest(block.x, block.y, block.rotation, content.block(block.block)).configure(block.config)); - setState(build); - } - } - } - } - - updateBuilding(); - } - - @Override - public boolean shouldRotate(){ - return isBuilding(); - } - - @Override - public StateMachine.UnitState getStartState(){ - return build; - } - - @Override - public void drawOver(){ - drawBuilding(); - } - - @Override - public float drawSize(){ - return isBuilding() ? placeDistance * 2f : 30f; - } - - @Override - public boolean canCreateBlocks(){ - return true; - } - - @Override - public void write(DataOutput data) throws IOException{ - super.write(data); - writeBuilding(data); - } - - @Override - public void read(DataInput data) throws IOException{ - super.read(data); - readBuilding(data); - } -} diff --git a/core/src/mindustry/entities/type/base/FlyingUnit.java b/core/src/mindustry/entities/type/base/FlyingUnit.java deleted file mode 100644 index 098966f02f..0000000000 --- a/core/src/mindustry/entities/type/base/FlyingUnit.java +++ /dev/null @@ -1,255 +0,0 @@ -package mindustry.entities.type.base; - -import arc.graphics.*; -import arc.graphics.g2d.*; -import arc.math.*; -import arc.math.geom.*; -import arc.util.*; -import mindustry.*; -import mindustry.entities.*; -import mindustry.entities.bullet.*; -import mindustry.entities.units.*; -import mindustry.graphics.*; -import mindustry.world.*; -import mindustry.world.meta.*; - -import static mindustry.Vars.*; - -public class FlyingUnit extends BaseUnit{ - protected float[] weaponAngles = {0,0}; - - protected final StateMachine.UnitState - - attack = new StateMachine.UnitState(){ - public void entered(){ - target = null; - } - - public void update(){ - - if(Units.invalidateTarget(target, team, x, y)){ - target = null; - } - - if(retarget()){ - targetClosest(); - - if(target == null) targetClosestEnemyFlag(BlockFlag.producer); - if(target == null) targetClosestEnemyFlag(BlockFlag.turret); - - if(target == null && isCommanded() && getCommand() != UnitCommand.attack){ - onCommand(getCommand()); - } - } - - if(getClosestSpawner() == null && getSpawner() != null && target == null){ - target = getSpawner(); - circle(80f + Mathf.randomSeed(id) * 120); - }else if(target != null){ - attack(type.attackLength); - - if((Angles.near(angleTo(target), rotation, type.shootCone) || getWeapon().ignoreRotation) //bombers and such don't care about rotation - && dst(target) < getWeapon().bullet.range()){ - BulletType ammo = getWeapon().bullet; - - if(type.rotateWeapon){ - for(boolean left : Mathf.booleans){ - int wi = Mathf.num(left); - float wx = x + Angles.trnsx(rotation - 90, getWeapon().width * Mathf.sign(left)); - float wy = y + Angles.trnsy(rotation - 90, getWeapon().width * Mathf.sign(left)); - - weaponAngles[wi] = Mathf.slerpDelta(weaponAngles[wi], Angles.angle(wx, wy, target.getX(), target.getY()), 0.1f); - - Tmp.v2.trns(weaponAngles[wi], getWeapon().length); - getWeapon().update(FlyingUnit.this, wx + Tmp.v2.x, wy + Tmp.v2.y, weaponAngles[wi], left); - } - }else{ - Vec2 to = Predict.intercept(FlyingUnit.this, target, ammo.speed); - getWeapon().update(FlyingUnit.this, to.x, to.y); - } - } - }else{ - target = getClosestSpawner(); - moveTo(Vars.state.rules.dropZoneRadius + 120f); - } - } - }, - rally = new StateMachine.UnitState(){ - public void update(){ - if(retarget()){ - targetClosestAllyFlag(BlockFlag.rally); - targetClosest(); - - if(target != null && !Units.invalidateTarget(target, team, x, y)){ - setState(attack); - return; - } - - if(target == null) target = getSpawner(); - } - - if(target != null){ - circle(65f + Mathf.randomSeed(id) * 100); - } - } - }, - retreat = new StateMachine.UnitState(){ - public void entered(){ - target = null; - } - - public void update(){ - if(retarget()){ - target = getSpawner(); - - Tile repair = Geometry.findClosest(x, y, indexer.getAllied(team, BlockFlag.repair)); - if(repair != null && damaged()) FlyingUnit.this.target = repair.entity; - if(target == null) target = getClosestCore(); - } - - circle(targetHasFlag(BlockFlag.repair) ? 20f : 60f + Mathf.randomSeed(id) * 50, 0.65f * type.speed); - } - };; - - @Override - public void onCommand(UnitCommand command){ - state.set(command == UnitCommand.retreat ? retreat : - command == UnitCommand.attack ? attack : - command == UnitCommand.rally ? rally : - null); - } - - @Override - public void move(float x, float y){ - moveBy(x, y); - } - - @Override - public void update(){ - super.update(); - - if(!net.client()){ - updateRotation(); - } - wobble(); - } - - @Override - public void drawUnder(){ - drawEngine(); - } - - @Override - public void draw(){ - Draw.mixcol(Color.white, hitTime / hitDuration); - Draw.rect(type.region, x, y, rotation - 90); - - drawWeapons(); - - Draw.mixcol(); - } - - public void drawWeapons(){ - for(int i : Mathf.signs){ - float tra = rotation - 90, trY = -type.weapon.getRecoil(this, i > 0) + type.weaponOffsetY; - float w = -i * type.weapon.region.getWidth() * Draw.scl; - Draw.rect(type.weapon.region, - x + Angles.trnsx(tra, getWeapon().width * i, trY), - y + Angles.trnsy(tra, getWeapon().width * i, trY), w, type.weapon.region.getHeight() * Draw.scl, rotation - 90); - } - } - - public void drawEngine(){ - Draw.color(Pal.engine); - Fill.circle(x + Angles.trnsx(rotation + 180, type.engineOffset), y + Angles.trnsy(rotation + 180, type.engineOffset), - type.engineSize + Mathf.absin(Time.time(), 2f, type.engineSize / 4f)); - - Draw.color(Color.white); - Fill.circle(x + Angles.trnsx(rotation + 180, type.engineOffset - 1f), y + Angles.trnsy(rotation + 180, type.engineOffset - 1f), - (type.engineSize + Mathf.absin(Time.time(), 2f, type.engineSize / 4f)) / 2f); - Draw.color(); - } - - @Override - public void behavior(){ - - if(Units.invalidateTarget(target, this)){ - for(boolean left : Mathf.booleans){ - int wi = Mathf.num(left); - weaponAngles[wi] = Mathf.slerpDelta(weaponAngles[wi], rotation, 0.1f); - } - } - } - - @Override - public StateMachine.UnitState getStartState(){ - return attack; - } - - protected void wobble(){ - if(net.client()) return; - - x += Mathf.sin(Time.time() + id * 999, 25f, 0.05f) * Time.delta(); - y += Mathf.cos(Time.time() + id * 999, 25f, 0.05f) * Time.delta(); - - if(velocity.len() <= 0.05f){ - //rotation += Mathf.sin(Time.time() + id * 99, 10f, 2f * type.speed)*Time.delta(); - } - } - - protected void updateRotation(){ - rotation = velocity.angle(); - } - - protected void circle(float circleLength){ - circle(circleLength, type.speed); - } - - protected void circle(float circleLength, float speed){ - if(target == null) return; - - Tmp.v1.set(target.getX() - x, target.getY() - y); - - if(Tmp.v1.len() < circleLength){ - Tmp.v1.rotate((circleLength - Tmp.v1.len()) / circleLength * 180f); - } - - Tmp.v1.setLength(speed * Time.delta()); - - velocity.add(Tmp.v1); - } - - protected void moveTo(float circleLength){ - if(target == null) return; - - Tmp.v1.set(target.getX() - x, target.getY() - y); - - float length = circleLength <= 0.001f ? 1f : Mathf.clamp((dst(target) - circleLength) / 100f, -1f, 1f); - - Tmp.v1.setLength(type.speed * Time.delta() * length); - if(length < -0.5f){ - Tmp.v1.rotate(180f); - }else if(length < 0){ - Tmp.v1.setZero(); - } - - velocity.add(Tmp.v1); - } - - protected void attack(float circleLength){ - Tmp.v1.set(target.getX() - x, target.getY() - y); - - float ang = angleTo(target); - float diff = Angles.angleDist(ang, rotation); - - if(diff > 100f && Tmp.v1.len() < circleLength){ - Tmp.v1.setAngle(velocity.angle()); - }else{ - Tmp.v1.setAngle(Mathf.slerpDelta(velocity.angle(), Tmp.v1.angle(), 0.44f)); - } - - Tmp.v1.setLength(type.speed * Time.delta()); - - velocity.add(Tmp.v1); - } -} diff --git a/core/src/mindustry/entities/type/base/GroundUnit.java b/core/src/mindustry/entities/type/base/GroundUnit.java deleted file mode 100644 index 247a5d941e..0000000000 --- a/core/src/mindustry/entities/type/base/GroundUnit.java +++ /dev/null @@ -1,259 +0,0 @@ -package mindustry.entities.type.base; - -import arc.graphics.*; -import arc.graphics.g2d.*; -import arc.math.*; -import arc.math.geom.*; -import arc.util.*; -import mindustry.*; -import mindustry.ai.Pathfinder.*; -import mindustry.entities.*; -import mindustry.entities.bullet.*; -import mindustry.entities.units.*; -import mindustry.game.*; -import mindustry.world.*; -import mindustry.world.blocks.*; -import mindustry.world.meta.*; - -import static mindustry.Vars.*; - -public class GroundUnit extends BaseUnit{ - protected static Vec2 vec = new Vec2(); - - protected float walkTime; - protected float stuckTime; - protected float baseRotation; - - public final StateMachine.UnitState - - attack = new StateMachine.UnitState(){ - public void entered(){ - target = null; - } - - public void update(){ - Tilec core = getClosestEnemyCore(); - - if(core == null){ - Tile closestSpawn = getClosestSpawner(); - if(closestSpawn == null || !withinDst(closestSpawn, Vars.state.rules.dropZoneRadius + 85f)){ - moveToCore(PathTarget.enemyCores); - } - }else{ - float dst = dst(core); - - if(dst < getWeapon().bullet.range() / 1.1f){ - target = core; - } - - if(dst > getWeapon().bullet.range() * 0.5f){ - moveToCore(PathTarget.enemyCores); - } - } - } - }, - rally = new StateMachine.UnitState(){ - public void update(){ - Tile target = getClosest(BlockFlag.rally); - - if(target != null && dst(target) > 80f){ - moveToCore(PathTarget.rallyPoints); - } - } - }, - retreat = new StateMachine.UnitState(){ - public void entered(){ - target = null; - } - - public void update(){ - moveAwayFromCore(); - } - }; - - @Override - public void onCommand(UnitCommand command){ - state.set(command == UnitCommand.retreat ? retreat : - command == UnitCommand.attack ? attack : - command == UnitCommand.rally ? rally : - null); - } - - @Override - public void interpolate(){ - super.interpolate(); - - if(interpolator.values.length > 1){ - baseRotation = interpolator.values[1]; - } - } - - @Override - public void move(float x, float y){ - float dst = Mathf.dst(x, y); - if(dst > 0.01f){ - baseRotation = Mathf.slerp(baseRotation, Mathf.angle(x, y), type.baseRotateSpeed * (dst / type.speed)); - } - super.move(x, y); - } - - @Override - public StateMachine.UnitState getStartState(){ - return attack; - } - - @Override - public void update(){ - super.update(); - - stuckTime = !vec.set(x, y).sub(lastPosition()).isZero(0.0001f) ? 0f : stuckTime + Time.delta(); - - if(!velocity.isZero()){ - baseRotation = Mathf.slerpDelta(baseRotation, velocity.angle(), 0.05f); - } - - if(stuckTime < 1f){ - walkTime += Time.delta(); - } - } - - @Override - public void draw(){ - Draw.mixcol(Color.white, hitTime / hitDuration); - - float ft = Mathf.sin(walkTime * type.speed * 5f, 6f, 2f + type.hitsize / 15f); - - Floor floor = getFloorOn(); - - if(floor.isLiquid){ - Draw.color(Color.white, floor.color, 0.5f); - } - - for(int i : Mathf.signs){ - Draw.rect(type.legRegion, - x + Angles.trnsx(baseRotation, ft * i), - y + Angles.trnsy(baseRotation, ft * i), - type.legRegion.getWidth() * i * Draw.scl, type.legRegion.getHeight() * Draw.scl - Mathf.clamp(ft * i, 0, 2), baseRotation - 90); - } - - if(floor.isLiquid){ - Draw.color(Color.white, floor.color, drownTime * 0.4f); - }else{ - Draw.color(Color.white); - } - - Draw.rect(type.baseRegion, x, y, baseRotation - 90); - - Draw.rect(type.region, x, y, rotation - 90); - - for(int i : Mathf.signs){ - float tra = rotation - 90, trY = -type.weapon.getRecoil(this, i > 0) + type.weaponOffsetY; - float w = -i * type.weapon.region.getWidth() * Draw.scl; - Draw.rect(type.weapon.region, - x + Angles.trnsx(tra, getWeapon().width * i, trY), - y + Angles.trnsy(tra, getWeapon().width * i, trY), w, type.weapon.region.getHeight() * Draw.scl, rotation - 90); - } - - Draw.mixcol(); - } - - @Override - public void behavior(){ - - if(!Units.invalidateTarget(target, this)){ - if(dst(target) < getWeapon().bullet.range()){ - - rotate(angleTo(target)); - - if(Angles.near(angleTo(target), rotation, 13f)){ - BulletType ammo = getWeapon().bullet; - - Vec2 to = Predict.intercept(GroundUnit.this, target, ammo.speed); - - getWeapon().update(GroundUnit.this, to.x, to.y); - } - } - } - } - - @Override - public void updateTargeting(){ - super.updateTargeting(); - - if(Units.invalidateTarget(target, team, x, y, Float.MAX_VALUE)){ - target = null; - } - - if(retarget()){ - targetClosest(); - } - } - - protected void patrol(){ - vec.trns(baseRotation, type.speed * Time.delta()); - velocity.add(vec.x, vec.y); - vec.trns(baseRotation, type.hitsizeTile * 5); - Tile tile = world.tileWorld(x + vec.x, y + vec.y); - if((tile == null || tile.solid() || tile.floor().drownTime > 0 || tile.floor().isLiquid) || stuckTime > 10f){ - baseRotation += Mathf.sign(id % 2 - 0.5f) * Time.delta() * 3f; - } - - rotation = Mathf.slerpDelta(rotation, velocity.angle(), type.rotatespeed); - } - - protected void circle(float circleLength){ - if(target == null) return; - - vec.set(target.getX() - x, target.getY() - y); - - if(vec.len() < circleLength){ - vec.rotate((circleLength - vec.len()) / circleLength * 180f); - } - - vec.setLength(type.speed * Time.delta()); - - velocity.add(vec); - } - - protected void moveToCore(PathTarget path){ - Tile tile = world.tileWorld(x, y); - if(tile == null) return; - Tile targetTile = pathfinder.getTargetTile(tile, team, path); - - if(tile == targetTile) return; - - velocity.add(vec.trns(angleTo(targetTile), type.speed * Time.delta())); - if(Units.invalidateTarget(target, this)){ - rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed); - } - } - - protected void moveAwayFromCore(){ - Team enemy = null; - for(Team team : team.enemies()){ - if(team.active()){ - enemy = team; - break; - } - } - - if(enemy == null){ - for(Team team : team.enemies()){ - enemy = team; - break; - } - } - - if(enemy == null) return; - - Tile tile = world.tileWorld(x, y); - if(tile == null) return; - Tile targetTile = pathfinder.getTargetTile(tile, enemy, PathTarget.enemyCores); - Tilec core = getClosestCore(); - - if(tile == targetTile || core == null || dst(core) < 120f) return; - - velocity.add(vec.trns(angleTo(targetTile), type.speed * Time.delta())); - rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed); - } -} diff --git a/core/src/mindustry/entities/type/base/HoverUnit.java b/core/src/mindustry/entities/type/base/HoverUnit.java deleted file mode 100644 index a1dfd25819..0000000000 --- a/core/src/mindustry/entities/type/base/HoverUnit.java +++ /dev/null @@ -1,34 +0,0 @@ -package mindustry.entities.type.base; - -import arc.graphics.g2d.Draw; -import arc.math.Angles; -import arc.math.Mathf; -import mindustry.entities.Units; - -public class HoverUnit extends FlyingUnit{ - - @Override - public void drawWeapons(){ - for(int i : Mathf.signs){ - float tra = rotation - 90, trY = -getWeapon().getRecoil(this, i > 0) + type.weaponOffsetY; - float w = i > 0 ? -12 : 12; - float wx = x + Angles.trnsx(tra, getWeapon().width * i, trY), wy = y + Angles.trnsy(tra, getWeapon().width * i, trY); - int wi = (i + 1) / 2; - Draw.rect(getWeapon().region, wx, wy, w, 12, weaponAngles[wi] - 90); - } - } - - @Override - protected void attack(float circleLength){ - moveTo(circleLength); - } - - @Override - protected void updateRotation(){ - if(!Units.invalidateTarget(target, this)){ - rotation = Mathf.slerpDelta(rotation, angleTo(target), type.rotatespeed); - }else{ - rotation = Mathf.slerpDelta(rotation, velocity.angle(), type.baseRotateSpeed); - } - } -} diff --git a/core/src/mindustry/entities/type/base/MinerDrone.java b/core/src/mindustry/entities/type/base/MinerDrone.java deleted file mode 100644 index 79325adda7..0000000000 --- a/core/src/mindustry/entities/type/base/MinerDrone.java +++ /dev/null @@ -1,178 +0,0 @@ -package mindustry.entities.type.base; - -import arc.math.Mathf; -import arc.util.Structs; -import mindustry.content.Blocks; -import mindustry.gen.*; -import mindustry.entities.units.StateMachine.UnitState; -import mindustry.gen.Call; -import mindustry.type.Item; -import mindustry.type.ItemType; -import mindustry.world.Pos; -import mindustry.world.Tile; - -import java.io.*; - -import static mindustry.Vars.*; - -/** A drone that only mines.*/ -public class MinerDrone extends BaseDrone implements MinerTrait{ - protected Item targetItem; - protected Tile mineTile; - - public final UnitState - - mine = new UnitState(){ - public void entered(){ - target = null; - } - - public void update(){ - Tilec entity = getClosestCore(); - - if(entity == null) return; - - findItem(); - - //core full of the target item, do nothing - if(targetItem != null && entity.block.acceptStack(targetItem, 1, entity.tile, MinerDrone.this) == 0){ - MinerDrone.this.clearItem(); - return; - } - - //if inventory is full, drop it off. - if(item.amount >= getItemCapacity() || (targetItem != null && !acceptsItem(targetItem))){ - setState(drop); - }else{ - if(retarget() && targetItem != null){ - target = indexer.findClosestOre(x, y, targetItem); - } - - if(target instanceof Tile){ - moveTo(type.range / 1.5f); - - if(dst(target) < type.range && mineTile != target){ - setMineTile((Tile)target); - } - - if(((Tile)target).block() != Blocks.air){ - setState(drop); - } - }else{ - //nothing to mine anymore, core full: circle spawnpoint - if(getSpawner() != null){ - target = getSpawner(); - - circle(40f); - } - } - } - } - - public void exited(){ - setMineTile(null); - } - }, - - drop = new UnitState(){ - public void entered(){ - target = null; - } - - public void update(){ - if(item.amount == 0 || item.item.type != ItemType.material){ - clearItem(); - setState(mine); - return; - } - - target = getClosestCore(); - - if(target == null) return; - - Tilec tile = (Tilec)target; - - if(dst(target) < type.range){ - if(tile.tile.block().acceptStack(item.item, item.amount, tile.tile, MinerDrone.this) > 0){ - Call.transferItemTo(item.item, item.amount, x, y, tile.tile); - } - - clearItem(); - setState(mine); - } - - circle(type.range / 1.8f); - } - }; - - @Override - public UnitState getStartState(){ - return mine; - } - - @Override - public void update(){ - super.update(); - - updateMining(); - } - - @Override - protected void updateRotation(){ - if(mineTile != null && shouldRotate() && mineTile.dst(this) < type.range){ - rotation = Mathf.slerpDelta(rotation, angleTo(mineTile), 0.3f); - }else{ - rotation = Mathf.slerpDelta(rotation, velocity.angle(), 0.3f); - } - } - - @Override - public boolean shouldRotate(){ - return isMining(); - } - - @Override - public void drawOver(){ - drawMining(); - } - - @Override - public boolean canMine(Item item){ - return type.toMine.contains(item); - } - - @Override - public float getMinePower(){ - return type.minePower; - } - - @Override - public Tile getMineTile(){ - return mineTile; - } - - @Override - public void setMineTile(Tile tile){ - mineTile = tile; - } - - @Override - public void write(DataOutput data) throws IOException{ - super.write(data); - data.writeInt(mineTile == null || !state.is(mine) ? Pos.invalid : mineTile.pos()); - } - - @Override - public void read(DataInput data) throws IOException{ - super.read(data); - mineTile = world.tile(data.readInt()); - } - - protected void findItem(){ - Tilec entity = getClosestCore(); - if(entity == null){ - return; - } - targetItem = Structs.findMin(type.toMine, indexer::hasOre, (a, b) -> -Integer.compare(entity.items().get(a), entity.items().get(b))); - } -} diff --git a/core/src/mindustry/entities/type/base/RepairDrone.java b/core/src/mindustry/entities/type/base/RepairDrone.java deleted file mode 100644 index 5f8861bbdb..0000000000 --- a/core/src/mindustry/entities/type/base/RepairDrone.java +++ /dev/null @@ -1,73 +0,0 @@ -package mindustry.entities.type.base; - -import mindustry.entities.Units; -import mindustry.gen.*; -import mindustry.entities.units.StateMachine.UnitState; -import mindustry.world.Pos; -import mindustry.world.Tile; -import mindustry.world.blocks.*; - -import java.io.*; - -import static mindustry.Vars.world; - -public class RepairDrone extends BaseDrone{ - public final UnitState repair = new UnitState(){ - - public void entered(){ - target = null; - } - - public void update(){ - - if(retarget()){ - target = Units.findDamagedTile(team, x, y); - } - - if(target instanceof Tilec && ((Tilec)target).block instanceof BuildBlock){ - target = null; - } - - if(target != null){ - if(target.dst(RepairDrone.this) > type.range){ - circle(type.range * 0.9f); - }else{ - getWeapon().update(RepairDrone.this, target.getX(), target.getY()); - } - }else{ - //circle spawner if there's nothing to repair - if(getSpawner() != null){ - target = getSpawner(); - circle(type.range * 1.5f, type.speed/2f); - target = null; - } - } - } - }; - - @Override - public boolean shouldRotate(){ - return target != null; - } - - @Override - public UnitState getStartState(){ - return repair; - } - - @Override - public void write(DataOutput data) throws IOException{ - super.write(data); - data.writeInt(state.is(repair) && target instanceof Tilec ? ((Tilec)target).tile.pos() : Pos.invalid); - } - - @Override - public void read(DataInput data) throws IOException{ - super.read(data); - Tile repairing = world.tile(data.readInt()); - - if(repairing != null){ - target = repairing.entity; - } - } -} diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index e2518d7e0c..148eb57276 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -3,7 +3,7 @@ package mindustry.game; import arc.util.ArcAnnotate.*; import mindustry.core.GameState.*; import mindustry.ctype.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.gen.*; import mindustry.type.*; @@ -62,10 +62,10 @@ public class EventType{ } public static class PlayerChatEvent{ - public final Player player; + public final Playerc player; public final String message; - public PlayerChatEvent(Player player, String message){ + public PlayerChatEvent(Playerc player, String message){ this.player = player; this.message = message; } @@ -144,11 +144,11 @@ public class EventType{ /** Called when the player withdraws items from a block. */ public static class WithdrawEvent{ public final Tile tile; - public final Player player; + public final Playerc player; public final Item item; public final int amount; - public WithdrawEvent(Tile tile, Player player, Item item, int amount){ + public WithdrawEvent(Tile tile, Playerc player, Item item, int amount){ this.tile = tile; this.player = player; this.item = item; @@ -159,11 +159,11 @@ public class EventType{ /** Called when a player deposits items to a block.*/ public static class DepositEvent{ public final Tile tile; - public final Player player; + public final Playerc player; public final Item item; public final int amount; - public DepositEvent(Tile tile, Player player, Item item, int amount){ + public DepositEvent(Tile tile, Playerc player, Item item, int amount){ this.tile = tile; this.player = player; this.item = item; @@ -174,9 +174,9 @@ public class EventType{ /** Called when the player taps a block. */ public static class TapEvent{ public final Tile tile; - public final Player player; + public final Playerc player; - public TapEvent(Tile tile, Player player){ + public TapEvent(Tile tile, Playerc player){ this.tile = tile; this.player = player; } @@ -185,10 +185,10 @@ public class EventType{ /** Called when the player sets a specific block. */ public static class TapConfigEvent{ public final Tile tile; - public final Player player; + public final Playerc player; public final int value; - public TapConfigEvent(Tile tile, Player player, int value){ + public TapConfigEvent(Tile tile, Playerc player, int value){ this.tile = tile; this.player = player; this.value = value; @@ -262,10 +262,10 @@ public class EventType{ public final Tile tile; public final Team team; public final @Nullable - Player player; + Playerc player; public final boolean breaking; - public BlockBuildEndEvent(Tile tile, @Nullable Player player, Team team, boolean breaking){ + public BlockBuildEndEvent(Tile tile, @Nullable Playerc player, Team team, boolean breaking){ this.tile = tile; this.team = team; this.player = player; @@ -323,10 +323,10 @@ public class EventType{ //TODO rename public static class MechChangeEvent{ - public final Player player; + public final Playerc player; public final UnitDef mech; - public MechChangeEvent(Player player, UnitDef mech){ + public MechChangeEvent(Playerc player, UnitDef mech){ this.player = player; this.mech = mech; } @@ -334,42 +334,42 @@ public class EventType{ /** Called after connecting; when a player recieves world data and is ready to play.*/ public static class PlayerJoin{ - public final Player player; + public final Playerc player; - public PlayerJoin(Player player){ + public PlayerJoin(Playerc player){ this.player = player; } } /** Called when a player connects, but has not joined the game yet.*/ public static class PlayerConnect{ - public final Player player; + public final Playerc player; - public PlayerConnect(Player player){ + public PlayerConnect(Playerc player){ this.player = player; } } public static class PlayerLeave{ - public final Player player; + public final Playerc player; - public PlayerLeave(Player player){ + public PlayerLeave(Playerc player){ this.player = player; } } public static class PlayerBanEvent{ - public final Player player; + public final Playerc player; - public PlayerBanEvent(Player player){ + public PlayerBanEvent(Playerc player){ this.player = player; } } public static class PlayerUnbanEvent{ - public final Player player; + public final Playerc player; - public PlayerUnbanEvent(Player player){ + public PlayerUnbanEvent(Playerc player){ this.player = player; } } diff --git a/core/src/mindustry/game/SpawnGroup.java b/core/src/mindustry/game/SpawnGroup.java index 0155c044e7..92945d543d 100644 --- a/core/src/mindustry/game/SpawnGroup.java +++ b/core/src/mindustry/game/SpawnGroup.java @@ -5,6 +5,7 @@ import arc.util.serialization.Json.Serializable; import arc.util.serialization.JsonValue; import mindustry.content.*; import mindustry.ctype.ContentType; +import mindustry.gen.*; import mindustry.type.*; import static mindustry.Vars.content; @@ -18,7 +19,7 @@ public class SpawnGroup implements Serializable{ public static final int never = Integer.MAX_VALUE; /** The unit type spawned */ - public UnitType type; + public UnitDef type; /** When this spawn should end */ public int end = never; /** When this spawn should start */ @@ -36,7 +37,7 @@ public class SpawnGroup implements Serializable{ /** Items this unit spawns with. Null to disable. */ public ItemStack items; - public SpawnGroup(UnitType type){ + public SpawnGroup(UnitDef type){ this.type = type; } @@ -56,8 +57,11 @@ public class SpawnGroup implements Serializable{ * Creates a unit, and assigns correct values based on this group's data. * This method does not add() the unit. */ - public BaseUnit createUnit(Team team){ - BaseUnit unit = type.create(team); + public Unitc createUnit(Team team){ + //TODO + throw new IllegalArgumentException("TODO"); + /* + Unitc unit = type.create(team); if(effect != null){ unit.applyEffect(effect, 999999f); @@ -67,7 +71,7 @@ public class SpawnGroup implements Serializable{ unit.addItem(items.item, items.amount); } - return unit; + return unit;*/ } @Override diff --git a/core/src/mindustry/game/Tutorial.java b/core/src/mindustry/game/Tutorial.java index 287492dedd..e6c7abd38d 100644 --- a/core/src/mindustry/game/Tutorial.java +++ b/core/src/mindustry/game/Tutorial.java @@ -10,7 +10,7 @@ import arc.scene.ui.*; import arc.scene.ui.layout.*; import arc.util.*; import mindustry.content.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.graphics.*; import mindustry.type.*; diff --git a/core/src/mindustry/graphics/MinimapRenderer.java b/core/src/mindustry/graphics/MinimapRenderer.java index 2773042d78..271431ffaf 100644 --- a/core/src/mindustry/graphics/MinimapRenderer.java +++ b/core/src/mindustry/graphics/MinimapRenderer.java @@ -12,7 +12,7 @@ import arc.util.*; import arc.util.ArcAnnotate.*; import arc.util.pooling.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.io.*; import mindustry.ui.*; @@ -97,8 +97,8 @@ public class MinimapRenderer implements Disposable{ Draw.rect(unit.getIconRegion(), x + rx, y + ry, scale, scale, unit.rotation - 90); Draw.reset(); - if(withLabels && unit instanceof Player){ - Player pl = (Player) unit; + if(withLabels && unit instanceof Playerc){ + Playerc pl = (Playerc) unit; if(!pl.isLocal){ // Only display names for other players. drawLabel(x + rx, y + ry, pl.name, unit.getTeam().color); diff --git a/core/src/mindustry/graphics/OverlayRenderer.java b/core/src/mindustry/graphics/OverlayRenderer.java index b320ab9b75..4d7551ae23 100644 --- a/core/src/mindustry/graphics/OverlayRenderer.java +++ b/core/src/mindustry/graphics/OverlayRenderer.java @@ -9,7 +9,7 @@ import arc.util.*; import mindustry.*; import mindustry.content.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.input.*; import mindustry.type.*; import mindustry.ui.*; @@ -36,7 +36,7 @@ public class OverlayRenderer{ public void drawTop(){ if(Core.settings.getBool("indicators")){ - for(Player player : playerGroup.all()){ + for(Playerc player : Groups.player.all()){ if(Vars.player != player && Vars.player.team() == player.team()){ if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f) .setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){ diff --git a/core/src/mindustry/graphics/Pixelator.java b/core/src/mindustry/graphics/Pixelator.java index f746ca69e3..d6c69c8b37 100644 --- a/core/src/mindustry/graphics/Pixelator.java +++ b/core/src/mindustry/graphics/Pixelator.java @@ -6,11 +6,11 @@ import arc.graphics.Texture.TextureFilter; import arc.graphics.g2d.Draw; import arc.graphics.gl.FrameBuffer; import arc.util.Disposable; -import mindustry.entities.type.Player; +import mindustry.gen.*; import static arc.Core.camera; import static arc.Core.graphics; -import static mindustry.Vars.playerGroup; +import static mindustry.Groups.player; import static mindustry.Vars.renderer; public class Pixelator implements Disposable{ @@ -55,7 +55,7 @@ public class Pixelator implements Disposable{ Draw.rect(Draw.wrap(buffer.getTexture()), Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height); Draw.blend(); - playerGroup.draw(p -> !p.isDead(), Player::drawName); + Groups.player.draw(p -> !p.isDead(), Playerc::drawName); Core.camera.position.set(px, py); Core.settings.put("animatedwater", hadWater); diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index e8575ecf24..583ba5a644 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -132,6 +132,8 @@ public class DesktopInput extends InputHandler{ @Override public void update(){ + super.update(); + if(net.active() && Core.input.keyTap(Binding.player_list)){ ui.listfrag.toggle(); } diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 8522b7c865..29f8bc3512 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -18,7 +18,7 @@ import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.entities.*; import mindustry.entities.effect.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.game.EventType.*; import mindustry.game.*; @@ -73,7 +73,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.client, called = Loc.server) - public static void dropItem(Player player, float angle){ + public static void dropItem(Playerc player, float angle){ if(net.server() && player.item().amount <= 0){ throw new ValidateException(player, "Player cannot drop an item."); } @@ -83,7 +83,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.both, called = Loc.server, forward = true, unreliable = true) - public static void rotateBlock(Player player, Tile tile, boolean direction){ + public static void rotateBlock(Playerc player, Tile tile, boolean direction){ if(net.server() && (!Units.canInteract(player, tile) || !netServer.admins.allowAction(player, ActionType.rotate, tile, action -> action.rotation = Mathf.mod(tile.rotation() + Mathf.sign(direction), 4)))){ throw new ValidateException(player, "Player cannot rotate a block."); @@ -98,8 +98,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.both, forward = true, called = Loc.server) - public static void transferInventory(Player player, Tile tile){ - if(player == null || player.timer == null) return; + public static void transferInventory(Playerc player, Tile tile){ + if(player == null) return; if(net.server() && (player.item().amount <= 0 || player.isTransferring|| !Units.canInteract(player, tile) || !netServer.admins.allowAction(player, ActionType.depositItem, tile, action -> { action.itemAmount = player.item().amount; @@ -152,7 +152,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.both, called = Loc.server, forward = true) - public static void onTileTapped(Player player, Tile tile){ + public static void onTileTapped(Playerc player, Tile tile){ if(tile == null || player == null) return; if(net.server() && (!Units.canInteract(player, tile) || !netServer.admins.allowAction(player, ActionType.tapTile, tile, action -> {}))) throw new ValidateException(player, "Player cannot tap a tile."); @@ -161,7 +161,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } @Remote(targets = Loc.both, called = Loc.both, forward = true) - public static void onTileConfig(Player player, Tile tile, int value){ + public static void onTileConfig(Playerc player, Tile tile, int value){ if(tile == null) return; if(net.server() && (!Units.canInteract(player, tile) || @@ -183,7 +183,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } public void update(){ - + player.typing(ui.chatfrag.shown()); } public float getMouseX(){ @@ -637,7 +637,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ && tile.drop() != null && tile.drop().hardness <= player.mech.drillPower && !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null) && player.acceptsItem(tile.drop()) - && tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= Player.mineDistance; + && tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= Playerc.mineDistance; } /** Returns the tile at the specified MOUSE coordinates. */ @@ -897,4 +897,192 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ public int x, y, rotation; public boolean last; } + + //TODO implement all of this! + /* + protected void updateKeyboard(){ + Tile tile = world.tileWorld(x, y); + boolean canMove = !Core.scene.hasKeyboard() || ui.minimapfrag.shown(); + + isBoosting = Core.input.keyDown(Binding.dash) && !mech.flying; + + //if player is in solid block + if(tile != null && tile.solid()){ + isBoosting = true; + } + + float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed; + + if(mech.flying){ + //prevent strafing backwards, have a penalty for doing so + float penalty = 0.2f; //when going 180 degrees backwards, reduce speed to 0.2x + speed *= Mathf.lerp(1f, penalty, Angles.angleDist(rotation, velocity.angle()) / 180f); + } + + movement.setZero(); + + float xa = Core.input.axis(Binding.move_x); + float ya = Core.input.axis(Binding.move_y); + if(!(Core.scene.getKeyboardFocus() instanceof TextField)){ + movement.y += ya * speed; + movement.x += xa * speed; + } + + if(Core.input.keyDown(Binding.mouse_move)){ + movement.x += Mathf.clamp((Core.input.mouseX() - Core.graphics.getWidth() / 2f) * 0.005f, -1, 1) * speed; + movement.y += Mathf.clamp((Core.input.mouseY() - Core.graphics.getHeight() / 2f) * 0.005f, -1, 1) * speed; + } + + Vec2 vec = Core.input.mouseWorld(control.input.getMouseX(), control.input.getMouseY()); + pointerX = vec.x; + pointerY = vec.y; + updateShooting(); + + movement.limit(speed).scl(Time.delta()); + + if(canMove){ + velocity.add(movement.x, movement.y); + }else{ + isShooting = false; + } + float prex = x, prey = y; + updateVelocityStatus(); + moved = dst(prex, prey) > 0.001f; + + if(canMove){ + float baseLerp = mech.getRotationAlpha(this); + if(!isShooting() || !mech.faceTarget){ + if(!movement.isZero()){ + rotation = Mathf.slerpDelta(rotation, mech.flying ? velocity.angle() : movement.angle(), 0.13f * baseLerp); + } + }else{ + float angle = control.input.mouseAngle(x, y); + this.rotation = Mathf.slerpDelta(this.rotation, angle, 0.1f * baseLerp); + } + } + } + + protected void updateShooting(){ + if(!state.isEditor() && isShooting() && mech.canShoot(this)){ + weapons.update(this); + //if(!mech.turnCursor){ + //shoot forward ignoring cursor + //mech.weapon.update(this, x + Angles.trnsx(rotation, mech.weapon.targetDistance), y + Angles.trnsy(rotation, mech.weapon.targetDistance)); + //}else{ + //mech.weapon.update(this, pointerX, pointerY); + //} + } + } + + protected void updateTouch(){ + if(Units.invalidateTarget(target, this) && + !(target instanceof Tilec && ((Tilec)target).damaged() && target.isValid() && target.team() == team && mech.canHeal && dst(target) < mech.range && !(((Tilec)target).block instanceof BuildBlock))){ + target = null; + } + + if(state.isEditor()){ + target = null; + } + + float targetX = Core.camera.position.x, targetY = Core.camera.position.y; + float attractDst = 15f; + float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed; + + if(moveTarget != null && !moveTarget.dead()){ + targetX = moveTarget.getX(); + targetY = moveTarget.getY(); + boolean tapping = moveTarget instanceof Tilec && moveTarget.team() == team; + attractDst = 0f; + + if(tapping){ + velocity.setAngle(angleTo(moveTarget)); + } + + if(dst(moveTarget) <= 2f * Time.delta()){ + if(tapping && !dead()){ + Tile tile = ((Tilec)moveTarget).tile; + tile.block().tapped(tile, this); + } + + moveTarget = null; + } + }else{ + moveTarget = null; + } + + movement.set((targetX - x) / Time.delta(), (targetY - y) / Time.delta()).limit(speed); + movement.setAngle(Mathf.slerp(movement.angle(), velocity.angle(), 0.05f)); + + if(dst(targetX, targetY) < attractDst){ + movement.setZero(); + } + + float expansion = 3f; + + hitbox(rect); + rect.x -= expansion; + rect.y -= expansion; + rect.width += expansion * 2f; + rect.height += expansion * 2f; + + isBoosting = collisions.overlapsTile(rect) || dst(targetX, targetY) > 85f; + + velocity.add(movement.scl(Time.delta())); + + if(velocity.len() <= 0.2f && mech.flying){ + rotation += Mathf.sin(Time.time() + id * 99, 10f, 1f); + }else if(target == null){ + rotation = Mathf.slerpDelta(rotation, velocity.angle(), velocity.len() / 10f); + } + + float lx = x, ly = y; + updateVelocityStatus(); + moved = dst(lx, ly) > 0.001f; + + if(mech.flying){ + //hovering effect + x += Mathf.sin(Time.time() + id * 999, 25f, 0.08f); + y += Mathf.cos(Time.time() + id * 999, 25f, 0.08f); + } + + //update shooting if not building, not mining and there's ammo left + if(!isBuilding() && getMineTile() == null){ + + //autofire + if(target == null){ + isShooting = false; + if(Core.settings.getBool("autotarget")){ + target = Units.closestTarget(team, x, y, mech.range, u -> u.team() != Team.derelict, u -> u.getTeam() != Team.derelict); + + if(mech.canHeal && target == null){ + target = Geometry.findClosest(x, y, indexer.getDamaged(Team.sharded)); + if(target != null && dst(target) > mech.range){ + target = null; + }else if(target != null){ + target = ((Tile)target).entity; + } + } + + if(target != null){ + setMineTile(null); + } + } + }else if(target.isValid() || (target instanceof Tilec && ((Tilec)target).damaged() && target.team() == team && mech.canHeal && dst(target) < mech.range)){ + //rotate toward and shoot the target + if(mech.faceTarget){ + rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f); + } + + Vec2 intercept = Predict.intercept(this, target, getWeapon().bullet.speed); + + pointerX = intercept.x; + pointerY = intercept.y; + + updateShooting(); + isShooting = true; + } + + } + } + */ } diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index f95f42acf9..4ba30a9ee3 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -577,6 +577,8 @@ public class MobileInput extends InputHandler implements GestureListener{ @Override public void update(){ + super.update(); + if(state.is(State.menu) ){ selectRequests.clear(); removals.clear(); diff --git a/core/src/mindustry/input/Placement.java b/core/src/mindustry/input/Placement.java index 49d3e9a030..318b3adc16 100644 --- a/core/src/mindustry/input/Placement.java +++ b/core/src/mindustry/input/Placement.java @@ -97,7 +97,7 @@ public class Placement{ int nodeLimit = 1000; int totalNodes = 0; - PriorityQueue queue = new PriorityQueue<>(10, (a, b) -> Float.compare(costs.get(a.pos(), 0f) + distanceHeuristic(a.x, a.y, end.x, end.y), costs.get(b.pos(), 0f) + distanceHeuristic(b.x, b.y, end.x, end.y))); + PriorityQueue queue = new PriorityQueue<>(10, (a, b) -> Float.compare(costs.get(a.pos(), 0f) + distanceHeuristic(a.x, a.y, end.x, end.y), costs.get(b.pos(), 0f) + distanceHeuristic(b.x(), b.y(), end.x, end.y))); queue.add(start); boolean found = false; while(!queue.isEmpty() && totalNodes++ < nodeLimit){ diff --git a/core/src/mindustry/io/TypeIO.java b/core/src/mindustry/io/TypeIO.java index d79100e2d3..8a6378f237 100644 --- a/core/src/mindustry/io/TypeIO.java +++ b/core/src/mindustry/io/TypeIO.java @@ -1,24 +1,18 @@ package mindustry.io; -import mindustry.annotations.Annotations.ReadClass; -import mindustry.annotations.Annotations.WriteClass; -import arc.graphics.Color; -import mindustry.ctype.ContentType; -import mindustry.entities.Effects; -import mindustry.entities.*; -import mindustry.entities.bullet.BulletType; -import mindustry.entities.units.BuildRequest; -import mindustry.entities.type.*; +import arc.graphics.*; +import mindustry.annotations.Annotations.*; +import mindustry.ctype.*; +import mindustry.entities.bullet.*; import mindustry.entities.units.*; import mindustry.game.*; -import mindustry.net.Administration.TraceInfo; -import mindustry.net.Packets.AdminAction; -import mindustry.net.Packets.KickReason; +import mindustry.net.Administration.*; +import mindustry.net.Packets.*; import mindustry.type.*; import mindustry.world.*; import java.io.*; -import java.nio.ByteBuffer; +import java.nio.*; import static mindustry.Vars.*; @@ -26,76 +20,6 @@ import static mindustry.Vars.*; @SuppressWarnings("unused") public class TypeIO{ - @WriteClass(Player.class) - public static void writePlayer(ByteBuffer buffer, Player player){ - if(player == null){ - buffer.putInt(-1); - }else{ - buffer.putInt(player.id); - } - } - - @ReadClass(Player.class) - public static Player readPlayer(ByteBuffer buffer){ - int id = buffer.getInt(); - return id == -1 ? null : playerGroup.getByID(id); - } - - @WriteClass(Unitc.class) - public static void writeUnit(ByteBuffer buffer, Unitc unit){ - if(unit.getGroup() == null){ - buffer.put((byte)-1); - return; - } - buffer.put((byte)unit.getGroup().getID()); - buffer.putInt(unit.getID()); - } - - @ReadClass(Unitc.class) - public static Unitc readUnit(ByteBuffer buffer){ - byte gid = buffer.get(); - if(gid == -1) return null; - int id = buffer.getInt(); - return (Unitc)entities.get(gid).getByID(id); - } - - @WriteClass(ShooterTrait.class) - public static void writeShooter(ByteBuffer buffer, ShooterTrait trait){ - buffer.put((byte)trait.getGroup().getID()); - buffer.putInt(trait.getID()); - } - - @ReadClass(ShooterTrait.class) - public static ShooterTrait readShooter(ByteBuffer buffer){ - byte gid = buffer.get(); - int id = buffer.getInt(); - return (ShooterTrait)entities.get(gid).getByID(id); - } - - @WriteClass(Bullet.class) - public static void writeBullet(ByteBuffer buffer, Bullet bullet){ - buffer.putInt(bullet.getID()); - } - - @ReadClass(Bullet.class) - public static Bullet readBullet(ByteBuffer buffer){ - int id = buffer.getInt(); - return bulletGroup.getByID(id); - } - - @WriteClass(BaseUnit.class) - public static void writeBaseUnit(ByteBuffer buffer, BaseUnit unit){ - buffer.put((byte) (int)unit.getTeam().id); - buffer.putInt(unit.getID()); - } - - @ReadClass(BaseUnit.class) - public static BaseUnit readBaseUnit(ByteBuffer buffer){ - byte tid = buffer.get(); - int id = buffer.getInt(); - return unitGroup.getByID(id); - } - @WriteClass(Tile.class) public static void writeTile(ByteBuffer buffer, Tile tile){ buffer.putInt(tile == null ? Pos.get(-1, -1) : tile.pos()); @@ -220,16 +144,6 @@ public class TypeIO{ return AdminAction.values()[buffer.get()]; } - @WriteClass(Effect.class) - public static void writeEffect(ByteBuffer buffer, Effect effect){ - buffer.putShort((short)effect.id); - } - - @ReadClass(Effect.class) - public static Effect readEffect(ByteBuffer buffer){ - return Effects.getEffect(buffer.getShort()); - } - @WriteClass(UnitDef.class) public static void writeUnitDef(ByteBuffer buffer, UnitDef effect){ buffer.putShort(effect.id); diff --git a/core/src/mindustry/io/versions/LegacyTypeTable.java b/core/src/mindustry/io/versions/LegacyTypeTable.java index a8e5d3b97f..0e8e58ead2 100644 --- a/core/src/mindustry/io/versions/LegacyTypeTable.java +++ b/core/src/mindustry/io/versions/LegacyTypeTable.java @@ -2,7 +2,7 @@ package mindustry.io.versions; import arc.func.Prov; import mindustry.entities.effect.*; -import mindustry.entities.type.Player; +import mindustry.gen.*; import mindustry.entities.type.base.*; /* @@ -78,7 +78,7 @@ public class LegacyTypeTable{ 13 = Revenant */ private static final Prov[] build81Table = { - Player::new, + Playerc::new, Fire::new, Puddle::new, MinerDrone::new, @@ -95,7 +95,7 @@ public class LegacyTypeTable{ }; private static final Prov[] build80Table = { - Player::new, + Playerc::new, Fire::new, Puddle::new, Bullet::new, @@ -114,7 +114,7 @@ public class LegacyTypeTable{ }; private static final Prov[] build79Table = { - Player::new, + Playerc::new, Fire::new, Puddle::new, Bullet::new, diff --git a/core/src/mindustry/maps/Map.java b/core/src/mindustry/maps/Map.java index 90bb4f2f87..296180680b 100644 --- a/core/src/mindustry/maps/Map.java +++ b/core/src/mindustry/maps/Map.java @@ -203,7 +203,7 @@ public class Map implements Comparable, Publishable{ @Override public boolean prePublish(){ - tags.put("author", player.name); + tags.put("author", player.name()); ui.editor.editor.getTags().put("author", tags.get("author")); ui.editor.save(); diff --git a/core/src/mindustry/maps/generators/BasicGenerator.java b/core/src/mindustry/maps/generators/BasicGenerator.java index a4a22e1095..ca35ce8bd8 100644 --- a/core/src/mindustry/maps/generators/BasicGenerator.java +++ b/core/src/mindustry/maps/generators/BasicGenerator.java @@ -182,7 +182,7 @@ public abstract class BasicGenerator extends RandomGenerator{ Tile end = tiles.getn(endX, endY); GridBits closed = new GridBits(width, height); IntFloatMap costs = new IntFloatMap(); - PriorityQueue queue = new PriorityQueue<>(tiles.width() * tiles.height()/4, (a, b) -> Float.compare(costs.get(a.pos(), 0f) + dh.cost(a.x, a.y, end.x, end.y), costs.get(b.pos(), 0f) + dh.cost(b.x, b.y, end.x, end.y))); + PriorityQueue queue = new PriorityQueue<>(tiles.width() * tiles.height()/4, (a, b) -> Float.compare(costs.get(a.pos(), 0f) + dh.cost(a.x, a.y, end.x, end.y), costs.get(b.pos(), 0f) + dh.cost(b.x(), b.y(), end.x, end.y))); queue.add(start); boolean found = false; while(!queue.isEmpty()){ diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index 4fa73994b7..be90e07a15 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -20,7 +20,7 @@ import mindustry.content.TechTree.*; import mindustry.ctype.*; import mindustry.entities.Effects.*; import mindustry.entities.bullet.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.game.*; import mindustry.game.Objectives.*; import mindustry.gen.*; @@ -280,7 +280,7 @@ public class ContentParser{ UnitType unit; if(locate(ContentType.unit, name) == null){ - Class type = resolve(legacyUnitMap.get(Strings.capitalize(getType(value)), getType(value)), "mindustry.entities.type.base"); + Class type = resolve(legacyUnitMap.get(Strings.capitalize(getType(value)), getType(value)), "mindustry.entities.type.base"); unit = new UnitDef(mod + "-" + name, supply(type)); }else{ unit = locate(ContentType.unit, name); diff --git a/core/src/mindustry/net/Administration.java b/core/src/mindustry/net/Administration.java index cfd3423608..8da95c14cc 100644 --- a/core/src/mindustry/net/Administration.java +++ b/core/src/mindustry/net/Administration.java @@ -5,11 +5,11 @@ import arc.func.*; import arc.struct.*; import arc.util.ArcAnnotate.*; import arc.util.*; -import arc.util.pooling.*; import arc.util.pooling.Pool.*; +import arc.util.pooling.*; import mindustry.*; import mindustry.annotations.Annotations.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.type.*; import mindustry.world.*; @@ -31,7 +31,7 @@ public class Administration{ //anti-spam addChatFilter((player, message) -> { long resetTime = Config.messageRateLimit.num() * 1000; - if(Config.antiSpam.bool() && !player.isLocal && !player.isAdmin){ + if(Config.antiSpam.bool() && !player.isLocal() && !player.admin()){ //prevent people from spamming messages quickly if(resetTime > 0 && Time.timeSinceMillis(player.getInfo().lastMessageTime) < resetTime){ //supress message @@ -39,7 +39,7 @@ public class Administration{ player.getInfo().messageInfractions ++; //kick player for spamming and prevent connection if they've done this several times if(player.getInfo().messageInfractions >= Config.messageSpamKick.num() && Config.messageSpamKick.num() != 0){ - player.con.kick("You have been kicked for spamming.", 1000 * 60 * 2); + player.con().kick("You have been kicked for spamming.", 1000 * 60 * 2); } return null; }else{ @@ -86,7 +86,7 @@ public class Administration{ } /** Filters out a chat message. */ - public @Nullable String filterMessage(Player player, String message){ + public @Nullable String filterMessage(Playerc player, String message){ String current = message; for(ChatFilter f : chatFilters){ current = f.filter(player, message); @@ -101,7 +101,7 @@ public class Administration{ } /** @return whether this action is allowed by the action filters. */ - public boolean allowAction(Player player, ActionType type, Tile tile, Cons setter){ + public boolean allowAction(Playerc player, ActionType type, Tile tile, Cons setter){ PlayerAction act = Pools.obtain(PlayerAction.class, PlayerAction::new); setter.get(act.set(player, type, tile)); for(ActionFilter filter : actionFilters){ @@ -172,7 +172,7 @@ public class Administration{ getCreateInfo(id).banned = true; save(); - Events.fire(new PlayerBanEvent(Vars.playerGroup.find(p -> id.equals(p.uuid)))); + Events.fire(new PlayerBanEvent(Groups.player.find(p -> id.equals(p.uuid())))); return true; } @@ -212,7 +212,7 @@ public class Administration{ info.banned = false; bannedIPs.removeAll(info.ips, false); save(); - Events.fire(new PlayerUnbanEvent(Vars.playerGroup.find(p -> id.equals(p.uuid)))); + Events.fire(new PlayerUnbanEvent(Groups.player.find(p -> id.equals(p.uuid())))); return true; } @@ -515,7 +515,7 @@ public class Administration{ /** Handles chat messages from players and changes their contents. */ public interface ChatFilter{ /** @return the filtered message; a null string signals that the message should not be sent. */ - @Nullable String filter(Player player, String message); + @Nullable String filter(Playerc player, String message); } /** Allows or disallows player actions. */ @@ -539,7 +539,7 @@ public class Administration{ /** Defines a (potentially dangerous) action that a player has done in the world. * These objects are pooled; do not cache them! */ public static class PlayerAction implements Poolable{ - public @NonNull Player player; + public @NonNull Playerc player; public @NonNull ActionType type; public @NonNull Tile tile; @@ -554,7 +554,7 @@ public class Administration{ public @Nullable Item item; public int itemAmount; - public PlayerAction set(Player player, ActionType type, Tile tile){ + public PlayerAction set(Playerc player, ActionType type, Tile tile){ this.player = player; this.type = type; this.tile = tile; diff --git a/core/src/mindustry/net/CrashSender.java b/core/src/mindustry/net/CrashSender.java index bcc25cea43..52792e275d 100644 --- a/core/src/mindustry/net/CrashSender.java +++ b/core/src/mindustry/net/CrashSender.java @@ -118,7 +118,7 @@ public class CrashSender{ ex(() -> value.addChild("revision", new JsonValue(Version.revision))); ex(() -> value.addChild("net", new JsonValue(fn))); ex(() -> value.addChild("server", new JsonValue(fs))); - ex(() -> value.addChild("players", new JsonValue(Vars.playerGroup.size()))); + ex(() -> value.addChild("players", new JsonValue(Groups.player.size()))); ex(() -> value.addChild("state", new JsonValue(Vars.state.getState().name()))); ex(() -> value.addChild("os", new JsonValue(System.getProperty("os.name") + "x" + (OS.is64Bit ? "64" : "32")))); ex(() -> value.addChild("trace", new JsonValue(parseException(exception)))); diff --git a/core/src/mindustry/net/NetConnection.java b/core/src/mindustry/net/NetConnection.java index eb70783998..36555b4ac7 100644 --- a/core/src/mindustry/net/NetConnection.java +++ b/core/src/mindustry/net/NetConnection.java @@ -3,7 +3,6 @@ package mindustry.net; import arc.struct.*; import arc.util.ArcAnnotate.*; import arc.util.*; -import mindustry.entities.type.*; import mindustry.entities.units.*; import mindustry.gen.*; import mindustry.net.Administration.*; @@ -16,8 +15,9 @@ import static mindustry.Vars.netServer; public abstract class NetConnection{ public final String address; + public String uuid = "AAAAAAAA", usid = uuid; public boolean mobile, modclient; - public @Nullable Player player; + public @Nullable Playerc player; /** ID of last recieved client snapshot. */ public int lastRecievedClientSnapshot = -1; @@ -37,8 +37,8 @@ public abstract class NetConnection{ public void kick(KickReason reason){ Log.info("Kicking connection {0}; Reason: {1}", address, reason.name()); - if(player != null && (reason == KickReason.kick || reason == KickReason.banned || reason == KickReason.vote) && player.uuid != null){ - PlayerInfo info = netServer.admins.getInfo(player.uuid); + if((reason == KickReason.kick || reason == KickReason.banned || reason == KickReason.vote)){ + PlayerInfo info = netServer.admins.getInfo(uuid); info.timesKicked++; info.lastKicked = Math.max(Time.millis() + 30 * 1000, info.lastKicked); } @@ -59,11 +59,9 @@ public abstract class NetConnection{ public void kick(String reason, int kickDuration){ Log.info("Kicking connection {0}; Reason: {1}", address, reason.replace("\n", " ")); - if(player != null && player.uuid != null){ - PlayerInfo info = netServer.admins.getInfo(player.uuid); - info.timesKicked++; - info.lastKicked = Math.max(Time.millis() + kickDuration, info.lastKicked); - } + PlayerInfo info = netServer.admins.getInfo(uuid); + info.timesKicked++; + info.lastKicked = Math.max(Time.millis() + kickDuration, info.lastKicked); Call.onKick(this, reason); diff --git a/core/src/mindustry/net/NetworkIO.java b/core/src/mindustry/net/NetworkIO.java index 27811fed9f..3a7e67fe0f 100644 --- a/core/src/mindustry/net/NetworkIO.java +++ b/core/src/mindustry/net/NetworkIO.java @@ -2,7 +2,7 @@ package mindustry.net; import arc.util.*; import mindustry.core.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.game.*; import mindustry.io.*; import mindustry.maps.Map; @@ -16,7 +16,7 @@ import static mindustry.Vars.*; public class NetworkIO{ - public static void writeWorld(Player player, OutputStream os){ + public static void writeWorld(Playerc player, OutputStream os){ try(DataOutputStream stream = new DataOutputStream(os)){ stream.writeUTF(JsonIO.write(state.rules)); @@ -62,7 +62,7 @@ public class NetworkIO{ } public static ByteBuffer writeServerData(){ - String name = (headless ? Config.name.string() : player.name); + String name = (headless ? Config.name.string() : player.name()); String description = headless && !Config.desc.string().equals("off") ? Config.desc.string() : ""; String map = world.getMap() == null ? "None" : world.getMap().name(); @@ -71,7 +71,7 @@ public class NetworkIO{ writeString(buffer, name, 100); writeString(buffer, map); - buffer.putInt(playerGroup.size()); + buffer.putInt(Groups.player.size()); buffer.putInt(state.wave); buffer.putInt(Version.build); writeString(buffer, Version.type); diff --git a/core/src/mindustry/net/ValidateException.java b/core/src/mindustry/net/ValidateException.java index f1291212ab..12a4ae4bdc 100644 --- a/core/src/mindustry/net/ValidateException.java +++ b/core/src/mindustry/net/ValidateException.java @@ -1,14 +1,14 @@ package mindustry.net; -import mindustry.entities.type.Player; +import mindustry.gen.*; /** * Thrown when a client sends invalid information. */ public class ValidateException extends RuntimeException{ - public final Player player; + public final Playerc player; - public ValidateException(Player player, String s){ + public ValidateException(Playerc player, String s){ super(s); this.player = player; } diff --git a/core/src/mindustry/type/UnitDef.java b/core/src/mindustry/type/UnitDef.java index 2984a026e1..49a6d95f06 100644 --- a/core/src/mindustry/type/UnitDef.java +++ b/core/src/mindustry/type/UnitDef.java @@ -21,7 +21,7 @@ import mindustry.ui.*; //TODO change to UnitType or Shell or something public class UnitDef extends UnlockableContent{ //TODO implement - public @NonNull Prov constructor = () -> this.flying ? new FlyingUnit() : new GroundUnit(); + public @NonNull Prov constructor = () -> this.flying ? new FlyingUnit() : new GroundUnit(); public TypeID typeID; public boolean flying; @@ -57,8 +57,8 @@ public class UnitDef extends UnlockableContent{ typeID = new TypeID(name, constructor); } - public BaseUnit create(Team team){ - BaseUnit unit = constructor.get(); + public Unitc create(Team team){ + Unitc unit = constructor.get(); unit.init(this, team); return unit; } diff --git a/core/src/mindustry/type/Weather.java b/core/src/mindustry/type/Weather.java index eb0d9a9bda..f93b315b81 100644 --- a/core/src/mindustry/type/Weather.java +++ b/core/src/mindustry/type/Weather.java @@ -4,7 +4,7 @@ import arc.util.ArcAnnotate.*; import mindustry.annotations.Annotations.*; import mindustry.ctype.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.type.Weather.*; import java.io.*; diff --git a/core/src/mindustry/ui/dialogs/AdminsDialog.java b/core/src/mindustry/ui/dialogs/AdminsDialog.java index 4b9d23816d..8d9c40688e 100644 --- a/core/src/mindustry/ui/dialogs/AdminsDialog.java +++ b/core/src/mindustry/ui/dialogs/AdminsDialog.java @@ -41,7 +41,7 @@ public class AdminsDialog extends FloatingDialog{ res.addImageButton(Icon.cancel, () -> { ui.showConfirm("$confirm", "$confirmunadmin", () -> { netServer.admins.unAdminPlayer(info.id); - playerGroup.all().each(player -> { + Groups.player.all().each(player -> { if(player != null && player.uuid != null && player.uuid.equals(info.id)){ player.isAdmin = false; } diff --git a/core/src/mindustry/ui/dialogs/JoinDialog.java b/core/src/mindustry/ui/dialogs/JoinDialog.java index 99f1e9c5e2..80c22c3e7f 100644 --- a/core/src/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/mindustry/ui/dialogs/JoinDialog.java @@ -253,7 +253,7 @@ public class JoinDialog extends FloatingDialog{ Core.settings.save(); }).grow().pad(8).get().setMaxLength(maxNameLength); }else{ - t.add(player.name).update(l -> l.setColor(player.color)).grow().pad(8); + t.add(player.name()).update(l -> l.setColor(player.color)).grow().pad(8); } ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> { diff --git a/core/src/mindustry/ui/dialogs/TraceDialog.java b/core/src/mindustry/ui/dialogs/TraceDialog.java index 9d31780501..0857f2b50e 100644 --- a/core/src/mindustry/ui/dialogs/TraceDialog.java +++ b/core/src/mindustry/ui/dialogs/TraceDialog.java @@ -2,7 +2,7 @@ package mindustry.ui.dialogs; import arc.Core; import arc.scene.ui.layout.Table; -import mindustry.entities.type.Player; +import mindustry.gen.*; import mindustry.gen.*; import mindustry.net.Administration.TraceInfo; @@ -15,7 +15,7 @@ public class TraceDialog extends FloatingDialog{ setFillParent(false); } - public void show(Player player, TraceInfo info){ + public void show(Playerc player, TraceInfo info){ cont.clear(); Table table = new Table(Tex.clear); @@ -23,7 +23,7 @@ public class TraceDialog extends FloatingDialog{ table.defaults().pad(1); table.defaults().left(); - table.add(Core.bundle.format("trace.playername", player.name)); + table.add(Core.bundle.format("trace.playername", player.name())); table.row(); table.add(Core.bundle.format("trace.ip", info.ip)); table.row(); diff --git a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java index a8e3a219aa..11f4821592 100644 --- a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java @@ -16,7 +16,7 @@ import arc.util.*; import mindustry.annotations.Annotations.*; import mindustry.core.GameState.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.gen.*; import mindustry.net.Administration.*; @@ -37,7 +37,7 @@ public class BlockInventoryFragment extends Fragment{ private Item lastItem; @Remote(called = Loc.server, targets = Loc.both, forward = true) - public static void requestItem(Player player, Tile tile, Item item, int amount){ + public static void requestItem(Playerc player, Tile tile, Item item, int amount){ if(player == null || tile == null || !tile.interactable(player.team())) return; amount = Mathf.clamp(amount, 0, player.ttemCapacity()); int fa = amount; diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 0f854b14c2..b8ee871f26 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -20,7 +20,7 @@ import mindustry.core.GameState.*; import mindustry.ctype.ContentType; import mindustry.ctype.UnlockableContent; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.game.*; import mindustry.game.EventType.*; import mindustry.gen.*; @@ -209,9 +209,9 @@ public class HudFragment extends Fragment{ if(e == null){ Vec2 world = Core.input.mouseWorld(); Units.nearby(world.x, world.y, 1f, 1f, unit -> { - if(!found[0] && unit instanceof BaseUnit){ + if(!found[0] && unit instanceof Unitc){ if(Core.input.keyTap(KeyCode.MOUSE_LEFT)){ - Call.removeUnitEditor(player, (BaseUnit)unit); + Call.removeUnitEditor(player, (Unitc)unit); } found[0] = true; unit.hitbox(Tmp.r1); @@ -344,16 +344,16 @@ public class HudFragment extends Fragment{ } @Remote(targets = Loc.both, forward = true, called = Loc.both) - public static void setPlayerTeamEditor(Player player, Team team){ + public static void setPlayerTeamEditor(Playerc player, Team team){ if(state.isEditor() && player != null){ player.team(team); } } @Remote(targets = Loc.both, called = Loc.server) - public static void spawnUnitEditor(Player player, UnitType type){ + public static void spawnUnitEditor(Playerc player, UnitType type){ if(state.isEditor()){ - BaseUnit unit = type.create(player.team()); + Unitc unit = type.create(player.team()); unit.set(player.x, player.y); unit.rotation = player.rotation; unit.add(); @@ -361,7 +361,7 @@ public class HudFragment extends Fragment{ } @Remote(targets = Loc.both, called = Loc.server, forward = true) - public static void removeUnitEditor(Player player, BaseUnit unit){ + public static void removeUnitEditor(Playerc player, Unitc unit){ if(state.isEditor() && unit != null){ unit.remove(); } diff --git a/core/src/mindustry/ui/fragments/PlayerListFragment.java b/core/src/mindustry/ui/fragments/PlayerListFragment.java index 9f9740d0f9..8b9c497c86 100644 --- a/core/src/mindustry/ui/fragments/PlayerListFragment.java +++ b/core/src/mindustry/ui/fragments/PlayerListFragment.java @@ -41,7 +41,7 @@ public class PlayerListFragment extends Fragment{ }); cont.table(Tex.buttonTrans, pane -> { - pane.label(() -> Core.bundle.format(playerGroup.size() == 1 ? "players.single" : "players", playerGroup.size())); + pane.label(() -> Core.bundle.format(Groups.player.size() == 1 ? "players.single" : "players", Groups.player.size())); pane.row(); pane.pane(content).grow().get().setScrollingDisabled(true, false); pane.row(); @@ -65,8 +65,8 @@ public class PlayerListFragment extends Fragment{ float h = 74f; - playerGroup.all().sort(Structs.comparing(Unitc::team)); - playerGroup.all().each(user -> { + Groups.player.all().sort(Structs.comparing(Unitc::team)); + Groups.player.all().each(user -> { NetConnection connection = user.con; if(connection == null && net.server() && !user.isLocal) return; @@ -129,7 +129,7 @@ public class PlayerListFragment extends Fragment{ t.addImageButton(Icon.zoom, Styles.clearPartiali, () -> Call.onAdminRequest(user, AdminAction.trace)); }).padRight(12).size(bs + 10f, bs); - }else if(!user.isLocal && !user.isAdmin && net.client() && playerGroup.size() >= 3 && player.team() == user.getTeam()){ //votekick + }else if(!user.isLocal && !user.isAdmin && net.client() && Groups.player.size() >= 3 && player.team() == user.getTeam()){ //votekick button.add().growY(); button.addImageButton(Icon.hammer, Styles.clearPartiali, diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 2a41af4c3b..61d34280b7 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -20,7 +20,7 @@ import mindustry.annotations.Annotations.*; import mindustry.ctype.*; import mindustry.entities.*; import mindustry.entities.effect.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.gen.*; import mindustry.graphics.*; @@ -467,12 +467,12 @@ public class Block extends BlockStorage{ } /** Called when the block is tapped. */ - public void tapped(Tile tile, Player player){ + public void tapped(Tile tile, Playerc player){ } /** Called when arbitrary configuration is applied to a tile. */ - public void configured(Tile tile, @Nullable Player player, int value){ + public void configured(Tile tile, @Nullable Playerc player, int value){ } @@ -503,12 +503,12 @@ public class Block extends BlockStorage{ } /** Returns whether this config menu should show when the specified player taps it. */ - public boolean shouldShowConfigure(Tile tile, Player player){ + public boolean shouldShowConfigure(Tile tile, Playerc player){ return true; } /** Whether this configuration should be hidden now. Called every frame the config is open. */ - public boolean shouldHideConfigure(Tile tile, Player player){ + public boolean shouldHideConfigure(Tile tile, Playerc player){ return false; } diff --git a/core/src/mindustry/world/blocks/BuildBlock.java b/core/src/mindustry/world/blocks/BuildBlock.java index 0b097ec8b6..7e0270650c 100644 --- a/core/src/mindustry/world/blocks/BuildBlock.java +++ b/core/src/mindustry/world/blocks/BuildBlock.java @@ -9,7 +9,7 @@ import arc.math.*; import arc.util.ArcAnnotate.*; import arc.util.*; import mindustry.content.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.game.EventType.*; @@ -55,7 +55,7 @@ public class BuildBlock extends Block{ public static void onDeconstructFinish(Tile tile, Block block, int builderID){ Team team = tile.getTeam(); Fx.breakBlock.at(tile.drawx(), tile.drawy(), block.size); - Events.fire(new BlockBuildEndEvent(tile, playerGroup.getByID(builderID), team, true)); + Events.fire(new BlockBuildEndEvent(tile, Groups.player.getByID(builderID), team, true)); tile.remove(); if(shouldPlay()) Sounds.breaks.at(tile, calcPitch(false)); } @@ -105,7 +105,7 @@ public class BuildBlock extends Block{ Call.onConstructFinish(tile, block, builderID, rotation, team, skipConfig); tile.block().placed(tile); - Events.fire(new BlockBuildEndEvent(tile, playerGroup.getByID(builderID), team, false)); + Events.fire(new BlockBuildEndEvent(tile, Groups.player.getByID(builderID), team, false)); if(shouldPlay()) Sounds.place.at(tile, calcPitch(true)); } @@ -138,7 +138,7 @@ public class BuildBlock extends Block{ } @Override - public void tapped(Tile tile, Player player){ + public void tapped(Tile tile, Playerc player){ BuildEntity entity = tile.ent(); //if the target is constructible, begin constructing @@ -279,7 +279,7 @@ public class BuildBlock extends Block{ progress = Mathf.clamp(progress - amount); - if(builder instanceof Player){ + if(builder instanceof Playerc){ builderID = builder.getID(); } diff --git a/core/src/mindustry/world/blocks/RespawnBlock.java b/core/src/mindustry/world/blocks/RespawnBlock.java index b27b0af621..81b460f14e 100644 --- a/core/src/mindustry/world/blocks/RespawnBlock.java +++ b/core/src/mindustry/world/blocks/RespawnBlock.java @@ -2,9 +2,8 @@ package mindustry.world.blocks; import arc.graphics.g2d.*; import arc.math.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.graphics.*; -import mindustry.type.*; import mindustry.ui.*; import mindustry.world.*; @@ -12,7 +11,7 @@ import static mindustry.Vars.net; public class RespawnBlock{ - public static void drawRespawn(Tile tile, float heat, float progress, float time, Player player, Mech to){ + public static void drawRespawn(Tile tile, float heat, float progress, float time, Playerc player, Mech to){ progress = Mathf.clamp(progress); Draw.color(Pal.darkMetal); @@ -67,7 +66,7 @@ public class RespawnBlock{ Draw.reset(); if(net.active() && player != null){ - tile.block().drawPlaceText(player.name, tile.x, tile.y - (Math.max((tile.block().size-1)/2, 0)), true); + tile.block().drawPlaceText(player.name(), tile.x, tile.y - (Math.max((tile.block().size-1)/2, 0)), true); } } } diff --git a/core/src/mindustry/world/blocks/defense/DeflectorWall.java b/core/src/mindustry/world/blocks/defense/DeflectorWall.java index 7c93fcdf54..2c96cb44db 100644 --- a/core/src/mindustry/world/blocks/defense/DeflectorWall.java +++ b/core/src/mindustry/world/blocks/defense/DeflectorWall.java @@ -50,7 +50,7 @@ public class DeflectorWall extends Wall{ bullet.hitbox(rect2); - Vec2 position = Geometry.raycastRect(bullet.x - bullet.velocity().x*Time.delta(), bullet.y - bullet.velocity().y*Time.delta(), bullet.x + bullet.velocity().x*Time.delta(), bullet.y + bullet.velocity().y*Time.delta(), + Vec2 position = Geometry.raycastRect(bullet.x - bullet.vel().x*Time.delta(), bullet.y - bullet.vel().y*Time.delta(), bullet.x + bullet.vel().x*Time.delta(), bullet.y + bullet.vel().y*Time.delta(), rect.setSize(size * tilesize + rect2.width*2 + rect2.height*2).setCenter(entity.getX(), entity.getY())); if(position != null){ @@ -58,9 +58,9 @@ public class DeflectorWall extends Wall{ } if(penX > penY){ - bullet.velocity().x *= -1; + bullet.vel().x *= -1; }else{ - bullet.velocity().y *= -1; + bullet.vel().y *= -1; } //bullet.updateVelocity(); diff --git a/core/src/mindustry/world/blocks/defense/Door.java b/core/src/mindustry/world/blocks/defense/Door.java index 3783ea7a25..de5a409736 100644 --- a/core/src/mindustry/world/blocks/defense/Door.java +++ b/core/src/mindustry/world/blocks/defense/Door.java @@ -8,7 +8,6 @@ import arc.graphics.g2d.*; import arc.math.geom.*; import mindustry.content.*; import mindustry.entities.*; -import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.gen.*; import mindustry.world.*; @@ -35,7 +34,7 @@ public class Door extends Wall{ } @Remote(called = Loc.server) - public static void onDoorToggle(Player player, Tile tile, boolean open){ + public static void onDoorToggle(Playerc player, Tile tile, boolean open){ DoorEntity entity = tile.ent(); if(entity != null){ entity.open = open; @@ -80,7 +79,7 @@ public class Door extends Wall{ } @Override - public void tapped(Tile tile, Player player){ + public void tapped(Tile tile, Playerc player){ DoorEntity entity = tile.ent(); if((Units.anyEntities(tile) && entity.open) || !tile.entity.timer(timerToggle, 30f)){ diff --git a/core/src/mindustry/world/blocks/defense/SurgeWall.java b/core/src/mindustry/world/blocks/defense/SurgeWall.java index f495beb94b..282c1fbbdc 100644 --- a/core/src/mindustry/world/blocks/defense/SurgeWall.java +++ b/core/src/mindustry/world/blocks/defense/SurgeWall.java @@ -18,7 +18,7 @@ public class SurgeWall extends Wall{ public void handleBulletHit(Tilec entity, Bullet bullet){ super.handleBulletHit(entity, bullet); if(Mathf.chance(lightningChance)){ - Lightning.create(entity.team(), Pal.surge, lightningDamage, bullet.x, bullet.y, bullet.rot() + 180f, lightningLength); + Lightning.create(entity.team(), Pal.surge, lightningDamage, bullet.x, bullet.y, bullet.rotation() + 180f, lightningLength); } } } diff --git a/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java b/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java index 03ed62b75f..355184dc1c 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java @@ -6,7 +6,7 @@ import arc.scene.ui.layout.*; import mindustry.*; import mindustry.content.*; import mindustry.entities.bullet.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.graphics.*; import mindustry.type.*; diff --git a/core/src/mindustry/world/blocks/distribution/BufferedItemBridge.java b/core/src/mindustry/world/blocks/distribution/BufferedItemBridge.java index 8240d2db25..87e7ce7e1e 100644 --- a/core/src/mindustry/world/blocks/distribution/BufferedItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/BufferedItemBridge.java @@ -23,8 +23,8 @@ public class BufferedItemBridge extends ExtendingItemBridge{ public void updateTransport(Tile tile, Tile other){ BufferedItemBridgeEntity entity = tile.ent(); - if(entity.buffer.accepts() && entity.getItems().total() > 0){ - entity.buffer.accept(entity.getItems().take()); + if(entity.buffer.accepts() && entity.items().total() > 0){ + entity.buffer.accept(entity.items().take()); } Item item = entity.buffer.poll(); diff --git a/core/src/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/mindustry/world/blocks/distribution/ItemBridge.java index dab5bf0189..64d0ab2b49 100644 --- a/core/src/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ItemBridge.java @@ -8,7 +8,7 @@ import arc.graphics.g2d.*; import arc.math.*; import arc.math.geom.*; import arc.util.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.graphics.*; import mindustry.type.*; @@ -45,7 +45,7 @@ public class ItemBridge extends Block{ } @Override - public void configured(Tile tile, Player player, int value){ + public void configured(Tile tile, Playerc player, int value){ tile.ent().link = value; } @@ -201,13 +201,13 @@ public class ItemBridge extends Block{ ItemBridgeEntity entity = tile.ent(); if(entity.uptime >= 0.5f && entity.timer(timerTransport, transportTime)){ - Item item = entity.getItems().take(); + Item item = entity.items().take(); if(item != null && other.block().acceptItem(item, other, tile)){ other.block().handleItem(item, other, tile); entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 4f, 0.05f); }else{ entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 1f, 0.01f); - if(item != null) entity.getItems().add(item, 1); + if(item != null) entity.items().add(item, 1); } } } diff --git a/core/src/mindustry/world/blocks/distribution/MassDriver.java b/core/src/mindustry/world/blocks/distribution/MassDriver.java index 5ae1ecc88c..9ca21ba8c2 100644 --- a/core/src/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/mindustry/world/blocks/distribution/MassDriver.java @@ -9,7 +9,7 @@ import arc.util.pooling.Pool.*; import arc.util.pooling.*; import mindustry.content.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; import mindustry.world.*; @@ -45,7 +45,7 @@ public class MassDriver extends Block{ } @Override - public void configured(Tile tile, Player player, int value){ + public void configured(Tile tile, Playerc player, int value){ tile.ent().link = value; } @@ -80,7 +80,7 @@ public class MassDriver extends Block{ //switch states if(entity.state == DriverState.idle){ //start accepting when idle and there's space - if(!entity.waitingShooters.isEmpty() && (itemCapacity - entity.getItems().total() >= minDistribute)){ + if(!entity.waitingShooters.isEmpty() && (itemCapacity - entity.items().total() >= minDistribute)){ entity.state = DriverState.accepting; }else if(hasLink){ //switch to shooting if there's a valid link. entity.state = DriverState.shooting; @@ -99,7 +99,7 @@ public class MassDriver extends Block{ if(entity.state == DriverState.accepting){ //if there's nothing shooting at this, bail - OR, items full - if(entity.currentShooter() == null || (itemCapacity - entity.getItems().total() < minDistribute)){ + if(entity.currentShooter() == null || (itemCapacity - entity.items().total() < minDistribute)){ entity.state = DriverState.idle; return; } @@ -108,7 +108,7 @@ public class MassDriver extends Block{ entity.rotation = Mathf.slerpDelta(entity.rotation, tile.angleTo(entity.currentShooter()), rotateSpeed * entity.efficiency()); }else if(entity.state == DriverState.shooting){ //if there's nothing to shoot at OR someone wants to shoot at this thing, bail - if(!hasLink || (!entity.waitingShooters.isEmpty() && (itemCapacity - entity.getItems().total() >= minDistribute))){ + if(!hasLink || (!entity.waitingShooters.isEmpty() && (itemCapacity - entity.items().total() >= minDistribute))){ entity.state = DriverState.idle; return; } @@ -240,10 +240,10 @@ public class MassDriver extends Block{ data.to = other; int totalUsed = 0; for(int i = 0; i < content.items().size; i++){ - int maxTransfer = Math.min(entity.getItems().get(content.item(i)), ((MassDriver)tile.block()).itemCapacity - totalUsed); + int maxTransfer = Math.min(entity.items().get(content.item(i)), ((MassDriver)tile.block()).itemCapacity - totalUsed); data.items[i] = maxTransfer; totalUsed += maxTransfer; - entity.getItems().remove(content.item(i), maxTransfer); + entity.items().remove(content.item(i), maxTransfer); } float angle = tile.angleTo(target); @@ -262,12 +262,12 @@ public class MassDriver extends Block{ } protected void handlePayload(MassDriverEntity entity, Bullet bullet, DriverBulletData data){ - int totalItems = entity.getItems().total(); + int totalItems = entity.items().total(); //add all the items possible for(int i = 0; i < data.items.length; i++){ int maxAdd = Math.min(data.items[i], itemCapacity * 2 - totalItems); - entity.getItems().add(content.item(i), maxAdd); + entity.items().add(content.item(i), maxAdd); data.items[i] -= maxAdd; totalItems += maxAdd; diff --git a/core/src/mindustry/world/blocks/distribution/Sorter.java b/core/src/mindustry/world/blocks/distribution/Sorter.java index 41b5359f07..3a5bf8e89b 100644 --- a/core/src/mindustry/world/blocks/distribution/Sorter.java +++ b/core/src/mindustry/world/blocks/distribution/Sorter.java @@ -5,7 +5,7 @@ import arc.math.*; import arc.scene.ui.layout.*; import arc.util.ArcAnnotate.*; import arc.util.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.type.*; import mindustry.world.*; @@ -44,7 +44,7 @@ public class Sorter extends Block{ } @Override - public void configured(Tile tile, Player player, int value){ + public void configured(Tile tile, Playerc player, int value){ tile.ent().sortItem = content.item(value); } diff --git a/core/src/mindustry/world/blocks/logic/MessageBlock.java b/core/src/mindustry/world/blocks/logic/MessageBlock.java index 49fcc287f0..3fdc47cf09 100644 --- a/core/src/mindustry/world/blocks/logic/MessageBlock.java +++ b/core/src/mindustry/world/blocks/logic/MessageBlock.java @@ -11,7 +11,6 @@ import arc.scene.ui.layout.*; import arc.util.*; import arc.util.pooling.*; import mindustry.entities.*; -import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.gen.*; import mindustry.net.*; @@ -36,7 +35,7 @@ public class MessageBlock extends Block{ } @Remote(targets = Loc.both, called = Loc.both, forward = true) - public static void setMessageBlockText(Player player, Tile tile, String text){ + public static void setMessageBlockText(Playerc player, Tile tile, String text){ if(!Units.canInteract(player, tile)) return; if(net.server() && text.length() > maxTextLength){ throw new ValidateException(player, "Player has gone above text limit."); diff --git a/core/src/mindustry/world/blocks/power/LightBlock.java b/core/src/mindustry/world/blocks/power/LightBlock.java index 69d30d4de7..6720331e2e 100644 --- a/core/src/mindustry/world/blocks/power/LightBlock.java +++ b/core/src/mindustry/world/blocks/power/LightBlock.java @@ -4,7 +4,6 @@ import arc.graphics.*; import arc.graphics.g2d.*; import arc.scene.ui.layout.*; import arc.util.*; -import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.gen.*; import mindustry.graphics.*; @@ -63,7 +62,7 @@ public class LightBlock extends Block{ } @Override - public void configured(Tile tile, Player player, int value){ + public void configured(Tile tile, Playerc player, int value){ tile.ent().color = value; } diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index 4b61227ab9..740956d5d1 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -9,7 +9,7 @@ import arc.math.*; import arc.math.geom.*; import arc.util.*; import arc.util.ArcAnnotate.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.graphics.*; import mindustry.ui.*; import mindustry.world.*; @@ -38,7 +38,7 @@ public class PowerNode extends PowerBlock{ } @Override - public void configured(Tile tile, Player player, int value){ + public void configured(Tile tile, Playerc player, int value){ Tilec entity = tile.entity; Tile other = world.tile(value); boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.power() != null; diff --git a/core/src/mindustry/world/blocks/production/Cultivator.java b/core/src/mindustry/world/blocks/production/Cultivator.java index 2e7715d183..e8dd4d05b4 100644 --- a/core/src/mindustry/world/blocks/production/Cultivator.java +++ b/core/src/mindustry/world/blocks/production/Cultivator.java @@ -6,7 +6,7 @@ import arc.graphics.g2d.*; import arc.math.*; import arc.util.*; import mindustry.content.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.graphics.*; import mindustry.ui.*; import mindustry.world.*; diff --git a/core/src/mindustry/world/blocks/sandbox/ItemSource.java b/core/src/mindustry/world/blocks/sandbox/ItemSource.java index 47c491d1a5..2135b3e5e0 100644 --- a/core/src/mindustry/world/blocks/sandbox/ItemSource.java +++ b/core/src/mindustry/world/blocks/sandbox/ItemSource.java @@ -4,7 +4,7 @@ import arc.*; import arc.graphics.g2d.*; import arc.scene.ui.layout.*; import arc.util.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.type.*; import mindustry.world.*; @@ -29,7 +29,7 @@ public class ItemSource extends Block{ } @Override - public void configured(Tile tile, Player player, int value){ + public void configured(Tile tile, Playerc player, int value){ tile.ent().outputItem = content.item(value); } @@ -73,9 +73,9 @@ public class ItemSource extends Block{ ItemSourceEntity entity = tile.ent(); if(entity.outputItem == null) return; - entity.getItems().set(entity.outputItem, 1); + entity.items().set(entity.outputItem, 1); tryDump(tile, entity.outputItem); - entity.getItems().set(entity.outputItem, 0); + entity.items().set(entity.outputItem, 0); } @Override diff --git a/core/src/mindustry/world/blocks/sandbox/LiquidSource.java b/core/src/mindustry/world/blocks/sandbox/LiquidSource.java index 98019ffd27..5dee8b94d8 100644 --- a/core/src/mindustry/world/blocks/sandbox/LiquidSource.java +++ b/core/src/mindustry/world/blocks/sandbox/LiquidSource.java @@ -8,7 +8,7 @@ import arc.scene.ui.*; import arc.scene.ui.layout.*; import arc.util.*; import arc.util.ArcAnnotate.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.type.*; @@ -108,7 +108,7 @@ public class LiquidSource extends Block{ } @Override - public void configured(Tile tile, Player player, int value){ + public void configured(Tile tile, Playerc player, int value){ tile.ent().source = value == -1 ? null : content.liquid(value); } diff --git a/core/src/mindustry/world/blocks/storage/CoreBlock.java b/core/src/mindustry/world/blocks/storage/CoreBlock.java index a9b1bd41b8..5336e12f64 100644 --- a/core/src/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/mindustry/world/blocks/storage/CoreBlock.java @@ -8,7 +8,7 @@ import arc.graphics.g2d.*; import arc.math.*; import arc.math.geom.*; import mindustry.content.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.graphics.*; @@ -22,7 +22,7 @@ import mindustry.world.modules.*; import static mindustry.Vars.*; public class CoreBlock extends StorageBlock{ - public Mech mech = Mechs.starter; + public UnitDef mech = UnitTypes.starter; public CoreBlock(String name){ super(name); @@ -38,15 +38,16 @@ public class CoreBlock extends StorageBlock{ } @Remote(called = Loc.server) - public static void onUnitRespawn(Tile tile, Player player){ + public static void onUnitRespawn(Tile tile, Playerc player){ if(player == null || tile.entity == null) return; CoreEntity entity = tile.ent(); Fx.spawn.at(entity); entity.progress = 0; entity.spawnPlayer = player; - entity.spawnPlayer.onRespawn(tile); - entity.spawnPlayer.applyImpulse(0, 8f); + //TODO fix + //entity.spawnPlayer.onRespawn(tile); + //entity.spawnPlayer.applyImpulse(0, 8f); entity.spawnPlayer = null; } @@ -58,7 +59,7 @@ public class CoreBlock extends StorageBlock{ new Bar( () -> Core.bundle.format("bar.capacity", ui.formatAmount(((CoreEntity)e).storageCapacity)), () -> Pal.items, - () -> e.items.total() / (float)(((CoreEntity)e).storageCapacity * content.items().count(i -> i.type == ItemType.material)) + () -> e.items().total() / (float)(((CoreEntity)e).storageCapacity * content.items().count(i -> i.type == ItemType.material)) )); } @@ -83,21 +84,21 @@ public class CoreBlock extends StorageBlock{ CoreEntity entity = tile.ent(); for(Tilec other : state.teams.cores(tile.getTeam())){ - if(other.tile != tile){ - entity.items() = other.items; + if(other.tile() != tile){ + entity.items(other.items()); } } state.teams.registerCore(entity); entity.storageCapacity = itemCapacity + entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0); entity.proximity().each(this::isContainer, t -> { - t.entity.items() = entity.items(); + t.entity.items(entity.items()); t.ent().linkedCore = tile; }); for(Tilec other : state.teams.cores(tile.getTeam())){ - if(other.tile == tile) continue; - entity.storageCapacity += other.block.itemCapacity + other.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0); + if(other.tile() == tile) continue; + entity.storageCapacity += other.block().itemCapacity + other.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0); } if(!world.isGenerating()){ @@ -135,9 +136,10 @@ public class CoreBlock extends StorageBlock{ @Override public float handleDamage(Tile tile, float amount){ - if(player != null && tile.getTeam() == player.team()){ - Events.fire(Trigger.teamCoreDamage); - } + //TODO implement + //if(player != null && tile.getTeam() == player.team()){ + // Events.fire(Trigger.teamCoreDamage); + //} return amount; } @@ -155,9 +157,9 @@ public class CoreBlock extends StorageBlock{ tile.entity.proximity().each(e -> isContainer(e) && e.entity.items() == tile.entity.items(), t -> { StorageBlockEntity ent = (StorageBlockEntity)t.entity; ent.linkedCore = null; - ent.items = new ItemModule(); + ent.items(new ItemModule()); for(Item item : content.items()){ - ent.items.set(item, (int)(fract * tile.entity.items().get(item))); + ent.items().set(item, (int)(fract * tile.entity.items().get(item))); } }); @@ -169,7 +171,7 @@ public class CoreBlock extends StorageBlock{ } for(CoreEntity other : state.teams.cores(tile.getTeam())){ - other.block.onProximityUpdate(other.tile); + other.block().onProximityUpdate(other.tile()); } } @@ -185,7 +187,8 @@ public class CoreBlock extends StorageBlock{ CoreEntity entity = tile.ent(); if(entity.heat > 0.001f){ - RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.spawnPlayer, mech); + //TODO implement + //RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.spawnPlayer, mech); } } @@ -203,6 +206,8 @@ public class CoreBlock extends StorageBlock{ public void update(Tile tile){ CoreEntity entity = tile.ent(); + //TODO implement + /* if(entity.spawnPlayer != null){ if(!entity.spawnPlayer.dead() || !entity.spawnPlayer.isAdded()){ entity.spawnPlayer = null; @@ -219,7 +224,7 @@ public class CoreBlock extends StorageBlock{ } }else{ entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.1f); - } + }*/ } @Override @@ -229,26 +234,11 @@ public class CoreBlock extends StorageBlock{ return entity.spawnPlayer != null; } - public class CoreEntity extends Tilec implements SpawnerTrait{ - protected Player spawnPlayer; + public class CoreEntity extends Tilec{ + protected Playerc spawnPlayer; protected float progress; protected float time; protected float heat; protected int storageCapacity; - - @Override - public boolean hasUnit(Unitc unit){ - return unit == spawnPlayer; - } - - @Override - public void updateSpawning(Player player){ - if(!netServer.isWaitingForPlayers() && spawnPlayer == null){ - spawnPlayer = player; - progress = 0f; - player.mech = mech; - player.beginRespawning(this); - } - } } } diff --git a/core/src/mindustry/world/blocks/storage/Unloader.java b/core/src/mindustry/world/blocks/storage/Unloader.java index 5de19bc053..ae06bb5e58 100644 --- a/core/src/mindustry/world/blocks/storage/Unloader.java +++ b/core/src/mindustry/world/blocks/storage/Unloader.java @@ -4,7 +4,7 @@ import arc.graphics.*; import arc.graphics.g2d.*; import arc.scene.ui.layout.*; import arc.util.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.type.*; import mindustry.world.*; @@ -54,7 +54,7 @@ public class Unloader extends Block{ } @Override - public void configured(Tile tile, Player player, int value){ + public void configured(Tile tile, Playerc player, int value){ tile.entity.items().clear(); tile.ent().sortItem = content.item(value); } @@ -65,14 +65,14 @@ public class Unloader extends Block{ if(tile.entity.timer(timerUnload, speed / entity.timeScale) && tile.entity.items().total() == 0){ for(Tile other : tile.entity.proximity()){ - if(other.interactable(tile.getTeam()) && other.block().unloadable && other.block().hasItems && entity.getItems().total() == 0 && + if(other.interactable(tile.getTeam()) && other.block().unloadable && other.block().hasItems && entity.items().total() == 0 && ((entity.sortItem == null && other.entity.items().total() > 0) || hasItem(other, entity.sortItem))){ offloadNear(tile, removeItem(other, entity.sortItem)); } } } - if(entity.getItems().total() > 0){ + if(entity.items().total() > 0){ tryDump(tile); } } @@ -85,10 +85,10 @@ public class Unloader extends Block{ Tilec entity = tile.entity; if(item == null){ - return entity.getItems().take(); + return entity.items().take(); }else{ - if(entity.getItems().has(item)){ - entity.getItems().remove(item, 1); + if(entity.items().has(item)){ + entity.items().remove(item, 1); return item; } @@ -103,9 +103,9 @@ public class Unloader extends Block{ private boolean hasItem(Tile tile, Item item){ Tilec entity = tile.entity; if(item == null){ - return entity.getItems().total() > 0; + return entity.items().total() > 0; }else{ - return entity.getItems().has(item); + return entity.items().has(item); } } diff --git a/core/src/mindustry/world/blocks/units/CommandCenter.java b/core/src/mindustry/world/blocks/units/CommandCenter.java index 38b9dfef1b..b200429fb2 100644 --- a/core/src/mindustry/world/blocks/units/CommandCenter.java +++ b/core/src/mindustry/world/blocks/units/CommandCenter.java @@ -10,7 +10,7 @@ import arc.struct.*; import arc.util.*; import mindustry.content.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.game.EventType.*; import mindustry.graphics.*; @@ -102,7 +102,7 @@ public class CommandCenter extends Block{ } @Override - public void configured(Tile tile, Player player, int value){ + public void configured(Tile tile, Playerc player, int value){ UnitCommand command = UnitCommand.all[value]; ((CommandCenter)tile.block()).effect.at(tile); diff --git a/core/src/mindustry/world/blocks/units/MechPad.java b/core/src/mindustry/world/blocks/units/MechPad.java index 557cd4387d..51dc1292c4 100644 --- a/core/src/mindustry/world/blocks/units/MechPad.java +++ b/core/src/mindustry/world/blocks/units/MechPad.java @@ -9,10 +9,11 @@ import arc.math.geom.*; import arc.util.*; import arc.util.ArcAnnotate.*; import mindustry.content.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.graphics.*; +import mindustry.type.*; import mindustry.world.*; import mindustry.world.blocks.*; import mindustry.world.meta.*; @@ -22,7 +23,7 @@ import java.io.*; import static mindustry.Vars.*; public class MechPad extends Block{ - public @NonNull Mech mech; + public @NonNull UnitDef mech; public float buildTime = 60 * 5; public MechPad(String name){ @@ -43,7 +44,7 @@ public class MechPad extends Block{ } @Remote(targets = Loc.both, called = Loc.server) - public static void onMechFactoryTap(Player player, Tile tile){ + public static void onMechFactoryTap(Playerc player, Tile tile){ if(player == null || tile == null || !(tile.block() instanceof MechPad) || !checkValidTap(tile, player)) return; MechFactoryEntity entity = tile.ent(); @@ -64,9 +65,9 @@ public class MechPad extends Block{ if(entity.player == null) return; Mech mech = ((MechPad)tile.block()).mech; boolean resetSpawner = !entity.sameMech && entity.player.mech == mech; - entity.player.mech = !entity.sameMech && entity.player.mech == mech ? Mechs.starter : mech; + entity.player.mech = !entity.sameMech && entity.player.mech == mech ? UnitTypes.starter : mech; - Player player = entity.player; + Playerc player = entity.player; entity.progress = 0; entity.player.onRespawn(tile); @@ -76,7 +77,7 @@ public class MechPad extends Block{ Events.fire(new MechChangeEvent(player, player.mech)); } - protected static boolean checkValidTap(Tile tile, Player player){ + protected static boolean checkValidTap(Tile tile, Playerc player){ MechFactoryEntity entity = tile.ent(); return !player.dead() && tile.interactable(player.team()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize && Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize && entity.consValid() && entity.player == null; @@ -93,12 +94,12 @@ public class MechPad extends Block{ } @Override - public void tapped(Tile tile, Player player){ + public void tapped(Tile tile, Playerc player){ MechFactoryEntity entity = tile.ent(); if(checkValidTap(tile, player)){ Call.onMechFactoryTap(player, tile); - }else if(player.isLocal && mobile && !player.dead() && entity.consValid() && entity.player == null){ + }else if(player.isLocal() && mobile && !player.dead() && entity.consValid() && entity.player == null){ //deselect on double taps player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity; } @@ -109,7 +110,7 @@ public class MechPad extends Block{ MechFactoryEntity entity = tile.ent(); if(entity.player != null){ - RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.player, (!entity.sameMech && entity.player.mech == mech ? Mechs.starter : mech)); + RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.player, (!entity.sameMech && entity.player.mech == mech ? UnitTypes.starter : mech)); } } @@ -133,7 +134,7 @@ public class MechPad extends Block{ } public class MechFactoryEntity extends Tilec implements SpawnerTrait{ - Player player; + Playerc player; boolean sameMech; float progress; float time; @@ -145,7 +146,7 @@ public class MechPad extends Block{ } @Override - public void updateSpawning(Player unit){ + public void updateSpawning(Playerc unit){ if(player == null){ progress = 0f; player = unit; diff --git a/core/src/mindustry/world/blocks/units/UnitFactory.java b/core/src/mindustry/world/blocks/units/UnitFactory.java index 0348494422..7084345243 100644 --- a/core/src/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/mindustry/world/blocks/units/UnitFactory.java @@ -1,33 +1,27 @@ package mindustry.world.blocks.units; import arc.*; -import mindustry.annotations.Annotations.Loc; -import mindustry.annotations.Annotations.Remote; -import arc.struct.EnumSet; import arc.graphics.g2d.*; -import arc.math.Mathf; -import mindustry.Vars; -import mindustry.content.Fx; -import mindustry.entities.Effects; -import mindustry.entities.type.*; -import mindustry.game.EventType.*; -import mindustry.gen.Call; -import mindustry.graphics.Pal; -import mindustry.graphics.Shaders; +import arc.math.*; +import arc.struct.*; +import mindustry.*; +import mindustry.annotations.Annotations.*; +import mindustry.content.*; +import mindustry.entities.*; +import mindustry.gen.*; +import mindustry.graphics.*; import mindustry.type.*; -import mindustry.ui.Bar; -import mindustry.ui.Cicon; -import mindustry.world.Block; -import mindustry.world.Tile; -import mindustry.world.consumers.ConsumeItems; -import mindustry.world.consumers.ConsumeType; +import mindustry.ui.*; +import mindustry.world.*; +import mindustry.world.consumers.*; import mindustry.world.meta.*; import java.io.*; -import static mindustry.Vars.*; + +import static mindustry.Vars.net; public class UnitFactory extends Block{ - public UnitType unitType; + public UnitDef unitType; public float produceTime = 1000f; public float launchVelocity = 0f; public TextureRegion topRegion; @@ -58,12 +52,14 @@ public class UnitFactory extends Block{ Fx.producesmoke.at(tile.drawx(), tile.drawy()); if(!net.client()){ - BaseUnit unit = factory.unitType.create(tile.getTeam()); + //TODO create the unit + /* + Unitc unit = factory.unitType.create(tile.getTeam()); unit.setSpawner(tile); unit.set(tile.drawx() + Mathf.range(4), tile.drawy() + Mathf.range(4)); unit.add(); - unit.velocity().y = factory.launchVelocity; - Events.fire(new UnitCreateEvent(unit)); + unit.vel().y = factory.launchVelocity; + Events.fire(new UnitCreateEvent(unit));*/ } } diff --git a/core/src/mindustry/world/consumers/ConsumeItemFilter.java b/core/src/mindustry/world/consumers/ConsumeItemFilter.java index 592866ba24..029faf2d64 100644 --- a/core/src/mindustry/world/consumers/ConsumeItemFilter.java +++ b/core/src/mindustry/world/consumers/ConsumeItemFilter.java @@ -53,8 +53,8 @@ public class ConsumeItemFilter extends Consume{ public void trigger(Tilec entity){ for(int i = 0; i < content.items().size; i++){ Item item = content.item(i); - if(entity.getItems() != null && entity.getItems().has(item) && this.filter.get(item)){ - entity.getItems().remove(item, 1); + if(entity.items() != null && entity.items().has(item) && this.filter.get(item)){ + entity.items().remove(item, 1); break; } } @@ -64,7 +64,7 @@ public class ConsumeItemFilter extends Consume{ public boolean valid(Tilec entity){ for(int i = 0; i < content.items().size; i++){ Item item = content.item(i); - if(entity.getItems() != null && entity.getItems().has(item) && this.filter.get(item)){ + if(entity.items() != null && entity.items().has(item) && this.filter.get(item)){ return true; } } diff --git a/core/src/mindustry/world/consumers/ConsumeItems.java b/core/src/mindustry/world/consumers/ConsumeItems.java index 9d11f13106..8dab4180b4 100644 --- a/core/src/mindustry/world/consumers/ConsumeItems.java +++ b/core/src/mindustry/world/consumers/ConsumeItems.java @@ -54,13 +54,13 @@ public class ConsumeItems extends Consume{ @Override public void trigger(Tilec entity){ for(ItemStack stack : items){ - entity.getItems().remove(stack); + entity.items().remove(stack); } } @Override public boolean valid(Tilec entity){ - return entity.getItems() != null && entity.getItems().has(items); + return entity.items() != null && entity.items().has(items); } @Override diff --git a/core/src/mindustry/world/consumers/ConsumeLiquid.java b/core/src/mindustry/world/consumers/ConsumeLiquid.java index 8be877ac0d..482ca6832d 100644 --- a/core/src/mindustry/world/consumers/ConsumeLiquid.java +++ b/core/src/mindustry/world/consumers/ConsumeLiquid.java @@ -3,7 +3,7 @@ package mindustry.world.consumers; import arc.struct.*; import arc.scene.ui.layout.*; import arc.util.ArcAnnotate.*; -import mindustry.entities.type.*; +import mindustry.gen.*; import mindustry.type.*; import mindustry.ui.*; import mindustry.ui.Cicon; diff --git a/desktop/src/mindustry/desktop/steam/SStats.java b/desktop/src/mindustry/desktop/steam/SStats.java index 02fe0b1c1f..f7911d65d9 100644 --- a/desktop/src/mindustry/desktop/steam/SStats.java +++ b/desktop/src/mindustry/desktop/steam/SStats.java @@ -64,7 +64,7 @@ public class SStats implements SteamUserStatsCallback{ } for(Tilec entity : player.team().cores()){ - if(!content.items().contains(i -> i.type == ItemType.material && entity.getItems().get(i) < entity.block.itemCapacity)){ + if(!content.items().contains(i -> i.type == ItemType.material && entity.items().get(i) < entity.block.itemCapacity)){ fillCoreAllCampaign.complete(); break; } @@ -78,7 +78,7 @@ public class SStats implements SteamUserStatsCallback{ if(e.unit.team() != Vars.player.team()){ SStat.unitsDestroyed.add(); - if(e.unit instanceof BaseUnit && ((BaseUnit)e.unit).isBoss()){ + if(e.unit instanceof Unitc && ((Unitc)e.unit).isBoss()){ SStat.bossesDefeated.add(); } } diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 645a1287a5..0920b6dbcb 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -15,7 +15,7 @@ import mindustry.*; import mindustry.core.GameState.*; import mindustry.core.*; import mindustry.entities.*; -import mindustry.entities.type.*; +import mindustry.entities.type.Playerc; import mindustry.game.*; import mindustry.game.EventType.*; import mindustry.gen.*; @@ -296,7 +296,7 @@ public class ServerControl implements ApplicationListener{ if(playerGroup.size() > 0){ info(" &lyPlayers: {0}", playerGroup.size()); - for(Player p : playerGroup.all()){ + for(Playerc p : playerGroup.all()){ info(" &y{0} / {1}", p.name, p.uuid); } }else{ @@ -585,7 +585,7 @@ public class ServerControl implements ApplicationListener{ return; } - Player target = playerGroup.find(p -> p.name.equals(arg[0])); + Playerc target = playerGroup.find(p -> p.name.equals(arg[0])); if(target != null){ Call.sendMessage("[scarlet] " + target.name + "[scarlet] has been kicked by the server."); @@ -601,7 +601,7 @@ public class ServerControl implements ApplicationListener{ netServer.admins.banPlayerID(arg[1]); info("Banned."); }else if(arg[0].equals("name")){ - Player target = playerGroup.find(p -> p.name.equalsIgnoreCase(arg[1])); + Playerc target = playerGroup.find(p -> p.name.equalsIgnoreCase(arg[1])); if(target != null){ netServer.admins.banPlayer(target.uuid); info("Banned."); @@ -615,7 +615,7 @@ public class ServerControl implements ApplicationListener{ err("Invalid type."); } - for(Player player : playerGroup.all()){ + for(Playerc player : playerGroup.all()){ if(netServer.admins.isIDBanned(player.uuid)){ Call.sendMessage("[scarlet] " + player.name + " has been banned."); player.con.kick(KickReason.banned); @@ -666,7 +666,7 @@ public class ServerControl implements ApplicationListener{ return; } - Player target = playerGroup.find(p -> p.name.equals(arg[0])); + Playerc target = playerGroup.find(p -> p.name.equals(arg[0])); if(target != null){ netServer.admins.adminPlayer(target.uuid, target.usid); @@ -683,7 +683,7 @@ public class ServerControl implements ApplicationListener{ return; } - Player target = playerGroup.find(p -> p.name.equals(arg[0])); + Playerc target = playerGroup.find(p -> p.name.equals(arg[0])); if(target != null){ netServer.admins.unAdminPlayer(target.uuid); @@ -863,8 +863,8 @@ public class ServerControl implements ApplicationListener{ private void play(boolean wait, Runnable run){ inExtraRound = true; Runnable r = () -> { - Array players = new Array<>(); - for(Player p : playerGroup.all()){ + Array players = new Array<>(); + for(Playerc p : playerGroup.all()){ players.add(p); p.dead(true); } @@ -876,7 +876,7 @@ public class ServerControl implements ApplicationListener{ state.rules = world.getMap().applyRules(lastMode); logic.play(); - for(Player p : players){ + for(Playerc p : players){ if(p.con == null) continue; p.reset(); diff --git a/tests/src/test/java/ApplicationTests.java b/tests/src/test/java/ApplicationTests.java index ccd55f5574..06753b86f0 100644 --- a/tests/src/test/java/ApplicationTests.java +++ b/tests/src/test/java/ApplicationTests.java @@ -424,7 +424,7 @@ public class ApplicationTests{ } void depositTest(Block block, Item item){ - BaseUnit unit = UnitTypes.spirit.create(Team.derelict); + Unitc unit = UnitTypes.spirit.create(Team.derelict); Tile tile = new Tile(0, 0, Blocks.air, Blocks.air, block); int capacity = tile.block().itemCapacity; diff --git a/tests/src/test/java/power/DirectConsumerTests.java b/tests/src/test/java/power/DirectConsumerTests.java index 9cd8df6dae..53004307c6 100644 --- a/tests/src/test/java/power/DirectConsumerTests.java +++ b/tests/src/test/java/power/DirectConsumerTests.java @@ -37,8 +37,8 @@ public class DirectConsumerTests extends PowerTestFixture{ consumes.power(requestedPower); consumes.items(new ItemStack(Items.silicon, 30), new ItemStack(Items.lead, 30)); }}); - consumertile.entity.getItems().add(Items.silicon, siliconAmount); - consumertile.entity.getItems().add(Items.lead, leadAmount); + consumertile.entity.items().add(Items.silicon, siliconAmount); + consumertile.entity.items().add(Items.lead, leadAmount); Tile producerTile = createFakeTile(2, 0, createFakeProducerBlock(producedPower)); producerTile.ent().productionEfficiency = 1f;