diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 619eea289d..03e2e9e89a 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -162,6 +162,7 @@ text.blocks.powerrange=Power range text.blocks.lasertilerange=Laser tile range text.blocks.capacity=Capacity text.blocks.itemcapacity=Item Capacity +text.blocks.maxpowergenerationsecond=Max Power Generation/second text.blocks.powergenerationsecond=Power Generation/second text.blocks.generationsecondsitem=Generation Seconds/item text.blocks.input=Input diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index bb15ce2efe..9b7842a864 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -102,6 +102,12 @@ public class NetClient extends Module { } } + for(int i = 0; i < data.weapons.length; i ++){ + Vars.control.addWeapon((Weapon) Upgrade.getByID(data.weapons[i])); + } + Vars.player.weaponLeft = Vars.player.weaponRight = Vars.control.getWeapons().peek(); + Vars.ui.hudfrag.updateWeapons(); + UCore.log("Recieved entities: " + Arrays.toString(data.players) + " player ID: " + data.playerid); gotEntities = true; }); diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index e15684ed2a..460732e253 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -1,9 +1,7 @@ package io.anuke.mindustry.core; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.utils.IntArray; -import com.badlogic.gdx.utils.IntMap; -import com.badlogic.gdx.utils.TimeUtils; +import com.badlogic.gdx.utils.*; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.BulletType; @@ -33,6 +31,7 @@ import java.util.Arrays; public class NetServer extends Module{ /**Maps connection IDs to players.*/ IntMap connections = new IntMap<>(); + ObjectMap weapons = new ObjectMap<>(); float serverSyncTime = 4, itemSyncTime = 10, blockSyncTime = 120; boolean closing = false; @@ -67,6 +66,7 @@ public class NetServer extends Module{ dp.playerid = player.id; dp.players = Vars.control.playerGroup.all().toArray(Player.class); + dp.weapons = weapons.get(packet.name, new ByteArray()).toArray(); UCore.log("Sending entities: " + Arrays.toString(dp.players)); @@ -145,7 +145,13 @@ public class NetServer extends Module{ }); Net.handleServer(UpgradePacket.class, packet -> { + Player player = connections.get(Net.getLastConnection()); + Weapon weapon = (Weapon)Upgrade.getByID(packet.id); + + if(!weapons.containsKey(player.name)) weapons.put(player.name, new ByteArray()); + if(!weapons.get(player.name).contains(weapon.id)) weapons.get(player.name).add(weapon.id); + Vars.control.removeItems(UpgradeRecipes.get(weapon)); }); diff --git a/core/src/io/anuke/mindustry/net/Packets.java b/core/src/io/anuke/mindustry/net/Packets.java index 784cd01c19..5b49f06a38 100644 --- a/core/src/io/anuke/mindustry/net/Packets.java +++ b/core/src/io/anuke/mindustry/net/Packets.java @@ -22,6 +22,7 @@ public class Packets { public static class EntityDataPacket{ public Player[] players; public int playerid; + public byte[] weapons; } public static class SyncPacket{ diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/NuclearReactor.java b/core/src/io/anuke/mindustry/world/blocks/types/production/NuclearReactor.java index 6164de883d..ce6db39a7e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/NuclearReactor.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/NuclearReactor.java @@ -14,6 +14,7 @@ import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Timers; import io.anuke.ucore.util.Mathf; +import io.anuke.ucore.util.Strings; import io.anuke.ucore.util.Tmp; import java.io.DataInputStream; @@ -35,7 +36,7 @@ public class NuclearReactor extends LiquidPowerGenerator{ protected int explosionRadius = 19; protected int explosionDamage = 135; protected float flashThreshold = 0.46f; //heat threshold at which the lights start flashing - + public NuclearReactor(String name) { super(name); generateItem = Item.uranium; @@ -52,6 +53,9 @@ public class NuclearReactor extends LiquidPowerGenerator{ public void getStats(Array list){ super.getStats(list); list.add("[powerinfo]Input Item: " + generateItem); + list.add("[powerinfo]Max Power Generation/second: " + Strings.toFixed(powerMultiplier*60f, 2)); + list.removeValue(list.select(s -> s.contains("Power/Liquid")).iterator().next(), true); + list.removeValue(list.select(s -> s.contains("Max liquid/second:")).iterator().next(), true); } @Override