From 7c06c1972bc75849efb3eb7f22448e9808c5dca9 Mon Sep 17 00:00:00 2001 From: circle-gon <97845741+circle-gon@users.noreply.github.com> Date: Thu, 22 Dec 2022 16:55:16 -0500 Subject: [PATCH 1/4] changes seconds to tick --- src/data/layers/factory.tsx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/data/layers/factory.tsx b/src/data/layers/factory.tsx index ecf1ca1..8be14c5 100644 --- a/src/data/layers/factory.tsx +++ b/src/data/layers/factory.tsx @@ -249,7 +249,7 @@ const factory = createLayer(id, () => { key: "0", name: "Conveyor", type: "conveyor", - description: "Moves items at 1 block per second.", + description: "Moves items at 1 block per tick.", energyCost: 1, tick: 1, ports: { @@ -267,7 +267,7 @@ const factory = createLayer(id, () => { key: "1", name: "Wood Machine", type: "processor", - description: "Produces 1 wood every 1 second.", + description: "Produces 1 wood per tick.", energyCost: 10, tick: 1, outputs: { @@ -282,7 +282,7 @@ const factory = createLayer(id, () => { key: "2", name: "Cloth Machine", type: "processor", - description: "Produces 1 cloth every 1 second.", + description: "Produces 1 cloth per tick.", energyCost: 10, tick: 1, outputs: { @@ -297,7 +297,7 @@ const factory = createLayer(id, () => { key: "3", name: "Dye Machine", type: "processor", - description: "Produces 1 dye every 1 second.", + description: "Produces 1 dye per tick.", energyCost: 10, tick: 1, outputs: { @@ -312,7 +312,7 @@ const factory = createLayer(id, () => { key: "4", name: "Metal Machine", type: "processor", - description: "Produces 1 metal every 1 second.", + description: "Produces 1 metal per tick.", energyCost: 10, tick: 1, outputs: { @@ -327,7 +327,7 @@ const factory = createLayer(id, () => { key: "5", name: "Plastic Machine", type: "processor", - description: "Produces 1 plastic every 1 second.", + description: "Produces 1 plastic per tick.", energyCost: 10, tick: 1, outputs: { @@ -341,7 +341,7 @@ const factory = createLayer(id, () => { key: "shift+1", name: "Sawmill", type: "processor", - description: "Turns 1 wood into 1 plank every second.", + description: "Turns 1 wood into 1 plank per tick.", energyCost: 2, tick: 1, inputs: { @@ -360,7 +360,7 @@ const factory = createLayer(id, () => { key: "shift+2", name: "Thread Spinner", type: "processor", - description: "Turns 1 cloth into 1 thread every second.", + description: "Turns 1 cloth into 1 thread per tick.", energyCost: 2, tick: 1, inputs: { @@ -384,7 +384,7 @@ const factory = createLayer(id, () => { () => `Turns 1 plastic into ${ toys.milestones.milestone5.earned.value ? "2 wheels" : "1 wheel" - } every second.` + } per tick.` ), energyCost: 2, tick: 1, @@ -404,7 +404,7 @@ const factory = createLayer(id, () => { key: "ctrl+shift+1", name: "Wooden Block Maker", type: "processor", - description: "Turns 1 plank into 1 wooden block every second.", + description: "Turns 1 plank into 1 wooden block per tick.", energyCost: 20, tick: 1, inputs: { @@ -424,7 +424,7 @@ const factory = createLayer(id, () => { key: "ctrl+shift+2", name: "Clothes Maker", type: "processor", - description: "Turns 2 threads, 3 cloth, and 1 dye into 1 clothes every second.", + description: "Turns 2 threads, 3 cloth, and 1 dye into 1 clothes per tick.", energyCost: 20, tick: 1, inputs: { @@ -450,7 +450,7 @@ const factory = createLayer(id, () => { key: "ctrl+shift+3", name: "Trucks Maker", type: "processor", - description: "Turns 2 metal and 4 wheels into 1 truck every second.", + description: "Turns 2 metal and 4 wheels into 1 truck per tick.", energyCost: 20, tick: 1, inputs: { From 255ecea3e1bc7a5634b983adaafae1405169c1cc Mon Sep 17 00:00:00 2001 From: circle-gon <97845741+circle-gon@users.noreply.github.com> Date: Thu, 22 Dec 2022 20:33:33 -0500 Subject: [PATCH 2/4] adds efficency display --- src/data/layers/factory.tsx | 81 ++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 14 deletions(-) diff --git a/src/data/layers/factory.tsx b/src/data/layers/factory.tsx index 8be14c5..388d6de 100644 --- a/src/data/layers/factory.tsx +++ b/src/data/layers/factory.tsx @@ -29,8 +29,8 @@ import { noPersist, Persistent, persistent, State } from "game/persistence"; import Decimal, { DecimalSource, format, formatWhole } from "util/bignum"; import { Direction } from "util/common"; import { ProcessedComputable } from "util/computed"; -import { render, renderRow } from "util/vue"; -import { computed, ComputedRef, reactive, ref, unref, watchEffect } from "vue"; +import { render, renderRow, VueFeature } from "util/vue"; +import { computed, ComputedRef, reactive, ref, shallowRef, unref, watchEffect } from "vue"; import coal from "./coal"; import _block from "./factory-components/block.svg"; import _blockMaker from "./factory-components/blockmaker.svg"; @@ -601,6 +601,10 @@ const factory = createLayer(id, () => { } interface FactoryInternalProcessor extends FactoryInternalBase { type: Exclude; + lastProdTimes: number[]; + + lastFactoryProd: number; + average: ComputedRef; } type FactoryInternal = FactoryInternalConveyor | FactoryInternalProcessor; @@ -743,9 +747,6 @@ const factory = createLayer(id, () => { loaded = true; watchEffect(updateGraphics); }); - (window as any).internal = compInternalData; - (window as any).comp = components; - (window as any).blocks = movingBlocks; function moveBlock(block: Block, newBlock: FactoryInternal, blockData: FactoryComponent) { // empty spot @@ -865,6 +866,12 @@ const factory = createLayer(id, () => { } } data.ticksDone -= cyclesDone * factoryData.tick; + const now = Date.now(); + const diff = (now - compData.lastFactoryProd) / 1000; + compData.lastProdTimes.push(diff); + console.log(compData.lastProdTimes); + if (compData.lastProdTimes.length > 10) compData.lastProdTimes.shift(); + compData.lastFactoryProd = now; } } else { data.ticksDone += factoryTicks; @@ -1009,6 +1016,26 @@ const factory = createLayer(id, () => { type: data.type, packages: isConveyor ? [] : undefined, nextPackages: isConveyor ? [] : undefined, + lastProdTimes: !isConveyor ? (reactive([]) as number[]) : undefined, + lastFactoryProd: !isConveyor + ? Date.now() - + 1000 * Decimal.div(data.ticksDone ?? 0, computedTickRate.value).toNumber() + : undefined, + average: !isConveyor + ? computed(() => { + const times = (compInternalData[x + "x" + y] as FactoryInternalProcessor) + .lastProdTimes; + if (times.length === 0) return undefined; + + // times is in SECONDS, not ticks + // seconds * Ticks per second -> ticks taken + + return Decimal.mul(times.length, factoryBaseData.tick) + .div(times.reduce((x, n) => x + n, 0)) + .div(computedTickRate.value) + .toNumber(); + }) + : undefined, canProduce: computed(() => { if (data.type === "conveyor") return true; if (!(factoryBaseData.canProduce?.value ?? true)) return false; @@ -1088,6 +1115,7 @@ const factory = createLayer(id, () => { const pointerDown = ref(false), pointerDrag = ref(false), compHovered = ref(undefined), + compInternalHovered = shallowRef(undefined), paused = ref(false); function onFactoryPointerMove(e: PointerEvent) { @@ -1117,12 +1145,12 @@ const factory = createLayer(id, () => { } if (!pointerDown.value && !pointerDrag.value) { const { tx, ty } = spriteContainer.localTransform; - compHovered.value = - components.value[ - Math.round(roundDownTo(x - tx, blockSize) / blockSize) + - "x" + - Math.round(roundDownTo(y - ty, blockSize) / blockSize) - ]; + const xyPos = + Math.round(roundDownTo(x - tx, blockSize) / blockSize) + + "x" + + Math.round(roundDownTo(y - ty, blockSize) / blockSize); + compHovered.value = components.value[xyPos]; + compInternalHovered.value = compInternalData[xyPos]; } } function onFactoryPointerDown(e: PointerEvent) { @@ -1217,6 +1245,7 @@ const factory = createLayer(id, () => { cComp.packages = []; } else { const producerComp = components.value[key] as FactoryComponentProcessor; + const cComp = comp as FactoryInternalProcessor; if (producerComp.outputStock !== undefined) { for (const key in producerComp.outputStock) { delete producerComp.outputStock[key as ResourceNames]; @@ -1228,6 +1257,8 @@ const factory = createLayer(id, () => { } } producerComp.ticksDone = 0; + cComp.lastFactoryProd = Date.now(); + cComp.lastProdTimes.splice(0, Infinity); } } } @@ -1339,7 +1370,7 @@ const factory = createLayer(id, () => { } const hoveredComponent = jsx(() => - compHovered.value !== undefined ? ( + compHovered.value !== undefined && compInternalHovered.value !== undefined ? (
{
{unref(FACTORY_COMPONENTS[compHovered.value.type].description)}
- {compHovered.value.type !== "conveyor" ? ( + {compHovered.value.type !== "conveyor" && + compInternalHovered.value.type !== "conveyor" ? ( <> {showStockAmount( compHovered.value.inputStock, @@ -1373,6 +1405,27 @@ const factory = createLayer(id, () => { "Outputs:", false )} +
+ Efficency:{" "} + {compInternalHovered.value.average.value !== undefined ? ( + 1 + ? "purple" + : compInternalHovered.value.average.value >= 0.9 + ? "green" + : compInternalHovered.value.average.value >= 0.5 + ? "yellow" + : "red" + }} + > + {formatWhole(compInternalHovered.value.average.value * 100)} + + ) : ( + "--" + )} + % ) : undefined}
@@ -1533,7 +1586,7 @@ const factory = createLayer(id, () => { display: jsx(() => ( <> {render(modifiersModal)} - {render(tabs)} + {render(tabs as VueFeature)} )) }; From 6be44c3a0a489906411e187bcb06a2e473996f73 Mon Sep 17 00:00:00 2001 From: Chunkybanana <62921243+chunkybanana@users.noreply.github.com> Date: Fri, 23 Dec 2022 13:13:13 +1000 Subject: [PATCH 3/4] Add some present images --- .../layers/factory-components/present.svg | 51 +++ .../factory-components/presentmaker.svg | 60 +++ .../layers/factory-components/ribbonmaker.svg | 412 ++++++++++++++++++ 3 files changed, 523 insertions(+) create mode 100644 src/data/layers/factory-components/present.svg create mode 100644 src/data/layers/factory-components/presentmaker.svg create mode 100644 src/data/layers/factory-components/ribbonmaker.svg diff --git a/src/data/layers/factory-components/present.svg b/src/data/layers/factory-components/present.svg new file mode 100644 index 0000000..8689a5f --- /dev/null +++ b/src/data/layers/factory-components/present.svg @@ -0,0 +1,51 @@ + + + + diff --git a/src/data/layers/factory-components/presentmaker.svg b/src/data/layers/factory-components/presentmaker.svg new file mode 100644 index 0000000..75093c5 --- /dev/null +++ b/src/data/layers/factory-components/presentmaker.svg @@ -0,0 +1,60 @@ + + + + diff --git a/src/data/layers/factory-components/ribbonmaker.svg b/src/data/layers/factory-components/ribbonmaker.svg new file mode 100644 index 0000000..a16086e --- /dev/null +++ b/src/data/layers/factory-components/ribbonmaker.svg @@ -0,0 +1,412 @@ + + + + From 72d13db963c32c80661d59a5007f5323038bfac6 Mon Sep 17 00:00:00 2001 From: ducdat0507 <62660527+ducdat0507@users.noreply.github.com> Date: Fri, 23 Dec 2022 16:29:17 +0700 Subject: [PATCH 4/4] --- src/data/layers/factory.tsx | 56 +++++++++++++++++------- src/data/layers/styles/day-gradients.css | 15 +++++++ 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/data/layers/factory.tsx b/src/data/layers/factory.tsx index 151b368..c6f6265 100644 --- a/src/data/layers/factory.tsx +++ b/src/data/layers/factory.tsx @@ -208,7 +208,7 @@ const factory = createLayer(id, () => { ? 1 : Decimal.sub(2, Decimal.div(energyConsumption.value, computedEnergy.value)), description: "Brighter work rooms", - enabled: () => upgrades[2][1].bought.value + enabled: () => upgrades[2][0].bought.value })), createMultiplicativeModifier(() => ({ multiplier: 1.5, @@ -217,6 +217,8 @@ const factory = createLayer(id, () => { })) ]); const computedTickRate = computed(() => tickRate.apply(1)); + const computedActualTickRate = computed(() => Decimal.min(computedTickRate.value, 5)); + const computedToyMultiplier = computed(() => Decimal.div(computedTickRate.value, 5).max(1)); const factorySize = createSequentialModifier(() => [ createAdditiveModifier(() => ({ addend: expandFactory.amount, @@ -578,7 +580,7 @@ const factory = createLayer(id, () => { } as FactoryComponentDeclaration, blocks: { imageSrc: _blockMaker, - key: "ctrl+shift+1", + key: "ctrl+1", name: "Wooden Block Maker", type: "processor", description: "Turns 1 plank into 1 wooden block per tick.", @@ -598,7 +600,7 @@ const factory = createLayer(id, () => { } as FactoryComponentDeclaration, clothes: { imageSrc: _clothesMaker, - key: "ctrl+shift+2", + key: "ctrl+2", name: "Clothes Maker", type: "processor", description: "Turns 2 threads, 3 cloth, and 1 dye into 1 clothes per tick.", @@ -624,7 +626,7 @@ const factory = createLayer(id, () => { } as FactoryComponentDeclaration, trucks: { imageSrc: _truckMaker, - key: "ctrl+shift+3", + key: "ctrl+3", name: "Trucks Maker", type: "processor", description: "Turns 2 metal and 4 wheels into 1 truck per tick.", @@ -647,7 +649,7 @@ const factory = createLayer(id, () => { } as FactoryComponentDeclaration, bear: { imageSrc: _bearMaker, - key: "ctrl+shift+4", + key: "ctrl+4", name: "Teddy Bear Maker", type: "processor", description: @@ -678,7 +680,7 @@ const factory = createLayer(id, () => { } as FactoryComponentDeclaration, bucketShovel: { imageSrc: _bucketShovelMaker, - key: "ctrl+shift+5", + key: "ctrl+5", name: "Shovel and Pail Maker", type: "processor", description: "Turns 1 bucket and 1 shovel into 1 shovel and pail every second.", @@ -702,7 +704,7 @@ const factory = createLayer(id, () => { } as FactoryComponentDeclaration, console: { imageSrc: _consoleMaker, - key: "ctrl+shift+6", + key: "ctrl+6", name: "Game Console Maker", type: "processor", description: @@ -1281,7 +1283,7 @@ const factory = createLayer(id, () => { globalBus.on("update", diff => { if (!loaded || paused.value) return; - const factoryTicks = Decimal.times(computedTickRate.value, diff).toNumber(); + const factoryTicks = Decimal.times(computedActualTickRate.value, diff).toNumber(); //debugger // make them produce @@ -1362,7 +1364,10 @@ const factory = createLayer(id, () => { if (val.resource != null) { val.resource.value = Decimal.add( val.resource.value, - unref(val.amount) + Decimal.times( + computedToyMultiplier.value, + unref(val.amount) + ) ); } else { data.outputStock[key as ResourceNames] = @@ -1444,9 +1449,17 @@ const factory = createLayer(id, () => { // however it needs to be aligned if Y is being moved // vice-versa sprite.x = - (x + xInc * 0.3 + (xInc == 0 ? Math.random() * 0.4 - 0.2 : 0)) * blockSize; + (x + xInc * 0.3 + (xInc == 0 ? Math.random() * 0.4 - 0.2 : 0) + 0.5) * + blockSize; sprite.y = - (y + yInc * 0.3 + (yInc == 0 ? Math.random() * 0.4 - 0.2 : 0)) * blockSize; + (y + yInc * 0.3 + (yInc == 0 ? Math.random() * 0.4 - 0.2 : 0) + 0.5) * + blockSize; + + if (computedFactorySize.value % 2 !== 0) { + sprite.x -= 0.5 * blockSize; + sprite.y -= 0.5 * blockSize; + } + sprite.anchor.set(0.5); sprite.width = blockSize / 2.5; sprite.height = blockSize / 2.5; @@ -1532,7 +1545,7 @@ const factory = createLayer(id, () => { lastProdTimes: !isConveyor ? (reactive([]) as number[]) : undefined, lastFactoryProd: !isConveyor ? Date.now() - - 1000 * Decimal.div(data.ticksDone ?? 0, computedTickRate.value).toNumber() + 1000 * Decimal.div(data.ticksDone ?? 0, computedActualTickRate.value).toNumber() : undefined, average: !isConveyor ? computed(() => { @@ -1545,7 +1558,7 @@ const factory = createLayer(id, () => { return Decimal.mul(times.length, factoryBaseData.tick) .div(times.reduce((x, n) => x + n, 0)) - .div(computedTickRate.value) + .div(computedActualTickRate.value) .toNumber(); }) : undefined, @@ -2050,7 +2063,20 @@ const factory = createLayer(id, () => { onUpdate:modelValue={(value: boolean) => (showModifiersModal.value = value)} v-slots={{ header: () =>

{name} Modifiers

, - body: generalTab + body: () => ( + <> + {render(generalTab)} + {Decimal.gte(computedTickRate.value, 5) ? ( + <> +
+ Note: the actual tick rate is capped at 5 TPS, but you'll gain extra + toys based on excessive tick rate as a compensation. + + ) : ( + "" + )} + + ) }} /> )); @@ -2059,7 +2085,7 @@ const factory = createLayer(id, () => { direction: Direction.Right, width: 600, height: 25, - fillStyle: `backgroundColor: ${color}`, + fillStyle: `animation: 15s factory-bar linear infinite`, progress: () => main.day.value === day ? Decimal.div(toys.clothes.value, toyGoal) diff --git a/src/data/layers/styles/day-gradients.css b/src/data/layers/styles/day-gradients.css index e35a4d3..b540378 100644 --- a/src/data/layers/styles/day-gradients.css +++ b/src/data/layers/styles/day-gradients.css @@ -62,4 +62,19 @@ green 10px 20px ); } +} + +@keyframes factory-bar { + from { + background: 0 0 / 114px 114px repeat repeating-linear-gradient(-45deg, + grey 0 10px, + yellow 10px 20px + ); + } + to { + background: 114px 0px / 114px 114px repeat repeating-linear-gradient(-45deg, + grey 0 10px, + yellow 10px 20px + ); + } } \ No newline at end of file