{"TotalCount":8,"Files":[{"Ident":"sbux.api","Path":"Code/UI/Prompt.razor","FileName":"Prompt.razor","PackageType":"library","CodeKind":"Game","AssetVersionId":65359,"IsPrivate":false,"Code":"@using System\r\n@using System.Threading.Tasks\r\n@using Sandbox\r\n@using Sandbox.UI\r\n@inherits WebPanel\r\n\r\n\u003Cstyle\u003E\r\n\t/* .scss files don\u0027t work in libraries. https://github.com/Facepunch/sbox-issues/issues/4813 */\r\n\tprompt {\r\n\t\twidth: 100%;\r\n\t\tpointer-events: all;\r\n\t}\r\n\u003C/style\u003E\r\n\r\n@code {\r\n\tpublic readonly TaskCompletionSource\u003Cbool\u003E Purchased;\r\n\t\r\n\tpublic Prompt( string URL )\r\n\t{\r\n\t\tUrl = URL;\r\n\t\tPurchased = new TaskCompletionSource\u003Cbool\u003E();\r\n\r\n\t\tif ( !Game.ActiveScene.Components.TryGet( out ScreenPanel panel ) )\r\n\t\t{\r\n\t\t\tpanel = Game.ActiveScene.Components.Create\u003CScreenPanel\u003E();\r\n\t\t\tpanel.GetPanel().ElementName = \u0022monetization\u0022;\r\n\t\t\tpanel.ZIndex = int.MaxValue;\r\n\t\t}\r\n\r\n\t\tParent = panel.GetPanel();\r\n\t}\r\n\t\r\n\tpublic override void OnDeleted()\r\n\t{\r\n\t\tif ( !Game.ActiveScene.Components.TryGet( out ScreenPanel panel ) )\r\n\t\t{\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\tif ( panel.GetPanel().HasChildren )\r\n\t\t{\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\tpanel.Destroy();\r\n\t}\r\n\r\n\tprotected override void OnAfterTreeRender( bool firstTime )\r\n\t{\r\n\t\t// This was the only way I could think of to get the\r\n\t\t// Steam browser to send data back data to the game.\r\n\t\t// If you have a better way let me know.\r\n\t\t\r\n\t\tswitch ( Surface.PageTitle )\r\n\t\t{\r\n\t\t\tcase \u0022finished\u0022: Delete();\r\n\t\t\t\tbreak;\r\n\t\t\tcase \u0022purchased\u0022: Purchased.TrySetResult( true );\r\n\t\t\t\tbreak;\r\n\t\t\tcase \u0022cancelled\u0022: Purchased.TrySetResult( false );\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t\r\n\tprotected override int BuildHash() =\u003E HashCode.Combine( Surface.PageTitle );\r\n}\r\n"},{"Ident":"sbux.api","Path":".obj/__compiler_extra.cs","FileName":"__compiler_extra.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":65359,"IsPrivate":false,"Code":"global using static Sandbox.Internal.GlobalGameNamespace;\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022AddonTitle\u0022, \u0022s\u0026bux API\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022AddonIdent\u0022, \u0022api\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022OrgIdent\u0022, \u0022sbux\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022Ident\u0022, \u0022sbux.api\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022CompileTime\u0022, \u00228/10/2024 3:38:14 PM\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022EngineVersion\u0022, \u002217\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022EngineMinorVersion\u0022, \u00221\u0022 )]\r\n\r\n[assembly: System.Runtime.Versioning.TargetFramework( \u0022.NETCoreApp,Version=v7.0\u0022, FrameworkDisplayName = \u0022.NET 7.0\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyVersion(\u00220.0.108.0\u0022)]\r\n[assembly: global::System.Reflection.AssemblyFileVersion(\u00220.0.108.0\u0022)]"},{"Ident":"sbux.api","Path":"UI/Prompt.razor","FileName":"Prompt.razor","PackageType":"library","CodeKind":"Game","AssetVersionId":65359,"IsPrivate":false,"Code":"@using System\r\n@using System.Threading.Tasks\r\n@using Sandbox\r\n@using Sandbox.UI\r\n@inherits WebPanel\r\n\r\n\u003Cstyle\u003E\r\n\t/* .scss files don\u0027t work in libraries. https://github.com/Facepunch/sbox-issues/issues/4813 */\r\n\tprompt {\r\n\t\twidth: 100%;\r\n\t\tpointer-events: all;\r\n\t}\r\n\u003C/style\u003E\r\n\r\n@code {\r\n\tpublic readonly TaskCompletionSource\u003Cbool\u003E Purchased;\r\n\t\r\n\tpublic Prompt( string URL )\r\n\t{\r\n\t\tUrl = URL;\r\n\t\tPurchased = new TaskCompletionSource\u003Cbool\u003E();\r\n\r\n\t\tif ( !Game.ActiveScene.Components.TryGet( out ScreenPanel panel ) )\r\n\t\t{\r\n\t\t\tpanel = Game.ActiveScene.Components.Create\u003CScreenPanel\u003E();\r\n\t\t\tpanel.GetPanel().ElementName = \u0022monetization\u0022;\r\n\t\t\tpanel.ZIndex = int.MaxValue;\r\n\t\t}\r\n\r\n\t\tParent = panel.GetPanel();\r\n\t}\r\n\t\r\n\tpublic override void OnDeleted()\r\n\t{\r\n\t\tif ( !Game.ActiveScene.Components.TryGet( out ScreenPanel panel ) )\r\n\t\t{\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\tif ( panel.GetPanel().HasChildren )\r\n\t\t{\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\tpanel.Destroy();\r\n\t}\r\n\r\n\tprotected override void OnAfterTreeRender( bool firstTime )\r\n\t{\r\n\t\t// This was the only way I could think of to get the\r\n\t\t// Steam browser to send data back data to the game.\r\n\t\t// If you have a better way let me know.\r\n\t\t\r\n\t\tswitch ( Surface.PageTitle )\r\n\t\t{\r\n\t\t\tcase \u0022finished\u0022: Delete();\r\n\t\t\t\tbreak;\r\n\t\t\tcase \u0022purchased\u0022: Purchased.TrySetResult( true );\r\n\t\t\t\tbreak;\r\n\t\t\tcase \u0022cancelled\u0022: Purchased.TrySetResult( false );\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t\r\n\tprotected override int BuildHash() =\u003E HashCode.Combine( Surface.PageTitle );\r\n}\r\n"},{"Ident":"sbux.api","Path":"Code/GamePass.cs","FileName":"GamePass.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":65359,"IsPrivate":false,"Code":"using System.Text.Json;\r\nnamespace Sandbox.Services;\r\n\r\n[GameResource( \u0022Game Pass\u0022, \u0022gamepass\u0022, \u0022A game pass\u0022, Icon = \u0022sbux\u0022 )]\r\npublic class GamePass : GameResource\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// The ident of this game pass. A short name with no special characters.\r\n\t/// \u003C/summary\u003E\r\n\t[Category(\u0022Game Pass Setup\u0022)]\r\n\tpublic string Ident { get; set; }\r\n\t\r\n\t/// \u003Csummary\u003E\r\n\t/// The amount of s\u0026amp;bux this game pass costs.\r\n\t/// \u003C/summary\u003E\r\n\t[Category(\u0022Game Pass Setup\u0022)]\r\n\tpublic int Cost { get; set; }\r\n\t\r\n\t/// \u003Csummary\u003E\r\n\t/// Name of the game pass to show in UI.\r\n\t/// \u003C/summary\u003E\r\n\t[Category(\u0022Display Information\u0022)]\r\n\tpublic string Title { get; set; }\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Icon for this game pass. Only works with urls (for now).\r\n\t/// \u003C/summary\u003E\r\n\t[Category( \u0022Display Information\u0022 )]\r\n\tpublic string Icon { get; set; }\r\n\t\r\n\tinternal string Serialize() =\u003E JsonSerializer.Serialize( new { Ident, Cost, Title, Icon } ).Base64Encode();\r\n}\r\n"},{"Ident":"sbux.api","Path":"GamePass.cs","FileName":"GamePass.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":65359,"IsPrivate":false,"Code":"using System.Text.Json;\r\nnamespace Sandbox.Services;\r\n\r\n[GameResource( \u0022Game Pass\u0022, \u0022gamepass\u0022, \u0022A game pass\u0022, Icon = \u0022sbux\u0022 )]\r\npublic class GamePass : GameResource\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// The ident of this game pass. A short name with no special characters.\r\n\t/// \u003C/summary\u003E\r\n\t[Category(\u0022Game Pass Setup\u0022)]\r\n\tpublic string Ident { get; set; }\r\n\t\r\n\t/// \u003Csummary\u003E\r\n\t/// The amount of s\u0026amp;bux this game pass costs.\r\n\t/// \u003C/summary\u003E\r\n\t[Category(\u0022Game Pass Setup\u0022)]\r\n\tpublic int Cost { get; set; }\r\n\t\r\n\t/// \u003Csummary\u003E\r\n\t/// Name of the game pass to show in UI.\r\n\t/// \u003C/summary\u003E\r\n\t[Category(\u0022Display Information\u0022)]\r\n\tpublic string Title { get; set; }\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Icon for this game pass. Only works with urls (for now).\r\n\t/// \u003C/summary\u003E\r\n\t[Category( \u0022Display Information\u0022 )]\r\n\tpublic string Icon { get; set; }\r\n\t\r\n\tinternal string Serialize() =\u003E JsonSerializer.Serialize( new { Ident, Cost, Title, Icon } ).Base64Encode();\r\n}\r\n"},{"Ident":"sbux.api","Path":"Monetization.cs","FileName":"Monetization.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":65359,"IsPrivate":false,"Code":"using Sandbox.Diagnostics;\r\nusing Sandbox.UI;\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Text.Json;\r\nusing System.Text.Json.Nodes;\r\nusing System.Threading.Tasks;\r\nnamespace Sandbox.Services;\r\n\r\npublic static class Monetization\r\n{\r\n\t[ConVar( \u0022sbux\u0022, Help = \u0022Your s\u0026bux balance.\u0022, Saved = true )]\r\n\tprivate static string _balance { get; set; }\r\n\r\n\tprivate static List\u003Cstring\u003E _gamePass { get; set; }\r\n\r\n\tprivate const string URL = \u0022https://sbux.party/\u0022;\r\n\r\n\tprivate static async Task\u003Cstring\u003E Identification() =\u003E $\u0022?steamid={Game.SteamId}\u0026token={await Auth.GetToken( \u0022sbux\u0022 )}\u0026ident={Game.Ident}\u0026balance={_balance}\u0022;\r\n\r\n\tprivate static readonly Task Loading;\r\n\r\n\tprivate static async Task Refresh()\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\tvar response = await Http.RequestAsync( URL \u002B await Identification() );\r\n\r\n\t\t\tif ( response.IsSuccessStatusCode )\r\n\t\t\t{\r\n\t\t\t\tvar result = JsonNode.Parse( await response.Content.ReadAsStringAsync() );\r\n\r\n\t\t\t\t_balance = result?[\u0022balance\u0022].Deserialize\u003Cstring\u003E() ?? \u00220\u0022;\r\n\t\t\t\t_gamePass = result?[\u0022gamepass\u0022].Deserialize\u003CList\u003Cstring\u003E\u003E() ?? new List\u003Cstring\u003E();\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch ( Exception e )\r\n\t\t{\r\n\t\t\tLog.Warning( $\u0022Something went wrong when trying to update monetization values. {e}\u0022 );\r\n\t\t}\r\n\t}\r\n\r\n\tstatic Monetization()\r\n\t{\r\n\t\tLoading = Refresh();\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// It may take a second to get a response from the backend. Use this to ensure everything is loaded.\r\n\t/// \u003C/summary\u003E\r\n\tpublic static Task WaitForLoad() =\u003E Loading;\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// If the player owns the game pass.\r\n\t/// \u003C/summary\u003E\r\n\tpublic static bool Has( this GamePass gamePass )\r\n\t{\r\n\t\tAssert.NotNull( gamePass );\r\n\r\n\t\treturn _gamePass.Contains( gamePass.Ident );\r\n\t}\r\n\r\n\t/// \u003Csummary\u003EPrompts the player to purchase the game pass.\u003C/summary\u003E\r\n\t/// \u003Creturns\u003ETrue if the game pass was bought.\u003C/returns\u003E\r\n\t/// \u003Cremarks\u003EA game pass can be purchased multiple times.\u003C/remarks\u003E\r\n\tpublic static async Task\u003Cbool\u003E Purchase( this GamePass gamePass )\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\tAssert.NotNull( gamePass );\r\n\r\n\t\t\tvar prompt = new Prompt( URL \u002B gamePass.Serialize() \u002B await Identification() );\r\n\r\n\t\t\tif ( await prompt.Purchased.Task )\r\n\t\t\t{\r\n\t\t\t\tawait Refresh();\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch ( Exception e )\r\n\t\t{\r\n\t\t\tLog.Info( e );\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// If the player owns the game pass, if not - prompt a purchase.\r\n\t/// \u003C/summary\u003E\r\n\tpublic static async Task\u003Cbool\u003E HasOrPurchase( this GamePass gamePass )\r\n\t{\r\n\t\treturn gamePass.Has() || await gamePass.Purchase();\r\n\t}\r\n}\r\n"},{"Ident":"sbux.api","Path":"__gen_RazorNamespace.cs","FileName":"__gen_RazorNamespace.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":65359,"IsPrivate":false,"Code":"global using Microsoft.AspNetCore.Components; \nglobal using Microsoft.AspNetCore.Components.Rendering;\n"},{"Ident":"sbux.api","Path":"Code/Monetization.cs","FileName":"Monetization.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":65359,"IsPrivate":false,"Code":"using Sandbox.Diagnostics;\r\nusing Sandbox.UI;\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Text.Json;\r\nusing System.Text.Json.Nodes;\r\nusing System.Threading.Tasks;\r\nnamespace Sandbox.Services;\r\n\r\npublic static class Monetization\r\n{\r\n\t[ConVar( \u0022sbux\u0022, Help = \u0022Your s\u0026bux balance.\u0022, Saved = true )]\r\n\tprivate static string _balance { get; set; }\r\n\r\n\tprivate static List\u003Cstring\u003E _gamePass { get; set; }\r\n\r\n\tprivate const string URL = \u0022https://sbux.party/\u0022;\r\n\r\n\tprivate static async Task\u003Cstring\u003E Identification() =\u003E $\u0022?steamid={Game.SteamId}\u0026token={await Auth.GetToken( \u0022sbux\u0022 )}\u0026ident={Game.Ident}\u0026balance={_balance}\u0022;\r\n\r\n\tprivate static readonly Task Loading;\r\n\r\n\tprivate static async Task Refresh()\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\tvar response = await Http.RequestAsync( URL \u002B await Identification() );\r\n\r\n\t\t\tif ( response.IsSuccessStatusCode )\r\n\t\t\t{\r\n\t\t\t\tvar result = JsonNode.Parse( await response.Content.ReadAsStringAsync() );\r\n\r\n\t\t\t\t_balance = result?[\u0022balance\u0022].Deserialize\u003Cstring\u003E() ?? \u00220\u0022;\r\n\t\t\t\t_gamePass = result?[\u0022gamepass\u0022].Deserialize\u003CList\u003Cstring\u003E\u003E() ?? new List\u003Cstring\u003E();\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch ( Exception e )\r\n\t\t{\r\n\t\t\tLog.Warning( $\u0022Something went wrong when trying to update monetization values. {e}\u0022 );\r\n\t\t}\r\n\t}\r\n\r\n\tstatic Monetization()\r\n\t{\r\n\t\tLoading = Refresh();\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// It may take a second to get a response from the backend. Use this to ensure everything is loaded.\r\n\t/// \u003C/summary\u003E\r\n\tpublic static Task WaitForLoad() =\u003E Loading;\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// If the player owns the game pass.\r\n\t/// \u003C/summary\u003E\r\n\tpublic static bool Has( this GamePass gamePass )\r\n\t{\r\n\t\tAssert.NotNull( gamePass );\r\n\r\n\t\treturn _gamePass.Contains( gamePass.Ident );\r\n\t}\r\n\r\n\t/// \u003Csummary\u003EPrompts the player to purchase the game pass.\u003C/summary\u003E\r\n\t/// \u003Creturns\u003ETrue if the game pass was bought.\u003C/returns\u003E\r\n\t/// \u003Cremarks\u003EA game pass can be purchased multiple times.\u003C/remarks\u003E\r\n\tpublic static async Task\u003Cbool\u003E Purchase( this GamePass gamePass )\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\tAssert.NotNull( gamePass );\r\n\r\n\t\t\tvar prompt = new Prompt( URL \u002B gamePass.Serialize() \u002B await Identification() );\r\n\r\n\t\t\tif ( await prompt.Purchased.Task )\r\n\t\t\t{\r\n\t\t\t\tawait Refresh();\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch ( Exception e )\r\n\t\t{\r\n\t\t\tLog.Info( e );\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// If the player owns the game pass, if not - prompt a purchase.\r\n\t/// \u003C/summary\u003E\r\n\tpublic static async Task\u003Cbool\u003E HasOrPurchase( this GamePass gamePass )\r\n\t{\r\n\t\treturn gamePass.Has() || await gamePass.Purchase();\r\n\t}\r\n}\r\n"}]}