From e2019fd5dc041df12e2f6f5d62c422c40b75072e Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 13 Oct 2024 22:57:53 -0400 Subject: [PATCH] Made unlocked blocks in campaign reflect host research --- core/src/mindustry/ctype/UnlockableContent.java | 1 + core/src/mindustry/input/InputHandler.java | 2 +- core/src/mindustry/ui/fragments/PlacementFragment.java | 4 ++-- core/src/mindustry/world/blocks/units/UnitFactory.java | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/ctype/UnlockableContent.java b/core/src/mindustry/ctype/UnlockableContent.java index e86da73fea..d1bb37fc6a 100644 --- a/core/src/mindustry/ctype/UnlockableContent.java +++ b/core/src/mindustry/ctype/UnlockableContent.java @@ -222,6 +222,7 @@ public abstract class UnlockableContent extends MappableContent{ } } + /** @return in multiplayer, whether this is unlocked for the host player, otherwise, whether it is unlocked for the local player (same as unlocked()) */ public boolean unlockedNowHost(){ if(!state.isCampaign()) return true; return net != null && net.client() ? diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 1000494da4..0bc95debcb 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -1728,7 +1728,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } boolean canRepairDerelict(Tile tile){ - return tile != null && tile.build != null && !state.rules.editor && player.team() != Team.derelict && tile.build.team == Team.derelict && tile.build.block.unlockedNow() && + return tile != null && tile.build != null && !state.rules.editor && player.team() != Team.derelict && tile.build.team == Team.derelict && tile.build.block.unlockedNowHost() && Build.validPlace(tile.block(), player.team(), tile.build.tileX(), tile.build.tileY(), tile.build.rotation); } diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index 0fac1453cf..6b42c3c3fc 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -739,8 +739,8 @@ public class PlacementFragment{ } boolean unlocked(Block block){ - return block.unlockedNow() && block.placeablePlayer && block.environmentBuildable() && - block.supportsEnv(state.rules.env); //TODO this hides env unsupported blocks, not always a good thing + return block.unlockedNowHost() && block.placeablePlayer && block.environmentBuildable() && + block.supportsEnv(state.rules.env); } boolean hasInfoBox(){ diff --git a/core/src/mindustry/world/blocks/units/UnitFactory.java b/core/src/mindustry/world/blocks/units/UnitFactory.java index 1a7b56f78f..b9a35f0ae6 100644 --- a/core/src/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/mindustry/world/blocks/units/UnitFactory.java @@ -285,6 +285,8 @@ public class UnitFactory extends UnitBlock{ rebuildCommands.run(); + //Since the menu gets hidden when a new unit is selected, this is unnecessary. + /* UnitType[] lastUnit = {unit()}; commands.update(() -> { @@ -292,7 +294,7 @@ public class UnitFactory extends UnitBlock{ lastUnit[0] = unit(); rebuildCommands.run(); } - }); + });*/ table.row();