From 056afa572ec7a1a23b11404faeb55a63e8b566a9 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Thu, 17 Dec 2020 18:37:47 +0100 Subject: [PATCH] Allow hidden blocks to be revealed by plugins (#4017) * Add revealedBlocks rule (1/2) * Use revealedBlocks rule (2/2) --- core/src/mindustry/game/Rules.java | 2 ++ core/src/mindustry/world/Block.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index c91a3fcb7f..046b2128cb 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -80,6 +80,8 @@ public class Rules{ public Seq weather = new Seq<>(1); /** Blocks that cannot be placed. */ public ObjectSet bannedBlocks = new ObjectSet<>(); + /** Reveals blocks normally hidden by build visibility */ + public ObjectSet revealedBlocks = new ObjectSet<>(); /** Unlocked content names. Only used in multiplayer when the campaign is enabled. */ public ObjectSet researched = new ObjectSet<>(); /** Whether ambient lighting is enabled. */ diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 1f8db5bd97..0f42b15b89 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -522,7 +522,7 @@ public class Block extends UnlockableContent{ } public boolean isVisible(){ - return buildVisibility.visible() && !isHidden(); + return (buildVisibility.visible() || state.rules.revealedBlocks.contains(this)) && !isHidden(); } public boolean isPlaceable(){ @@ -718,7 +718,7 @@ public class Block extends UnlockableContent{ @Override public boolean isHidden(){ - return !buildVisibility.visible(); + return !buildVisibility.visible() && !state.rules.revealedBlocks.contains(this); } @Override