Cleanup continues
This commit is contained in:
@@ -287,10 +287,11 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
|
|
||||||
//get interface for each component
|
//get interface for each component
|
||||||
for(Stype comp : def.components){
|
for(Stype comp : def.components){
|
||||||
|
|
||||||
//implement the interface
|
//implement the interface
|
||||||
Stype inter = interfaces.find(i -> i.name().equals(interfaceName(comp)));
|
Stype inter = interfaces.find(i -> i.name().equals(interfaceName(comp)));
|
||||||
if(inter == null){
|
if(inter == null){
|
||||||
err("Failed to generate interface for component. Interfaces are " + interfaces + "\nComponent", comp);
|
err("Failed to generate interface for", comp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,12 +72,12 @@ public class RemoteProcess extends BaseProcessor{
|
|||||||
|
|
||||||
//check for static
|
//check for static
|
||||||
if(!element.getModifiers().contains(Modifier.STATIC) || !element.getModifiers().contains(Modifier.PUBLIC)){
|
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
|
//can't generate none methods
|
||||||
if(annotation.targets() == Loc.none){
|
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
|
//get and create class entry if needed
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#Maps entity names to IDs. Autogenerated.
|
#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.DecalDef=1
|
||||||
mindustry.entities.def.EntityDefs.EffectDef=2
|
mindustry.entities.def.EntityDefs.EffectDef=2
|
||||||
mindustry.entities.def.EntityDefs.TileDef=3
|
mindustry.entities.def.EntityDefs.TileDef=3
|
||||||
mindustry.entities.def.EntityDefs.BulletDef=0
|
mindustry.entities.def.EntityDefs.BulletDef=0
|
||||||
|
mindustry.entities.def.EntityDefs.PlayerDef=4
|
||||||
+96
-507
@@ -4,11 +4,8 @@ import arc.graphics.Color;
|
|||||||
import java.lang.String;
|
import java.lang.String;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import mindustry.entities.bullet.BulletType;
|
import mindustry.entities.bullet.BulletType;
|
||||||
import mindustry.entities.type.Player;
|
|
||||||
import mindustry.entities.units.BuildRequest;
|
|
||||||
import mindustry.game.Rules;
|
import mindustry.game.Rules;
|
||||||
import mindustry.game.Team;
|
import mindustry.game.Team;
|
||||||
import mindustry.net.Administration;
|
|
||||||
import mindustry.net.NetConnection;
|
import mindustry.net.NetConnection;
|
||||||
import mindustry.net.Packets;
|
import mindustry.net.Packets;
|
||||||
import mindustry.type.Item;
|
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,
|
public static synchronized void createBullet(BulletType type, Team team, float x, float y,
|
||||||
float angle, float velocityScl, float lifetimeScl) {
|
float angle, float velocityScl, float lifetimeScl) {
|
||||||
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
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() {
|
public static synchronized void launchZone() {
|
||||||
mindustry.core.Logic.launchZone();
|
mindustry.core.Logic.launchZone();
|
||||||
if(mindustry.Vars.net.server()) {
|
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) {
|
public static synchronized void onBlockSnapshot(short amount, short dataLen, byte[] data) {
|
||||||
if(mindustry.Vars.net.server()) {
|
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);
|
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) {
|
public static synchronized void onConnect(NetConnection playerConnection, String ip, int port) {
|
||||||
if(mindustry.Vars.net.client() || !mindustry.Vars.net.active()) {
|
if(mindustry.Vars.net.client() || !mindustry.Vars.net.active()) {
|
||||||
mindustry.core.NetClient.onConnect(ip, port);
|
mindustry.core.NetClient.onConnect(ip, port);
|
||||||
@@ -286,33 +204,14 @@ public class Call {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void onDoorToggle(Player player, Tile tile, boolean open) {
|
public static synchronized void onEntitySnapshot(NetConnection playerConnection, short amount,
|
||||||
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
short dataLen, byte[] data) {
|
||||||
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) {
|
|
||||||
if(mindustry.Vars.net.server()) {
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)2;
|
packet.priority = (byte)2;
|
||||||
packet.type = (byte)14;
|
packet.type = (byte)14;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
TEMP_BUFFER.put(groupID);
|
|
||||||
TEMP_BUFFER.putShort(amount);
|
TEMP_BUFFER.putShort(amount);
|
||||||
TEMP_BUFFER.putShort(dataLen);
|
TEMP_BUFFER.putShort(dataLen);
|
||||||
mindustry.io.TypeIO.writeBytes(TEMP_BUFFER, data);
|
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()) {
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
@@ -370,6 +270,45 @@ public class Call {
|
|||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeString(TEMP_BUFFER, message);
|
mindustry.io.TypeIO.writeString(TEMP_BUFFER, message);
|
||||||
TEMP_BUFFER.putFloat(duration);
|
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();
|
packet.writeLength = TEMP_BUFFER.position();
|
||||||
mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp);
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)17;
|
packet.type = (byte)18;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeString(TEMP_BUFFER, message);
|
mindustry.io.TypeIO.writeString(TEMP_BUFFER, message);
|
||||||
TEMP_BUFFER.putFloat(duration);
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)1;
|
packet.priority = (byte)1;
|
||||||
packet.type = (byte)18;
|
packet.type = (byte)19;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeString(TEMP_BUFFER, reason);
|
mindustry.io.TypeIO.writeString(TEMP_BUFFER, reason);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)1;
|
packet.priority = (byte)1;
|
||||||
packet.type = (byte)19;
|
packet.type = (byte)20;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeKick(TEMP_BUFFER, reason);
|
mindustry.io.TypeIO.writeKick(TEMP_BUFFER, reason);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
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) {
|
public static synchronized void onMechFactoryDone(Tile tile) {
|
||||||
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
||||||
mindustry.world.blocks.units.MechPad.onMechFactoryDone(tile);
|
mindustry.world.blocks.units.MechPad.onMechFactoryDone(tile);
|
||||||
}
|
}
|
||||||
if(mindustry.Vars.net.server()) {
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)22;
|
packet.type = (byte)22;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
TEMP_BUFFER.putLong(time);
|
mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
packet.writeLength = TEMP_BUFFER.position();
|
||||||
mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp);
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)23;
|
packet.type = (byte)25;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
TEMP_BUFFER.putLong(time);
|
TEMP_BUFFER.putLong(time);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
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) {
|
public static synchronized void onPlayerDisconnect(int playerid) {
|
||||||
if(mindustry.Vars.net.server()) {
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)25;
|
packet.type = (byte)26;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
TEMP_BUFFER.putInt(playerid);
|
TEMP_BUFFER.putInt(playerid);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)26;
|
packet.type = (byte)27;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
TEMP_BUFFER.putFloat(x);
|
TEMP_BUFFER.putFloat(x);
|
||||||
TEMP_BUFFER.putFloat(y);
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)27;
|
packet.type = (byte)28;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
TEMP_BUFFER.putInt(puddleid);
|
TEMP_BUFFER.putInt(puddleid);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)28;
|
packet.type = (byte)29;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
TEMP_BUFFER.putInt(fid);
|
TEMP_BUFFER.putInt(fid);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)29;
|
packet.type = (byte)30;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeRules(TEMP_BUFFER, rules);
|
mindustry.io.TypeIO.writeRules(TEMP_BUFFER, rules);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)29;
|
packet.type = (byte)30;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeRules(TEMP_BUFFER, rules);
|
mindustry.io.TypeIO.writeRules(TEMP_BUFFER, rules);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)2;
|
packet.priority = (byte)2;
|
||||||
packet.type = (byte)30;
|
packet.type = (byte)31;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
TEMP_BUFFER.putFloat(waveTime);
|
TEMP_BUFFER.putFloat(waveTime);
|
||||||
TEMP_BUFFER.putInt(wave);
|
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) {
|
public static synchronized void onTileDamage(Tile tile, float health) {
|
||||||
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
||||||
mindustry.world.Tile.onTileDamage(tile, health);
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)32;
|
packet.type = (byte)33;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile);
|
mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile);
|
||||||
TEMP_BUFFER.putFloat(health);
|
TEMP_BUFFER.putFloat(health);
|
||||||
@@ -652,89 +540,21 @@ public class Call {
|
|||||||
mindustry.world.Tile.onTileDestroyed(tile);
|
mindustry.world.Tile.onTileDestroyed(tile);
|
||||||
}
|
}
|
||||||
if(mindustry.Vars.net.server()) {
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)34;
|
packet.type = (byte)34;
|
||||||
TEMP_BUFFER.position(0);
|
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.writeTile(TEMP_BUFFER, tile);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
packet.writeLength = TEMP_BUFFER.position();
|
||||||
mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp);
|
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) {
|
public static synchronized void onUnitFactorySpawn(Tile tile, int spawns) {
|
||||||
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
||||||
mindustry.world.blocks.units.UnitFactory.onUnitFactorySpawn(tile, spawns);
|
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()) {
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
@@ -742,7 +562,7 @@ public class Call {
|
|||||||
packet.type = (byte)37;
|
packet.type = (byte)37;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile);
|
mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile);
|
||||||
mindustry.io.TypeIO.writePlayer(TEMP_BUFFER, player);
|
TEMP_BUFFER.putInt(spawns);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
packet.writeLength = TEMP_BUFFER.position();
|
||||||
mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp);
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)38;
|
packet.type = (byte)39;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
packet.writeLength = TEMP_BUFFER.position();
|
||||||
mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp);
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)38;
|
packet.type = (byte)39;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
packet.writeLength = TEMP_BUFFER.position();
|
||||||
playerConnection.send(packet, mindustry.net.Net.SendMode.tcp);
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)39;
|
packet.type = (byte)40;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
TEMP_BUFFER.putInt(x);
|
TEMP_BUFFER.putInt(x);
|
||||||
TEMP_BUFFER.putInt(y);
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)40;
|
packet.type = (byte)41;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile);
|
mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile);
|
||||||
packet.writeLength = TEMP_BUFFER.position();
|
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) {
|
public static synchronized void sendMessage(String message) {
|
||||||
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
||||||
mindustry.core.NetClient.sendMessage(message);
|
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()) {
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
@@ -922,99 +635,11 @@ public class Call {
|
|||||||
packet.type = (byte)46;
|
packet.type = (byte)46;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeString(TEMP_BUFFER, message);
|
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();
|
packet.writeLength = TEMP_BUFFER.position();
|
||||||
mindustry.Vars.net.send(packet, mindustry.net.Net.SendMode.tcp);
|
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) {
|
public static synchronized void setTile(Tile tile, Block block, Team team, int rotation) {
|
||||||
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
||||||
mindustry.world.Tile.setTile(tile, block, team, rotation);
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)49;
|
packet.type = (byte)50;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile);
|
mindustry.io.TypeIO.writeTile(TEMP_BUFFER, tile);
|
||||||
mindustry.io.TypeIO.writeBlock(TEMP_BUFFER, block);
|
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,
|
public static synchronized void transferItemTo(Item item, int amount, float x, float y,
|
||||||
Tile tile) {
|
Tile tile) {
|
||||||
if(mindustry.Vars.net.server() || !mindustry.Vars.net.active()) {
|
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);
|
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.writeBuffer = TEMP_BUFFER;
|
||||||
packet.priority = (byte)0;
|
packet.priority = (byte)0;
|
||||||
packet.type = (byte)53;
|
packet.type = (byte)54;
|
||||||
TEMP_BUFFER.position(0);
|
TEMP_BUFFER.position(0);
|
||||||
mindustry.io.TypeIO.writeItem(TEMP_BUFFER, item);
|
mindustry.io.TypeIO.writeItem(TEMP_BUFFER, item);
|
||||||
TEMP_BUFFER.putInt(amount);
|
TEMP_BUFFER.putInt(amount);
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ public class Vars implements Loadable{
|
|||||||
public static NetServer netServer;
|
public static NetServer netServer;
|
||||||
public static NetClient netClient;
|
public static NetClient netClient;
|
||||||
|
|
||||||
public static Unitc player;
|
public static Playerc player;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadAsync(){
|
public void loadAsync(){
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import mindustry.content.*;
|
|||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
@@ -34,7 +35,7 @@ public class WaveSpawner{
|
|||||||
|
|
||||||
/** @return true if the player is near a ground spawn point. */
|
/** @return true if the player is near a ground spawn point. */
|
||||||
public boolean playerNear(){
|
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(){
|
public void spawnEnemies(){
|
||||||
@@ -48,9 +49,10 @@ public class WaveSpawner{
|
|||||||
|
|
||||||
eachFlyerSpawn((spawnX, spawnY) -> {
|
eachFlyerSpawn((spawnX, spawnY) -> {
|
||||||
for(int i = 0; i < spawned; i++){
|
for(int i = 0; i < spawned; i++){
|
||||||
BaseUnit unit = group.createUnit(state.rules.waveTeam);
|
//TODO
|
||||||
unit.set(spawnX + Mathf.range(spread), spawnY + Mathf.range(spread));
|
//Unitc unit = group.createUnit(state.rules.waveTeam);
|
||||||
unit.add();
|
//unit.set(spawnX + Mathf.range(spread), spawnY + Mathf.range(spread));
|
||||||
|
//unit.add();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
@@ -61,10 +63,11 @@ public class WaveSpawner{
|
|||||||
for(int i = 0; i < spawned; i++){
|
for(int i = 0; i < spawned; i++){
|
||||||
Tmp.v1.rnd(spread);
|
Tmp.v1.rnd(spread);
|
||||||
|
|
||||||
BaseUnit unit = group.createUnit(state.rules.waveTeam);
|
//TODO
|
||||||
unit.set(spawnX + Tmp.v1.x, spawnY + Tmp.v1.y);
|
//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()){
|
if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam) && !state.teams.playerCores().isEmpty()){
|
||||||
Tilec firstCore = state.teams.playerCores().first();
|
Tilec firstCore = state.teams.playerCores().first();
|
||||||
for(Tilec core : state.rules.waveTeam.cores()){
|
for(Tilec core : state.rules.waveTeam.cores()){
|
||||||
Tmp.v1.set(firstCore).sub(core.x, core.y).limit(coreMargin + core.block.size*tilesize);
|
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);
|
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)){
|
if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam)){
|
||||||
for(Tilec core : state.teams.get(state.rules.waveTeam).cores){
|
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);
|
flySpawns.add(fspawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnEffect(BaseUnit unit){
|
private void spawnEffect(Unitc unit){
|
||||||
Fx.unitSpawn.at(unit.x, unit.y, 0f, unit);
|
Fx.unitSpawn.at(unit.x(), unit.y(), 0f, unit);
|
||||||
Time.run(30f, () -> {
|
Time.run(30f, () -> {
|
||||||
unit.add();
|
unit.add();
|
||||||
Fx.spawn.at(unit);
|
Fx.spawn.at(unit);
|
||||||
|
|||||||
@@ -1281,7 +1281,6 @@ public class Blocks implements ContentList{
|
|||||||
health = 1100;
|
health = 1100;
|
||||||
itemCapacity = 4000;
|
itemCapacity = 4000;
|
||||||
size = 3;
|
size = 3;
|
||||||
mech = Mechs.vanguard;
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
coreFoundation = new CoreBlock("core-foundation"){{
|
coreFoundation = new CoreBlock("core-foundation"){{
|
||||||
@@ -1290,7 +1289,6 @@ public class Blocks implements ContentList{
|
|||||||
health = 2000;
|
health = 2000;
|
||||||
itemCapacity = 9000;
|
itemCapacity = 9000;
|
||||||
size = 4;
|
size = 4;
|
||||||
mech = Mechs.vanguard;
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
coreNucleus = new CoreBlock("core-nucleus"){{
|
coreNucleus = new CoreBlock("core-nucleus"){{
|
||||||
@@ -1299,7 +1297,6 @@ public class Blocks implements ContentList{
|
|||||||
health = 4000;
|
health = 4000;
|
||||||
itemCapacity = 13000;
|
itemCapacity = 13000;
|
||||||
size = 5;
|
size = 5;
|
||||||
mech = Mechs.vanguard;
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
vault = new Vault("vault"){{
|
vault = new Vault("vault"){{
|
||||||
@@ -1548,7 +1545,7 @@ public class Blocks implements ContentList{
|
|||||||
@Override
|
@Override
|
||||||
public void init(Bulletc b){
|
public void init(Bulletc b){
|
||||||
for(int i = 0; i < rays; i++){
|
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.color(Color.white, Pal.lancerLaser, b.fin());
|
||||||
//Draw.alpha(b.fout());
|
//Draw.alpha(b.fout());
|
||||||
for(int i = 0; i < 7; i++){
|
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);
|
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.rotation() + 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, b.y, 20f * b.fout(), (rayLength + 50), b.rot());
|
Drawf.tri(b.x(), b.y(), 20f * b.fout(), (rayLength + 50), b.rotation());
|
||||||
Drawf.tri(b.x, b.y, 20f * b.fout(), 10f, b.rot() + 180f);
|
Drawf.tri(b.x(), b.y(), 20f * b.fout(), 10f, b.rotation() + 180f);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1783,56 +1780,56 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
dartPad = new MechPad("dart-ship-pad"){{
|
dartPad = new MechPad("dart-ship-pad"){{
|
||||||
requirements(Category.upgrade, ItemStack.with(Items.lead, 100, Items.graphite, 50, Items.copper, 75));
|
requirements(Category.upgrade, ItemStack.with(Items.lead, 100, Items.graphite, 50, Items.copper, 75));
|
||||||
mech = Mechs.dart;
|
mech = UnitTypes.dart;
|
||||||
size = 2;
|
size = 2;
|
||||||
consumes.power(0.5f);
|
consumes.power(0.5f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
alphaPad = new MechPad("alpha-mech-pad"){{
|
alphaPad = new MechPad("alpha-mech-pad"){{
|
||||||
requirements(Category.upgrade, ItemStack.with(Items.lead, 100, Items.graphite, 50, Items.copper, 75));
|
requirements(Category.upgrade, ItemStack.with(Items.lead, 100, Items.graphite, 50, Items.copper, 75));
|
||||||
mech = Mechs.alpha;
|
mech = UnitTypes.alpha;
|
||||||
size = 2;
|
size = 2;
|
||||||
consumes.power(0.5f);
|
consumes.power(0.5f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
deltaPad = new MechPad("delta-mech-pad"){{
|
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));
|
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;
|
size = 2;
|
||||||
consumes.power(0.7f);
|
consumes.power(0.7f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
tauPad = new MechPad("tau-mech-pad"){{
|
tauPad = new MechPad("tau-mech-pad"){{
|
||||||
requirements(Category.upgrade, ItemStack.with(Items.lead, 125, Items.titanium, 125, Items.copper, 125, Items.silicon, 125));
|
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;
|
size = 2;
|
||||||
consumes.power(1f);
|
consumes.power(1f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
omegaPad = new MechPad("omega-mech-pad"){{
|
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));
|
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;
|
size = 3;
|
||||||
consumes.power(1.2f);
|
consumes.power(1.2f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
javelinPad = new MechPad("javelin-ship-pad"){{
|
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));
|
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;
|
size = 2;
|
||||||
consumes.power(0.8f);
|
consumes.power(0.8f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
tridentPad = new MechPad("trident-ship-pad"){{
|
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));
|
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;
|
size = 2;
|
||||||
consumes.power(1f);
|
consumes.power(1f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
glaivePad = new MechPad("glaive-ship-pad"){{
|
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));
|
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;
|
size = 3;
|
||||||
consumes.power(1.2f);
|
consumes.power(1.2f);
|
||||||
}};
|
}};
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ import arc.graphics.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.ctype.ContentList;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.entities.effect.*;
|
import mindustry.entities.effect.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -412,31 +411,31 @@ public class Bullets implements ContentList{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bulletc b){
|
public void init(Bulletc b){
|
||||||
b.velocity().setLength(0.6f + Mathf.random(2f));
|
b.vel().setLength(0.6f + Mathf.random(2f));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Bulletc b){
|
public void draw(Bulletc b){
|
||||||
Draw.color(Pal.lightFlame, Pal.darkFlame, Color.gray, b.fin());
|
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();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Bulletc b){
|
public void update(Bulletc b){
|
||||||
if(Mathf.chance(0.04 * Time.delta())){
|
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){
|
if(tile != null){
|
||||||
Fire.create(tile);
|
Fire.create(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Mathf.chance(0.1 * Time.delta())){
|
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())){
|
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
|
@Override
|
||||||
public void update(Bulletc b){
|
public void update(Bulletc b){
|
||||||
if(b.timer.get(1, 5f)){
|
if(b.timer(1, 5f)){
|
||||||
Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rot(), length, true);
|
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
|
@Override
|
||||||
public void hit(Bulletc b, float hitx, float hity){
|
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)){
|
if(Mathf.chance(0.4)){
|
||||||
Fire.create(world.tileWorld(hitx + Mathf.range(5f), hity + Mathf.range(5f)));
|
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){
|
public void draw(Bulletc b){
|
||||||
float baseLen = (length) * b.fout();
|
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++){
|
for(int s = 0; s < colors.length; s++){
|
||||||
Draw.color(tmpColor.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f)));
|
Draw.color(tmpColor.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f)));
|
||||||
for(int i = 0; i < tscales.length; i++){
|
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.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();
|
Draw.reset();
|
||||||
@@ -587,7 +586,8 @@ public class Bullets implements ContentList{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bulletc b){
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+831
-837
File diff suppressed because it is too large
Load Diff
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,7 @@ public class StatusEffects implements ContentList{
|
|||||||
opposite(wet,freezing);
|
opposite(wet,freezing);
|
||||||
trans(tarred, ((unit, time, newTime, result) -> {
|
trans(tarred, ((unit, time, newTime, result) -> {
|
||||||
unit.damage(1f);
|
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));
|
result.set(this, Math.min(time + newTime, 300f));
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
package mindustry.content;
|
package mindustry.content;
|
||||||
|
|
||||||
import arc.struct.*;
|
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.bullet.*;
|
|
||||||
import mindustry.entities.type.base.*;
|
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
|
||||||
public class UnitTypes implements ContentList{
|
public class UnitTypes implements ContentList{
|
||||||
@@ -13,8 +9,12 @@ public class UnitTypes implements ContentList{
|
|||||||
wraith, ghoul, revenant, lich, reaper,
|
wraith, ghoul, revenant, lich, reaper,
|
||||||
dagger, crawler, titan, fortress, eruptor, chaosArray, eradicator;
|
dagger, crawler, titan, fortress, eruptor, chaosArray, eradicator;
|
||||||
|
|
||||||
|
public static UnitDef vanguard, alpha, delta, tau, omega, dart, javelin, trident, glaive;
|
||||||
|
public static UnitDef starter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
|
/*
|
||||||
draug = new UnitDef("draug", MinerDrone::new){{
|
draug = new UnitDef("draug", MinerDrone::new){{
|
||||||
flying = true;
|
flying = true;
|
||||||
drag = 0.01f;
|
drag = 0.01f;
|
||||||
@@ -372,5 +372,440 @@ public class UnitTypes implements ContentList{
|
|||||||
shootSound = Sounds.shootBig;
|
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;*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ public class ContentLoader{
|
|||||||
return getBy(ContentType.zone);
|
return getBy(ContentType.zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Array<UnitType> units(){
|
public Array<UnitDef> units(){
|
||||||
return getBy(ContentType.unit);
|
return getBy(ContentType.unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import arc.util.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
@@ -63,7 +63,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(PlayEvent.class, event -> {
|
Events.on(PlayEvent.class, event -> {
|
||||||
player.team(netServer.assignTeam(player, playerGroup.all()));
|
player.team(netServer.assignTeam(player, Groups.player.all()));
|
||||||
player.dead(true);
|
player.dead(true);
|
||||||
player.add();
|
player.add();
|
||||||
|
|
||||||
@@ -204,10 +204,10 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void createPlayer(){
|
void createPlayer(){
|
||||||
player = new Player();
|
player = new Playerc();
|
||||||
player.name = Core.settings.getString("name");
|
player.name = Core.settings.getString("name");
|
||||||
player.color.set(Core.settings.getInt("color-0"));
|
player.color.set(Core.settings.getInt("color-0"));
|
||||||
player.isLocal = true;
|
player.isLocal() = true;
|
||||||
player.isMobile = mobile;
|
player.isMobile = mobile;
|
||||||
|
|
||||||
if(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);
|
Tile tile = world.ltile(cx, cy);
|
||||||
if(tile != null && tile.getTeam() == state.rules.defaultTeam && !(tile.block() instanceof CoreBlock)){
|
if(tile != null && tile.getTeam() == state.rules.defaultTeam && !(tile.block() instanceof CoreBlock)){
|
||||||
tile.remove();
|
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();
|
world.endMapLoad();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package mindustry.core;
|
package mindustry.core;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -25,8 +25,8 @@ public class GameState{
|
|||||||
/** Current game state. */
|
/** Current game state. */
|
||||||
private State state = State.menu;
|
private State state = State.menu;
|
||||||
|
|
||||||
public BaseUnit boss(){
|
public Unitc boss(){
|
||||||
return unitGroup.find(u -> u.isBoss() && u.getTeam() == rules.waveTeam);
|
return Groups.unit.find(u -> u.isBoss() && u.team() == rules.waveTeam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(State astate){
|
public void set(State astate){
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import mindustry.annotations.Annotations.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
@@ -79,7 +78,7 @@ public class Logic implements ApplicationListener{
|
|||||||
while(it.hasNext()){
|
while(it.hasNext()){
|
||||||
BrokenBlock b = it.next();
|
BrokenBlock b = it.next();
|
||||||
Block block = content.block(b.block);
|
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();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,7 +205,7 @@ public class Logic implements ApplicationListener{
|
|||||||
if(!state.is(State.menu)){
|
if(!state.is(State.menu)){
|
||||||
if(!net.client()){
|
if(!net.client()){
|
||||||
//TODO
|
//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()){
|
if(!state.isPaused()){
|
||||||
@@ -230,7 +229,7 @@ public class Logic implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!state.isEditor()){
|
if(!state.isEditor()){
|
||||||
unitGroup.update();
|
Groups.unit.update();
|
||||||
puddleGroup.update();
|
puddleGroup.update();
|
||||||
shieldGroup.update();
|
shieldGroup.update();
|
||||||
bulletGroup.update();
|
bulletGroup.update();
|
||||||
@@ -238,12 +237,12 @@ public class Logic implements ApplicationListener{
|
|||||||
fireGroup.update();
|
fireGroup.update();
|
||||||
weatherGroup.update();
|
weatherGroup.update();
|
||||||
}else{
|
}else{
|
||||||
unitGroup.updateEvents();
|
Groups.unit.updateEvents();
|
||||||
collisions.updatePhysics(unitGroup);
|
collisions.updatePhysics(Groups.unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
playerGroup.update();
|
Groups.player.update();
|
||||||
|
|
||||||
//effect group only contains item transfers in the headless version, update it!
|
//effect group only contains item transfers in the headless version, update it!
|
||||||
if(headless){
|
if(headless){
|
||||||
@@ -252,7 +251,7 @@ public class Logic implements ApplicationListener{
|
|||||||
|
|
||||||
if(!state.isEditor()){
|
if(!state.isEditor()){
|
||||||
//bulletGroup
|
//bulletGroup
|
||||||
collisions.collideGroups(bulletGroup, unitGroup);
|
collisions.collideGroups(bulletGroup, Groups.unit);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import mindustry.annotations.Annotations.*;
|
|||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
@@ -60,7 +60,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
net.handleClient(Connect.class, packet -> {
|
net.handleClient(Connect.class, packet -> {
|
||||||
Log.info("Connecting to server: {0}", packet.addressTCP);
|
Log.info("Connecting to server: {0}", packet.addressTCP);
|
||||||
|
|
||||||
player.isAdmin = false;
|
player.admin(false);
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
@@ -75,11 +75,11 @@ public class NetClient implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
|
|
||||||
ConnectPacket c = new ConnectPacket();
|
ConnectPacket c = new ConnectPacket();
|
||||||
c.name = player.name;
|
c.name = player.name();
|
||||||
c.mods = mods.getModStrings();
|
c.mods = mods.getModStrings();
|
||||||
c.mobile = mobile;
|
c.mobile = mobile;
|
||||||
c.versionType = Version.type;
|
c.versionType = Version.type;
|
||||||
c.color = Color.rgba8888(player.color);
|
c.color = Color.rgba8888(player.color());
|
||||||
c.usid = getUsid(packet.addressTCP);
|
c.usid = getUsid(packet.addressTCP);
|
||||||
c.uuid = platform.getUUID();
|
c.uuid = platform.getUUID();
|
||||||
|
|
||||||
@@ -133,14 +133,14 @@ public class NetClient implements ApplicationListener{
|
|||||||
|
|
||||||
//called on all clients
|
//called on all clients
|
||||||
@Remote(targets = Loc.server, variants = Variant.both)
|
@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){
|
if(Vars.ui != null){
|
||||||
Vars.ui.chatfrag.addMessage(message, sender);
|
Vars.ui.chatfrag.addMessage(message, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playersender != null){
|
if(playersender != null){
|
||||||
playersender.lastText = message;
|
playersender.lastText(message);
|
||||||
playersender.textFadeTime = 1f;
|
playersender.textFadeTime(1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
|
|
||||||
//called when a server recieves a chat message from a player
|
//called when a server recieves a chat message from a player
|
||||||
@Remote(called = Loc.server, targets = Loc.client)
|
@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){
|
if(message.length() > maxTextLength){
|
||||||
throw new ValidateException(player, "Player has sent a message above the text limit.");
|
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
|
//special case; graphical server needs to see its message
|
||||||
if(!headless){
|
if(!headless){
|
||||||
sendMessage(message, colorizeName(player.id, player.name), player);
|
sendMessage(message, colorizeName(player.id(), player.name()), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
//server console logging
|
//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
|
//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
|
//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{
|
}else{
|
||||||
//log command to console but with brackets
|
//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
|
//a command was sent, now get the output
|
||||||
if(response.type != ResponseType.valid){
|
if(response.type != ResponseType.valid){
|
||||||
@@ -204,9 +204,9 @@ public class NetClient implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String colorizeName(int id, String name){
|
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;
|
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)
|
@Remote(called = Loc.client, variants = Variant.one)
|
||||||
@@ -219,8 +219,8 @@ public class NetClient implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.client)
|
@Remote(targets = Loc.client)
|
||||||
public static void onPing(Player player, long time){
|
public static void onPing(Playerc player, long time){
|
||||||
Call.onPingResponse(player.con, time);
|
Call.onPingResponse(player.con(), time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(variants = Variant.one)
|
@Remote(variants = Variant.one)
|
||||||
@@ -229,7 +229,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Remote(variants = Variant.one)
|
@Remote(variants = Variant.one)
|
||||||
public static void onTraceInfo(Player player, TraceInfo info){
|
public static void onTraceInfo(Playerc player, TraceInfo info){
|
||||||
if(player != null){
|
if(player != null){
|
||||||
ui.traces.show(player, info);
|
ui.traces.show(player, info);
|
||||||
}
|
}
|
||||||
@@ -265,9 +265,6 @@ public class NetClient implements ApplicationListener{
|
|||||||
ui.showText("", message);
|
ui.showText("", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO these are commented out to enforce compatibility with 103! uncomment before 104 release
|
|
||||||
/*
|
|
||||||
|
|
||||||
@Remote(variants = Variant.both)
|
@Remote(variants = Variant.both)
|
||||||
public static void onInfoPopup(String message, float duration, int align, int top, int left, int bottom, int right){
|
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);
|
ui.showInfoPopup(message, duration, align, top, left, bottom, right);
|
||||||
@@ -278,14 +275,15 @@ public class NetClient implements ApplicationListener{
|
|||||||
ui.showLabel(info, duration, worldx, worldy);
|
ui.showLabel(info, duration, worldx, worldy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Remote(variants = Variant.both, unreliable = true)
|
@Remote(variants = Variant.both, unreliable = true)
|
||||||
public static void onEffect(Effect effect, float x, float y, float rotation, Color color){
|
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)
|
@Remote(variants = Variant.both)
|
||||||
public static void onEffectReliable(Effect effect, float x, float y, float rotation, Color color){
|
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)
|
@Remote(variants = Variant.both)
|
||||||
@@ -323,35 +321,33 @@ public class NetClient implements ApplicationListener{
|
|||||||
|
|
||||||
@Remote
|
@Remote
|
||||||
public static void onPlayerDisconnect(int playerid){
|
public static void onPlayerDisconnect(int playerid){
|
||||||
playerGroup.removeByID(playerid);
|
Groups.player.removeByID(playerid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true)
|
@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{
|
try{
|
||||||
netClient.byteStream.setBytes(net.decompressSnapshot(data, dataLen));
|
netClient.byteStream.setBytes(net.decompressSnapshot(data, dataLen));
|
||||||
DataInputStream input = netClient.dataStream;
|
DataInputStream input = netClient.dataStream;
|
||||||
|
|
||||||
EntityGroup group = entities.get(groupID);
|
|
||||||
|
|
||||||
//go through each entity
|
//go through each entity
|
||||||
for(int j = 0; j < amount; j++){
|
for(int j = 0; j < amount; j++){
|
||||||
int id = input.readInt();
|
int id = input.readInt();
|
||||||
byte typeID = input.readByte();
|
byte typeID = input.readByte();
|
||||||
|
|
||||||
SyncTrait entity = group == null ? null : (SyncTrait)group.getByID(id);
|
Syncc entity = Groups.sync.getByID(id);
|
||||||
boolean add = false, created = false;
|
boolean add = false, created = false;
|
||||||
|
|
||||||
if(entity == null && id == player.id){
|
if(entity == null && id == player.id()){
|
||||||
entity = player;
|
entity = player;
|
||||||
add = true;
|
add = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//entity must not be added yet, so create it
|
//entity must not be added yet, so create it
|
||||||
if(entity == null){
|
if(entity == null){
|
||||||
entity = (SyncTrait)content.<TypeID>getByID(ContentType.typeid, typeID).constructor.get();
|
entity = (Syncc)ClassMapping.map(typeID).get();
|
||||||
entity.resetID(id);
|
entity.id(id);
|
||||||
if(!netClient.isEntityUsed(entity.getID())){
|
if(!netClient.isEntityUsed(entity.id())){
|
||||||
add = true;
|
add = true;
|
||||||
}
|
}
|
||||||
created = true;
|
created = true;
|
||||||
@@ -360,17 +356,14 @@ public class NetClient implements ApplicationListener{
|
|||||||
//read the entity
|
//read the entity
|
||||||
entity.read(input);
|
entity.read(input);
|
||||||
|
|
||||||
if(created && entity.getInterpolator() != null && entity.getInterpolator().target != null){
|
if(created && entity.interpolator().target != null){
|
||||||
//set initial starting position
|
//set initial starting position
|
||||||
entity.setNet(entity.getInterpolator().target.x, entity.getInterpolator().target.y);
|
entity.setNet(entity.interpolator().target.x, entity.interpolator().target.y);
|
||||||
if(entity instanceof Unitc && entity.getInterpolator().targets.length > 0){
|
|
||||||
((Unitc)entity).rotation = entity.getInterpolator().targets[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(add){
|
if(add){
|
||||||
entity.add();
|
entity.add();
|
||||||
netClient.addRemovedEntity(entity.getID());
|
netClient.addRemovedEntity(entity.id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
@@ -391,7 +384,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
Log.warn("Missing entity at {0}. Skipping block snapshot.", tile);
|
Log.warn("Missing entity at {0}. Skipping block snapshot.", tile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tile.entity.read(input, tile.entity.version());
|
tile.entity.read(input);
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -525,7 +518,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
|
|
||||||
Call.onClientShapshot(lastSent++, player.x, player.y,
|
Call.onClientShapshot(lastSent++, player.x, player.y,
|
||||||
player.pointerX, player.pointerY, player.rotation, player.baseRotation,
|
player.pointerX, player.pointerY, player.rotation, player.baseRotation,
|
||||||
player.velocity().x, player.velocity().y,
|
player.vel().x, player.vel().y,
|
||||||
player.getMineTile(),
|
player.getMineTile(),
|
||||||
player.isBoosting, player.isShooting, ui.chatfrag.shown(), player.isBuilding,
|
player.isBoosting, player.isShooting, ui.chatfrag.shown(), player.isBuilding,
|
||||||
requests,
|
requests,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import mindustry.annotations.Annotations.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.net.Administration;
|
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.
|
//find team with minimum amount of players and auto-assign player to that.
|
||||||
TeamData re = state.teams.getActive().min(data -> {
|
TeamData re = state.teams.getActive().min(data -> {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for(Player other : players){
|
for(Playerc other : players){
|
||||||
if(other.team() == data.team && other != player){
|
if(other.team() == data.team && other != player){
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(admins.getPlayerLimit() > 0 && playerGroup.size() >= admins.getPlayerLimit()){
|
if(admins.getPlayerLimit() > 0 && Groups.player.size() >= admins.getPlayerLimit()){
|
||||||
con.kick(KickReason.playerLimit);
|
con.kick(KickReason.playerLimit);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
boolean preventDuplicates = headless && netServer.admins.getStrict();
|
boolean preventDuplicates = headless && netServer.admins.getStrict();
|
||||||
|
|
||||||
if(preventDuplicates){
|
if(preventDuplicates){
|
||||||
for(Player player : playerGroup.all()){
|
for(Playerc player : Groups.player.all()){
|
||||||
if(player.name.trim().equalsIgnoreCase(packet.name.trim())){
|
if(player.name.trim().equalsIgnoreCase(packet.name.trim())){
|
||||||
con.kick(KickReason.nameInUse);
|
con.kick(KickReason.nameInUse);
|
||||||
return;
|
return;
|
||||||
@@ -194,7 +194,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
con.modclient = true;
|
con.modclient = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = new Player();
|
Playerc player = new Playerc();
|
||||||
player.isAdmin = admins.isAdmin(uuid, packet.usid);
|
player.isAdmin = admins.isAdmin(uuid, packet.usid);
|
||||||
player.con = con;
|
player.con = con;
|
||||||
player.usid = packet.usid;
|
player.usid = packet.usid;
|
||||||
@@ -218,7 +218,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
con.player = player;
|
con.player = player;
|
||||||
|
|
||||||
//playing in pvp mode automatically assigns players to teams
|
//playing in pvp mode automatically assigns players to teams
|
||||||
player.team(assignTeam(player, playerGroup.all()));
|
player.team(assignTeam(player, Groups.player.all()));
|
||||||
|
|
||||||
sendWorldData(player);
|
sendWorldData(player);
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerCommands(){
|
private void registerCommands(){
|
||||||
clientCommands.<Player>register("help", "[page]", "Lists all commands.", (args, player) -> {
|
clientCommands.<Playerc>register("help", "[page]", "Lists all commands.", (args, player) -> {
|
||||||
if(args.length > 0 && !Strings.canParseInt(args[0])){
|
if(args.length > 0 && !Strings.canParseInt(args[0])){
|
||||||
player.sendMessage("[scarlet]'page' must be a number.");
|
player.sendMessage("[scarlet]'page' must be a number.");
|
||||||
return;
|
return;
|
||||||
@@ -278,8 +278,8 @@ public class NetServer implements ApplicationListener{
|
|||||||
player.sendMessage(result.toString());
|
player.sendMessage(result.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
clientCommands.<Player>register("t", "<message...>", "Send a message only to your teammates.", (args, player) -> {
|
clientCommands.<Playerc>register("t", "<message...>", "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() + "]<T>" + NetClient.colorizeName(player.id, player.name)));
|
Groups.player.all().each(p -> p.getTeam() == player.team(), o -> o.sendMessage(args[0], player, "[#" + player.team().color.toString() + "]<T>" + NetClient.colorizeName(player.id, player.name())));
|
||||||
});
|
});
|
||||||
|
|
||||||
//duration of a a kick in seconds
|
//duration of a a kick in seconds
|
||||||
@@ -290,13 +290,13 @@ public class NetServer implements ApplicationListener{
|
|||||||
int voteCooldown = 60 * 1;
|
int voteCooldown = 60 * 1;
|
||||||
|
|
||||||
class VoteSession{
|
class VoteSession{
|
||||||
Player target;
|
Playerc target;
|
||||||
ObjectSet<String> voted = new ObjectSet<>();
|
ObjectSet<String> voted = new ObjectSet<>();
|
||||||
VoteSession[] map;
|
VoteSession[] map;
|
||||||
Timer.Task task;
|
Timer.Task task;
|
||||||
int votes;
|
int votes;
|
||||||
|
|
||||||
public VoteSession(VoteSession[] map, Player target){
|
public VoteSession(VoteSession[] map, Playerc target){
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.map = map;
|
this.map = map;
|
||||||
this.task = Timer.schedule(() -> {
|
this.task = Timer.schedule(() -> {
|
||||||
@@ -308,19 +308,19 @@ public class NetServer implements ApplicationListener{
|
|||||||
}, voteDuration);
|
}, voteDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vote(Player player, int d){
|
void vote(Playerc player, int d){
|
||||||
votes += d;
|
votes += d;
|
||||||
voted.addAll(player.uuid, admins.getInfo(player.uuid).lastIP);
|
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 <y/n>[] to agree.",
|
Call.sendMessage(Strings.format("[orange]{0}[lightgray] has voted to kick[orange] {1}[].[accent] ({2}/{3})\n[lightgray]Type[orange] /vote <y/n>[] to agree.",
|
||||||
player.name, target.name, votes, votesRequired()));
|
player.name(), target.name, votes, votesRequired()));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkPass(){
|
boolean checkPass(){
|
||||||
if(votes >= votesRequired()){
|
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)));
|
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;
|
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;
|
map[0] = null;
|
||||||
task.cancel();
|
task.cancel();
|
||||||
return true;
|
return true;
|
||||||
@@ -333,18 +333,18 @@ public class NetServer implements ApplicationListener{
|
|||||||
//current kick sessions
|
//current kick sessions
|
||||||
VoteSession[] currentlyKicking = {null};
|
VoteSession[] currentlyKicking = {null};
|
||||||
|
|
||||||
clientCommands.<Player>register("votekick", "[player...]", "Vote to kick a player, with a cooldown.", (args, player) -> {
|
clientCommands.<Playerc>register("votekick", "[player...]", "Vote to kick a player, with a cooldown.", (args, player) -> {
|
||||||
if(!Config.enableVotekick.bool()){
|
if(!Config.enableVotekick.bool()){
|
||||||
player.sendMessage("[scarlet]Vote-kick is disabled on this server.");
|
player.sendMessage("[scarlet]Vote-kick is disabled on this server.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playerGroup.size() < 3){
|
if(Groups.player.size() < 3){
|
||||||
player.sendMessage("[scarlet]At least 3 players are needed to start a votekick.");
|
player.sendMessage("[scarlet]At least 3 players are needed to start a votekick.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.isLocal){
|
if(player.isLocal()){
|
||||||
player.sendMessage("[scarlet]Just kick them yourself if you're the host.");
|
player.sendMessage("[scarlet]Just kick them yourself if you're the host.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -352,19 +352,19 @@ public class NetServer implements ApplicationListener{
|
|||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("[orange]Players to kick: \n");
|
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;
|
if(p.isAdmin || p.con == null || p == player) continue;
|
||||||
|
|
||||||
builder.append("[lightgray] ").append(p.name).append("[accent] (#").append(p.id).append(")\n");
|
builder.append("[lightgray] ").append(p.name).append("[accent] (#").append(p.id).append(")\n");
|
||||||
}
|
}
|
||||||
player.sendMessage(builder.toString());
|
player.sendMessage(builder.toString());
|
||||||
}else{
|
}else{
|
||||||
Player found;
|
Playerc found;
|
||||||
if(args[0].length() > 1 && args[0].startsWith("#") && Strings.canParseInt(args[0].substring(1))){
|
if(args[0].length() > 1 && args[0].startsWith("#") && Strings.canParseInt(args[0].substring(1))){
|
||||||
int id = Strings.parseInt(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{
|
}else{
|
||||||
found = playerGroup.find(p -> p.name.equalsIgnoreCase(args[0]));
|
found = Groups.player.find(p -> p.name.equalsIgnoreCase(args[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(found != null){
|
if(found != null){
|
||||||
@@ -391,11 +391,11 @@ public class NetServer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
clientCommands.<Player>register("vote", "<y/n>", "Vote to kick the current player.", (arg, player) -> {
|
clientCommands.<Playerc>register("vote", "<y/n>", "Vote to kick the current player.", (arg, player) -> {
|
||||||
if(currentlyKicking[0] == null){
|
if(currentlyKicking[0] == null){
|
||||||
player.sendMessage("[scarlet]Nobody is being voted on.");
|
player.sendMessage("[scarlet]Nobody is being voted on.");
|
||||||
}else{
|
}else{
|
||||||
if(player.isLocal){
|
if(player.isLocal()){
|
||||||
player.sendMessage("Local players can't vote. Kick the player yourself instead.");
|
player.sendMessage("Local players can't vote. Kick the player yourself instead.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -422,8 +422,8 @@ public class NetServer implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
clientCommands.<Player>register("sync", "Re-synchronize world state.", (args, player) -> {
|
clientCommands.<Playerc>register("sync", "Re-synchronize world state.", (args, player) -> {
|
||||||
if(player.isLocal){
|
if(player.isLocal()){
|
||||||
player.sendMessage("[scarlet]Re-synchronizing as the host is pointless.");
|
player.sendMessage("[scarlet]Re-synchronizing as the host is pointless.");
|
||||||
}else{
|
}else{
|
||||||
if(Time.timeSinceMillis(player.getInfo().lastSyncTime) < 1000 * 5){
|
if(Time.timeSinceMillis(player.getInfo().lastSyncTime) < 1000 * 5){
|
||||||
@@ -439,14 +439,14 @@ public class NetServer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int votesRequired(){
|
public int votesRequired(){
|
||||||
return 2 + (playerGroup.size() > 4 ? 1 : 0);
|
return 2 + (Groups.player.size() > 4 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Team assignTeam(Player current, Iterable<Player> players){
|
public Team assignTeam(Playerc current, Iterable<Playerc> players){
|
||||||
return assigner.assign(current, players);
|
return assigner.assign(current, players);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendWorldData(Player player){
|
public void sendWorldData(Playerc player){
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
DeflaterOutputStream def = new FastDeflaterOutputStream(stream);
|
DeflaterOutputStream def = new FastDeflaterOutputStream(stream);
|
||||||
NetworkIO.writeWorld(player, def);
|
NetworkIO.writeWorld(player, def);
|
||||||
@@ -457,7 +457,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
Log.debug("Packed {0} compressed bytes of world data.", stream.size());
|
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
|
//singleplayer multiplayer wierdness
|
||||||
if(player.con == null){
|
if(player.con == null){
|
||||||
player.remove();
|
player.remove();
|
||||||
@@ -471,7 +471,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
Call.onPlayerDisconnect(player.id);
|
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();
|
player.remove();
|
||||||
@@ -480,7 +480,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
|
|
||||||
@Remote(targets = Loc.client, unreliable = true)
|
@Remote(targets = Loc.client, unreliable = true)
|
||||||
public static void onClientShapshot(
|
public static void onClientShapshot(
|
||||||
Player player,
|
Playerc player,
|
||||||
int snapshotID,
|
int snapshotID,
|
||||||
float x, float y,
|
float x, float y,
|
||||||
float pointerX, float pointerY,
|
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 maxSpeed = boosting && !player.mech.flying ? player.mech.compoundSpeedBoost : player.mech.compoundSpeed;
|
||||||
float maxMove = elapsed / 1000f * 60f * Math.min(maxSpeed, player.mech.maxSpeed) * 1.2f;
|
float maxMove = elapsed / 1000f * 60f * Math.min(maxSpeed, player.mech.maxSpeed) * 1.2f;
|
||||||
|
|
||||||
player.pointerX = pointerX;
|
player.mouseX(pointerX);
|
||||||
player.pointerY = pointerY;
|
player.mouseY(pointerY);
|
||||||
player.setMineTile(mining);
|
player.setMineTile(mining);
|
||||||
player.isTyping = chatting;
|
player.isTyping = chatting;
|
||||||
player.isBoosting = boosting;
|
player.isBoosting = boosting;
|
||||||
@@ -571,23 +571,23 @@ public class NetServer implements ApplicationListener{
|
|||||||
|
|
||||||
//set interpolator target to *new* position so it moves toward it
|
//set interpolator target to *new* position so it moves toward it
|
||||||
player.getInterpolator().read(player.x, player.y, newx, newy, rotation, baseRotation);
|
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.lastRecievedClientSnapshot = snapshotID;
|
||||||
connection.lastRecievedClientTime = Time.millis();
|
connection.lastRecievedClientTime = Time.millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.client, called = Loc.server)
|
@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.",
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(other == null || ((other.isAdmin && !player.isLocal) && other != player)){
|
if(other == null || ((other.admin() && !player.isLocal()) && other != player)){
|
||||||
Log.warn("{0} attempted to perform admin action on nonexistant or admin player.", player.name);
|
Log.warn("{0} attempted to perform admin action on nonexistant or admin player.", player.name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,32 +596,32 @@ public class NetServer implements ApplicationListener{
|
|||||||
//not a real issue, because server owners may want to do just that
|
//not a real issue, because server owners may want to do just that
|
||||||
state.wavetime = 0f;
|
state.wavetime = 0f;
|
||||||
}else if(action == AdminAction.ban){
|
}else if(action == AdminAction.ban){
|
||||||
netServer.admins.banPlayerIP(other.con.address);
|
netServer.admins.banPlayerIP(other.con().address);
|
||||||
other.con.kick(KickReason.banned);
|
other.kick(KickReason.banned);
|
||||||
Log.info("&lc{0} has banned {1}.", player.name, other.name);
|
Log.info("&lc{0} has banned {1}.", player.name(), other.name());
|
||||||
}else if(action == AdminAction.kick){
|
}else if(action == AdminAction.kick){
|
||||||
other.con.kick(KickReason.kick);
|
other.kick(KickReason.kick);
|
||||||
Log.info("&lc{0} has kicked {1}.", player.name, other.name);
|
Log.info("&lc{0} has kicked {1}.", player.name(), other.name());
|
||||||
}else if(action == AdminAction.trace){
|
}else if(action == AdminAction.trace){
|
||||||
TraceInfo info = new TraceInfo(other.con.address, other.uuid, other.con.modclient, other.con.mobile);
|
TraceInfo info = new TraceInfo(other.con().address, other.uuid(), other.con().modclient, other.con.mobile);
|
||||||
if(player.con != null){
|
if(player.con() != null){
|
||||||
Call.onTraceInfo(player.con, other, info);
|
Call.onTraceInfo(player.con(), other, info);
|
||||||
}else{
|
}else{
|
||||||
NetClient.onTraceInfo(other, info);
|
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)
|
@Remote(targets = Loc.client)
|
||||||
public static void connectConfirm(Player player){
|
public static void connectConfirm(Playerc player){
|
||||||
if(player.con == null || player.con.hasConnected) return;
|
if(player.con() == null || player.con().hasConnected) return;
|
||||||
|
|
||||||
player.add();
|
player.add();
|
||||||
player.con.hasConnected = true;
|
player.con().hasConnected = true;
|
||||||
if(Config.showConnectMessages.bool()){
|
if(Config.showConnectMessages.bool()){
|
||||||
Call.sendMessage("[accent]" + player.name + "[accent] has connected.");
|
Call.sendMessage("[accent]" + player.name() + "[accent] has connected.");
|
||||||
Log.info("&lm[{1}] &y{0} has connected. ", player.name, player.uuid);
|
Log.info("&lm[{1}] &y{0} has connected. ", player.name(), player.uuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Config.motd.string().equalsIgnoreCase("off")){
|
if(!Config.motd.string().equalsIgnoreCase("off")){
|
||||||
@@ -635,7 +635,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
if(state.rules.pvp){
|
if(state.rules.pvp){
|
||||||
int used = 0;
|
int used = 0;
|
||||||
for(TeamData t : state.teams.getActive()){
|
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++;
|
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();
|
syncStream.reset();
|
||||||
Array<CoreEntity> cores = state.teams.cores(player.team());
|
Array<CoreEntity> cores = state.teams.cores(player.team());
|
||||||
|
|
||||||
dataStream.writeByte(cores.size);
|
dataStream.writeByte(cores.size);
|
||||||
|
|
||||||
for(CoreEntity entity : cores){
|
for(CoreEntity entity : cores){
|
||||||
dataStream.writeInt(entity.tile.pos());
|
dataStream.writeInt(entity.tile().pos());
|
||||||
entity.items().write(dataStream);
|
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);
|
viewport.setSize(player.con.viewWidth, player.con.viewHeight).setCenter(player.con.viewX, player.con.viewY);
|
||||||
|
|
||||||
//check for syncable groups
|
//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
|
//make sure mapping is enabled for this group
|
||||||
if(!group.mappingEnabled()){
|
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.");
|
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()){
|
for(Entity entity : group.all()){
|
||||||
SyncTrait sync = (SyncTrait)entity;
|
SyncTrait sync = (SyncTrait)entity;
|
||||||
|
|
||||||
//write all entities now
|
//write all entities now
|
||||||
dataStream.writeInt(entity.getID()); //write id
|
dataStream.writeInt(entity.getID()); //write id
|
||||||
dataStream.writeByte(sync.getTypeID().id); //write type ID
|
dataStream.writeByte(sync.getTypeID().id); //write type ID
|
||||||
sync.write(dataStream); //write entity
|
sync.write(dataStream); //write entity
|
||||||
|
|
||||||
sent++;
|
sent++;
|
||||||
|
|
||||||
if(syncStream.size() > maxSnapshotSize){
|
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();
|
dataStream.close();
|
||||||
|
|
||||||
byte[] syncBytes = syncStream.toByteArray();
|
byte[] syncBytes = syncStream.toByteArray();
|
||||||
Call.onEntitySnapshot(player.con, (byte)group.getID(), (short)sent, (short)syncBytes.length, net.compressSnapshot(syncBytes));
|
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){
|
String fixName(String name){
|
||||||
@@ -824,9 +822,9 @@ public class NetServer implements ApplicationListener{
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
//iterate through each player
|
//iterate through each player
|
||||||
for(int i = 0; i < playerGroup.size(); i++){
|
for(int i = 0; i < Groups.player.size(); i++){
|
||||||
Player player = playerGroup.all().get(i);
|
Playerc player = Groups.player.all().get(i);
|
||||||
if(player.isLocal) continue;
|
if(player.isLocal()) continue;
|
||||||
|
|
||||||
if(player.con == null || !player.con.isConnected()){
|
if(player.con == null || !player.con.isConnected()){
|
||||||
onDisconnect(player, "disappeared");
|
onDisconnect(player, "disappeared");
|
||||||
@@ -835,12 +833,12 @@ public class NetServer implements ApplicationListener{
|
|||||||
|
|
||||||
NetConnection connection = player.con;
|
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);
|
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();
|
writeBlockSnapshots();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,6 +848,6 @@ public class NetServer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface TeamAssigner{
|
public interface TeamAssigner{
|
||||||
Team assign(Player player, Iterable<Player> players);
|
Team assign(Playerc player, Iterable<Playerc> players);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import arc.scene.ui.layout.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
@@ -242,7 +242,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
overlays.drawBottom();
|
overlays.drawBottom();
|
||||||
playerGroup.draw(p -> p.isLocal, Player::drawBuildRequests);
|
Groups.player.draw(p -> p.isLocal, Playerc::drawBuildRequests);
|
||||||
|
|
||||||
if(shieldGroup.countInBounds() > 0){
|
if(shieldGroup.countInBounds() > 0){
|
||||||
if(settings.getBool("animatedshields") && Shaders.shield != null){
|
if(settings.getBool("animatedshields") && Shaders.shield != null){
|
||||||
@@ -265,7 +265,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
|
|
||||||
overlays.drawTop();
|
overlays.drawTop();
|
||||||
|
|
||||||
playerGroup.draw(p -> !p.isDead(), Player::drawName);
|
Groups.player.draw(p -> !p.isDead(), Playerc::drawName);
|
||||||
|
|
||||||
if(state.rules.lighting){
|
if(state.rules.lighting){
|
||||||
lights.draw();
|
lights.draw();
|
||||||
@@ -311,10 +311,10 @@ public class Renderer implements ApplicationListener{
|
|||||||
Draw.rect("circle-shadow", u.x, u.y, size * rad, size * rad);
|
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()){
|
if(!Groups.player.isEmpty()){
|
||||||
playerGroup.draw(unit -> !unit.isDead(), draw::get);
|
Groups.player.draw(unit -> !unit.isDead(), draw::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.color();
|
Draw.color();
|
||||||
@@ -324,21 +324,21 @@ public class Renderer implements ApplicationListener{
|
|||||||
float trnsX = -12, trnsY = -13;
|
float trnsX = -12, trnsY = -13;
|
||||||
Draw.color(0, 0, 0, 0.22f);
|
Draw.color(0, 0, 0, 0.22f);
|
||||||
|
|
||||||
unitGroup.draw(unit -> unit.isFlying() && !unit.isDead(), baseUnit -> baseUnit.drawShadow(trnsX, trnsY));
|
Groups.unit.draw(unit -> unit.isFlying() && !unit.isDead(), baseUnit -> baseUnit.drawShadow(trnsX, trnsY));
|
||||||
playerGroup.draw(unit -> unit.isFlying() && !unit.isDead(), player -> player.drawShadow(trnsX, trnsY));
|
Groups.player.draw(unit -> unit.isFlying() && !unit.isDead(), player -> player.drawShadow(trnsX, trnsY));
|
||||||
|
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawAllTeams(boolean flying){
|
private void drawAllTeams(boolean flying){
|
||||||
unitGroup.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawUnder);
|
Groups.unit.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawUnder);
|
||||||
playerGroup.draw(p -> p.isFlying() == flying && !p.isDead(), Unitc::drawUnder);
|
Groups.player.draw(p -> p.isFlying() == flying && !p.isDead(), Unitc::drawUnder);
|
||||||
|
|
||||||
unitGroup.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawAll);
|
Groups.unit.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawAll);
|
||||||
playerGroup.draw(p -> p.isFlying() == flying, Unitc::drawAll);
|
Groups.player.draw(p -> p.isFlying() == flying, Unitc::drawAll);
|
||||||
|
|
||||||
unitGroup.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawOver);
|
Groups.unit.draw(u -> u.isFlying() == flying && !u.isDead(), Unitc::drawOver);
|
||||||
playerGroup.draw(p -> p.isFlying() == flying, Unitc::drawOver);
|
Groups.player.draw(p -> p.isFlying() == flying, Unitc::drawOver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scaleCamera(float amount){
|
public void scaleCamera(float amount){
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ public enum ContentType{
|
|||||||
status,
|
status,
|
||||||
unit,
|
unit,
|
||||||
weather,
|
weather,
|
||||||
effect,
|
effect_UNUSED,
|
||||||
zone,
|
zone,
|
||||||
loadout,
|
loadout_UNUSED,
|
||||||
typeid,
|
typeid_UNUSED,
|
||||||
error,
|
error,
|
||||||
planet;
|
planet;
|
||||||
|
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
platform.publish(map);
|
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();
|
menu.cont.row();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
collideLine(hitter, team, effect, x, y, angle, length, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ public class Damage{
|
|||||||
* Damages entities in a line.
|
* Damages entities in a line.
|
||||||
* Only enemies of the specified team are damaged.
|
* 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();
|
collidedBlocks.clear();
|
||||||
tr.trns(angle, length);
|
tr.trns(angle, length);
|
||||||
Intc2 collider = (cx, cy) -> {
|
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)){
|
if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.entity != null && tile.getTeamID() != team.id && tile.entity.collide(hitter)){
|
||||||
tile.entity.collision(hitter);
|
tile.entity.collision(hitter);
|
||||||
collidedBlocks.add(tile.pos());
|
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);
|
entity.damage(amount);
|
||||||
//TODO better velocity displacement
|
//TODO better velocity displacement
|
||||||
float dst = tr.set(entity.getX() - x, entity.getY() - y).len();
|
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){
|
if(complete && damage >= 9999999f && entity == player){
|
||||||
Events.fire(Trigger.exclusionDeath);
|
Events.fire(Trigger.exclusionDeath);
|
||||||
@@ -235,8 +235,8 @@ public class Damage{
|
|||||||
|
|
||||||
//apply damage to entity if needed
|
//apply damage to entity if needed
|
||||||
if(tile.entity != null && tile.getTeam() != team){
|
if(tile.entity != null && tile.getTeam() != team){
|
||||||
int health = (int)tile.entity.health;
|
int health = (int)tile.entity.health();
|
||||||
if(tile.entity.health > 0){
|
if(tile.entity.health() > 0){
|
||||||
tile.entity.damage(scaledDamage);
|
tile.entity.damage(scaledDamage);
|
||||||
scaledDamage -= health;
|
scaledDamage -= health;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ public class Effect{
|
|||||||
/** Clip size. */
|
/** Clip size. */
|
||||||
public float size;
|
public float size;
|
||||||
|
|
||||||
|
public boolean ground;
|
||||||
|
public float groundDuration;
|
||||||
|
|
||||||
public Effect(float life, float clipsize, Cons<EffectContainer> renderer){
|
public Effect(float life, float clipsize, Cons<EffectContainer> renderer){
|
||||||
this.id = lastid++;
|
this.id = lastid++;
|
||||||
this.lifetime = life;
|
this.lifetime = life;
|
||||||
@@ -27,6 +30,17 @@ public class Effect{
|
|||||||
this(life, 28f, renderer);
|
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){
|
public void at(Position pos){
|
||||||
Effects.createEffect(this, pos.getX(), pos.getY(), 0, Color.white, null);
|
Effects.createEffect(this, pos.getX(), pos.getY(), 0, Color.white, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import arc.graphics.*;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.pooling.*;
|
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -40,13 +38,14 @@ public class Effects{
|
|||||||
Rect pos = Tmp.r2.setSize(effect.size).setCenter(x, y);
|
Rect pos = Tmp.r2.setSize(effect.size).setCenter(x, y);
|
||||||
|
|
||||||
if(view.overlaps(pos)){
|
if(view.overlaps(pos)){
|
||||||
EffectEntity entity = Pools.obtain(EffectEntity.class, EffectEntity::new);
|
//TODO implement create() method here.
|
||||||
entity.effect = effect;
|
//EffectEntity entity = Pools.obtain(EffectEntity.class, EffectEntity::new);
|
||||||
entity.color.set(color);
|
//entity.effect = effect;
|
||||||
entity.rotation = rotation;
|
//entity.color.set(color);
|
||||||
entity.data = data;
|
//entity.rotation = rotation;
|
||||||
entity.id++;
|
//entity.data = data;
|
||||||
entity.set(x, y);
|
//entity.id++;
|
||||||
|
//entity.set(x, y);
|
||||||
//if(data instanceof Entity){
|
//if(data instanceof Entity){
|
||||||
// entity.setParent((Entity)data);
|
// entity.setParent((Entity)data);
|
||||||
//}
|
//}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package mindustry.entities;
|
|||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -18,7 +18,7 @@ public class Units{
|
|||||||
private static boolean boolResult;
|
private static boolean boolResult;
|
||||||
|
|
||||||
/** @return whether this player can interact with a specific tile. if either of these are null, returns true.*/
|
/** @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());
|
return player == null || tile == null || tile.interactable(player.team());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ public class Units{
|
|||||||
|
|
||||||
/** Iterates over all units in a rectangle. */
|
/** Iterates over all units in a rectangle. */
|
||||||
public static void nearby(Team team, float x, float y, float width, float height, Cons<Unitc> cons){
|
public static void nearby(Team team, float x, float y, float width, float height, Cons<Unitc> cons){
|
||||||
unitGroup.intersect(x, y, width, height, u -> {
|
Groups.unit.intersect(x, y, width, height, u -> {
|
||||||
if(u.getTeam() == team){
|
if(u.getTeam() == team){
|
||||||
cons.get(u);
|
cons.get(u);
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ public class Units{
|
|||||||
|
|
||||||
/** Iterates over all units in a circle around this position. */
|
/** Iterates over all units in a circle around this position. */
|
||||||
public static void nearby(Team team, float x, float y, float radius, Cons<Unitc> cons){
|
public static void nearby(Team team, float x, float y, float radius, Cons<Unitc> 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)){
|
if(unit.getTeam() == team && unit.withinDst(x, y, radius)){
|
||||||
cons.get(unit);
|
cons.get(unit);
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ public class Units{
|
|||||||
|
|
||||||
/** Iterates over all units in a rectangle. */
|
/** Iterates over all units in a rectangle. */
|
||||||
public static void nearby(float x, float y, float width, float height, Cons<Unitc> cons){
|
public static void nearby(float x, float y, float width, float height, Cons<Unitc> cons){
|
||||||
unitGroup.intersect(x, y, width, height, cons);
|
Groups.unit.intersect(x, y, width, height, cons);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Iterates over all units in a rectangle. */
|
/** Iterates over all units in a rectangle. */
|
||||||
@@ -176,7 +176,7 @@ public class Units{
|
|||||||
|
|
||||||
/** Iterates over all units that are enemies of this team. */
|
/** 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<Unitc> cons){
|
public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons<Unitc> cons){
|
||||||
unitGroup.intersect(x, y, width, height, u -> {
|
Groups.unit.intersect(x, y, width, height, u -> {
|
||||||
if(team.isEnemy(u.getTeam())){
|
if(team.isEnemy(u.getTeam())){
|
||||||
cons.get(u);
|
cons.get(u);
|
||||||
}
|
}
|
||||||
@@ -190,11 +190,11 @@ public class Units{
|
|||||||
|
|
||||||
/** Iterates over all units. */
|
/** Iterates over all units. */
|
||||||
public static void all(Cons<Unitc> cons){
|
public static void all(Cons<Unitc> cons){
|
||||||
unitGroup.all().each(cons);
|
Groups.unit.all().each(cons);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void each(Team team, Cons<BaseUnit> cons){
|
public static void each(Team team, Cons<Unitc> cons){
|
||||||
unitGroup.all().each(t -> t.getTeam() == team, cons);
|
Groups.unit.all().each(t -> t.getTeam() == team, cons);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class ArtilleryBulletType extends BasicBulletType{
|
|||||||
super.update(b);
|
super.update(b);
|
||||||
|
|
||||||
if(b.timer.get(0, 3 + b.fslope() * 2f)){
|
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());
|
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||||
|
|
||||||
Draw.color(backColor);
|
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.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();
|
Draw.color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ public class BasicBulletType extends BulletType{
|
|||||||
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||||
|
|
||||||
Draw.color(backColor);
|
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.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();
|
Draw.color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public abstract class BulletType extends Content{
|
|||||||
|
|
||||||
bullet.velocity.set(0, type.speed).setAngle(angle).scl(velocityScl);
|
bullet.velocity.set(0, type.speed).setAngle(angle).scl(velocityScl);
|
||||||
if(type.keepVelocity){
|
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;
|
bullet.team = team;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class FlakBulletType extends BasicBulletType{
|
|||||||
if(b.getData() instanceof Integer) return;
|
if(b.getData() instanceof Integer) return;
|
||||||
|
|
||||||
if(b.timer.get(2, 6)){
|
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(b.getData() instanceof Float) return;
|
||||||
|
|
||||||
if(unit.dst(b) < explodeRange){
|
if(unit.dst(b) < explodeRange){
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ public class HealBulletType extends BulletType{
|
|||||||
public void draw(Bulletc b){
|
public void draw(Bulletc b){
|
||||||
Draw.color(backColor);
|
Draw.color(backColor);
|
||||||
Lines.stroke(bulletWidth);
|
Lines.stroke(bulletWidth);
|
||||||
Lines.lineAngleCenter(b.x, b.y, b.rot(), bulletHeight);
|
Lines.lineAngleCenter(b.x(), b.y(), b.rotation(), bulletHeight);
|
||||||
Draw.color(frontColor);
|
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();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class LaserBulletType extends BulletType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bulletc b){
|
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
|
@Override
|
||||||
@@ -51,18 +51,18 @@ public class LaserBulletType extends BulletType{
|
|||||||
float cwidth = width;
|
float cwidth = width;
|
||||||
float compound = 1f;
|
float compound = 1f;
|
||||||
|
|
||||||
Lines.lineAngle(b.x, b.y, b.rot(), baseLen);
|
Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen);
|
||||||
Lines.precise(true);
|
Lines.precise(true);
|
||||||
for(Color color : colors){
|
for(Color color : colors){
|
||||||
Draw.color(color);
|
Draw.color(color);
|
||||||
Lines.stroke((cwidth *= lengthFalloff) * b.fout());
|
Lines.stroke((cwidth *= lengthFalloff) * b.fout());
|
||||||
Lines.lineAngle(b.x, b.y, b.rot(), baseLen, CapStyle.none);
|
Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen, CapStyle.none);
|
||||||
Tmp.v1.trns(b.rot(), baseLen);
|
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.rot());
|
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){
|
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;
|
compound *= lengthFalloff;
|
||||||
|
|||||||
@@ -25,6 +25,6 @@ public class LightningBulletType extends BulletType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bulletc b){
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class LiquidBulletType extends BulletType{
|
|||||||
super.update(b);
|
super.update(b);
|
||||||
|
|
||||||
if(liquid.canExtinguish()){
|
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)){
|
if(tile != null && Fire.has(tile.x, tile.y)){
|
||||||
Fire.extinguish(tile, 100f);
|
Fire.extinguish(tile, 100f);
|
||||||
b.remove();
|
b.remove();
|
||||||
@@ -61,7 +61,7 @@ public class LiquidBulletType extends BulletType{
|
|||||||
public void draw(Bulletc b){
|
public void draw(Bulletc b){
|
||||||
Draw.color(liquid.color, Color.white, b.fout() / 100f);
|
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
|
@Override
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ public class MassDriverBolt extends BulletType{
|
|||||||
float w = 11f, h = 13f;
|
float w = 11f, h = 13f;
|
||||||
|
|
||||||
Draw.color(Pal.bulletYellowBack);
|
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.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();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
@@ -92,8 +92,8 @@ public class MassDriverBolt extends BulletType{
|
|||||||
for(int i = 0; i < data.items.length; i++){
|
for(int i = 0; i < data.items.length; i++){
|
||||||
int amountDropped = Mathf.random(0, data.items[i]);
|
int amountDropped = Mathf.random(0, data.items[i]);
|
||||||
if(amountDropped > 0){
|
if(amountDropped > 0){
|
||||||
float angle = b.rot() + Mathf.range(100f);
|
float angle = b.rotation() + Mathf.range(100f);
|
||||||
Fx.dropItem.at(b.x, b.y, angle, Color.white, content.item(i));
|
Fx.dropItem.at(b.x(), b.y(), angle, Color.white, content.item(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ public class MissileBulletType extends BasicBulletType{
|
|||||||
super.update(b);
|
super.update(b);
|
||||||
|
|
||||||
if(Mathf.chance(Time.delta() * 0.2)){
|
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){
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import arc.util.pooling.*;
|
|||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
|
import mindustry.core.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
@@ -25,7 +26,9 @@ import mindustry.game.EventType.*;
|
|||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.net.Administration.*;
|
||||||
import mindustry.net.*;
|
import mindustry.net.*;
|
||||||
|
import mindustry.net.Packets.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -179,6 +182,11 @@ public class EntityComps{
|
|||||||
|
|
||||||
Object data;
|
Object data;
|
||||||
BulletType type;
|
BulletType type;
|
||||||
|
Interval timer = new Interval(6);
|
||||||
|
|
||||||
|
public boolean timer(int index, float time){
|
||||||
|
return timer.get(index, time);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getDamage(){
|
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
|
@Component
|
||||||
abstract class TeamComp implements Posc, Healthc{
|
abstract class TeamComp implements Posc, Healthc{
|
||||||
transient float x, y;
|
transient float x, y;
|
||||||
@@ -1194,6 +1332,25 @@ public class EntityComps{
|
|||||||
current.progress = entity.progress;
|
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. */
|
/** @return whether this request should be skipped, in favor of the next one. */
|
||||||
boolean shouldSkip(BuildRequest request, @Nullable Tilec core){
|
boolean shouldSkip(BuildRequest request, @Nullable Tilec core){
|
||||||
//requests that you have at least *started* are considered
|
//requests that you have at least *started* are considered
|
||||||
@@ -1557,7 +1714,7 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean isLocal(){
|
boolean isLocal(){
|
||||||
return this == Vars.player;
|
return this instanceof Unitc && ((Unitc)this).controller() == player || this == player;
|
||||||
}
|
}
|
||||||
|
|
||||||
<T> T as(Class<T> type){
|
<T> T as(Class<T> type){
|
||||||
@@ -1566,5 +1723,13 @@ public class EntityComps{
|
|||||||
|
|
||||||
@InternalImpl
|
@InternalImpl
|
||||||
abstract int classId();
|
abstract int classId();
|
||||||
|
|
||||||
|
void read(DataInput input) throws IOException{
|
||||||
|
//TODO dynamic io
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(DataOutput output) throws IOException{
|
||||||
|
//TODO dynamic io
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,7 @@ class EntityDefs{
|
|||||||
|
|
||||||
@EntityDef({DecalComp.class})
|
@EntityDef({DecalComp.class})
|
||||||
class DecalDef{}
|
class DecalDef{}
|
||||||
|
|
||||||
|
@EntityDef({PlayerComp.class})
|
||||||
|
class PlayerDef{}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ import mindustry.entities.def.EntityComps.*;
|
|||||||
|
|
||||||
public class EntityGroupDefs{
|
public class EntityGroupDefs{
|
||||||
|
|
||||||
|
@GroupDef(PlayerComp.class)
|
||||||
|
void player(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@GroupDef(UnitComp.class)
|
@GroupDef(UnitComp.class)
|
||||||
void unit(){
|
void unit(){
|
||||||
|
|
||||||
@@ -16,7 +21,12 @@ public class EntityGroupDefs{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GroupDef(DrawComp.class)
|
@GroupDef(DrawComp.class)
|
||||||
void drawers(){
|
void drawer(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GroupDef(SyncComp.class)
|
||||||
|
void sync(){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ import arc.util.pooling.*;
|
|||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
|||||||
|
|
||||||
unit.applyEffect(liquid.effect, 60 * 2);
|
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);
|
Fx.ripple.at(liquid.color, unit.x, unit.y);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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<BuildRequest> 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<BuildRequest> 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
|
|
||||||
}
|
|
||||||
@@ -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();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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<BuildRequest> 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<BuildRequest> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ package mindustry.game;
|
|||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -62,10 +62,10 @@ public class EventType{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class PlayerChatEvent{
|
public static class PlayerChatEvent{
|
||||||
public final Player player;
|
public final Playerc player;
|
||||||
public final String message;
|
public final String message;
|
||||||
|
|
||||||
public PlayerChatEvent(Player player, String message){
|
public PlayerChatEvent(Playerc player, String message){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
@@ -144,11 +144,11 @@ public class EventType{
|
|||||||
/** Called when the player withdraws items from a block. */
|
/** Called when the player withdraws items from a block. */
|
||||||
public static class WithdrawEvent{
|
public static class WithdrawEvent{
|
||||||
public final Tile tile;
|
public final Tile tile;
|
||||||
public final Player player;
|
public final Playerc player;
|
||||||
public final Item item;
|
public final Item item;
|
||||||
public final int amount;
|
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.tile = tile;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
@@ -159,11 +159,11 @@ public class EventType{
|
|||||||
/** Called when a player deposits items to a block.*/
|
/** Called when a player deposits items to a block.*/
|
||||||
public static class DepositEvent{
|
public static class DepositEvent{
|
||||||
public final Tile tile;
|
public final Tile tile;
|
||||||
public final Player player;
|
public final Playerc player;
|
||||||
public final Item item;
|
public final Item item;
|
||||||
public final int amount;
|
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.tile = tile;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
@@ -174,9 +174,9 @@ public class EventType{
|
|||||||
/** Called when the player taps a block. */
|
/** Called when the player taps a block. */
|
||||||
public static class TapEvent{
|
public static class TapEvent{
|
||||||
public final Tile tile;
|
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.tile = tile;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
@@ -185,10 +185,10 @@ public class EventType{
|
|||||||
/** Called when the player sets a specific block. */
|
/** Called when the player sets a specific block. */
|
||||||
public static class TapConfigEvent{
|
public static class TapConfigEvent{
|
||||||
public final Tile tile;
|
public final Tile tile;
|
||||||
public final Player player;
|
public final Playerc player;
|
||||||
public final int value;
|
public final int value;
|
||||||
|
|
||||||
public TapConfigEvent(Tile tile, Player player, int value){
|
public TapConfigEvent(Tile tile, Playerc player, int value){
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@@ -262,10 +262,10 @@ public class EventType{
|
|||||||
public final Tile tile;
|
public final Tile tile;
|
||||||
public final Team team;
|
public final Team team;
|
||||||
public final @Nullable
|
public final @Nullable
|
||||||
Player player;
|
Playerc player;
|
||||||
public final boolean breaking;
|
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.tile = tile;
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@@ -323,10 +323,10 @@ public class EventType{
|
|||||||
|
|
||||||
//TODO rename
|
//TODO rename
|
||||||
public static class MechChangeEvent{
|
public static class MechChangeEvent{
|
||||||
public final Player player;
|
public final Playerc player;
|
||||||
public final UnitDef mech;
|
public final UnitDef mech;
|
||||||
|
|
||||||
public MechChangeEvent(Player player, UnitDef mech){
|
public MechChangeEvent(Playerc player, UnitDef mech){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.mech = mech;
|
this.mech = mech;
|
||||||
}
|
}
|
||||||
@@ -334,42 +334,42 @@ public class EventType{
|
|||||||
|
|
||||||
/** Called after connecting; when a player recieves world data and is ready to play.*/
|
/** Called after connecting; when a player recieves world data and is ready to play.*/
|
||||||
public static class PlayerJoin{
|
public static class PlayerJoin{
|
||||||
public final Player player;
|
public final Playerc player;
|
||||||
|
|
||||||
public PlayerJoin(Player player){
|
public PlayerJoin(Playerc player){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called when a player connects, but has not joined the game yet.*/
|
/** Called when a player connects, but has not joined the game yet.*/
|
||||||
public static class PlayerConnect{
|
public static class PlayerConnect{
|
||||||
public final Player player;
|
public final Playerc player;
|
||||||
|
|
||||||
public PlayerConnect(Player player){
|
public PlayerConnect(Playerc player){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PlayerLeave{
|
public static class PlayerLeave{
|
||||||
public final Player player;
|
public final Playerc player;
|
||||||
|
|
||||||
public PlayerLeave(Player player){
|
public PlayerLeave(Playerc player){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PlayerBanEvent{
|
public static class PlayerBanEvent{
|
||||||
public final Player player;
|
public final Playerc player;
|
||||||
|
|
||||||
public PlayerBanEvent(Player player){
|
public PlayerBanEvent(Playerc player){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PlayerUnbanEvent{
|
public static class PlayerUnbanEvent{
|
||||||
public final Player player;
|
public final Playerc player;
|
||||||
|
|
||||||
public PlayerUnbanEvent(Player player){
|
public PlayerUnbanEvent(Playerc player){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import arc.util.serialization.Json.Serializable;
|
|||||||
import arc.util.serialization.JsonValue;
|
import arc.util.serialization.JsonValue;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.ctype.ContentType;
|
import mindustry.ctype.ContentType;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
|
||||||
import static mindustry.Vars.content;
|
import static mindustry.Vars.content;
|
||||||
@@ -18,7 +19,7 @@ public class SpawnGroup implements Serializable{
|
|||||||
public static final int never = Integer.MAX_VALUE;
|
public static final int never = Integer.MAX_VALUE;
|
||||||
|
|
||||||
/** The unit type spawned */
|
/** The unit type spawned */
|
||||||
public UnitType type;
|
public UnitDef type;
|
||||||
/** When this spawn should end */
|
/** When this spawn should end */
|
||||||
public int end = never;
|
public int end = never;
|
||||||
/** When this spawn should start */
|
/** When this spawn should start */
|
||||||
@@ -36,7 +37,7 @@ public class SpawnGroup implements Serializable{
|
|||||||
/** Items this unit spawns with. Null to disable. */
|
/** Items this unit spawns with. Null to disable. */
|
||||||
public ItemStack items;
|
public ItemStack items;
|
||||||
|
|
||||||
public SpawnGroup(UnitType type){
|
public SpawnGroup(UnitDef type){
|
||||||
this.type = 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.
|
* Creates a unit, and assigns correct values based on this group's data.
|
||||||
* This method does not add() the unit.
|
* This method does not add() the unit.
|
||||||
*/
|
*/
|
||||||
public BaseUnit createUnit(Team team){
|
public Unitc createUnit(Team team){
|
||||||
BaseUnit unit = type.create(team);
|
//TODO
|
||||||
|
throw new IllegalArgumentException("TODO");
|
||||||
|
/*
|
||||||
|
Unitc unit = type.create(team);
|
||||||
|
|
||||||
if(effect != null){
|
if(effect != null){
|
||||||
unit.applyEffect(effect, 999999f);
|
unit.applyEffect(effect, 999999f);
|
||||||
@@ -67,7 +71,7 @@ public class SpawnGroup implements Serializable{
|
|||||||
unit.addItem(items.item, items.amount);
|
unit.addItem(items.item, items.amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return unit;
|
return unit;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import arc.scene.ui.*;
|
|||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import arc.util.*;
|
|||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.pooling.*;
|
import arc.util.pooling.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.io.*;
|
import mindustry.io.*;
|
||||||
import mindustry.ui.*;
|
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.rect(unit.getIconRegion(), x + rx, y + ry, scale, scale, unit.rotation - 90);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|
||||||
if(withLabels && unit instanceof Player){
|
if(withLabels && unit instanceof Playerc){
|
||||||
Player pl = (Player) unit;
|
Playerc pl = (Playerc) unit;
|
||||||
if(!pl.isLocal){
|
if(!pl.isLocal){
|
||||||
// Only display names for other players.
|
// Only display names for other players.
|
||||||
drawLabel(x + rx, y + ry, pl.name, unit.getTeam().color);
|
drawLabel(x + rx, y + ry, pl.name, unit.getTeam().color);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import arc.util.*;
|
|||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.input.*;
|
import mindustry.input.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
@@ -36,7 +36,7 @@ public class OverlayRenderer{
|
|||||||
public void drawTop(){
|
public void drawTop(){
|
||||||
|
|
||||||
if(Core.settings.getBool("indicators")){
|
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(Vars.player != player && Vars.player.team() == player.team()){
|
||||||
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
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)){
|
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import arc.graphics.Texture.TextureFilter;
|
|||||||
import arc.graphics.g2d.Draw;
|
import arc.graphics.g2d.Draw;
|
||||||
import arc.graphics.gl.FrameBuffer;
|
import arc.graphics.gl.FrameBuffer;
|
||||||
import arc.util.Disposable;
|
import arc.util.Disposable;
|
||||||
import mindustry.entities.type.Player;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
import static arc.Core.camera;
|
import static arc.Core.camera;
|
||||||
import static arc.Core.graphics;
|
import static arc.Core.graphics;
|
||||||
import static mindustry.Vars.playerGroup;
|
import static mindustry.Groups.player;
|
||||||
import static mindustry.Vars.renderer;
|
import static mindustry.Vars.renderer;
|
||||||
|
|
||||||
public class Pixelator implements Disposable{
|
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.rect(Draw.wrap(buffer.getTexture()), Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height);
|
||||||
Draw.blend();
|
Draw.blend();
|
||||||
|
|
||||||
playerGroup.draw(p -> !p.isDead(), Player::drawName);
|
Groups.player.draw(p -> !p.isDead(), Playerc::drawName);
|
||||||
|
|
||||||
Core.camera.position.set(px, py);
|
Core.camera.position.set(px, py);
|
||||||
Core.settings.put("animatedwater", hadWater);
|
Core.settings.put("animatedwater", hadWater);
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
super.update();
|
||||||
|
|
||||||
if(net.active() && Core.input.keyTap(Binding.player_list)){
|
if(net.active() && Core.input.keyTap(Binding.player_list)){
|
||||||
ui.listfrag.toggle();
|
ui.listfrag.toggle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import mindustry.annotations.Annotations.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.effect.*;
|
import mindustry.entities.effect.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
@@ -73,7 +73,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.client, called = Loc.server)
|
@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){
|
if(net.server() && player.item().amount <= 0){
|
||||||
throw new ValidateException(player, "Player cannot drop an item.");
|
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)
|
@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) ||
|
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)))){
|
!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.");
|
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)
|
@Remote(targets = Loc.both, forward = true, called = Loc.server)
|
||||||
public static void transferInventory(Player player, Tile tile){
|
public static void transferInventory(Playerc player, Tile tile){
|
||||||
if(player == null || player.timer == null) return;
|
if(player == null) return;
|
||||||
if(net.server() && (player.item().amount <= 0 || player.isTransferring|| !Units.canInteract(player, tile) ||
|
if(net.server() && (player.item().amount <= 0 || player.isTransferring|| !Units.canInteract(player, tile) ||
|
||||||
!netServer.admins.allowAction(player, ActionType.depositItem, tile, action -> {
|
!netServer.admins.allowAction(player, ActionType.depositItem, tile, action -> {
|
||||||
action.itemAmount = player.item().amount;
|
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)
|
@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(tile == null || player == null) return;
|
||||||
if(net.server() && (!Units.canInteract(player, tile) ||
|
if(net.server() && (!Units.canInteract(player, tile) ||
|
||||||
!netServer.admins.allowAction(player, ActionType.tapTile, tile, action -> {}))) throw new ValidateException(player, "Player cannot tap a 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)
|
@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(tile == null) return;
|
||||||
|
|
||||||
if(net.server() && (!Units.canInteract(player, tile) ||
|
if(net.server() && (!Units.canInteract(player, tile) ||
|
||||||
@@ -183,7 +183,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
|
player.typing(ui.chatfrag.shown());
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMouseX(){
|
public float getMouseX(){
|
||||||
@@ -637,7 +637,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
&& tile.drop() != null && tile.drop().hardness <= player.mech.drillPower
|
&& tile.drop() != null && tile.drop().hardness <= player.mech.drillPower
|
||||||
&& !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null)
|
&& !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null)
|
||||||
&& player.acceptsItem(tile.drop())
|
&& 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. */
|
/** 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 int x, y, rotation;
|
||||||
public boolean last;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -577,6 +577,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
super.update();
|
||||||
|
|
||||||
if(state.is(State.menu) ){
|
if(state.is(State.menu) ){
|
||||||
selectRequests.clear();
|
selectRequests.clear();
|
||||||
removals.clear();
|
removals.clear();
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class Placement{
|
|||||||
int nodeLimit = 1000;
|
int nodeLimit = 1000;
|
||||||
int totalNodes = 0;
|
int totalNodes = 0;
|
||||||
|
|
||||||
PriorityQueue<Tile> 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<Tile> 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);
|
queue.add(start);
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
while(!queue.isEmpty() && totalNodes++ < nodeLimit){
|
while(!queue.isEmpty() && totalNodes++ < nodeLimit){
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
package mindustry.io;
|
package mindustry.io;
|
||||||
|
|
||||||
import mindustry.annotations.Annotations.ReadClass;
|
import arc.graphics.*;
|
||||||
import mindustry.annotations.Annotations.WriteClass;
|
import mindustry.annotations.Annotations.*;
|
||||||
import arc.graphics.Color;
|
import mindustry.ctype.*;
|
||||||
import mindustry.ctype.ContentType;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.entities.Effects;
|
|
||||||
import mindustry.entities.*;
|
|
||||||
import mindustry.entities.bullet.BulletType;
|
|
||||||
import mindustry.entities.units.BuildRequest;
|
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.net.Administration.TraceInfo;
|
import mindustry.net.Administration.*;
|
||||||
import mindustry.net.Packets.AdminAction;
|
import mindustry.net.Packets.*;
|
||||||
import mindustry.net.Packets.KickReason;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -26,76 +20,6 @@ import static mindustry.Vars.*;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class TypeIO{
|
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)
|
@WriteClass(Tile.class)
|
||||||
public static void writeTile(ByteBuffer buffer, Tile tile){
|
public static void writeTile(ByteBuffer buffer, Tile tile){
|
||||||
buffer.putInt(tile == null ? Pos.get(-1, -1) : tile.pos());
|
buffer.putInt(tile == null ? Pos.get(-1, -1) : tile.pos());
|
||||||
@@ -220,16 +144,6 @@ public class TypeIO{
|
|||||||
return AdminAction.values()[buffer.get()];
|
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)
|
@WriteClass(UnitDef.class)
|
||||||
public static void writeUnitDef(ByteBuffer buffer, UnitDef effect){
|
public static void writeUnitDef(ByteBuffer buffer, UnitDef effect){
|
||||||
buffer.putShort(effect.id);
|
buffer.putShort(effect.id);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package mindustry.io.versions;
|
|||||||
|
|
||||||
import arc.func.Prov;
|
import arc.func.Prov;
|
||||||
import mindustry.entities.effect.*;
|
import mindustry.entities.effect.*;
|
||||||
import mindustry.entities.type.Player;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.type.base.*;
|
import mindustry.entities.type.base.*;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -78,7 +78,7 @@ public class LegacyTypeTable{
|
|||||||
13 = Revenant
|
13 = Revenant
|
||||||
*/
|
*/
|
||||||
private static final Prov[] build81Table = {
|
private static final Prov[] build81Table = {
|
||||||
Player::new,
|
Playerc::new,
|
||||||
Fire::new,
|
Fire::new,
|
||||||
Puddle::new,
|
Puddle::new,
|
||||||
MinerDrone::new,
|
MinerDrone::new,
|
||||||
@@ -95,7 +95,7 @@ public class LegacyTypeTable{
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static final Prov[] build80Table = {
|
private static final Prov[] build80Table = {
|
||||||
Player::new,
|
Playerc::new,
|
||||||
Fire::new,
|
Fire::new,
|
||||||
Puddle::new,
|
Puddle::new,
|
||||||
Bullet::new,
|
Bullet::new,
|
||||||
@@ -114,7 +114,7 @@ public class LegacyTypeTable{
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static final Prov[] build79Table = {
|
private static final Prov[] build79Table = {
|
||||||
Player::new,
|
Playerc::new,
|
||||||
Fire::new,
|
Fire::new,
|
||||||
Puddle::new,
|
Puddle::new,
|
||||||
Bullet::new,
|
Bullet::new,
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ public class Map implements Comparable<Map>, Publishable{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean prePublish(){
|
public boolean prePublish(){
|
||||||
tags.put("author", player.name);
|
tags.put("author", player.name());
|
||||||
ui.editor.editor.getTags().put("author", tags.get("author"));
|
ui.editor.editor.getTags().put("author", tags.get("author"));
|
||||||
ui.editor.save();
|
ui.editor.save();
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public abstract class BasicGenerator extends RandomGenerator{
|
|||||||
Tile end = tiles.getn(endX, endY);
|
Tile end = tiles.getn(endX, endY);
|
||||||
GridBits closed = new GridBits(width, height);
|
GridBits closed = new GridBits(width, height);
|
||||||
IntFloatMap costs = new IntFloatMap();
|
IntFloatMap costs = new IntFloatMap();
|
||||||
PriorityQueue<Tile> 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<Tile> 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);
|
queue.add(start);
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
while(!queue.isEmpty()){
|
while(!queue.isEmpty()){
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import mindustry.content.TechTree.*;
|
|||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.Effects.*;
|
import mindustry.entities.Effects.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.game.Objectives.*;
|
import mindustry.game.Objectives.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
@@ -280,7 +280,7 @@ public class ContentParser{
|
|||||||
|
|
||||||
UnitType unit;
|
UnitType unit;
|
||||||
if(locate(ContentType.unit, name) == null){
|
if(locate(ContentType.unit, name) == null){
|
||||||
Class<BaseUnit> type = resolve(legacyUnitMap.get(Strings.capitalize(getType(value)), getType(value)), "mindustry.entities.type.base");
|
Class<Unitc> type = resolve(legacyUnitMap.get(Strings.capitalize(getType(value)), getType(value)), "mindustry.entities.type.base");
|
||||||
unit = new UnitDef(mod + "-" + name, supply(type));
|
unit = new UnitDef(mod + "-" + name, supply(type));
|
||||||
}else{
|
}else{
|
||||||
unit = locate(ContentType.unit, name);
|
unit = locate(ContentType.unit, name);
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import arc.func.*;
|
|||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.pooling.*;
|
|
||||||
import arc.util.pooling.Pool.*;
|
import arc.util.pooling.Pool.*;
|
||||||
|
import arc.util.pooling.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ public class Administration{
|
|||||||
//anti-spam
|
//anti-spam
|
||||||
addChatFilter((player, message) -> {
|
addChatFilter((player, message) -> {
|
||||||
long resetTime = Config.messageRateLimit.num() * 1000;
|
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
|
//prevent people from spamming messages quickly
|
||||||
if(resetTime > 0 && Time.timeSinceMillis(player.getInfo().lastMessageTime) < resetTime){
|
if(resetTime > 0 && Time.timeSinceMillis(player.getInfo().lastMessageTime) < resetTime){
|
||||||
//supress message
|
//supress message
|
||||||
@@ -39,7 +39,7 @@ public class Administration{
|
|||||||
player.getInfo().messageInfractions ++;
|
player.getInfo().messageInfractions ++;
|
||||||
//kick player for spamming and prevent connection if they've done this several times
|
//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){
|
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;
|
return null;
|
||||||
}else{
|
}else{
|
||||||
@@ -86,7 +86,7 @@ public class Administration{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Filters out a chat message. */
|
/** Filters out a chat message. */
|
||||||
public @Nullable String filterMessage(Player player, String message){
|
public @Nullable String filterMessage(Playerc player, String message){
|
||||||
String current = message;
|
String current = message;
|
||||||
for(ChatFilter f : chatFilters){
|
for(ChatFilter f : chatFilters){
|
||||||
current = f.filter(player, message);
|
current = f.filter(player, message);
|
||||||
@@ -101,7 +101,7 @@ public class Administration{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return whether this action is allowed by the action filters. */
|
/** @return whether this action is allowed by the action filters. */
|
||||||
public boolean allowAction(Player player, ActionType type, Tile tile, Cons<PlayerAction> setter){
|
public boolean allowAction(Playerc player, ActionType type, Tile tile, Cons<PlayerAction> setter){
|
||||||
PlayerAction act = Pools.obtain(PlayerAction.class, PlayerAction::new);
|
PlayerAction act = Pools.obtain(PlayerAction.class, PlayerAction::new);
|
||||||
setter.get(act.set(player, type, tile));
|
setter.get(act.set(player, type, tile));
|
||||||
for(ActionFilter filter : actionFilters){
|
for(ActionFilter filter : actionFilters){
|
||||||
@@ -172,7 +172,7 @@ public class Administration{
|
|||||||
getCreateInfo(id).banned = true;
|
getCreateInfo(id).banned = true;
|
||||||
|
|
||||||
save();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ public class Administration{
|
|||||||
info.banned = false;
|
info.banned = false;
|
||||||
bannedIPs.removeAll(info.ips, false);
|
bannedIPs.removeAll(info.ips, false);
|
||||||
save();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +515,7 @@ public class Administration{
|
|||||||
/** Handles chat messages from players and changes their contents. */
|
/** Handles chat messages from players and changes their contents. */
|
||||||
public interface ChatFilter{
|
public interface ChatFilter{
|
||||||
/** @return the filtered message; a null string signals that the message should not be sent. */
|
/** @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. */
|
/** 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.
|
/** Defines a (potentially dangerous) action that a player has done in the world.
|
||||||
* These objects are pooled; do not cache them! */
|
* These objects are pooled; do not cache them! */
|
||||||
public static class PlayerAction implements Poolable{
|
public static class PlayerAction implements Poolable{
|
||||||
public @NonNull Player player;
|
public @NonNull Playerc player;
|
||||||
public @NonNull ActionType type;
|
public @NonNull ActionType type;
|
||||||
public @NonNull Tile tile;
|
public @NonNull Tile tile;
|
||||||
|
|
||||||
@@ -554,7 +554,7 @@ public class Administration{
|
|||||||
public @Nullable Item item;
|
public @Nullable Item item;
|
||||||
public int itemAmount;
|
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.player = player;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class CrashSender{
|
|||||||
ex(() -> value.addChild("revision", new JsonValue(Version.revision)));
|
ex(() -> value.addChild("revision", new JsonValue(Version.revision)));
|
||||||
ex(() -> value.addChild("net", new JsonValue(fn)));
|
ex(() -> value.addChild("net", new JsonValue(fn)));
|
||||||
ex(() -> value.addChild("server", new JsonValue(fs)));
|
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("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("os", new JsonValue(System.getProperty("os.name") + "x" + (OS.is64Bit ? "64" : "32"))));
|
||||||
ex(() -> value.addChild("trace", new JsonValue(parseException(exception))));
|
ex(() -> value.addChild("trace", new JsonValue(parseException(exception))));
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package mindustry.net;
|
|||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.net.Administration.*;
|
import mindustry.net.Administration.*;
|
||||||
@@ -16,8 +15,9 @@ import static mindustry.Vars.netServer;
|
|||||||
|
|
||||||
public abstract class NetConnection{
|
public abstract class NetConnection{
|
||||||
public final String address;
|
public final String address;
|
||||||
|
public String uuid = "AAAAAAAA", usid = uuid;
|
||||||
public boolean mobile, modclient;
|
public boolean mobile, modclient;
|
||||||
public @Nullable Player player;
|
public @Nullable Playerc player;
|
||||||
|
|
||||||
/** ID of last recieved client snapshot. */
|
/** ID of last recieved client snapshot. */
|
||||||
public int lastRecievedClientSnapshot = -1;
|
public int lastRecievedClientSnapshot = -1;
|
||||||
@@ -37,8 +37,8 @@ public abstract class NetConnection{
|
|||||||
public void kick(KickReason reason){
|
public void kick(KickReason reason){
|
||||||
Log.info("Kicking connection {0}; Reason: {1}", address, reason.name());
|
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){
|
if((reason == KickReason.kick || reason == KickReason.banned || reason == KickReason.vote)){
|
||||||
PlayerInfo info = netServer.admins.getInfo(player.uuid);
|
PlayerInfo info = netServer.admins.getInfo(uuid);
|
||||||
info.timesKicked++;
|
info.timesKicked++;
|
||||||
info.lastKicked = Math.max(Time.millis() + 30 * 1000, info.lastKicked);
|
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){
|
public void kick(String reason, int kickDuration){
|
||||||
Log.info("Kicking connection {0}; Reason: {1}", address, reason.replace("\n", " "));
|
Log.info("Kicking connection {0}; Reason: {1}", address, reason.replace("\n", " "));
|
||||||
|
|
||||||
if(player != null && player.uuid != null){
|
PlayerInfo info = netServer.admins.getInfo(uuid);
|
||||||
PlayerInfo info = netServer.admins.getInfo(player.uuid);
|
info.timesKicked++;
|
||||||
info.timesKicked++;
|
info.lastKicked = Math.max(Time.millis() + kickDuration, info.lastKicked);
|
||||||
info.lastKicked = Math.max(Time.millis() + kickDuration, info.lastKicked);
|
|
||||||
}
|
|
||||||
|
|
||||||
Call.onKick(this, reason);
|
Call.onKick(this, reason);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package mindustry.net;
|
|||||||
|
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.io.*;
|
import mindustry.io.*;
|
||||||
import mindustry.maps.Map;
|
import mindustry.maps.Map;
|
||||||
@@ -16,7 +16,7 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
public class NetworkIO{
|
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)){
|
try(DataOutputStream stream = new DataOutputStream(os)){
|
||||||
stream.writeUTF(JsonIO.write(state.rules));
|
stream.writeUTF(JsonIO.write(state.rules));
|
||||||
@@ -62,7 +62,7 @@ public class NetworkIO{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ByteBuffer writeServerData(){
|
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 description = headless && !Config.desc.string().equals("off") ? Config.desc.string() : "";
|
||||||
String map = world.getMap() == null ? "None" : world.getMap().name();
|
String map = world.getMap() == null ? "None" : world.getMap().name();
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ public class NetworkIO{
|
|||||||
writeString(buffer, name, 100);
|
writeString(buffer, name, 100);
|
||||||
writeString(buffer, map);
|
writeString(buffer, map);
|
||||||
|
|
||||||
buffer.putInt(playerGroup.size());
|
buffer.putInt(Groups.player.size());
|
||||||
buffer.putInt(state.wave);
|
buffer.putInt(state.wave);
|
||||||
buffer.putInt(Version.build);
|
buffer.putInt(Version.build);
|
||||||
writeString(buffer, Version.type);
|
writeString(buffer, Version.type);
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package mindustry.net;
|
package mindustry.net;
|
||||||
|
|
||||||
import mindustry.entities.type.Player;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when a client sends invalid information.
|
* Thrown when a client sends invalid information.
|
||||||
*/
|
*/
|
||||||
public class ValidateException extends RuntimeException{
|
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);
|
super(s);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import mindustry.ui.*;
|
|||||||
//TODO change to UnitType or Shell or something
|
//TODO change to UnitType or Shell or something
|
||||||
public class UnitDef extends UnlockableContent{
|
public class UnitDef extends UnlockableContent{
|
||||||
//TODO implement
|
//TODO implement
|
||||||
public @NonNull Prov<? extends BaseUnit> constructor = () -> this.flying ? new FlyingUnit() : new GroundUnit();
|
public @NonNull Prov<? extends Unitc> constructor = () -> this.flying ? new FlyingUnit() : new GroundUnit();
|
||||||
public TypeID typeID;
|
public TypeID typeID;
|
||||||
|
|
||||||
public boolean flying;
|
public boolean flying;
|
||||||
@@ -57,8 +57,8 @@ public class UnitDef extends UnlockableContent{
|
|||||||
typeID = new TypeID(name, constructor);
|
typeID = new TypeID(name, constructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseUnit create(Team team){
|
public Unitc create(Team team){
|
||||||
BaseUnit unit = constructor.get();
|
Unitc unit = constructor.get();
|
||||||
unit.init(this, team);
|
unit.init(this, team);
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import arc.util.ArcAnnotate.*;
|
|||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.Weather.*;
|
import mindustry.type.Weather.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class AdminsDialog extends FloatingDialog{
|
|||||||
res.addImageButton(Icon.cancel, () -> {
|
res.addImageButton(Icon.cancel, () -> {
|
||||||
ui.showConfirm("$confirm", "$confirmunadmin", () -> {
|
ui.showConfirm("$confirm", "$confirmunadmin", () -> {
|
||||||
netServer.admins.unAdminPlayer(info.id);
|
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)){
|
if(player != null && player.uuid != null && player.uuid.equals(info.id)){
|
||||||
player.isAdmin = false;
|
player.isAdmin = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ public class JoinDialog extends FloatingDialog{
|
|||||||
Core.settings.save();
|
Core.settings.save();
|
||||||
}).grow().pad(8).get().setMaxLength(maxNameLength);
|
}).grow().pad(8).get().setMaxLength(maxNameLength);
|
||||||
}else{
|
}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, () -> {
|
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package mindustry.ui.dialogs;
|
|||||||
|
|
||||||
import arc.Core;
|
import arc.Core;
|
||||||
import arc.scene.ui.layout.Table;
|
import arc.scene.ui.layout.Table;
|
||||||
import mindustry.entities.type.Player;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.net.Administration.TraceInfo;
|
import mindustry.net.Administration.TraceInfo;
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ public class TraceDialog extends FloatingDialog{
|
|||||||
setFillParent(false);
|
setFillParent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(Player player, TraceInfo info){
|
public void show(Playerc player, TraceInfo info){
|
||||||
cont.clear();
|
cont.clear();
|
||||||
|
|
||||||
Table table = new Table(Tex.clear);
|
Table table = new Table(Tex.clear);
|
||||||
@@ -23,7 +23,7 @@ public class TraceDialog extends FloatingDialog{
|
|||||||
table.defaults().pad(1);
|
table.defaults().pad(1);
|
||||||
|
|
||||||
table.defaults().left();
|
table.defaults().left();
|
||||||
table.add(Core.bundle.format("trace.playername", player.name));
|
table.add(Core.bundle.format("trace.playername", player.name()));
|
||||||
table.row();
|
table.row();
|
||||||
table.add(Core.bundle.format("trace.ip", info.ip));
|
table.add(Core.bundle.format("trace.ip", info.ip));
|
||||||
table.row();
|
table.row();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import arc.util.*;
|
|||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.net.Administration.*;
|
import mindustry.net.Administration.*;
|
||||||
@@ -37,7 +37,7 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
private Item lastItem;
|
private Item lastItem;
|
||||||
|
|
||||||
@Remote(called = Loc.server, targets = Loc.both, forward = true)
|
@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;
|
if(player == null || tile == null || !tile.interactable(player.team())) return;
|
||||||
amount = Mathf.clamp(amount, 0, player.ttemCapacity());
|
amount = Mathf.clamp(amount, 0, player.ttemCapacity());
|
||||||
int fa = amount;
|
int fa = amount;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import mindustry.core.GameState.*;
|
|||||||
import mindustry.ctype.ContentType;
|
import mindustry.ctype.ContentType;
|
||||||
import mindustry.ctype.UnlockableContent;
|
import mindustry.ctype.UnlockableContent;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
@@ -209,9 +209,9 @@ public class HudFragment extends Fragment{
|
|||||||
if(e == null){
|
if(e == null){
|
||||||
Vec2 world = Core.input.mouseWorld();
|
Vec2 world = Core.input.mouseWorld();
|
||||||
Units.nearby(world.x, world.y, 1f, 1f, unit -> {
|
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)){
|
if(Core.input.keyTap(KeyCode.MOUSE_LEFT)){
|
||||||
Call.removeUnitEditor(player, (BaseUnit)unit);
|
Call.removeUnitEditor(player, (Unitc)unit);
|
||||||
}
|
}
|
||||||
found[0] = true;
|
found[0] = true;
|
||||||
unit.hitbox(Tmp.r1);
|
unit.hitbox(Tmp.r1);
|
||||||
@@ -344,16 +344,16 @@ public class HudFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.both, forward = true, called = Loc.both)
|
@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){
|
if(state.isEditor() && player != null){
|
||||||
player.team(team);
|
player.team(team);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.both, called = Loc.server)
|
@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()){
|
if(state.isEditor()){
|
||||||
BaseUnit unit = type.create(player.team());
|
Unitc unit = type.create(player.team());
|
||||||
unit.set(player.x, player.y);
|
unit.set(player.x, player.y);
|
||||||
unit.rotation = player.rotation;
|
unit.rotation = player.rotation;
|
||||||
unit.add();
|
unit.add();
|
||||||
@@ -361,7 +361,7 @@ public class HudFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.both, called = Loc.server, forward = true)
|
@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){
|
if(state.isEditor() && unit != null){
|
||||||
unit.remove();
|
unit.remove();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class PlayerListFragment extends Fragment{
|
|||||||
});
|
});
|
||||||
|
|
||||||
cont.table(Tex.buttonTrans, pane -> {
|
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.row();
|
||||||
pane.pane(content).grow().get().setScrollingDisabled(true, false);
|
pane.pane(content).grow().get().setScrollingDisabled(true, false);
|
||||||
pane.row();
|
pane.row();
|
||||||
@@ -65,8 +65,8 @@ public class PlayerListFragment extends Fragment{
|
|||||||
|
|
||||||
float h = 74f;
|
float h = 74f;
|
||||||
|
|
||||||
playerGroup.all().sort(Structs.comparing(Unitc::team));
|
Groups.player.all().sort(Structs.comparing(Unitc::team));
|
||||||
playerGroup.all().each(user -> {
|
Groups.player.all().each(user -> {
|
||||||
NetConnection connection = user.con;
|
NetConnection connection = user.con;
|
||||||
|
|
||||||
if(connection == null && net.server() && !user.isLocal) return;
|
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));
|
t.addImageButton(Icon.zoom, Styles.clearPartiali, () -> Call.onAdminRequest(user, AdminAction.trace));
|
||||||
|
|
||||||
}).padRight(12).size(bs + 10f, bs);
|
}).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.add().growY();
|
||||||
|
|
||||||
button.addImageButton(Icon.hammer, Styles.clearPartiali,
|
button.addImageButton(Icon.hammer, Styles.clearPartiali,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import mindustry.annotations.Annotations.*;
|
|||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.effect.*;
|
import mindustry.entities.effect.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
@@ -467,12 +467,12 @@ public class Block extends BlockStorage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Called when the block is tapped. */
|
/** 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. */
|
/** 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. */
|
/** 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether this configuration should be hidden now. Called every frame the config is open. */
|
/** 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import arc.math.*;
|
|||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
@@ -55,7 +55,7 @@ public class BuildBlock extends Block{
|
|||||||
public static void onDeconstructFinish(Tile tile, Block block, int builderID){
|
public static void onDeconstructFinish(Tile tile, Block block, int builderID){
|
||||||
Team team = tile.getTeam();
|
Team team = tile.getTeam();
|
||||||
Fx.breakBlock.at(tile.drawx(), tile.drawy(), block.size);
|
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();
|
tile.remove();
|
||||||
if(shouldPlay()) Sounds.breaks.at(tile, calcPitch(false));
|
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);
|
Call.onConstructFinish(tile, block, builderID, rotation, team, skipConfig);
|
||||||
tile.block().placed(tile);
|
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));
|
if(shouldPlay()) Sounds.place.at(tile, calcPitch(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ public class BuildBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tapped(Tile tile, Player player){
|
public void tapped(Tile tile, Playerc player){
|
||||||
BuildEntity entity = tile.ent();
|
BuildEntity entity = tile.ent();
|
||||||
|
|
||||||
//if the target is constructible, begin constructing
|
//if the target is constructible, begin constructing
|
||||||
@@ -279,7 +279,7 @@ public class BuildBlock extends Block{
|
|||||||
|
|
||||||
progress = Mathf.clamp(progress - amount);
|
progress = Mathf.clamp(progress - amount);
|
||||||
|
|
||||||
if(builder instanceof Player){
|
if(builder instanceof Playerc){
|
||||||
builderID = builder.getID();
|
builderID = builder.getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ package mindustry.world.blocks;
|
|||||||
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
@@ -12,7 +11,7 @@ import static mindustry.Vars.net;
|
|||||||
|
|
||||||
public class RespawnBlock{
|
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);
|
progress = Mathf.clamp(progress);
|
||||||
|
|
||||||
Draw.color(Pal.darkMetal);
|
Draw.color(Pal.darkMetal);
|
||||||
@@ -67,7 +66,7 @@ public class RespawnBlock{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|
||||||
if(net.active() && player != null){
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class DeflectorWall extends Wall{
|
|||||||
|
|
||||||
bullet.hitbox(rect2);
|
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()));
|
rect.setSize(size * tilesize + rect2.width*2 + rect2.height*2).setCenter(entity.getX(), entity.getY()));
|
||||||
|
|
||||||
if(position != null){
|
if(position != null){
|
||||||
@@ -58,9 +58,9 @@ public class DeflectorWall extends Wall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(penX > penY){
|
if(penX > penY){
|
||||||
bullet.velocity().x *= -1;
|
bullet.vel().x *= -1;
|
||||||
}else{
|
}else{
|
||||||
bullet.velocity().y *= -1;
|
bullet.vel().y *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//bullet.updateVelocity();
|
//bullet.updateVelocity();
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import arc.graphics.g2d.*;
|
|||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -35,7 +34,7 @@ public class Door extends Wall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Remote(called = Loc.server)
|
@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();
|
DoorEntity entity = tile.ent();
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
entity.open = open;
|
entity.open = open;
|
||||||
@@ -80,7 +79,7 @@ public class Door extends Wall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tapped(Tile tile, Player player){
|
public void tapped(Tile tile, Playerc player){
|
||||||
DoorEntity entity = tile.ent();
|
DoorEntity entity = tile.ent();
|
||||||
|
|
||||||
if((Units.anyEntities(tile) && entity.open) || !tile.entity.timer(timerToggle, 30f)){
|
if((Units.anyEntities(tile) && entity.open) || !tile.entity.timer(timerToggle, 30f)){
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class SurgeWall extends Wall{
|
|||||||
public void handleBulletHit(Tilec entity, Bullet bullet){
|
public void handleBulletHit(Tilec entity, Bullet bullet){
|
||||||
super.handleBulletHit(entity, bullet);
|
super.handleBulletHit(entity, bullet);
|
||||||
if(Mathf.chance(lightningChance)){
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import arc.scene.ui.layout.*;
|
|||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ public class BufferedItemBridge extends ExtendingItemBridge{
|
|||||||
public void updateTransport(Tile tile, Tile other){
|
public void updateTransport(Tile tile, Tile other){
|
||||||
BufferedItemBridgeEntity entity = tile.ent();
|
BufferedItemBridgeEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.buffer.accepts() && entity.getItems().total() > 0){
|
if(entity.buffer.accepts() && entity.items().total() > 0){
|
||||||
entity.buffer.accept(entity.getItems().take());
|
entity.buffer.accept(entity.items().take());
|
||||||
}
|
}
|
||||||
|
|
||||||
Item item = entity.buffer.poll();
|
Item item = entity.buffer.poll();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import arc.graphics.g2d.*;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -45,7 +45,7 @@ public class ItemBridge extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Playerc player, int value){
|
||||||
tile.<ItemBridgeEntity>ent().link = value;
|
tile.<ItemBridgeEntity>ent().link = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,13 +201,13 @@ public class ItemBridge extends Block{
|
|||||||
ItemBridgeEntity entity = tile.ent();
|
ItemBridgeEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.uptime >= 0.5f && entity.timer(timerTransport, transportTime)){
|
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)){
|
if(item != null && other.block().acceptItem(item, other, tile)){
|
||||||
other.block().handleItem(item, other, tile);
|
other.block().handleItem(item, other, tile);
|
||||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 4f, 0.05f);
|
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 4f, 0.05f);
|
||||||
}else{
|
}else{
|
||||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 1f, 0.01f);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import arc.util.pooling.Pool.*;
|
|||||||
import arc.util.pooling.*;
|
import arc.util.pooling.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -45,7 +45,7 @@ public class MassDriver extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Playerc player, int value){
|
||||||
tile.<MassDriverEntity>ent().link = value;
|
tile.<MassDriverEntity>ent().link = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ public class MassDriver extends Block{
|
|||||||
//switch states
|
//switch states
|
||||||
if(entity.state == DriverState.idle){
|
if(entity.state == DriverState.idle){
|
||||||
//start accepting when idle and there's space
|
//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;
|
entity.state = DriverState.accepting;
|
||||||
}else if(hasLink){ //switch to shooting if there's a valid link.
|
}else if(hasLink){ //switch to shooting if there's a valid link.
|
||||||
entity.state = DriverState.shooting;
|
entity.state = DriverState.shooting;
|
||||||
@@ -99,7 +99,7 @@ public class MassDriver extends Block{
|
|||||||
|
|
||||||
if(entity.state == DriverState.accepting){
|
if(entity.state == DriverState.accepting){
|
||||||
//if there's nothing shooting at this, bail - OR, items full
|
//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;
|
entity.state = DriverState.idle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ public class MassDriver extends Block{
|
|||||||
entity.rotation = Mathf.slerpDelta(entity.rotation, tile.angleTo(entity.currentShooter()), rotateSpeed * entity.efficiency());
|
entity.rotation = Mathf.slerpDelta(entity.rotation, tile.angleTo(entity.currentShooter()), rotateSpeed * entity.efficiency());
|
||||||
}else if(entity.state == DriverState.shooting){
|
}else if(entity.state == DriverState.shooting){
|
||||||
//if there's nothing to shoot at OR someone wants to shoot at this thing, bail
|
//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;
|
entity.state = DriverState.idle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -240,10 +240,10 @@ public class MassDriver extends Block{
|
|||||||
data.to = other;
|
data.to = other;
|
||||||
int totalUsed = 0;
|
int totalUsed = 0;
|
||||||
for(int i = 0; i < content.items().size; i++){
|
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;
|
data.items[i] = maxTransfer;
|
||||||
totalUsed += maxTransfer;
|
totalUsed += maxTransfer;
|
||||||
entity.getItems().remove(content.item(i), maxTransfer);
|
entity.items().remove(content.item(i), maxTransfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
float angle = tile.angleTo(target);
|
float angle = tile.angleTo(target);
|
||||||
@@ -262,12 +262,12 @@ public class MassDriver extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void handlePayload(MassDriverEntity entity, Bullet bullet, DriverBulletData data){
|
protected void handlePayload(MassDriverEntity entity, Bullet bullet, DriverBulletData data){
|
||||||
int totalItems = entity.getItems().total();
|
int totalItems = entity.items().total();
|
||||||
|
|
||||||
//add all the items possible
|
//add all the items possible
|
||||||
for(int i = 0; i < data.items.length; i++){
|
for(int i = 0; i < data.items.length; i++){
|
||||||
int maxAdd = Math.min(data.items[i], itemCapacity * 2 - totalItems);
|
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;
|
data.items[i] -= maxAdd;
|
||||||
totalItems += maxAdd;
|
totalItems += maxAdd;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import arc.math.*;
|
|||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -44,7 +44,7 @@ public class Sorter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Playerc player, int value){
|
||||||
tile.<SorterEntity>ent().sortItem = content.item(value);
|
tile.<SorterEntity>ent().sortItem = content.item(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import arc.scene.ui.layout.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.pooling.*;
|
import arc.util.pooling.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.net.*;
|
import mindustry.net.*;
|
||||||
@@ -36,7 +35,7 @@ public class MessageBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.both, called = Loc.both, forward = true)
|
@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(!Units.canInteract(player, tile)) return;
|
||||||
if(net.server() && text.length() > maxTextLength){
|
if(net.server() && text.length() > maxTextLength){
|
||||||
throw new ValidateException(player, "Player has gone above text limit.");
|
throw new ValidateException(player, "Player has gone above text limit.");
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import arc.graphics.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
@@ -63,7 +62,7 @@ public class LightBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Playerc player, int value){
|
||||||
tile.<LightEntity>ent().color = value;
|
tile.<LightEntity>ent().color = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import arc.math.*;
|
|||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -38,7 +38,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Playerc player, int value){
|
||||||
Tilec entity = tile.entity;
|
Tilec entity = tile.entity;
|
||||||
Tile other = world.tile(value);
|
Tile other = world.tile(value);
|
||||||
boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.power() != null;
|
boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.power() != null;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import arc.graphics.g2d.*;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import arc.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -29,7 +29,7 @@ public class ItemSource extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Playerc player, int value){
|
||||||
tile.<ItemSourceEntity>ent().outputItem = content.item(value);
|
tile.<ItemSourceEntity>ent().outputItem = content.item(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,9 +73,9 @@ public class ItemSource extends Block{
|
|||||||
ItemSourceEntity entity = tile.ent();
|
ItemSourceEntity entity = tile.ent();
|
||||||
if(entity.outputItem == null) return;
|
if(entity.outputItem == null) return;
|
||||||
|
|
||||||
entity.getItems().set(entity.outputItem, 1);
|
entity.items().set(entity.outputItem, 1);
|
||||||
tryDump(tile, entity.outputItem);
|
tryDump(tile, entity.outputItem);
|
||||||
entity.getItems().set(entity.outputItem, 0);
|
entity.items().set(entity.outputItem, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import arc.scene.ui.*;
|
|||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -108,7 +108,7 @@ public class LiquidSource extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Playerc player, int value){
|
||||||
tile.<LiquidSourceEntity>ent().source = value == -1 ? null : content.liquid(value);
|
tile.<LiquidSourceEntity>ent().source = value == -1 ? null : content.liquid(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import arc.graphics.g2d.*;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
@@ -22,7 +22,7 @@ import mindustry.world.modules.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class CoreBlock extends StorageBlock{
|
public class CoreBlock extends StorageBlock{
|
||||||
public Mech mech = Mechs.starter;
|
public UnitDef mech = UnitTypes.starter;
|
||||||
|
|
||||||
public CoreBlock(String name){
|
public CoreBlock(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -38,15 +38,16 @@ public class CoreBlock extends StorageBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Remote(called = Loc.server)
|
@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;
|
if(player == null || tile.entity == null) return;
|
||||||
|
|
||||||
CoreEntity entity = tile.ent();
|
CoreEntity entity = tile.ent();
|
||||||
Fx.spawn.at(entity);
|
Fx.spawn.at(entity);
|
||||||
entity.progress = 0;
|
entity.progress = 0;
|
||||||
entity.spawnPlayer = player;
|
entity.spawnPlayer = player;
|
||||||
entity.spawnPlayer.onRespawn(tile);
|
//TODO fix
|
||||||
entity.spawnPlayer.applyImpulse(0, 8f);
|
//entity.spawnPlayer.onRespawn(tile);
|
||||||
|
//entity.spawnPlayer.applyImpulse(0, 8f);
|
||||||
entity.spawnPlayer = null;
|
entity.spawnPlayer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
new Bar(
|
new Bar(
|
||||||
() -> Core.bundle.format("bar.capacity", ui.formatAmount(((CoreEntity)e).storageCapacity)),
|
() -> Core.bundle.format("bar.capacity", ui.formatAmount(((CoreEntity)e).storageCapacity)),
|
||||||
() -> Pal.items,
|
() -> 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();
|
CoreEntity entity = tile.ent();
|
||||||
|
|
||||||
for(Tilec other : state.teams.cores(tile.getTeam())){
|
for(Tilec other : state.teams.cores(tile.getTeam())){
|
||||||
if(other.tile != tile){
|
if(other.tile() != tile){
|
||||||
entity.items() = other.items;
|
entity.items(other.items());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.teams.registerCore(entity);
|
state.teams.registerCore(entity);
|
||||||
|
|
||||||
entity.storageCapacity = itemCapacity + entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
entity.storageCapacity = itemCapacity + entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||||
entity.proximity().each(this::isContainer, t -> {
|
entity.proximity().each(this::isContainer, t -> {
|
||||||
t.entity.items() = entity.items();
|
t.entity.items(entity.items());
|
||||||
t.<StorageBlockEntity>ent().linkedCore = tile;
|
t.<StorageBlockEntity>ent().linkedCore = tile;
|
||||||
});
|
});
|
||||||
|
|
||||||
for(Tilec other : state.teams.cores(tile.getTeam())){
|
for(Tilec other : state.teams.cores(tile.getTeam())){
|
||||||
if(other.tile == tile) continue;
|
if(other.tile() == tile) continue;
|
||||||
entity.storageCapacity += other.block.itemCapacity + other.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
entity.storageCapacity += other.block().itemCapacity + other.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!world.isGenerating()){
|
if(!world.isGenerating()){
|
||||||
@@ -135,9 +136,10 @@ public class CoreBlock extends StorageBlock{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float handleDamage(Tile tile, float amount){
|
public float handleDamage(Tile tile, float amount){
|
||||||
if(player != null && tile.getTeam() == player.team()){
|
//TODO implement
|
||||||
Events.fire(Trigger.teamCoreDamage);
|
//if(player != null && tile.getTeam() == player.team()){
|
||||||
}
|
// Events.fire(Trigger.teamCoreDamage);
|
||||||
|
//}
|
||||||
return amount;
|
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 -> {
|
tile.entity.proximity().each(e -> isContainer(e) && e.entity.items() == tile.entity.items(), t -> {
|
||||||
StorageBlockEntity ent = (StorageBlockEntity)t.entity;
|
StorageBlockEntity ent = (StorageBlockEntity)t.entity;
|
||||||
ent.linkedCore = null;
|
ent.linkedCore = null;
|
||||||
ent.items = new ItemModule();
|
ent.items(new ItemModule());
|
||||||
for(Item item : content.items()){
|
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())){
|
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();
|
CoreEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.heat > 0.001f){
|
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){
|
public void update(Tile tile){
|
||||||
CoreEntity entity = tile.ent();
|
CoreEntity entity = tile.ent();
|
||||||
|
|
||||||
|
//TODO implement
|
||||||
|
/*
|
||||||
if(entity.spawnPlayer != null){
|
if(entity.spawnPlayer != null){
|
||||||
if(!entity.spawnPlayer.dead() || !entity.spawnPlayer.isAdded()){
|
if(!entity.spawnPlayer.dead() || !entity.spawnPlayer.isAdded()){
|
||||||
entity.spawnPlayer = null;
|
entity.spawnPlayer = null;
|
||||||
@@ -219,7 +224,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.1f);
|
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.1f);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -229,26 +234,11 @@ public class CoreBlock extends StorageBlock{
|
|||||||
return entity.spawnPlayer != null;
|
return entity.spawnPlayer != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CoreEntity extends Tilec implements SpawnerTrait{
|
public class CoreEntity extends Tilec{
|
||||||
protected Player spawnPlayer;
|
protected Playerc spawnPlayer;
|
||||||
protected float progress;
|
protected float progress;
|
||||||
protected float time;
|
protected float time;
|
||||||
protected float heat;
|
protected float heat;
|
||||||
protected int storageCapacity;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import arc.graphics.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -54,7 +54,7 @@ public class Unloader extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Playerc player, int value){
|
||||||
tile.entity.items().clear();
|
tile.entity.items().clear();
|
||||||
tile.<UnloaderEntity>ent().sortItem = content.item(value);
|
tile.<UnloaderEntity>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){
|
if(tile.entity.timer(timerUnload, speed / entity.timeScale) && tile.entity.items().total() == 0){
|
||||||
for(Tile other : tile.entity.proximity()){
|
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))){
|
((entity.sortItem == null && other.entity.items().total() > 0) || hasItem(other, entity.sortItem))){
|
||||||
offloadNear(tile, removeItem(other, entity.sortItem));
|
offloadNear(tile, removeItem(other, entity.sortItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.getItems().total() > 0){
|
if(entity.items().total() > 0){
|
||||||
tryDump(tile);
|
tryDump(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,10 +85,10 @@ public class Unloader extends Block{
|
|||||||
Tilec entity = tile.entity;
|
Tilec entity = tile.entity;
|
||||||
|
|
||||||
if(item == null){
|
if(item == null){
|
||||||
return entity.getItems().take();
|
return entity.items().take();
|
||||||
}else{
|
}else{
|
||||||
if(entity.getItems().has(item)){
|
if(entity.items().has(item)){
|
||||||
entity.getItems().remove(item, 1);
|
entity.items().remove(item, 1);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,9 +103,9 @@ public class Unloader extends Block{
|
|||||||
private boolean hasItem(Tile tile, Item item){
|
private boolean hasItem(Tile tile, Item item){
|
||||||
Tilec entity = tile.entity;
|
Tilec entity = tile.entity;
|
||||||
if(item == null){
|
if(item == null){
|
||||||
return entity.getItems().total() > 0;
|
return entity.items().total() > 0;
|
||||||
}else{
|
}else{
|
||||||
return entity.getItems().has(item);
|
return entity.items().has(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import arc.struct.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
@@ -102,7 +102,7 @@ public class CommandCenter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Playerc player, int value){
|
||||||
UnitCommand command = UnitCommand.all[value];
|
UnitCommand command = UnitCommand.all[value];
|
||||||
((CommandCenter)tile.block()).effect.at(tile);
|
((CommandCenter)tile.block()).effect.at(tile);
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ import arc.math.geom.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
@@ -22,7 +23,7 @@ import java.io.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class MechPad extends Block{
|
public class MechPad extends Block{
|
||||||
public @NonNull Mech mech;
|
public @NonNull UnitDef mech;
|
||||||
public float buildTime = 60 * 5;
|
public float buildTime = 60 * 5;
|
||||||
|
|
||||||
public MechPad(String name){
|
public MechPad(String name){
|
||||||
@@ -43,7 +44,7 @@ public class MechPad extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.both, called = Loc.server)
|
@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;
|
if(player == null || tile == null || !(tile.block() instanceof MechPad) || !checkValidTap(tile, player)) return;
|
||||||
|
|
||||||
MechFactoryEntity entity = tile.ent();
|
MechFactoryEntity entity = tile.ent();
|
||||||
@@ -64,9 +65,9 @@ public class MechPad extends Block{
|
|||||||
if(entity.player == null) return;
|
if(entity.player == null) return;
|
||||||
Mech mech = ((MechPad)tile.block()).mech;
|
Mech mech = ((MechPad)tile.block()).mech;
|
||||||
boolean resetSpawner = !entity.sameMech && entity.player.mech == 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.progress = 0;
|
||||||
entity.player.onRespawn(tile);
|
entity.player.onRespawn(tile);
|
||||||
@@ -76,7 +77,7 @@ public class MechPad extends Block{
|
|||||||
Events.fire(new MechChangeEvent(player, player.mech));
|
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();
|
MechFactoryEntity entity = tile.ent();
|
||||||
return !player.dead() && tile.interactable(player.team()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize &&
|
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;
|
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
|
@Override
|
||||||
public void tapped(Tile tile, Player player){
|
public void tapped(Tile tile, Playerc player){
|
||||||
MechFactoryEntity entity = tile.ent();
|
MechFactoryEntity entity = tile.ent();
|
||||||
|
|
||||||
if(checkValidTap(tile, player)){
|
if(checkValidTap(tile, player)){
|
||||||
Call.onMechFactoryTap(player, tile);
|
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
|
//deselect on double taps
|
||||||
player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity;
|
player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity;
|
||||||
}
|
}
|
||||||
@@ -109,7 +110,7 @@ public class MechPad extends Block{
|
|||||||
MechFactoryEntity entity = tile.ent();
|
MechFactoryEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.player != null){
|
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{
|
public class MechFactoryEntity extends Tilec implements SpawnerTrait{
|
||||||
Player player;
|
Playerc player;
|
||||||
boolean sameMech;
|
boolean sameMech;
|
||||||
float progress;
|
float progress;
|
||||||
float time;
|
float time;
|
||||||
@@ -145,7 +146,7 @@ public class MechPad extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateSpawning(Player unit){
|
public void updateSpawning(Playerc unit){
|
||||||
if(player == null){
|
if(player == null){
|
||||||
progress = 0f;
|
progress = 0f;
|
||||||
player = unit;
|
player = unit;
|
||||||
|
|||||||
@@ -1,33 +1,27 @@
|
|||||||
package mindustry.world.blocks.units;
|
package mindustry.world.blocks.units;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import mindustry.annotations.Annotations.Loc;
|
|
||||||
import mindustry.annotations.Annotations.Remote;
|
|
||||||
import arc.struct.EnumSet;
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.Mathf;
|
import arc.math.*;
|
||||||
import mindustry.Vars;
|
import arc.struct.*;
|
||||||
import mindustry.content.Fx;
|
import mindustry.*;
|
||||||
import mindustry.entities.Effects;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.content.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.gen.Call;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.*;
|
||||||
import mindustry.graphics.Shaders;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.Bar;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.Cicon;
|
import mindustry.world.*;
|
||||||
import mindustry.world.Block;
|
import mindustry.world.consumers.*;
|
||||||
import mindustry.world.Tile;
|
|
||||||
import mindustry.world.consumers.ConsumeItems;
|
|
||||||
import mindustry.world.consumers.ConsumeType;
|
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import static mindustry.Vars.*;
|
|
||||||
|
import static mindustry.Vars.net;
|
||||||
|
|
||||||
public class UnitFactory extends Block{
|
public class UnitFactory extends Block{
|
||||||
public UnitType unitType;
|
public UnitDef unitType;
|
||||||
public float produceTime = 1000f;
|
public float produceTime = 1000f;
|
||||||
public float launchVelocity = 0f;
|
public float launchVelocity = 0f;
|
||||||
public TextureRegion topRegion;
|
public TextureRegion topRegion;
|
||||||
@@ -58,12 +52,14 @@ public class UnitFactory extends Block{
|
|||||||
Fx.producesmoke.at(tile.drawx(), tile.drawy());
|
Fx.producesmoke.at(tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
if(!net.client()){
|
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.setSpawner(tile);
|
||||||
unit.set(tile.drawx() + Mathf.range(4), tile.drawy() + Mathf.range(4));
|
unit.set(tile.drawx() + Mathf.range(4), tile.drawy() + Mathf.range(4));
|
||||||
unit.add();
|
unit.add();
|
||||||
unit.velocity().y = factory.launchVelocity;
|
unit.vel().y = factory.launchVelocity;
|
||||||
Events.fire(new UnitCreateEvent(unit));
|
Events.fire(new UnitCreateEvent(unit));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ public class ConsumeItemFilter extends Consume{
|
|||||||
public void trigger(Tilec entity){
|
public void trigger(Tilec entity){
|
||||||
for(int i = 0; i < content.items().size; i++){
|
for(int i = 0; i < content.items().size; i++){
|
||||||
Item item = content.item(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)){
|
||||||
entity.getItems().remove(item, 1);
|
entity.items().remove(item, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ public class ConsumeItemFilter extends Consume{
|
|||||||
public boolean valid(Tilec entity){
|
public boolean valid(Tilec entity){
|
||||||
for(int i = 0; i < content.items().size; i++){
|
for(int i = 0; i < content.items().size; i++){
|
||||||
Item item = content.item(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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user