mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Allow completing puzzles
This commit is contained in:
parent
31811f20b7
commit
272508ff87
@ -11,11 +11,15 @@ export class GoalAcceptorSystem extends GameSystemWithFilter {
|
||||
/** @param {GameRoot} root */
|
||||
constructor(root) {
|
||||
super(root, [GoalAcceptorComponent]);
|
||||
|
||||
this.puzzleCompleted = false;
|
||||
}
|
||||
|
||||
update() {
|
||||
const now = this.root.time.now();
|
||||
|
||||
let allAccepted = true;
|
||||
|
||||
for (let i = 0; i < this.allEntities.length; ++i) {
|
||||
const entity = this.allEntities[i];
|
||||
const goalComp = entity.components.GoalAcceptor;
|
||||
@ -25,6 +29,20 @@ export class GoalAcceptorSystem extends GameSystemWithFilter {
|
||||
d =>
|
||||
now - d.time < globalConfig.goalAcceptorMinimumDurationSeconds && d.item === goalComp.item
|
||||
);
|
||||
|
||||
if (goalComp.deliveryHistory.length < goalComp.getRequiredDeliveryHistorySize()) {
|
||||
allAccepted = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!this.puzzleCompleted &&
|
||||
this.root.gameInitialized &&
|
||||
allAccepted &&
|
||||
!this.root.gameMode.getIsEditor()
|
||||
) {
|
||||
this.root.hud.parts.dialogs.showInfo("Puzzle completed", "Congrats!");
|
||||
this.puzzleCompleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user