diff --git a/src/js/game/hub_goals.js b/src/js/game/hub_goals.js
index adea22de..51a1448f 100644
--- a/src/js/game/hub_goals.js
+++ b/src/js/game/hub_goals.js
@@ -107,16 +107,19 @@ export class HubGoals extends BasicSerializableObject {
/**
* @type {{
- * definitions: ShapeDefinition[],
- * requires: Array<{
- * throughputOnly?: Boolean,
+ * definitions: Array<{
+ * shape: ShapeDefinition,
* amount: Number,
+ * throughputOnly?: Boolean,
* }>,
* reward: enumHubGoalRewards,
+ * inOrder?: Boolean,
* }}
*/
this.currentGoal = null;
+ this.deliverOrder = [];
+
this.computeNextGoal();
// Allow quickly switching goals in dev mode
@@ -182,15 +185,15 @@ export class HubGoals extends BasicSerializableObject {
const currentGoalDeliverd = [];
for (let i = 0; i < this.currentGoal.definitions.length; i++) {
- if (this.currentGoal.requires[i].throughputOnly) {
+ if (this.currentGoal.definitions[i].throughputOnly) {
currentGoalDeliverd.push(
this.root.productionAnalytics.getCurrentShapeRateRaw(
enumAnalyticsDataSource.delivered,
- this.currentGoal.definitions[i]
+ this.currentGoal.definitions[i].shape
) / globalConfig.analyticsSliceDurationSeconds
);
} else {
- currentGoalDeliverd.push(this.getShapesStored(this.currentGoal.definitions[i]));
+ currentGoalDeliverd.push(this.getShapesStored(this.currentGoal.definitions[i].shape));
}
}
return currentGoalDeliverd;
@@ -203,7 +206,7 @@ export class HubGoals extends BasicSerializableObject {
const delivered = this.getCurrentGoalDelivered();
for (let i = 0; i < delivered.length; i++) {
- if (delivered[i] < this.currentGoal.requires[i].amount) return false;
+ if (delivered[i] < this.currentGoal.definitions[i].amount) return false;
}
return true;
@@ -239,9 +242,52 @@ export class HubGoals extends BasicSerializableObject {
*/
handleDefinitionDelivered(definition) {
const hash = definition.getHash();
- this.storedShapes[hash] = (this.storedShapes[hash] || 0) + 1;
- this.root.signals.shapeDelivered.dispatch(definition);
+ const definitions = this.currentGoal.definitions;
+ // In order and shape is goal shape
+ if (this.currentGoal.inOrder && definitions.some(goal => goal.shape.getHash() === hash)) {
+ // Add to delivered order
+ this.deliverOrder.push(hash);
+
+ if (this.deliverOrder.length === definitions.length) {
+ // Check if order is correct
+ const startIndex = this.deliverOrder.findIndex(
+ hash => hash === definitions[0].shape.getHash()
+ );
+
+ if (startIndex > -1) {
+ for (let i = 0; i < definitions.length; i++) {
+ // Offset order to first shape
+ let currentOrder = startIndex + i;
+ if (currentOrder >= this.deliverOrder.length)
+ currentOrder = currentOrder - this.deliverOrder.length;
+
+ // Wrong order clear order
+ if (this.deliverOrder[currentOrder] !== definitions[i].shape.getHash()) {
+ this.deliverOrder = [];
+ break;
+ }
+ }
+ } else {
+ this.deliverOrder = [];
+ }
+
+ // Add to stored shapes
+ for (let i = 0; i < this.deliverOrder.length; i++) {
+ this.storedShapes[this.deliverOrder[i]] =
+ (this.storedShapes[this.deliverOrder[i]] || 0) + 1;
+ this.root.signals.shapeDelivered.dispatch(
+ ShapeDefinition.fromShortKey(this.deliverOrder[i])
+ );
+ }
+
+ this.deliverOrder = [];
+ }
+ } else {
+ this.storedShapes[hash] = (this.storedShapes[hash] || 0) + 1;
+
+ this.root.signals.shapeDelivered.dispatch(definition);
+ }
// Check if we have enough for the next level
if (this.isGoalCompleted() || (G_IS_DEV && globalConfig.debug.rewardsInstant)) {
@@ -258,12 +304,18 @@ export class HubGoals extends BasicSerializableObject {
const storyIndex = this.level - 1;
const levels = this.root.gameMode.getLevelDefinitions();
if (storyIndex < levels.length) {
- const { shapes, requires, reward } = levels[storyIndex];
+ const { shapes, reward, inOrder } = levels[storyIndex];
if (shapes) {
this.currentGoal = {
- definitions: shapes.map(code => this.root.shapeDefinitionMgr.getShapeFromShortKey(code)),
- requires: requires,
+ definitions: shapes.map(shape => {
+ return {
+ ...shape,
+ shape: this.root.shapeDefinitionMgr.getShapeFromShortKey(shape.key),
+ key: null,
+ };
+ }),
reward,
+ inOrder,
};
return;
}
@@ -272,8 +324,9 @@ export class HubGoals extends BasicSerializableObject {
//Floor Required amount to remove confusion
const required = Math.min(200, Math.floor(4 + (this.level - 27) * 0.25));
this.currentGoal = {
- definitions: [this.computeFreeplayShape(this.level)],
- requires: [{ throughputOnly: true, amount: required }],
+ definitions: [
+ { shape: this.computeFreeplayShape(this.level), throughputOnly: true, amount: required },
+ ],
reward: enumHubGoalRewards.no_reward_freeplay,
};
}
diff --git a/src/js/game/hud/parts/pinned_shapes.js b/src/js/game/hud/parts/pinned_shapes.js
index 2323f5dd..8c4ca769 100644
--- a/src/js/game/hud/parts/pinned_shapes.js
+++ b/src/js/game/hud/parts/pinned_shapes.js
@@ -104,10 +104,10 @@ export class HUDPinnedShapes extends BaseHUDPart {
*/
findGoalValueForShape(key) {
const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex(
- shape => shape.getHash() === key
+ goal => goal.shape.getHash() === key
);
if (goalIndex > -1) {
- return this.root.hubGoals.currentGoal.requires[goalIndex].amount;
+ return this.root.hubGoals.currentGoal.definitions[goalIndex].amount;
}
if (key === this.root.gameMode.getBlueprintShapeKey()) {
return null;
@@ -142,7 +142,7 @@ export class HUDPinnedShapes extends BaseHUDPart {
*/
isShapePinned(key) {
const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex(
- shape => shape.getHash() === key
+ goal => goal.shape.getHash() === key
);
if (goalIndex > -1 || key === this.root.gameMode.getBlueprintShapeKey()) {
// This is a "special" shape which is always pinned
@@ -174,12 +174,11 @@ export class HUDPinnedShapes extends BaseHUDPart {
// Pin story goal
for (let i = 0; i < currentGoal.definitions.length; i++) {
- console.log(currentGoal);
this.internalPinShape({
- key: currentGoal.definitions[i].getHash(),
+ key: currentGoal.definitions[i].shape.getHash(),
canUnpin: false,
className: "goal",
- throughputOnly: currentGoal.requires[i].throughputOnly,
+ throughputOnly: currentGoal.definitions[i].throughputOnly,
});
}
@@ -195,7 +194,7 @@ export class HUDPinnedShapes extends BaseHUDPart {
// Pin manually pinned shapes
for (let i = 0; i < this.pinnedShapes.length; ++i) {
const key = this.pinnedShapes[i];
- const goalIndex = currentGoal.definitions.findIndex(shape => shape.getHash() === key);
+ const goalIndex = currentGoal.definitions.findIndex(goal => goal.shape.getHash() === key);
if (goalIndex < 0) {
this.internalPinShape({ key });
}
@@ -315,7 +314,7 @@ export class HUDPinnedShapes extends BaseHUDPart {
pinNewShape(definition) {
const key = definition.getHash();
const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex(
- shape => shape.getHash() === key
+ goal => goal.shape.getHash() === key
);
if (goalIndex > -1) {
// Can not pin current goal
diff --git a/src/js/game/hud/parts/sandbox_controller.js b/src/js/game/hud/parts/sandbox_controller.js
index 3436b59d..15ffe439 100644
--- a/src/js/game/hud/parts/sandbox_controller.js
+++ b/src/js/game/hud/parts/sandbox_controller.js
@@ -48,6 +48,7 @@ export class HUDSandboxController extends BaseHUDPart {
+
`
@@ -57,6 +58,7 @@ export class HUDSandboxController extends BaseHUDPart {
bind(".giveBlueprints", this.giveBlueprints);
bind(".maxOutAll", this.maxOutAll);
+ bind(".clearAll", this.clearAll);
bind(".levelToggle .minus", () => this.modifyLevel(-1));
bind(".levelToggle .plus", () => this.modifyLevel(1));
@@ -81,6 +83,13 @@ export class HUDSandboxController extends BaseHUDPart {
this.root.hubGoals.storedShapes[shape] += 1e9;
}
+ clearAll() {
+ this.modifyUpgrade("belt", -1000);
+ this.modifyUpgrade("miner", -1000);
+ this.modifyUpgrade("processors", -1000);
+ this.modifyUpgrade("painting", -1000);
+ }
+
maxOutAll() {
this.modifyUpgrade("belt", 100);
this.modifyUpgrade("miner", 100);
@@ -117,7 +126,7 @@ export class HUDSandboxController extends BaseHUDPart {
// Clear all shapes of this level
for (let i = 0; i < hubGoals.currentGoal.definitions.length; i++) {
- hubGoals.storedShapes[hubGoals.currentGoal.definitions[i].getHash()] = 0;
+ hubGoals.storedShapes[hubGoals.currentGoal.definitions[i].shape.getHash()] = 0;
}
if (this.root.hud.parts.pinnedShapes) {
diff --git a/src/js/game/hud/parts/shop.js b/src/js/game/hud/parts/shop.js
index 0b8a64ec..68667ccd 100644
--- a/src/js/game/hud/parts/shop.js
+++ b/src/js/game/hud/parts/shop.js
@@ -124,7 +124,7 @@ export class HUDShop extends BaseHUDPart {
container.appendChild(viewInfoButton);
const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex(
- goal => goal.getHash() === shape
+ goal => goal.shape.getHash() === shape
);
if (goalIndex > -1) {
pinButton.classList.add("isGoal");
diff --git a/src/js/game/modes/regular.js b/src/js/game/modes/regular.js
index ca102819..8dfa0207 100644
--- a/src/js/game/modes/regular.js
+++ b/src/js/game/modes/regular.js
@@ -56,12 +56,13 @@ import { MetaItemProducerBuilding } from "../buildings/item_producer";
/**
* @typedef {{
- * shapes: String[],
- * requires: Array<{
- * throughputOnly?: Boolean,
+ * shapes: String[] | Array<{
+ * key: String,
* amount: Number,
+ * throughputOnly?: Boolean,
* }>,
* reward: enumHubGoalRewards,
+ * inOrder?: Boolean,
* }} LevelDefinition */
export const rocketShape = "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw";
@@ -299,101 +300,88 @@ export function generateLevelDefinitions(limitedVersion = false) {
// 1
// Circle
{
- shapes: ["CuCuCuCu"], // belts t1
- requires: [{ amount: 30 }],
+ shapes: [{ key: "CuCuCuCu", amount: 30 }], // belts t1
reward: enumHubGoalRewards.reward_cutter_and_trash,
},
// 2
// Cutter
{
- shapes: ["----CuCu"], //
- requires: [{ amount: 40 }],
+ shapes: [{ key: "----CuCu", amount: 40 }], //
reward: enumHubGoalRewards.no_reward,
},
// 3
// Rectangle
{
- shapes: ["RuRuRuRu"], // miners t1
- requires: [{ amount: 70 }],
+ shapes: [{ key: "RuRuRuRu", amount: 70 }], // miners t1
reward: enumHubGoalRewards.reward_balancer,
},
// 4
{
- shapes: ["RuRu----"], // processors t2
- requires: [{ amount: 70 }],
+ shapes: [{ key: "RuRu----", amount: 70 }], // processors t2
reward: enumHubGoalRewards.reward_rotater,
},
// 5
// Rotater
{
- shapes: ["Cu----Cu"], // belts t2
- requires: [{ amount: 170 }],
+ shapes: [{ key: "Cu----Cu", amount: 170 }], // belts t2
reward: enumHubGoalRewards.reward_tunnel,
},
// 6
{
- shapes: ["Cu------"], // miners t2
- requires: [{ amount: 270 }],
+ shapes: [{ key: "Cu------", amount: 270 }], // miners t2
reward: enumHubGoalRewards.reward_painter,
},
// 7
// Painter
{
- shapes: ["CrCrCrCr"], // unused
- requires: [{ amount: 300 }],
+ shapes: [{ key: "CrCrCrCr", amount: 300 }], // unused
reward: enumHubGoalRewards.reward_rotater_ccw,
},
// 8
{
- shapes: ["RbRb----"], // painter t2
- requires: [{ amount: 480 }],
+ shapes: [{ key: "RbRb----", amount: 480 }], // painter t2
reward: enumHubGoalRewards.reward_mixer,
},
// 9
// Mixing (purple)
{
- shapes: ["CpCpCpCp"], // belts t3
- requires: [{ amount: 600 }],
+ shapes: [{ key: "CpCpCpCp", amount: 600 }], // belts t3
reward: enumHubGoalRewards.reward_merger,
},
// 10
// STACKER: Star shapes + cyan
{
- shapes: ["ScScScSc"], // miners t3
- requires: [{ amount: 800 }],
+ shapes: [{ key: "ScScScSc", amount: 800 }], // miners t3
reward: enumHubGoalRewards.reward_stacker,
},
// 11
// Chainable miner
{
- shapes: ["CgScScCg"], // processors t3
- requires: [{ amount: 1000 }],
+ shapes: [{ key: "CgScScCg", amount: 1000 }], // processors t3
reward: enumHubGoalRewards.reward_miner_chainable,
},
// 12
// Blueprints
{
- shapes: ["CbCbCbRb:CwCwCwCw"],
- requires: [{ amount: 1000 }],
+ shapes: [{ key: "CbCbCbRb:CwCwCwCw", amount: 1000 }],
reward: enumHubGoalRewards.reward_blueprints,
},
// 13
// Tunnel Tier 2
{
- shapes: [chinaShapes ? "CuCuCuCu:CwCwCwCw:Sb--Sr--" : "RpRpRpRp:CwCwCwCw"], // painting t3
- requires: [{ amount: 3800 }],
+ shapes: [{ key: chinaShapes ? "CuCuCuCu:CwCwCwCw:Sb--Sr--" : "RpRpRpRp:CwCwCwCw", amount: 3800 }], // painting t3
reward: enumHubGoalRewards.reward_underground_belt_tier_2,
},
@@ -401,8 +389,12 @@ export function generateLevelDefinitions(limitedVersion = false) {
...(limitedVersion
? [
{
- shapes: [chinaShapes ? "CuCuCuCu:CwCwCwCw:Sb--Sr--" : "RpRpRpRp:CwCwCwCw"],
- requires: [{ amount: 0 }],
+ shapes: [
+ {
+ key: chinaShapes ? "CuCuCuCu:CwCwCwCw:Sb--Sr--" : "RpRpRpRp:CwCwCwCw",
+ amount: 0,
+ },
+ ],
reward: enumHubGoalRewards.reward_demo_end,
},
]
@@ -410,24 +402,21 @@ export function generateLevelDefinitions(limitedVersion = false) {
// 14
// Belt reader
{
- shapes: ["--Cg----:--Cr----"], // unused
- requires: [{ amount: 8, throughputOnly: true }], // Per second!
+ shapes: [{ key: "--Cg----:--Cr----", amount: 8, throughputOnly: true }], // unused
reward: enumHubGoalRewards.reward_belt_reader,
},
// 15
// Storage
{
- shapes: ["SrSrSrSr:CyCyCyCy"], // unused
- requires: [{ amount: 10000 }],
+ shapes: [{ key: "SrSrSrSr:CyCyCyCy", amount: 10000 }], // unused
reward: enumHubGoalRewards.reward_storage,
},
// 16
// Quad Cutter
{
- shapes: ["SrSrSrSr:CyCyCyCy:SwSwSwSw"], // belts t4 (two variants)
- requires: [{ amount: 6000 }],
+ shapes: [{ key: "SrSrSrSr:CyCyCyCy:SwSwSwSw", amount: 6000 }], // belts t4 (two variants)
reward: enumHubGoalRewards.reward_cutter_quad,
},
@@ -435,41 +424,41 @@ export function generateLevelDefinitions(limitedVersion = false) {
// Double painter
{
shapes: [
- chinaShapes ? "CyCyCyCy:CyCyCyCy:RyRyRyRy:RuRuRuRu" : "CbRbRbCb:CwCwCwCw:WbWbWbWb",
+ {
+ key: chinaShapes
+ ? "CyCyCyCy:CyCyCyCy:RyRyRyRy:RuRuRuRu"
+ : "CbRbRbCb:CwCwCwCw:WbWbWbWb",
+ amount: 20000,
+ },
], // miner t4 (two variants)
- requires: [{ amount: 20000 }],
reward: enumHubGoalRewards.reward_painter_double,
},
// 18
// Rotater (180deg)
{
- shapes: ["Sg----Sg:CgCgCgCg:--CyCy--"], // unused
- requires: [{ amount: 20000 }],
+ shapes: [{ key: "Sg----Sg:CgCgCgCg:--CyCy--", amount: 20000 }], // unused
reward: enumHubGoalRewards.reward_rotater_180,
},
// 19
// Compact splitter
{
- shapes: ["CpRpCp--:SwSwSwSw"],
- requires: [{ amount: 25000 }],
+ shapes: [{ key: "CpRpCp--:SwSwSwSw", amount: 25000 }],
reward: enumHubGoalRewards.reward_splitter,
},
// 20
// WIRES
{
- shapes: [finalGameShape],
- requires: [{ amount: 25000 }],
+ shapes: [{ key: finalGameShape, amount: 25000 }],
reward: enumHubGoalRewards.reward_wires_painter_and_levers,
},
// 21
// Filter
{
- shapes: ["CrCwCrCw:CwCrCwCr:CrCwCrCw:CwCrCwCr"],
- requires: [{ amount: 25000 }],
+ shapes: [{ key: "CrCwCrCw:CwCrCwCr:CrCwCrCw:CwCrCwCr", amount: 25000 }],
reward: enumHubGoalRewards.reward_filter,
},
@@ -477,9 +466,13 @@ export function generateLevelDefinitions(limitedVersion = false) {
// Constant signal
{
shapes: [
- chinaShapes ? "RrSySrSy:RyCrCwCr:CyCyRyCy" : "Cg----Cr:Cw----Cw:Sy------:Cy----Cy",
+ {
+ key: chinaShapes
+ ? "RrSySrSy:RyCrCwCr:CyCyRyCy"
+ : "Cg----Cr:Cw----Cw:Sy------:Cy----Cy",
+ amount: 25000,
+ },
],
- requires: [{ amount: 25000 }],
reward: enumHubGoalRewards.reward_constant_signal,
},
@@ -487,62 +480,63 @@ export function generateLevelDefinitions(limitedVersion = false) {
// Display
{
shapes: [
- chinaShapes ? "CrCrCrCr:CwCwCwCw:WwWwWwWw:CrCrCrCr" : "CcSyCcSy:SyCcSyCc:CcSyCcSy",
+ {
+ key: chinaShapes
+ ? "CrCrCrCr:CwCwCwCw:WwWwWwWw:CrCrCrCr"
+ : "CcSyCcSy:SyCcSyCc:CcSyCcSy",
+ amount: 25000,
+ },
],
- requires: [{ amount: 25000 }],
reward: enumHubGoalRewards.reward_display,
},
// 24 Logic gates
{
shapes: [
- chinaShapes
- ? "Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw"
- : "CcRcCcRc:RwCwRwCw:Sr--Sw--:CyCyCyCy",
+ {
+ key: chinaShapes
+ ? "Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw"
+ : "CcRcCcRc:RwCwRwCw:Sr--Sw--:CyCyCyCy",
+ amount: 25000,
+ },
],
- requires: [{ amount: 25000 }],
reward: enumHubGoalRewards.reward_logic_gates,
},
// 25 Virtual Processing
{
- shapes: ["Rg--Rg--:CwRwCwRw:--Rg--Rg"],
- requires: [{ amount: 25000 }],
+ shapes: [{ key: "Rg--Rg--:CwRwCwRw:--Rg--Rg", amount: 25000 }],
reward: enumHubGoalRewards.reward_virtual_processing,
},
// 26 Freeplay
{
- shapes: ["CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw"],
- requires: [{ amount: 50000 }],
+ shapes: [{ key: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", amount: 50000 }],
reward: enumHubGoalRewards.reward_freeplay,
},
// 27 Random
{
shapes: null,
- requires: null,
reward: null,
},
// 28 More shapes
{
- shapes: ["CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", "Rg--Rg--:CwRwCwRw:--Rg--Rg"],
- requires: [{ amount: 50000 }, { amount: 30000, throughputOnly: true }],
+ shapes: [
+ { key: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", amount: 50000 },
+ { key: "Rg--Rg--:CwRwCwRw:--Rg--Rg", amount: 30000, throughputOnly: true },
+ ],
reward: enumHubGoalRewards.reward_freeplay,
+ inOrder: true,
},
// 29 More shapes
{
shapes: [
- "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw",
- "Rg--Rg--:CwRwCwRw:--Rg--Rg",
- "Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw",
- ],
- requires: [
- { amount: 50000 },
- { amount: 30000, throughputOnly: true },
- { amount: 70000, throughputOnly: true },
+ { key: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", amount: 50000 },
+ { key: "Rg--Rg--:CwRwCwRw:--Rg--Rg", amount: 30000, throughputOnly: true },
+ { key: "Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw", amount: 70000, throughputOnly: true },
],
reward: enumHubGoalRewards.reward_freeplay,
},
@@ -550,16 +544,24 @@ export function generateLevelDefinitions(limitedVersion = false) {
// 30 More shapes
{
shapes: [
- "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw",
- "Rg--Rg--:CwRwCwRw:--Rg--Rg",
- "Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw",
- "CrCrCrCr:CwCwCwCw:WwWwWwWw:CrCrCrCr",
- ],
- requires: [
- { amount: 50000 },
- { amount: 30000, throughputOnly: true },
- { amount: 70000, throughputOnly: true },
- { amount: 90000 },
+ {
+ key: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw",
+ amount: 50000,
+ },
+ {
+ key: "Rg--Rg--:CwRwCwRw:--Rg--Rg",
+ amount: 30000,
+ throughputOnly: true,
+ },
+ {
+ key: "Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw",
+ amount: 70000,
+ throughputOnly: true,
+ },
+ {
+ key: "CrCrCrCr:CwCwCwCw:WwWwWwWw:CrCrCrCr",
+ amount: 90000,
+ },
],
reward: enumHubGoalRewards.reward_freeplay,
},
@@ -570,11 +572,11 @@ export function generateLevelDefinitions(limitedVersion = false) {
levelDefinitions.forEach(({ shapes }) => {
if (!shapes) return;
- shapes.forEach(shape => {
+ shapes.forEach(goal => {
try {
- ShapeDefinition.fromShortKey(shape);
+ ShapeDefinition.fromShortKey(goal.key);
} catch (ex) {
- throw new Error("Invalid tutorial goal: '" + ex + "' for shape" + shape);
+ throw new Error("Invalid tutorial goal: '" + ex + "' for shape" + goal.key);
}
});
});
diff --git a/src/js/game/systems/constant_signal.js b/src/js/game/systems/constant_signal.js
index 47637330..d437f072 100644
--- a/src/js/game/systems/constant_signal.js
+++ b/src/js/game/systems/constant_signal.js
@@ -78,7 +78,7 @@ export class ConstantSignalSystem extends GameSystemWithFilter {
for (let i = 0; i < this.root.hubGoals.currentGoal.definitions.length; i++) {
items.push(
this.root.shapeDefinitionMgr.getShapeItemFromDefinition(
- this.root.hubGoals.currentGoal.definitions[i]
+ this.root.hubGoals.currentGoal.definitions[i].shape
)
);
}
diff --git a/src/js/game/systems/hub.js b/src/js/game/systems/hub.js
index 03c85429..7f35a4e8 100644
--- a/src/js/game/systems/hub.js
+++ b/src/js/game/systems/hub.js
@@ -42,7 +42,7 @@ export class HubSystem extends GameSystemWithFilter {
}
pinsComp.slots[i].value = this.root.shapeDefinitionMgr.getShapeItemFromDefinition(
- this.root.hubGoals.currentGoal.definitions[i]
+ this.root.hubGoals.currentGoal.definitions[i].shape
);
}
}
@@ -84,53 +84,50 @@ export class HubSystem extends GameSystemWithFilter {
}
const goals = this.root.hubGoals.currentGoal;
+ const goalsLength = goals.definitions.length;
const delivered = this.root.hubGoals.getCurrentGoalDelivered();
- for (let i = 0; i < goals.definitions.length; i++) {
- const x =
- 45 +
- (goals.definitions.length > 3
- ? 22 * i - 14
- : goals.definitions.length > 2
- ? 28 * i - 8
- : goals.definitions.length > 1
- ? 43 * i
- : 0);
- const y = 58 + (goals.definitions.length > 1 ? -3 : 0);
- goals.definitions[i].drawCentered(
- x,
- y,
- parameters,
- goals.definitions.length > 3
- ? 20
- : goals.definitions.length > 2
- ? 26
- : goals.definitions.length > 1
- ? 32
- : 36
- );
+
+ let x = 45;
+ let y = 58 + (goalsLength > 1 ? -3 : 0);
+
+ if (goalsLength > 3) x += -36;
+ else if (goalsLength > 2) x += -36;
+ else if (goalsLength > 1) x += -44;
+
+ let size = 36;
+ if (goalsLength > 3) size = 20;
+ else if (goalsLength > 2) size = 26;
+ else if (goalsLength > 1) size = 32;
+
+ for (let i = 0; i < goalsLength; i++) {
+ if (goalsLength > 3) x += 22;
+ else if (goalsLength > 2) x += 28;
+ else if (goalsLength > 1) x += 43;
+
+ goals.definitions[i].shape.drawCentered(x, y, parameters, size);
const textOffsetX = 0;
const textOffsetY = 24;
- if (goals.requires[i].throughputOnly) {
+ if (goals.definitions[i].throughputOnly) {
// Throughput
const deliveredText = T.ingame.statistics.shapesDisplayUnits.second.replace(
"",
- formatBigNumber(goals.requires[i].amount)
+ formatBigNumber(goals.definitions[i].amount)
);
- if (goals.definitions.length > 3) {
+ if (goalsLength > 3) {
context.font = "bold 6px GameFont";
context.fillStyle = "#64666e";
context.textAlign = "left";
const offset = context.measureText(deliveredText).width;
context.fillText(deliveredText, textOffsetX + x - offset / 2, textOffsetY + y - 6);
- } else if (goals.definitions.length > 2) {
+ } else if (goalsLength > 2) {
context.font = "bold 6px GameFont";
context.fillStyle = "#64666e";
context.textAlign = "left";
const offset = context.measureText(deliveredText).width;
context.fillText(deliveredText, textOffsetX + x - offset / 2, textOffsetY + y - 4);
- } else if (goals.definitions.length > 1) {
+ } else if (goalsLength > 1) {
context.font = "bold 8px GameFont";
context.fillStyle = "#64666e";
context.textAlign = "left";
@@ -144,9 +141,9 @@ export class HubSystem extends GameSystemWithFilter {
context.fillText(deliveredText, textOffsetX + 86 - offset / 2, textOffsetY + 40);
}
} else {
- const textRequired = "/" + formatBigNumber(goals.requires[i].amount);
+ const textRequired = "/" + formatBigNumber(goals.definitions[i].amount);
const textDelivered = formatBigNumber(delivered[i]);
- if (goals.definitions.length > 3) {
+ if (goalsLength > 3) {
context.font = "6px GameFont";
const offsetRequired = context.measureText(textRequired).width;
@@ -167,7 +164,7 @@ export class HubSystem extends GameSystemWithFilter {
textOffsetX + x + offsetDelivered - totalOffset / 2,
textOffsetY + y - 6
);
- } else if (goals.definitions.length > 2) {
+ } else if (goalsLength > 2) {
context.font = "6px GameFont";
const offsetRequired = context.measureText(textRequired).width;
@@ -188,7 +185,7 @@ export class HubSystem extends GameSystemWithFilter {
textOffsetX + x + offsetDelivered - totalOffset / 2,
textOffsetY + y - 4
);
- } else if (goals.definitions.length > 1) {
+ } else if (goalsLength > 1) {
context.font = "8px GameFont";
const offsetRequired = context.measureText(textRequired).width;