Skip to content

Commit

Permalink
Better way to retrieve some data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Braasileiro committed Feb 8, 2024
1 parent 6e16e74 commit 4601c9b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 35 deletions.
24 changes: 7 additions & 17 deletions MDRPC/Models/ActivityModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Il2CppAssets.Scripts.PeroTools.Commons;
using Il2CppAssets.Scripts.PeroTools.Nice.Datas;
using Il2CppAssets.Scripts.PeroTools.Nice.Interface;
using MDRPC.Patches;
using Il2CppAssets.Scripts.Database;

namespace MDRPC.Models;

Expand All @@ -24,21 +21,14 @@ public ActivityModel(bool isPlaying, string levelInfo)
// Song
songInfo = !string.IsNullOrEmpty(levelInfo) ? levelInfo.Split(" - ") : null;

// Account
var account = Singleton<DataManager>.instance["Account"];
playerName = DataHelper.nickname;
playerLevel = DataHelper.Level;

playerName = account["PlayerName"].GetResult<string>();
playerLevel = Math.Ceiling(account["Exp"].GetResult<int>() / 100d);

if (isPlaying)
if (isPlaying)
{
songLevel = new SongLevelModel(
HideBmsCheckPatch.Level,
HideBmsCheckPatch.Difficulty
);

playerElfin = ElfinModel.GetName(account["SelectedElfinIndex"].GetResult<int>());
playerCharacter = CharacterModel.GetName(account["SelectedRoleIndex"].GetResult<int>());
songLevel = new SongLevelModel();
playerElfin = ElfinModel.GetName();
playerCharacter = CharacterModel.GetName();
}
}

Expand Down
22 changes: 11 additions & 11 deletions MDRPC/Models/CharacterModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ internal class CharacterModel
{ "Marija" }
};

public static string GetName(int id)
public static string GetName()
{
var entity = GlobalDataBase.dbConfig.m_ConfigDic["character"].Cast<DBConfigCharacter>().GetLocal().GetInfoByIndex(id);
var entity = GlobalDataBase
.dbConfig
.m_ConfigDic["character"]
.Cast<DBConfigCharacter>()
.GetLocal()
.GetInfoByIndex(DataHelper.selectedRoleIndex);

if (entity != null)
{
if (CosCharacters.Contains(entity.characterName, StringComparer.OrdinalIgnoreCase))
return $"{entity.cosName} {entity.characterName}";
if (CosCharacters.Contains(entity.characterName, StringComparer.OrdinalIgnoreCase))
return $"{entity.cosName} {entity.characterName}";

return entity.characterName;
}

return id.ToString();
}
return entity.characterName;
}
}
15 changes: 8 additions & 7 deletions MDRPC/Models/ElfinModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ namespace MDRPC.Models;

internal class ElfinModel
{
public static string GetName(int id)
public static string GetName()
{
var entity = GlobalDataBase.dbConfig.m_ConfigDic["elfin"].Cast<DBConfigElfin>().GetLocal().GetInfoByIndex(id);

if (entity != null)
return entity.name;

return id.ToString();
return GlobalDataBase
.dbConfig
.m_ConfigDic["elfin"]
.Cast<DBConfigElfin>()
.GetLocal()
.GetInfoByIndex(DataHelper.selectedElfinIndex)
.name;
}
}

0 comments on commit 4601c9b

Please sign in to comment.