1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-09 16:21:51 +00:00
This commit is contained in:
Bagel03 2023-03-04 11:39:02 -05:00 committed by EmeraldBlock
parent 1eb264716a
commit ddb904432e
10 changed files with 82 additions and 85 deletions

View File

@ -58,9 +58,10 @@ export class StaleAreaDetector {
for (let i = 0; i < componentIds.length; ++i) {
if (entity.components[componentIds[i]]) {
// Entity is relevant, compute affected area
const area = entity.components.StaticMapEntity.getTileSpaceBounds().expandedInAllDirections(
tilesAround
);
const area =
entity.components.StaticMapEntity.getTileSpaceBounds().expandedInAllDirections(
tilesAround
);
this.invalidate(area);
return;
}

View File

@ -303,17 +303,14 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
const mouseTile = worldPos.toTileSpace();
// Compute best rotation variant
const {
rotation,
rotationVariant,
connectedEntities,
} = metaBuilding.computeOptimalDirectionAndRotationVariantAtTile({
root: this.root,
tile: mouseTile,
rotation: this.currentBaseRotation,
variant: this.currentVariant.get(),
layer: metaBuilding.getLayer(),
});
const { rotation, rotationVariant, connectedEntities } =
metaBuilding.computeOptimalDirectionAndRotationVariantAtTile({
root: this.root,
tile: mouseTile,
rotation: this.currentBaseRotation,
variant: this.currentVariant.get(),
layer: metaBuilding.getLayer(),
});
// Check if there are connected entities
if (connectedEntities) {

View File

@ -112,14 +112,8 @@ export class HUDGameMenu extends BaseHUDPart {
// Check for notifications and badges
for (let i = 0; i < this.badgesToUpdate.length; ++i) {
const {
badge,
button,
badgeElement,
lastRenderAmount,
notification,
condition,
} = this.badgesToUpdate[i];
const { badge, button, badgeElement, lastRenderAmount, notification, condition } =
this.badgesToUpdate[i];
if (condition && !condition()) {
// Do not show notifications for invisible buttons

View File

@ -150,8 +150,9 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
}
for (const key in building.components) {
/** @type {import("../../../core/global_registries").Component} */ (building
.components[key]).copyAdditionalStateTo(result.components[key]);
/** @type {import("../../../core/global_registries").Component} */ (
building.components[key]
).copyAdditionalStateTo(result.components[key]);
}
}
});

View File

@ -99,10 +99,12 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.cutShape, null);
return /** @type {[ShapeDefinition, ShapeDefinition]} */ (this.operationCache[key] = [
this.registerOrReturnHandle(rightSide),
this.registerOrReturnHandle(leftSide),
]);
return /** @type {[ShapeDefinition, ShapeDefinition]} */ (
this.operationCache[key] = [
this.registerOrReturnHandle(rightSide),
this.registerOrReturnHandle(leftSide),
]
);
}
/**
@ -113,18 +115,19 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
shapeActionCutQuad(definition) {
const key = "cut-quad/" + definition.getHash();
if (this.operationCache[key]) {
return /** @type {[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]} */ (this
.operationCache[key]);
return /** @type {[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]} */ (
this.operationCache[key]
);
}
return /** @type {[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]} */ (this.operationCache[
key
] = [
this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([0])),
this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([1])),
this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([2])),
this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([3])),
]);
return /** @type {[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]} */ (
this.operationCache[key] = [
this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([0])),
this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([1])),
this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([2])),
this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([3])),
]
);
}
/**
@ -142,9 +145,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.rotateShape, null);
return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle(
rotated
));
return /** @type {ShapeDefinition} */ (
this.operationCache[key] = this.registerOrReturnHandle(rotated)
);
}
/**
@ -160,9 +163,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
const rotated = definition.cloneRotateCCW();
return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle(
rotated
));
return /** @type {ShapeDefinition} */ (
this.operationCache[key] = this.registerOrReturnHandle(rotated)
);
}
/**
@ -178,9 +181,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
const rotated = definition.cloneRotate180();
return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle(
rotated
));
return /** @type {ShapeDefinition} */ (
this.operationCache[key] = this.registerOrReturnHandle(rotated)
);
}
/**
@ -198,9 +201,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.stackShape, null);
const stacked = lowerDefinition.cloneAndStackWith(upperDefinition);
return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle(
stacked
));
return /** @type {ShapeDefinition} */ (
this.operationCache[key] = this.registerOrReturnHandle(stacked)
);
}
/**
@ -218,9 +221,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.paintShape, null);
const colorized = definition.cloneAndPaintWith(color);
return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle(
colorized
));
return /** @type {ShapeDefinition} */ (
this.operationCache[key] = this.registerOrReturnHandle(colorized)
);
}
/**
@ -235,9 +238,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
return /** @type {ShapeDefinition} */ (this.operationCache[key]);
}
const colorized = definition.cloneAndPaintWith4Colors(colors);
return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle(
colorized
));
return /** @type {ShapeDefinition} */ (
this.operationCache[key] = this.registerOrReturnHandle(colorized)
);
}
/**
@ -261,9 +264,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
* @returns {ShapeDefinition}
*/
getDefinitionFromSimpleShapes(subShapes, color = enumColors.uncolored) {
const shapeLayer = /** @type {import("./shape_definition").ShapeLayer} */ (subShapes.map(
subShape => ({ subShape, color })
));
const shapeLayer = /** @type {import("./shape_definition").ShapeLayer} */ (
subShapes.map(subShape => ({ subShape, color }))
);
return this.registerOrReturnHandle(new ShapeDefinition({ layers: [shapeLayer] }));
}

