private void OnUserStatsReceived(UserStatsReceived_t results)
		{
			if (results.m_nGameID == 105600uL && results.m_steamIDUser == SteamUser.GetSteamID())
			{
				this._areStatsReceived = true;
			}
		}
 internal static void InstallEvents()
 {
     UserStatsReceived_t.Install((UserStatsReceived_t x) => {
         if (x.SteamIDUser == SteamClient.SteamId)
         {
             SteamUserStats.StatsRecieved = true;
         }
         Action <SteamId, Result> onUserStatsReceived = SteamUserStats.OnUserStatsReceived;
         if (onUserStatsReceived != null)
         {
             onUserStatsReceived(x.SteamIDUser, x.Result);
         }
         else
         {
         }
     }, false);
     UserStatsStored_t.Install((UserStatsStored_t x) => {
         Action <Result> onUserStatsStored = SteamUserStats.OnUserStatsStored;
         if (onUserStatsStored != null)
         {
             onUserStatsStored(x.Result);
         }
         else
         {
         }
     }, false);
     UserAchievementStored_t.Install((UserAchievementStored_t x) => {
         Action <Achievement, int, int> onAchievementProgress = SteamUserStats.OnAchievementProgress;
         if (onAchievementProgress != null)
         {
             onAchievementProgress(new Achievement(x.AchievementName), x.CurProgress, x.MaxProgress);
         }
         else
         {
         }
     }, false);
     UserStatsUnloaded_t.Install((UserStatsUnloaded_t x) => {
         Action <SteamId> onUserStatsUnloaded = SteamUserStats.OnUserStatsUnloaded;
         if (onUserStatsUnloaded != null)
         {
             onUserStatsUnloaded(x.SteamIDUser);
         }
         else
         {
         }
     }, false);
     UserAchievementIconFetched_t.Install((UserAchievementIconFetched_t x) => {
         Action <string, int> onAchievementIconFetched = SteamUserStats.OnAchievementIconFetched;
         if (onAchievementIconFetched != null)
         {
             onAchievementIconFetched(x.AchievementName, x.IconHandle);
         }
         else
         {
         }
     }, false);
 }
        internal static void InstallEvents()
        {
            UserStatsReceived_t.Install(x =>
            {
                if (x.SteamIDUser == SteamClient.SteamId)
                {
                    StatsRecieved = true;
                }

                OnUserStatsReceived?.Invoke(x.SteamIDUser, x.Result);
            });

            UserStatsStored_t.Install(x => OnUserStatsStored?.Invoke(x.Result));
            UserAchievementStored_t.Install(x => OnAchievementProgress?.Invoke(x.AchievementName, (int)x.CurProgress, (int)x.MaxProgress));
            UserStatsUnloaded_t.Install(x => OnUserStatsUnloaded?.Invoke(x.SteamIDUser));
        }
	private void OnUserStatsStored(UserStatsStored_t pCallback) {
		// We may get callbacks for other games' stats arriving, ignore them
		if ((ulong)m_GameID != pCallback.m_nGameID)
			return;
		
		if (EResult.k_EResultOK != pCallback.m_eResult) {
			if (EResult.k_EResultInvalidParam == pCallback.m_eResult) {
				// One or more stats we set broke a constraint. They've been reverted,
				// and we should re-iterate the values now to keep in sync.
				Debug.LogWarning("StoreStats - some failed to validate");

				// Fake up a callback here so that we re-load the values.
				UserStatsReceived_t callback = new UserStatsReceived_t();
				callback.m_eResult = EResult.k_EResultOK;
				callback.m_nGameID = (ulong)m_GameID;
				OnUserStatsReceived(callback);
			}
			else {
				Debug.LogWarning("StoreStats - failed, " + pCallback.m_eResult);
			}
		}

		//Debug.Log("UserStats Stored");
	}
	private void OnUserStatsReceived(UserStatsReceived_t pCallback) {
		// We may get callbacks for other games' stats arriving, ignore them
		if ((ulong)m_GameID != pCallback.m_nGameID)
			return;

		if (pCallback.m_eResult != EResult.k_EResultOK) {
			Debug.Log("RequestStats - failed, " + pCallback.m_eResult);
			return;
		}

		// Load achievements
		foreach (Achievement_t ach in m_Achievements) {
			bool ret = SteamUserStats.GetAchievement(ach.m_strAchievementID, out ach.m_bAchieved);
			if (ret) {
				ach.m_strName = SteamUserStats.GetAchievementDisplayAttribute(ach.m_strAchievementID, "name");
				ach.m_strDescription = SteamUserStats.GetAchievementDisplayAttribute(ach.m_strAchievementID, "desc");
			}
			else {
				Debug.LogWarning("SteamUserStats.GetAchievement failed for Achievement " + ach.m_strAchievementID + "\nIs it registered in the Steam Partner site?");
			}
		}

		// load stats

		if (m_Stats != null) {
			for (int i = 0; i < m_Stats.Length; ++i) {
				bool ret;
				if (m_Stats[i].m_StatType == typeof(float)) {
					ret = SteamUserStats.GetStat(m_Stats[i].m_strStatName, out m_Stats[i].m_fValue);
				}
				else {
					ret = SteamUserStats.GetStat(m_Stats[i].m_strStatName, out m_Stats[i].m_nValue);
				}

				if (!ret) {
					Debug.LogWarning(" SteamUserStats.GetStat failed for Stat " + m_Stats[i].m_strStatName + "\nIs it registered in the Steam Partner site?");
				}
			}
		}

		//Debug.Log("UserStats Received");
		m_bStatsValid = true;
	}
