mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Pass variant and rotationVariant to getIsReplaceable
This commit is contained in:
parent
895a9eb7ae
commit
556caed760
@ -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() {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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)) {
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user