1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Start to rework the graphics for the wires layer, make wires cooler than belts

This commit is contained in:
tobspr
2020-06-30 12:38:20 +02:00
parent 18fb9cb04f
commit 722c8ef836
35 changed files with 684 additions and 606 deletions

View File

@@ -312,7 +312,7 @@ export class BeltSystem extends GameSystemWithFilter {
drawLayer(parameters, layer) {
for (let i = 0; i < this.beltPaths.length; ++i) {
const path = this.beltPaths[i];
if (path.getLayer() === layer) {
if (path.layer === layer) {
path.draw(parameters);
}
}
@@ -507,13 +507,13 @@ export class BeltSystem extends GameSystemWithFilter {
}
// Limit speed to avoid belts going backwards
const speedMultiplier = Math.min(this.root.hubGoals.getBeltBaseSpeed(), 10);
const speedMultiplier = Math.min(this.root.hubGoals.getBeltBaseSpeed(enumLayer.regular), 10);
// SYNC with systems/item_acceptor.js:drawEntityUnderlays!
// 126 / 42 is the exact animation speed of the png animation
const animationIndex = Math.floor(
((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
globalConfig.itemSpacingOnBelts
globalConfig.beltItemSpacingByLayer[enumLayer.regular]
);
const contents = chunk.contents;
for (let y = 0; y < globalConfig.mapChunkSize; ++y) {
@@ -546,15 +546,6 @@ export class BeltSystem extends GameSystemWithFilter {
return;
}
// Limit speed to avoid belts going backwards
const speedMultiplier = Math.min(this.root.hubGoals.getBeltBaseSpeed(), 10);
// SYNC with systems/item_acceptor.js:drawEntityUnderlays!
// 126 / 42 is the exact animation speed of the png animation
const animationIndex = Math.floor(
((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
globalConfig.itemSpacingOnBelts
);
const contents = chunk.wireContents;
for (let y = 0; y < globalConfig.mapChunkSize; ++y) {
for (let x = 0; x < globalConfig.mapChunkSize; ++x) {

View File

@@ -22,11 +22,7 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
}
update() {
const progress =
this.root.dynamicTickrate.deltaSeconds *
this.root.hubGoals.getBeltBaseSpeed() *
2 * // * 2 because its only a half tile
globalConfig.itemSpacingOnBelts;
const progress = this.root.dynamicTickrate.deltaSeconds * 2; // * 2 because its only a half tile
for (let i = 0; i < this.allEntities.length; ++i) {
const entity = this.allEntities[i];
@@ -36,7 +32,11 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
// Process item consumption animations to avoid items popping from the belts
for (let animIndex = 0; animIndex < animations.length; ++animIndex) {
const anim = animations[animIndex];
anim.animProgress += progress;
const layer = aceptorComp.slots[anim.slotIndex].layer;
anim.animProgress +=
progress *
this.root.hubGoals.getBeltBaseSpeed(layer) *
globalConfig.beltItemSpacingByLayer[layer];
if (anim.animProgress > 1) {
// Original
// animations.splice(animIndex, 1);
@@ -120,7 +120,7 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
}
// Limit speed to avoid belts going backwards
const speedMultiplier = Math.min(this.root.hubGoals.getBeltBaseSpeed(), 10);
const speedMultiplier = Math.min(this.root.hubGoals.getBeltBaseSpeed(layer), 10);
const underlays = acceptorComp.beltUnderlays;
for (let i = 0; i < underlays.length; ++i) {
@@ -136,7 +136,7 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
// SYNC with systems/belt.js:drawSingleEntity!
const animationIndex = Math.floor(
((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
globalConfig.itemSpacingOnBelts
globalConfig.beltItemSpacingByLayer[layer]
);
drawRotatedSprite({

View File

@@ -185,8 +185,7 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
}
// Precompute effective belt speed
const effectiveBeltSpeed = this.root.hubGoals.getBeltBaseSpeed() * globalConfig.itemSpacingOnBelts;
let progressGrowth = (effectiveBeltSpeed / 0.5) * this.root.dynamicTickrate.deltaSeconds;
let progressGrowth = 2 * this.root.dynamicTickrate.deltaSeconds;
if (G_IS_DEV && globalConfig.debug.instantBelts) {
progressGrowth = 1;
@@ -217,7 +216,13 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
const targetEntity = sourceSlot.cachedTargetEntity;
// Advance items on the slot
sourceSlot.progress = Math.min(1, sourceSlot.progress + progressGrowth);
sourceSlot.progress = Math.min(
1,
sourceSlot.progress +
progressGrowth *
this.root.hubGoals.getBeltBaseSpeed(sourceSlot.layer) *
globalConfig.beltItemSpacingByLayer[sourceSlot.layer]
);
// Check if we are still in the process of ejecting, can't proceed then
if (sourceSlot.progress < 1.0) {