Skip to content

Commit a192466

Browse files
authored
v1.0.2
1 parent ac6481b commit a192466

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# 1.0.0
1+
# 1.0.2
22
- Initial release

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"id": "beat.afk_pause",
1010
"name": "AFK Pause",
11-
"version": "v1.0.1",
11+
"version": "v1.0.2",
1212
"developer": "Beat",
1313
"description": "Automatically pauses the level if you go AFK",
1414
"tags": [

src/main.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,32 @@
44

55
using namespace geode::prelude;
66

7-
int afkDeaths = 1;
8-
9-
class $modify(afkPlayerObject, PlayerObject) {
10-
bool pushButton(PlayerButton p0) {
11-
if (!PlayerObject::pushButton(p0) || !GameManager::sharedState()->getPlayLayer()) return false;
12-
afkDeaths = 1;
13-
return true;
14-
}
15-
};
16-
177
class $modify(afkPlayLayer, PlayLayer) {
8+
struct Fields {
9+
int m_afkDeaths = 1;
10+
};
11+
1812
void resetLevel() {
1913
PlayLayer::resetLevel();
2014

21-
if (afkDeaths >= Mod::get()->getSettingValue<int64_t>("attempt-threshold")) {
22-
afkDeaths = 1;
15+
if (m_fields->m_afkDeaths >= Mod::get()->getSettingValue<int64_t>("attempt-threshold")) {
16+
m_fields->m_afkDeaths = 1;
2317
if (Mod::get()->getSettingValue<bool>("enabled")) {
2418
this->pauseGame(false);
19+
Notification::create("Game paused due to inactivity.", CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png"))->show();
2520
}
2621
} else {
27-
afkDeaths++;
22+
m_fields->m_afkDeaths++;
2823
}
2924
return;
3025
}
3126
};
27+
28+
class $modify(afkPlayerObject, PlayerObject) {
29+
bool pushButton(PlayerButton p0) {
30+
if (auto playLayer = static_cast<afkPlayLayer*>(PlayLayer::get())) {
31+
playLayer->m_fields->m_afkDeaths = 1;
32+
}
33+
return PlayerObject::pushButton(p0);
34+
}
35+
};

0 commit comments

Comments
 (0)