mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Major performance improvements
This commit is contained in:
@@ -331,6 +331,10 @@ export class BeltSystem extends GameSystemWithFilter {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!staticComp.shouldBeDrawn(parameters)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < items.length; ++i) {
|
||||
const itemAndProgress = items[i];
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@ export class HubSystem extends GameSystemWithFilter {
|
||||
const context = parameters.context;
|
||||
const staticComp = entity.components.StaticMapEntity;
|
||||
|
||||
if (!staticComp.shouldBeDrawn(parameters)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pos = staticComp.getTileSpaceBounds().getCenter().toWorldSpace();
|
||||
|
||||
// Background
|
||||
|
||||
@@ -59,6 +59,10 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
|
||||
const staticComp = entity.components.StaticMapEntity;
|
||||
const acceptorComp = entity.components.ItemAcceptor;
|
||||
|
||||
if (!staticComp.shouldBeDrawn(parameters)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let animIndex = 0; animIndex < acceptorComp.itemConsumptionAnimations.length; ++animIndex) {
|
||||
const { item, slotIndex, animProgress, direction } = acceptorComp.itemConsumptionAnimations[
|
||||
animIndex
|
||||
@@ -88,6 +92,10 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
|
||||
const staticComp = entity.components.StaticMapEntity;
|
||||
const acceptorComp = entity.components.ItemAcceptor;
|
||||
|
||||
if (!staticComp.shouldBeDrawn(parameters)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const underlays = acceptorComp.beltUnderlays;
|
||||
for (let i = 0; i < underlays.length; ++i) {
|
||||
const { pos, direction } = underlays[i];
|
||||
|
||||
@@ -141,6 +141,10 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
||||
const ejectorComp = entity.components.ItemEjector;
|
||||
const staticComp = entity.components.StaticMapEntity;
|
||||
|
||||
if (!staticComp.shouldBeDrawn(parameters)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < ejectorComp.slots.length; ++i) {
|
||||
const slot = ejectorComp.slots[i];
|
||||
const ejectedItem = slot.item;
|
||||
|
||||
@@ -13,23 +13,34 @@ export class MapResourcesSystem extends GameSystem {
|
||||
const renderItems = parameters.zoomLevel >= globalConfig.mapChunkOverviewMinZoom;
|
||||
|
||||
parameters.context.globalAlpha = 0.5;
|
||||
|
||||
const layer = chunk.lowerLayer;
|
||||
for (let x = 0; x < globalConfig.mapChunkSize; ++x) {
|
||||
const row = layer[x];
|
||||
const worldX = (chunk.tileX + x) * globalConfig.tileSize;
|
||||
for (let y = 0; y < globalConfig.mapChunkSize; ++y) {
|
||||
const lowerItem = row[y];
|
||||
if (lowerItem) {
|
||||
const worldY = (chunk.tileY + y) * globalConfig.tileSize;
|
||||
|
||||
if (
|
||||
!parameters.visibleRect.containsRect4Params(
|
||||
worldX,
|
||||
worldY,
|
||||
globalConfig.tileSize,
|
||||
globalConfig.tileSize
|
||||
)
|
||||
) {
|
||||
// Clipped
|
||||
continue;
|
||||
}
|
||||
|
||||
parameters.context.fillStyle = lowerItem.getBackgroundColorAsResource();
|
||||
parameters.context.fillRect(
|
||||
(chunk.tileX + x) * globalConfig.tileSize,
|
||||
(chunk.tileY + y) * globalConfig.tileSize,
|
||||
globalConfig.tileSize,
|
||||
globalConfig.tileSize
|
||||
);
|
||||
parameters.context.fillRect(worldX, worldY, globalConfig.tileSize, globalConfig.tileSize);
|
||||
if (renderItems) {
|
||||
lowerItem.draw(
|
||||
(chunk.tileX + x + 0.5) * globalConfig.tileSize,
|
||||
(chunk.tileY + y + 0.5) * globalConfig.tileSize,
|
||||
worldX + globalConfig.halfTileSize,
|
||||
worldY + globalConfig.halfTileSize,
|
||||
parameters
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,6 +103,10 @@ export class MinerSystem extends GameSystemWithFilter {
|
||||
|
||||
if (entity && entity.components.Miner) {
|
||||
const staticComp = entity.components.StaticMapEntity;
|
||||
if (!staticComp.shouldBeDrawn(parameters)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const lowerLayerItem = this.root.map.getLowerLayerContentXY(
|
||||
staticComp.origin.x,
|
||||
staticComp.origin.y
|
||||
|
||||
Reference in New Issue
Block a user