Example #6
0
 private static void OnUserStatsReceived(UserStatsReceived_t pCallback)
 {
     var num = 0;
     while (num < StatDefinitions.Length)
         ++num;
 }
	// CallResult version for: SteamUserStats.RequestUserStats() (Other Players)
	private void OnUserStatsReceived(UserStatsReceived_t pCallback, bool bIOFailure) {
		Debug.Log("[" + UserStatsStored_t.k_iCallback + " - UserStatsReceived] - " + pCallback.m_nGameID + " -- " + pCallback.m_eResult + " -- " + pCallback.m_steamIDUser);
	}
 internal async Task <UserStatsReceived_t?> RequestUserStats(SteamId steamIDUser)
 {
     return(await UserStatsReceived_t.GetResultAsync(_RequestUserStats( Self, steamIDUser )));
 }
	//-----------------------------------------------------------------------------
	// Purpose: We have stats data from Steam. It is authoritative, so update
	//			our data with those results now.
	//-----------------------------------------------------------------------------
	private void OnUserStatsReceived(UserStatsReceived_t pCallback) {
		if (!SteamManager.Initialized)
			return;

		// we may get callbacks for other games' stats arriving, ignore them
		if ((ulong)m_GameID == pCallback.m_nGameID) {
			if (EResult.k_EResultOK == pCallback.m_eResult) {
				Debug.Log("Received stats and achievements from Steam\n");

				m_bStatsValid = true;

				// load achievements
				foreach (Achievement_t ach in m_Achievements) {
					bool ret = SteamUserStats.GetAchievement(ach.m_eAchievementID.ToString(), out ach.m_bAchieved);
					if (ret) {
						ach.m_strName = SteamUserStats.GetAchievementDisplayAttribute(ach.m_eAchievementID.ToString(), "name");
						ach.m_strDescription = SteamUserStats.GetAchievementDisplayAttribute(ach.m_eAchievementID.ToString(), "desc");
					}
					else {
						Debug.LogWarning("SteamUserStats.GetAchievement failed for Achievement " + ach.m_eAchievementID + "\nIs it registered in the Steam Partner site?");
					}
				}

				// load stats
				SteamUserStats.GetStat("NumGames", out m_nTotalGamesPlayed);
				SteamUserStats.GetStat("NumWins", out m_nTotalNumWins);
				SteamUserStats.GetStat("NumLosses", out m_nTotalNumLosses);
				SteamUserStats.GetStat("FeetTraveled", out m_flTotalFeetTraveled);
				SteamUserStats.GetStat("MaxFeetTraveled", out m_flMaxFeetTraveled);
				SteamUserStats.GetStat("AverageSpeed", out m_flAverageSpeed);
			}
			else {
				Debug.Log("RequestStats - failed, " + pCallback.m_eResult);
			}
		}
	}
