mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-30 23:19:49 +00:00
Optimize Steam achievement requesting
This commit is contained in:
parent
7c12ec228e
commit
e686f114a8
|
@ -9,6 +9,15 @@ const APP_ID := 2779170
|
||||||
## We are using a variable instead of the `Steam` singleton directly,
|
## We are using a variable instead of the `Steam` singleton directly,
|
||||||
## because it is not available in non-Steam builds.
|
## because it is not available in non-Steam builds.
|
||||||
static var steam_class
|
static var steam_class
|
||||||
|
static var achievements := {
|
||||||
|
"ACH_FIRST_PIXEL": false,
|
||||||
|
"ACH_ERASE_PIXEL": false,
|
||||||
|
"ACH_SAVE": false,
|
||||||
|
"ACH_PREFERENCES": false,
|
||||||
|
"ACH_ONLINE_DOCS": false,
|
||||||
|
"ACH_SUPPORT_DEVELOPMENT": false,
|
||||||
|
"ACH_3D_LAYER": false,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
|
@ -34,12 +43,16 @@ func _ready() -> void:
|
||||||
|
|
||||||
## Unlocks an achievement on Steam based on its [param achievement_name].
|
## Unlocks an achievement on Steam based on its [param achievement_name].
|
||||||
static func set_achievement(achievement_name: String) -> void:
|
static func set_achievement(achievement_name: String) -> void:
|
||||||
|
if achievements[achievement_name]: # Return early if the achievement has already been achieved
|
||||||
|
return
|
||||||
if not is_instance_valid(steam_class):
|
if not is_instance_valid(steam_class):
|
||||||
return
|
return
|
||||||
if not steam_class.isSteamRunning():
|
if not steam_class.isSteamRunning():
|
||||||
return
|
return
|
||||||
var status: Dictionary = steam_class.getAchievement(achievement_name)
|
var status: Dictionary = steam_class.getAchievement(achievement_name)
|
||||||
if status["achieved"]:
|
if status["achieved"]:
|
||||||
|
achievements[achievement_name] = true
|
||||||
return
|
return
|
||||||
steam_class.setAchievement(achievement_name)
|
steam_class.setAchievement(achievement_name)
|
||||||
steam_class.storeStats()
|
steam_class.storeStats()
|
||||||
|
achievements[achievement_name] = true
|
||||||
|
|
Loading…
Reference in a new issue