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();
|
return !$old.getShowWiresLayerPreview();
|
||||||
},
|
},
|
||||||
|
|
||||||
getIsReplaceable() {
|
getIsReplaceable(variant, rotationVariant) {
|
||||||
// Instead of super, use $super
|
// Instead of super, use $super
|
||||||
return $super.getIsReplaceable.call(this);
|
return $super.getIsReplaceable.call(this, variant, rotationVariant);
|
||||||
},
|
},
|
||||||
|
|
||||||
getIsRemoveable() {
|
getIsRemoveable() {
|
||||||
|
@ -3,20 +3,8 @@ const options = queryString.parse(location.search);
|
|||||||
|
|
||||||
export let queryParamOptions = {
|
export let queryParamOptions = {
|
||||||
embedProvider: null,
|
embedProvider: null,
|
||||||
fullVersion: false,
|
|
||||||
sandboxMode: false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.embed) {
|
if (options.embed) {
|
||||||
queryParamOptions.embedProvider = 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryParamOptions.fullVersion) {
|
|
||||||
// Full version is activated via flag
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (queryParamOptions.embedProvider === "gamedistribution") {
|
if (queryParamOptions.embedProvider === "gamedistribution") {
|
||||||
// also full version on gamedistribution
|
// also full version on gamedistribution
|
||||||
return false;
|
return false;
|
||||||
|
@ -1619,7 +1619,17 @@ export class BeltPath extends BasicSerializableObject {
|
|||||||
|
|
||||||
const sprite = this.root.buffers.getForKey({
|
const sprite = this.root.buffers.getForKey({
|
||||||
key: "beltpaths",
|
key: "beltpaths",
|
||||||
subKey: "stack-" + directionProp + "-" + dpi + "-" + stack.length + firstItem[1].serialize(),
|
subKey:
|
||||||
|
"stack-" +
|
||||||
|
directionProp +
|
||||||
|
"-" +
|
||||||
|
dpi +
|
||||||
|
"#" +
|
||||||
|
stack.length +
|
||||||
|
"#" +
|
||||||
|
firstItem[1].getItemType() +
|
||||||
|
"#" +
|
||||||
|
firstItem[1].serialize(),
|
||||||
dpi,
|
dpi,
|
||||||
w: dimensions.x,
|
w: dimensions.x,
|
||||||
h: dimensions.y,
|
h: dimensions.y,
|
||||||
|
@ -16,7 +16,7 @@ export function itemResolverSingleton(root, data) {
|
|||||||
const itemData = data.data;
|
const itemData = data.data;
|
||||||
|
|
||||||
if (MODS_ADDITIONAL_ITEMS[itemType]) {
|
if (MODS_ADDITIONAL_ITEMS[itemType]) {
|
||||||
return MODS_ADDITIONAL_ITEMS[itemType](itemData);
|
return MODS_ADDITIONAL_ITEMS[itemType](itemData, root);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
|
@ -72,8 +72,13 @@ export class GameLogic {
|
|||||||
// Check if there is any direct collision
|
// Check if there is any direct collision
|
||||||
const otherEntity = this.root.map.getLayerContentXY(x, y, entity.layer);
|
const otherEntity = this.root.map.getLayerContentXY(x, y, entity.layer);
|
||||||
if (otherEntity) {
|
if (otherEntity) {
|
||||||
const metaClass = otherEntity.components.StaticMapEntity.getMetaBuilding();
|
const staticComp = otherEntity.components.StaticMapEntity;
|
||||||
if (!allowReplaceBuildings || !metaClass.getIsReplaceable()) {
|
if (
|
||||||
|
!allowReplaceBuildings ||
|
||||||
|
!staticComp
|
||||||
|
.getMetaBuilding()
|
||||||
|
.getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant())
|
||||||
|
) {
|
||||||
// This one is a direct blocker
|
// This one is a direct blocker
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -140,8 +145,11 @@ export class GameLogic {
|
|||||||
for (let y = rect.y; y < rect.y + rect.h; ++y) {
|
for (let y = rect.y; y < rect.y + rect.h; ++y) {
|
||||||
const contents = this.root.map.getLayerContentXY(x, y, entity.layer);
|
const contents = this.root.map.getLayerContentXY(x, y, entity.layer);
|
||||||
if (contents) {
|
if (contents) {
|
||||||
|
const staticComp = contents.components.StaticMapEntity;
|
||||||
assertAlways(
|
assertAlways(
|
||||||
contents.components.StaticMapEntity.getMetaBuilding().getIsReplaceable(),
|
staticComp
|
||||||
|
.getMetaBuilding()
|
||||||
|
.getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant()),
|
||||||
"Tried to replace non-repleaceable entity"
|
"Tried to replace non-repleaceable entity"
|
||||||
);
|
);
|
||||||
if (!this.tryDeleteBuilding(contents)) {
|
if (!this.tryDeleteBuilding(contents)) {
|
||||||
|
@ -88,8 +88,10 @@ export class MetaBuilding {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this building can get replaced
|
* Returns whether this building can get replaced
|
||||||
|
* @param {string} variant
|
||||||
|
* @param {number} rotationVariant
|
||||||
*/
|
*/
|
||||||
getIsReplaceable() {
|
getIsReplaceable(variant, rotationVariant) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,18 +594,8 @@ export class RegularGameMode extends GameMode {
|
|||||||
this.additionalHudParts.interactiveTutorial = HUDInteractiveTutorial;
|
this.additionalHudParts.interactiveTutorial = HUDInteractiveTutorial;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
if (queryParamOptions.sandboxMode || window.sandboxMode || G_IS_DEV) {
|
|
||||||
this.additionalHudParts.sandboxController = HUDSandboxController;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @type {(typeof MetaBuilding)[]} */
|
/** @type {(typeof MetaBuilding)[]} */
|
||||||
this.hiddenBuildings = [MetaConstantProducerBuilding, MetaGoalAcceptorBuilding, MetaBlockBuilding];
|
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;
|
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
|
// Don't mind here, even if there would be a collision we
|
||||||
// could replace it
|
// could replace it
|
||||||
continue;
|
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 there's an entity, and it can't get removed -> That's a collision
|
||||||
if (collidingEntity) {
|
if (collidingEntity) {
|
||||||
if (!collidingEntity.components.StaticMapEntity.getMetaBuilding().getIsReplaceable()) {
|
const staticComp = collidingEntity.components.StaticMapEntity;
|
||||||
|
if (
|
||||||
|
!staticComp
|
||||||
|
.getMetaBuilding()
|
||||||
|
.getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant())
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,8 +147,11 @@ export class WiredPinsSystem extends GameSystemWithFilter {
|
|||||||
const worldPos = entity.components.StaticMapEntity.localTileToWorld(slot.pos);
|
const worldPos = entity.components.StaticMapEntity.localTileToWorld(slot.pos);
|
||||||
const collidingEntity = this.root.map.getLayerContentXY(worldPos.x, worldPos.y, "wires");
|
const collidingEntity = this.root.map.getLayerContentXY(worldPos.x, worldPos.y, "wires");
|
||||||
if (collidingEntity) {
|
if (collidingEntity) {
|
||||||
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
assertAlways(
|
assertAlways(
|
||||||
collidingEntity.components.StaticMapEntity.getMetaBuilding().getIsReplaceable(),
|
staticComp
|
||||||
|
.getMetaBuilding()
|
||||||
|
.getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant()),
|
||||||
"Tried to replace non-repleaceable entity for pins"
|
"Tried to replace non-repleaceable entity for pins"
|
||||||
);
|
);
|
||||||
if (!this.root.logic.tryDeleteBuilding(collidingEntity)) {
|
if (!this.root.logic.tryDeleteBuilding(collidingEntity)) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { globalConfig } from "../../core/config";
|
import { globalConfig } from "../../core/config";
|
||||||
import { createLogger } from "../../core/logging";
|
import { createLogger } from "../../core/logging";
|
||||||
import { queryParamOptions } from "../../core/query_parameters";
|
|
||||||
import { BeltComponent } from "../../game/components/belt";
|
import { BeltComponent } from "../../game/components/belt";
|
||||||
import { StaticMapEntityComponent } from "../../game/components/static_map_entity";
|
import { StaticMapEntityComponent } from "../../game/components/static_map_entity";
|
||||||
import { RegularGameMode } from "../../game/modes/regular";
|
import { RegularGameMode } from "../../game/modes/regular";
|
||||||
@ -24,9 +23,6 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (G_IS_STANDALONE) {
|
if (G_IS_STANDALONE) {
|
||||||
if (queryParamOptions.sandboxMode) {
|
|
||||||
return "steam-sandbox";
|
|
||||||
}
|
|
||||||
return "steam";
|
return "steam";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,14 +31,8 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (window.location.host.indexOf("alpha") >= 0) {
|
if (window.location.host.indexOf("alpha") >= 0) {
|
||||||
if (queryParamOptions.sandboxMode) {
|
|
||||||
return "alpha-sandbox";
|
|
||||||
}
|
|
||||||
return "alpha";
|
return "alpha";
|
||||||
} else {
|
} else {
|
||||||
if (queryParamOptions.sandboxMode) {
|
|
||||||
return "beta-sandbox";
|
|
||||||
}
|
|
||||||
return "beta";
|
return "beta";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user