View File

@ -151,16 +151,14 @@ export class BeltSystem extends GameSystem {
continue;
}
const {
rotation,
rotationVariant,
} = metaBelt.computeOptimalDirectionAndRotationVariantAtTile({
root: this.root,
tile: new Vector(x, y),
rotation: targetStaticComp.originalRotation,
variant: defaultBuildingVariant,
layer: targetEntity.layer,
});
const { rotation, rotationVariant } =
metaBelt.computeOptimalDirectionAndRotationVariantAtTile({
root: this.root,
tile: new Vector(x, y),
rotation: targetStaticComp.originalRotation,
variant: defaultBuildingVariant,
layer: targetEntity.layer,
});
// Compute delta to see if anything changed
const newDirection = arrayBeltVariantToRotation[rotationVariant];

View File

@ -76,9 +76,8 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
const staticComp = entity.components.StaticMapEntity;
for (let animIndex = 0; animIndex < acceptorComp.itemConsumptionAnimations.length; ++animIndex) {
const { item, slotIndex, animProgress, direction } = acceptorComp.itemConsumptionAnimations[
animIndex
];
const { item, slotIndex, animProgress, direction } =
acceptorComp.itemConsumptionAnimations[animIndex];
const slotData = acceptorComp.slots[slotIndex];
const realSlotPos = staticComp.localTileToWorld(slotData.pos);

View File

@ -730,16 +730,14 @@ export class WireSystem extends GameSystem {
const variant = targetStaticComp.getVariant();
const {
rotation,
rotationVariant,
} = metaWire.computeOptimalDirectionAndRotationVariantAtTile({
root: this.root,
tile: new Vector(x, y),
rotation: targetStaticComp.originalRotation,
variant,
layer: targetEntity.layer,
});
const { rotation, rotationVariant } =
metaWire.computeOptimalDirectionAndRotationVariantAtTile({
root: this.root,
tile: new Vector(x, y),
rotation: targetStaticComp.originalRotation,
variant,
layer: targetEntity.layer,
});
// Compute delta to see if anything changed
const newType = arrayWireRotationVariantToType[rotationVariant];

View File

@ -28,6 +28,12 @@ export const MOD_SIGNALS = {
stateEntered: /** @type {TypedSignal<[GameState]>} */ (new Signal()),
gameSerialized: /** @type {TypedSignal<[GameRoot, import("../savegame/savegame_typedefs").SerializedGame]>} */ (new Signal()),
gameDeserialized: /** @type {TypedSignal<[GameRoot, import("../savegame/savegame_typedefs").SerializedGame]>} */ (new Signal()),
gameSerialized:
/** @type {TypedSignal<[GameRoot, import("../savegame/savegame_typedefs").SerializedGame]>} */ (
new Signal()
),
gameDeserialized:
/** @type {TypedSignal<[GameRoot, import("../savegame/savegame_typedefs").SerializedGame]>} */ (
new Signal()
),
};

View File

@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["ES2018","WebWorker"]
"lib": ["ES2018", "WebWorker"]
},
"exclude": [],
"extends": "../tsconfig",