mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-02-12 02:49:20 +00:00
minor cleanup and fixes
This commit is contained in:
parent
2867a8bba2
commit
7a3ab7aaed
@ -1,6 +1,6 @@
|
|||||||
import { enumDirection, Vector } from "../../core/vector";
|
import { enumDirection, Vector } from "../../core/vector";
|
||||||
import { HubComponent } from "../components/hub";
|
import { HubComponent } from "../components/hub";
|
||||||
import { enumItemAcceptorTypes, ItemAcceptorComponent } from "../components/item_acceptor";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
||||||
|
|||||||
@ -81,7 +81,6 @@ export class MetaStorageBuilding extends MetaBuilding {
|
|||||||
direction: enumDirection.bottom,
|
direction: enumDirection.bottom,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
lengthMultiplier: 3, // make progress 1.5 to reach the ejector
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -53,9 +53,8 @@ export class ItemAcceptorComponent extends Component {
|
|||||||
*
|
*
|
||||||
* @param {object} param0
|
* @param {object} param0
|
||||||
* @param {Array<ItemAcceptorSlotConfig>} param0.slots The slots from which we accept items
|
* @param {Array<ItemAcceptorSlotConfig>} param0.slots The slots from which we accept items
|
||||||
* @param {number=} param0.lengthMultiplier Whether the acceptor is double the usual length
|
|
||||||
*/
|
*/
|
||||||
constructor({ slots = [], lengthMultiplier = 1 }) {
|
constructor({ slots = [] }) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
/** @type {ItemAcceptorInputs} */
|
/** @type {ItemAcceptorInputs} */
|
||||||
@ -63,7 +62,6 @@ export class ItemAcceptorComponent extends Component {
|
|||||||
/** @type {ItemAcceptorCompletedInputs} */
|
/** @type {ItemAcceptorCompletedInputs} */
|
||||||
this.completedInputs = new Map(); // @SENSETODO does this need to be saved?
|
this.completedInputs = new Map(); // @SENSETODO does this need to be saved?
|
||||||
this.setSlots(slots);
|
this.setSlots(slots);
|
||||||
this.progressLength = 0.5 * lengthMultiplier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,7 +101,7 @@ export class ItemAcceptorComponent extends Component {
|
|||||||
this.inputs.set(slotIndex, {
|
this.inputs.set(slotIndex, {
|
||||||
item,
|
item,
|
||||||
direction,
|
direction,
|
||||||
animProgress: Math.min(this.progressLength, startProgress),
|
animProgress: Math.min(0.5, startProgress),
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -197,8 +197,7 @@ export class Entity extends BasicSerializableObject {
|
|||||||
for (let i = 0; i < acceptorComp.slots.length; ++i) {
|
for (let i = 0; i < acceptorComp.slots.length; ++i) {
|
||||||
const slot = acceptorComp.slots[i];
|
const slot = acceptorComp.slots[i];
|
||||||
const slotTile = staticComp.localTileToWorld(slot.pos);
|
const slotTile = staticComp.localTileToWorld(slot.pos);
|
||||||
for (let k = 0; k < slot.directions.length; ++k) {
|
const direction = staticComp.localDirectionToWorld(slot.direction);
|
||||||
const direction = staticComp.localDirectionToWorld(slot.directions[k]);
|
|
||||||
const directionVector = enumDirectionToVector[direction];
|
const directionVector = enumDirectionToVector[direction];
|
||||||
const angle = Math.radians(enumDirectionToAngle[direction] + 180);
|
const angle = Math.radians(enumDirectionToAngle[direction] + 180);
|
||||||
context.globalAlpha = 0.4;
|
context.globalAlpha = 0.4;
|
||||||
@ -212,7 +211,6 @@ export class Entity extends BasicSerializableObject {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
context.globalAlpha = 1;
|
context.globalAlpha = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -532,8 +532,6 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
case enumItemProcessorTypes.painterDouble:
|
case enumItemProcessorTypes.painterDouble:
|
||||||
case enumItemProcessorTypes.painterQuad: {
|
case enumItemProcessorTypes.painterQuad: {
|
||||||
return this.getProcessorTimeWithUpgrades(this.upgradeImprovements.painting, processorType);
|
return this.getProcessorTimeWithUpgrades(this.upgradeImprovements.painting, processorType);
|
||||||
// b2 + 4 = 4
|
|
||||||
// b2 + 8 = 8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case enumItemProcessorTypes.cutter:
|
case enumItemProcessorTypes.cutter:
|
||||||
@ -561,6 +559,7 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
"Processor type has no speed set in globalConfig.buildingSpeeds: " + processorType
|
"Processor type has no speed set in globalConfig.buildingSpeeds: " + processorType
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// super complicated maths here, but it works
|
||||||
const processorTime =
|
const processorTime =
|
||||||
globalConfig.buildingAmountsToBelt[processorType] / globalConfig.beltSpeedItemsPerSecond;
|
globalConfig.buildingAmountsToBelt[processorType] / globalConfig.beltSpeedItemsPerSecond;
|
||||||
return processorTime / upgrade;
|
return processorTime / upgrade;
|
||||||
@ -573,7 +572,7 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
getProcessingSpeed(processorType) {
|
getProcessingSpeed(processorType) {
|
||||||
const time = this.getProcessingTime(processorType);
|
const time = this.getProcessingTime(processorType);
|
||||||
if (time == 0) {
|
if (time == 0) {
|
||||||
return time;
|
return this.getBeltBaseSpeed();
|
||||||
}
|
}
|
||||||
return 1 / time;
|
return 1 / time;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { globalConfig } from "../../core/config";
|
|
||||||
import { BaseItem } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { FilterComponent } from "../components/filter";
|
import { FilterComponent } from "../components/filter";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
import { globalConfig } from "../../core/config";
|
import { globalConfig } from "../../core/config";
|
||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
import { enumDirectionToVector } from "../../core/vector";
|
import { enumDirectionToVector } from "../../core/vector";
|
||||||
import { ACHIEVEMENTS } from "../../platform/achievement_provider";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
import { ItemAcceptorComponent, InputCompletedArgs } from "../components/item_acceptor";
|
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { ShapeItem } from "../items/shape_item";
|
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
|
|
||||||
export class ItemAcceptorSystem extends GameSystemWithFilter {
|
export class ItemAcceptorSystem extends GameSystemWithFilter {
|
||||||
@ -23,7 +21,7 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
|
|||||||
const entity = this.allEntities[i];
|
const entity = this.allEntities[i];
|
||||||
const acceptorComp = entity.components.ItemAcceptor;
|
const acceptorComp = entity.components.ItemAcceptor;
|
||||||
const inputs = acceptorComp.inputs;
|
const inputs = acceptorComp.inputs;
|
||||||
const maxProgress = acceptorComp.progressLength;
|
const maxProgress = 0.5;
|
||||||
|
|
||||||
inputs.forEach((values, index) => {
|
inputs.forEach((values, index) => {
|
||||||
values.animProgress += progressGrowth;
|
values.animProgress += progressGrowth;
|
||||||
|
|||||||
@ -4,8 +4,6 @@ import { createLogger } from "../../core/logging";
|
|||||||
import { Rectangle } from "../../core/rectangle";
|
import { Rectangle } from "../../core/rectangle";
|
||||||
import { StaleAreaDetector } from "../../core/stale_area_detector";
|
import { StaleAreaDetector } from "../../core/stale_area_detector";
|
||||||
import { enumDirection, enumDirectionToVector } from "../../core/vector";
|
import { enumDirection, enumDirectionToVector } from "../../core/vector";
|
||||||
import { ACHIEVEMENTS } from "../../platform/achievement_provider";
|
|
||||||
import { BaseItem } from "../base_item";
|
|
||||||
import { BeltComponent } from "../components/belt";
|
import { BeltComponent } from "../components/belt";
|
||||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
import { ItemEjectorComponent } from "../components/item_ejector";
|
import { ItemEjectorComponent } from "../components/item_ejector";
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { Loader } from "../../core/loader";
|
|||||||
import { createLogger } from "../../core/logging";
|
import { createLogger } from "../../core/logging";
|
||||||
import { Rectangle } from "../../core/rectangle";
|
import { Rectangle } from "../../core/rectangle";
|
||||||
import { StaleAreaDetector } from "../../core/stale_area_detector";
|
import { StaleAreaDetector } from "../../core/stale_area_detector";
|
||||||
import { fastArrayDelete } from "../../core/utils";
|
|
||||||
import {
|
import {
|
||||||
enumAngleToDirection,
|
enumAngleToDirection,
|
||||||
enumDirection,
|
enumDirection,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user