EVERYTHING
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BlockSpace.Account
|
||||
{
|
||||
public static class BlockSpaceAccountPrefs
|
||||
{
|
||||
public const string LinkedKey = "BlockSpace.Account.Linked";
|
||||
|
||||
public const string LinkedPlayerIdKey = "BlockSpace.Account.PlayerId";
|
||||
|
||||
public const string LinkedDiscordIdKey = "BlockSpace.Account.DiscordId";
|
||||
|
||||
public const string LinkedDiscordDisplayNameKey = "BlockSpace.Account.DiscordDisplayName";
|
||||
|
||||
public const string LocalUserIdKey = "BlockSpace.LocalUserId";
|
||||
|
||||
public static bool IsLinked => PlayerPrefs.GetInt("BlockSpace.Account.Linked", 0) == 1;
|
||||
|
||||
public static string GetLinkedPlayerId()
|
||||
{
|
||||
return PlayerPrefs.GetString("BlockSpace.Account.PlayerId", string.Empty);
|
||||
}
|
||||
|
||||
public static string GetDiscordId()
|
||||
{
|
||||
return PlayerPrefs.GetString("BlockSpace.Account.DiscordId", string.Empty);
|
||||
}
|
||||
|
||||
public static string GetDiscordDisplayName()
|
||||
{
|
||||
return PlayerPrefs.GetString("BlockSpace.Account.DiscordDisplayName", string.Empty);
|
||||
}
|
||||
|
||||
public static void SetLinkedAccount(string playerId, string discordId, string discordDisplayName)
|
||||
{
|
||||
PlayerPrefs.SetInt("BlockSpace.Account.Linked", 1);
|
||||
PlayerPrefs.SetString("BlockSpace.Account.PlayerId", playerId ?? string.Empty);
|
||||
PlayerPrefs.SetString("BlockSpace.Account.DiscordId", discordId ?? string.Empty);
|
||||
PlayerPrefs.SetString("BlockSpace.Account.DiscordDisplayName", discordDisplayName ?? string.Empty);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public static string GetOrCreateLocalUserId()
|
||||
{
|
||||
string text = PlayerPrefs.GetString("BlockSpace.LocalUserId", string.Empty);
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
return text;
|
||||
}
|
||||
string text2 = Guid.NewGuid().ToString("N");
|
||||
PlayerPrefs.SetString("BlockSpace.LocalUserId", text2);
|
||||
PlayerPrefs.Save();
|
||||
return text2;
|
||||
}
|
||||
|
||||
public static string GetUserFolderId()
|
||||
{
|
||||
string linkedPlayerId = GetLinkedPlayerId();
|
||||
if (string.IsNullOrEmpty(linkedPlayerId))
|
||||
{
|
||||
return GetOrCreateLocalUserId();
|
||||
}
|
||||
return linkedPlayerId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 215cf74244dadac5aef29414bd4d4247
|
||||
timeCreated: 1780325055
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user