From 556caed760f9a2ea731b0b574dfddf0685d5cda0 Mon Sep 17 00:00:00 2001 From: tobspr Date: Tue, 22 Feb 2022 16:37:55 +0100 Subject: [PATCH] Pass variant and rotationVariant to getIsReplaceable --- mod_examples/class_extensions.js | 4 ++-- src/js/core/query_parameters.js | 12 ------------ src/js/core/restriction_manager.js | 5 ----- src/js/game/belt_path.js | 12 +++++++++++- src/js/game/item_resolver.js | 2 +- src/js/game/logic.js | 14 +++++++++++--- src/js/game/meta_building.js | 4 +++- src/js/game/modes/regular.js | 10 ---------- src/js/game/systems/wired_pins.js | 18 +++++++++++++++--- src/js/platform/browser/game_analytics.js | 10 ---------- version | 2 +- 11 files changed, 44 insertions(+), 49 deletions(-) diff --git a/mod_examples/class_extensions.js b/mod_examples/class_extensions.js index 8647fd45..ace5aae9 100644 --- a/mod_examples/class_extensions.js +++ b/mod_examples/class_extensions.js @@ -15,9 +15,9 @@ const BeltExtension = ({ $super, $old }) => ({ return !$old.getShowWiresLayerPreview(); }, - getIsReplaceable() { + getIsReplaceable(variant, rotationVariant) { // Instead of super, use $super - return $super.getIsReplaceable.call(this); + return $super.getIsReplaceable.call(this, variant, rotationVariant); }, getIsRemoveable() { diff --git a/src/js/core/query_parameters.js b/src/js/core/query_parameters.js index 7837acb5..b3dab1b3 100644 --- a/src/js/core/query_parameters.js +++ b/src/js/core/query_parameters.js @@ -3,20 +3,8 @@ const options = queryString.parse(location.search); export let queryParamOptions = { embedProvider: null, - fullVersion: false, - sandboxMode: false, }; if (options.embed) { queryParamOptions.embedProvider = options.embed; } - -// Allow testing full version outside of standalone -if (options.fullVersion && !G_IS_RELEASE) { - queryParamOptions.fullVersion = true; -} - -// Allow testing full version outside of standalone -if (options.sandboxMode && !G_IS_RELEASE) { - queryParamOptions.sandboxMode = true; -} diff --git a/src/js/core/restriction_manager.js b/src/js/core/restriction_manager.js index c899b494..3ca30597 100644 --- a/src/js/core/restriction_manager.js +++ b/src/js/core/restriction_manager.js @@ -84,11 +84,6 @@ export class RestrictionManager extends ReadWriteProxy { return false; } - if (queryParamOptions.fullVersion) { - // Full version is activated via flag - return false; - } - if (queryParamOptions.embedProvider === "gamedistribution") { // also full version on gamedistribution return false; diff --git a/src/js/game/belt_path.js b/src/js/game/belt_path.js index e1b466e9..80efecbe 100644 --- a/src/js/game/belt_path.js +++ b/src/js/game/belt_path.js @@ -1619,7 +1619,17 @@ export class BeltPath extends BasicSerializableObject { const sprite = this.root.buffers.getForKey({ key: "beltpaths", - subKey: "stack-" + directionProp + "-" + dpi + "-" + stack.length + firstItem[1].serialize(), + subKey: + "stack-" + + directionProp + + "-" + + dpi + + "#" + + stack.length + + "#" + + firstItem[1].getItemType() + + "#" + + firstItem[1].serialize(), dpi, w: dimensions.x, h: dimensions.y, diff --git a/src/js/game/item_resolver.js b/src/js/game/item_resolver.js index ff91b0a3..3e7c87af 100644 --- a/src/js/game/item_resolver.js +++ b/src/js/game/item_resolver.js @@ -16,7 +16,7 @@ export function itemResolverSingleton(root, data) { const itemData = data.data; if (MODS_ADDITIONAL_ITEMS[itemType]) { - return MODS_ADDITIONAL_ITEMS[itemType](itemData); + return MODS_ADDITIONAL_ITEMS[itemType](itemData, root); } switch (itemType) { diff --git a/src/js/game/logic.js b/src/js/game/logic.js index 0e915fea..3fdc871e 100644 --- a/src/js/game/logic.js +++ b/src/js/game/logic.js @@ -72,8 +72,13 @@ export class GameLogic { // Check if there is any direct collision const otherEntity = this.root.map.getLayerContentXY(x, y, entity.layer); if (otherEntity) { - const metaClass = otherEntity.components.StaticMapEntity.getMetaBuilding(); - if (!allowReplaceBuildings || !metaClass.getIsReplaceable()) { + const staticComp = otherEntity.components.StaticMapEntity; + if ( + !allowReplaceBuildings || + !staticComp + .getMetaBuilding() + .getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant()) + ) { // This one is a direct blocker return false; } @@ -140,8 +145,11 @@ export class GameLogic { for (let y = rect.y; y < rect.y + rect.h; ++y) { const contents = this.root.map.getLayerContentXY(x, y, entity.layer); if (contents) { + const staticComp = contents.components.StaticMapEntity; assertAlways( - contents.components.StaticMapEntity.getMetaBuilding().getIsReplaceable(), + staticComp + .getMetaBuilding() + .getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant()), "Tried to replace non-repleaceable entity" ); if (!this.tryDeleteBuilding(contents)) { diff --git a/src/js/game/meta_building.js b/src/js/game/meta_building.js index 4482a281..e89a04cd 100644 --- a/src/js/game/meta_building.js +++ b/src/js/game/meta_building.js @@ -88,8 +88,10 @@ export class MetaBuilding { /** * Returns whether this building can get replaced + * @param {string} variant + * @param {number} rotationVariant */ - getIsReplaceable() { + getIsReplaceable(variant, rotationVariant) { return false; } diff --git a/src/js/game/modes/regular.js b/src/js/game/modes/regular.js index cd14833e..6be5b2a3 100644 --- a/src/js/game/modes/regular.js +++ b/src/js/game/modes/regular.js @@ -594,18 +594,8 @@ export class RegularGameMode extends GameMode { this.additionalHudParts.interactiveTutorial = HUDInteractiveTutorial; } - // @ts-ignore - if (queryParamOptions.sandboxMode || window.sandboxMode || G_IS_DEV) { - this.additionalHudParts.sandboxController = HUDSandboxController; - } - /** @type {(typeof MetaBuilding)[]} */ this.hiddenBuildings = [MetaConstantProducerBuilding, MetaGoalAcceptorBuilding, MetaBlockBuilding]; - - // @ts-ignore - if (!(G_IS_DEV || window.sandboxMode || queryParamOptions.sandboxMode)) { - this.hiddenBuildings.push(MetaItemProducerBuilding); - } } /** diff --git a/src/js/game/systems/wired_pins.js b/src/js/game/systems/wired_pins.js index e8bc1882..9e318795 100644 --- a/src/js/game/systems/wired_pins.js +++ b/src/js/game/systems/wired_pins.js @@ -59,7 +59,11 @@ export class WiredPinsSystem extends GameSystemWithFilter { continue; } - if (staticComp.getMetaBuilding().getIsReplaceable()) { + if ( + staticComp + .getMetaBuilding() + .getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant()) + ) { // Don't mind here, even if there would be a collision we // could replace it continue; @@ -113,7 +117,12 @@ export class WiredPinsSystem extends GameSystemWithFilter { // If there's an entity, and it can't get removed -> That's a collision if (collidingEntity) { - if (!collidingEntity.components.StaticMapEntity.getMetaBuilding().getIsReplaceable()) { + const staticComp = collidingEntity.components.StaticMapEntity; + if ( + !staticComp + .getMetaBuilding() + .getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant()) + ) { return true; } } @@ -138,8 +147,11 @@ export class WiredPinsSystem extends GameSystemWithFilter { const worldPos = entity.components.StaticMapEntity.localTileToWorld(slot.pos); const collidingEntity = this.root.map.getLayerContentXY(worldPos.x, worldPos.y, "wires"); if (collidingEntity) { + const staticComp = entity.components.StaticMapEntity; assertAlways( - collidingEntity.components.StaticMapEntity.getMetaBuilding().getIsReplaceable(), + staticComp + .getMetaBuilding() + .getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant()), "Tried to replace non-repleaceable entity for pins" ); if (!this.root.logic.tryDeleteBuilding(collidingEntity)) { diff --git a/src/js/platform/browser/game_analytics.js b/src/js/platform/browser/game_analytics.js index 9411b258..aa0ac796 100644 --- a/src/js/platform/browser/game_analytics.js +++ b/src/js/platform/browser/game_analytics.js @@ -1,6 +1,5 @@ import { globalConfig } from "../../core/config"; import { createLogger } from "../../core/logging"; -import { queryParamOptions } from "../../core/query_parameters"; import { BeltComponent } from "../../game/components/belt"; import { StaticMapEntityComponent } from "../../game/components/static_map_entity"; import { RegularGameMode } from "../../game/modes/regular"; @@ -24,9 +23,6 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface { } if (G_IS_STANDALONE) { - if (queryParamOptions.sandboxMode) { - return "steam-sandbox"; - } return "steam"; } @@ -35,14 +31,8 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface { } if (window.location.host.indexOf("alpha") >= 0) { - if (queryParamOptions.sandboxMode) { - return "alpha-sandbox"; - } return "alpha"; } else { - if (queryParamOptions.sandboxMode) { - return "beta-sandbox"; - } return "beta"; } } diff --git a/version b/version index 3e1ad720..8e03717d 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.5.0 \ No newline at end of file +1.5.1 \ No newline at end of file