1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-10 00:31: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) { for (let i = 0; i < componentIds.length; ++i) {
if (entity.components[componentIds[i]]) { if (entity.components[componentIds[i]]) {
// Entity is relevant, compute affected area // Entity is relevant, compute affected area
const area = entity.components.StaticMapEntity.getTileSpaceBounds().expandedInAllDirections( const area =
tilesAround entity.components.StaticMapEntity.getTileSpaceBounds().expandedInAllDirections(
); tilesAround
);
this.invalidate(area); this.invalidate(area);
return; return;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,6 +28,12 @@ export const MOD_SIGNALS = {
stateEntered: /** @type {TypedSignal<[GameState]>} */ (new Signal()), stateEntered: /** @type {TypedSignal<[GameState]>} */ (new Signal()),
gameSerialized: /** @type {TypedSignal<[GameRoot, import("../savegame/savegame_typedefs").SerializedGame]>} */ (new Signal()), gameSerialized:
gameDeserialized: /** @type {TypedSignal<[GameRoot, import("../savegame/savegame_typedefs").SerializedGame]>} */ (new Signal()), /** @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": { "compilerOptions": {
"lib": ["ES2018","WebWorker"] "lib": ["ES2018", "WebWorker"]
}, },
"exclude": [], "exclude": [],
"extends": "../tsconfig", "extends": "../tsconfig",