Example #10
0
		private static void OnUserStatsReceived(UserStatsReceived_t pCallback)
		{
			if (!SteamInitialized) return;

			if (pCallback.m_nGameID != Main.SteamAppID || pCallback.m_eResult != EResult.k_EResultOK) return;

			//I'm sorry, Evan. We'll need to find somewhere nice to put this part.
			string[] cheevoNames = new string[]
			{
				"ending_a",
				"ending_b",
				"ending_c",
				"ending_d",
				"pillar_crushed",
				"orbs",
				"notes",
				"flashback",
				"god_mode",
				"first_orb",
				"first_note",
				"first_challenge_level",
				"level_editor",
			};
			string[] statNames = new string[]
			{
				"orbs_collected",
				"notes_read",
				"challenge_levels_played",
			};

			foreach (var cheevo in cheevoNames)
			{
				bool value;
				bool success = SteamUserStats.GetAchievement("cheevo_" + cheevo, out value);
				if (success)
					_achievementDictionary.Add("cheevo_" + cheevo, value);
				else
					_achievementDictionary.Add("cheevo_" + cheevo, false);
			}

			foreach (var stat in statNames)
			{
				int value;
				bool success = SteamUserStats.GetStat("stat_" + stat, out value);
				if (success)
					_statDictionary.Add("stat_" + stat, value);
				else
					_statDictionary.Add("stat_" + stat, 0);
			}
			StatsInitialized.Value = true;
		}
Example #11
0
		private static void OnUserStatsReceived(UserStatsReceived_t pCallback)
		{
			if (!SteamInitialized) return;

			if (pCallback.m_nGameID != 300340 || pCallback.m_eResult != EResult.k_EResultOK) return;

			//I'm sorry, Evan. We'll need to find somewhere nice to put this part.
			string[] cheevoNames = new string[] { "perverse", "win_the_game", "100_blocks", "250_blocks",
				"500_blocks", "1000_blocks", "10000_blocks", "cheating_jerk", "5_minutes_played", 
				"30_minutes_played", "120_minutes_played", "300_minutes_played", "600_minutes_played" };
			string[] statNames = new string[] { "time_played", "blocks_created", "distance_traveled", "times_died", "time_perverse" };

			foreach (var cheevo in cheevoNames)
			{
				bool value;
				bool success = SteamUserStats.GetAchievement("cheevo_" + cheevo, out value);
				if (success)
					_achievementDictionary.Add("cheevo_" + cheevo, value);
			}

			foreach (var stat in statNames)
			{
				int value;
				bool success = SteamUserStats.GetStat("stat_" + stat, out value);
				if (success)
				{
					_statDictionary.Add("stat_" + stat, value);
					if (stat == "time_played")
					{
						Main.TotalGameTime.Value = value;
					}
				}
			}
			StatsInitialized = true;
		}
Example #12
0
        internal async Task <UserStatsReceived_t?> RequestUserStats(SteamId steamIDUser)
        {
            UserStatsReceived_t?resultAsync = await UserStatsReceived_t.GetResultAsync(this._RequestUserStats(this.Self, steamIDUser));

            return(resultAsync);
        }
Example #13
0
        internal async Task <UserStatsReceived_t?> RequestUserStats(SteamId steamIDUser)
        {
            var returnValue = _RequestUserStats(Self, steamIDUser);

            return(await UserStatsReceived_t.GetResultAsync(returnValue));
        }