mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-13 10:11:50 +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 { 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 { Entity } from "../entity";
|
||||
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
||||
|
||||
@ -81,7 +81,6 @@ export class MetaStorageBuilding extends MetaBuilding {
|
||||
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 {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();
|
||||
|
||||
/** @type {ItemAcceptorInputs} */
|
||||
@ -63,7 +62,6 @@ export class ItemAcceptorComponent extends Component {
|
||||
/** @type {ItemAcceptorCompletedInputs} */
|
||||
this.completedInputs = new Map(); // @SENSETODO does this need to be saved?
|
||||
this.setSlots(slots);
|
||||
this.progressLength = 0.5 * lengthMultiplier;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +101,7 @@ export class ItemAcceptorComponent extends Component {
|
||||
this.inputs.set(slotIndex, {
|
||||
item,
|
||||
direction,
|
||||
animProgress: Math.min(this.progressLength, startProgress),
|
||||
animProgress: Math.min(0.5, startProgress),
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -197,20 +197,18 @@ export class Entity extends BasicSerializableObject {
|
||||
for (let i = 0; i < acceptorComp.slots.length; ++i) {
|
||||
const slot = acceptorComp.slots[i];
|
||||
const slotTile = staticComp.localTileToWorld(slot.pos);
|
||||
for (let k = 0; k < slot.directions.length; ++k) {
|
||||
const direction = staticComp.localDirectionToWorld(slot.directions[k]);
|
||||
const directionVector = enumDirectionToVector[direction];
|
||||
const angle = Math.radians(enumDirectionToAngle[direction] + 180);
|
||||
context.globalAlpha = 0.4;
|
||||
drawRotatedSprite({
|
||||
parameters,
|
||||
sprite: acceptorSprite,
|
||||
x: (slotTile.x + 0.5 + directionVector.x * 0.37) * globalConfig.tileSize,
|
||||
y: (slotTile.y + 0.5 + directionVector.y * 0.37) * globalConfig.tileSize,
|
||||
angle,
|
||||
size: globalConfig.tileSize * 0.25,
|
||||
});
|
||||
}
|
||||
const direction = staticComp.localDirectionToWorld(slot.direction);
|
||||
const directionVector = enumDirectionToVector[direction];
|
||||
const angle = Math.radians(enumDirectionToAngle[direction] + 180);
|
||||
context.globalAlpha = 0.4;
|
||||
drawRotatedSprite({
|
||||
parameters,
|
||||
sprite: acceptorSprite,
|
||||
x: (slotTile.x + 0.5 + directionVector.x * 0.37) * globalConfig.tileSize,
|
||||
y: (slotTile.y + 0.5 + directionVector.y * 0.37) * globalConfig.tileSize,
|
||||
angle,
|
||||
size: globalConfig.tileSize * 0.25,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -532,8 +532,6 @@ export class HubGoals extends BasicSerializableObject {
|
||||
case enumItemProcessorTypes.painterDouble:
|
||||
case enumItemProcessorTypes.painterQuad: {
|
||||
return this.getProcessorTimeWithUpgrades(this.upgradeImprovements.painting, processorType);
|
||||
// b2 + 4 = 4
|
||||
// b2 + 8 = 8
|
||||
}
|
||||
|
||||
case enumItemProcessorTypes.cutter:
|
||||
@ -561,6 +559,7 @@ export class HubGoals extends BasicSerializableObject {
|
||||
"Processor type has no speed set in globalConfig.buildingSpeeds: " + processorType
|
||||
);
|
||||
|
||||
// super complicated maths here, but it works
|
||||
const processorTime =
|
||||
globalConfig.buildingAmountsToBelt[processorType] / globalConfig.beltSpeedItemsPerSecond;
|
||||
return processorTime / upgrade;
|
||||
@ -573,7 +572,7 @@ export class HubGoals extends BasicSerializableObject {
|
||||
getProcessingSpeed(processorType) {
|
||||
const time = this.getProcessingTime(processorType);
|
||||
if (time == 0) {
|
||||
return time;
|
||||
return this.getBeltBaseSpeed();
|
||||
}
|
||||
return 1 / time;
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { globalConfig } from "../../core/config";
|
||||
import { BaseItem } from "../base_item";
|
||||
import { FilterComponent } from "../components/filter";
|
||||
import { Entity } from "../entity";
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
import { globalConfig } from "../../core/config";
|
||||
import { DrawParameters } from "../../core/draw_parameters";
|
||||
import { enumDirectionToVector } from "../../core/vector";
|
||||
import { ACHIEVEMENTS } from "../../platform/achievement_provider";
|
||||
import { ItemAcceptorComponent, InputCompletedArgs } from "../components/item_acceptor";
|
||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||
import { ShapeItem } from "../items/shape_item";
|
||||
import { MapChunkView } from "../map_chunk_view";
|
||||
|
||||
export class ItemAcceptorSystem extends GameSystemWithFilter {
|
||||
@ -23,7 +21,7 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
|
||||
const entity = this.allEntities[i];
|
||||
const acceptorComp = entity.components.ItemAcceptor;
|
||||
const inputs = acceptorComp.inputs;
|
||||
const maxProgress = acceptorComp.progressLength;
|
||||
const maxProgress = 0.5;
|
||||
|
||||
inputs.forEach((values, index) => {
|
||||
values.animProgress += progressGrowth;
|
||||
|
||||
@ -4,8 +4,6 @@ import { createLogger } from "../../core/logging";
|
||||
import { Rectangle } from "../../core/rectangle";
|
||||
import { StaleAreaDetector } from "../../core/stale_area_detector";
|
||||
import { enumDirection, enumDirectionToVector } from "../../core/vector";
|
||||
import { ACHIEVEMENTS } from "../../platform/achievement_provider";
|
||||
import { BaseItem } from "../base_item";
|
||||
import { BeltComponent } from "../components/belt";
|
||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||
import { ItemEjectorComponent } from "../components/item_ejector";
|
||||
|
||||
@ -3,7 +3,6 @@ import { Loader } from "../../core/loader";
|
||||
import { createLogger } from "../../core/logging";
|
||||
import { Rectangle } from "../../core/rectangle";
|
||||
import { StaleAreaDetector } from "../../core/stale_area_detector";
|
||||
import { fastArrayDelete } from "../../core/utils";
|
||||
import {
|
||||
enumAngleToDirection,
|
||||
enumDirection,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user