Skip to content

Commit 5e44d70

Browse files
committed
manual way to configure sdk
1 parent 4792fd8 commit 5e44d70

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

Runtime/Client/LootLockerConfig.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ public static LootLockerConfig Get()
6969
#endif
7070
}
7171

72+
public static bool CreateNewSettings(string apiKey, string gameVersion, platformType platform, bool onDevelopmentMode)
73+
{
74+
settingsInstance = CreateInstance<LootLockerConfig>();
75+
settingsInstance.apiKey = apiKey;
76+
settingsInstance.game_version = gameVersion;
77+
settingsInstance.platform = platform;
78+
settingsInstance.developmentMode = onDevelopmentMode;
79+
80+
return true;
81+
}
82+
7283
#if UNITY_EDITOR
7384
public void EditorSave()
7485
{

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,46 @@
88
using System.Text;
99
using Newtonsoft.Json;
1010
using LootLocker.LootLockerEnums;
11+
using static LootLocker.LootLockerConfig;
1112

1213
namespace LootLocker.Requests
1314
{
15+
1416
public partial class LootLockerSDKManager
1517
{
1618
#region Init
1719

1820
static bool initialized;
19-
public static bool Init()
21+
static bool Init()
2022
{
2123
DebugMessage("SDK is Intializing");
2224
LootLockerServerManager.CheckInit();
2325
return LoadConfig();
2426
}
2527

28+
public static bool Init(string apiKey, string gameVersion, platformType platform, bool onDevelopmentMode)
29+
{
30+
DebugMessage("SDK is Intializing");
31+
LootLockerServerManager.CheckInit();
32+
return LootLockerConfig.CreateNewSettings(apiKey, gameVersion, platform, onDevelopmentMode);
33+
}
34+
2635
static bool LoadConfig()
2736
{
2837
initialized = true;
38+
if (LootLockerConfig.current == null)
39+
{
40+
Debug.LogError("SDK could not find settings, please contact support \n You can also set config manually by calling init");
41+
return false;
42+
}
2943
if (string.IsNullOrEmpty(LootLockerConfig.current.apiKey))
3044
{
3145
DebugMessage("Key has not been set, Please login to sdk manager or set key manually and then try again");
3246
initialized = false;
3347
return false;
3448
}
3549

50+
3651
return initialized;
3752
}
3853

@@ -78,21 +93,49 @@ public static void DebugMessage(string message, bool IsError = false)
7893
#region Authentication
7994
public static void VerifySteamID(string steamSessionTicket, Action<LootLockerVerifyResponse> onComplete)
8095
{
81-
if (!CheckInitialized()) return;
96+
if (!CheckInitialized())
97+
{
98+
LootLockerVerifyResponse response = new LootLockerVerifyResponse();
99+
response.success = false;
100+
response.hasError = true;
101+
response.Error = "SDk not initialised";
102+
response.text = "SDk not initialised";
103+
onComplete?.Invoke(response);
104+
return;
105+
}
82106
LootLockerVerifyRequest verifyRequest = new LootLockerVerifyRequest(steamSessionTicket);
83107
LootLockerAPIManager.Verify(verifyRequest, onComplete);
84108
}
85109

86110
public static void VerifyID(string deviceId, Action<LootLockerVerifyResponse> onComplete)
87111
{
88-
if (!CheckInitialized()) return;
112+
if (!CheckInitialized())
113+
{
114+
LootLockerVerifyResponse response = new LootLockerVerifyResponse();
115+
response.success = false;
116+
response.hasError = true;
117+
response.Error = "SDk not initialised";
118+
response.text = "SDk not initialised";
119+
onComplete?.Invoke(response);
120+
return;
121+
}
89122
LootLockerVerifyRequest verifyRequest = new LootLockerVerifyRequest(deviceId);
90123
LootLockerAPIManager.Verify(verifyRequest, onComplete);
91124
}
92125

93126
public static void StartSession(string deviceId, Action<LootLockerSessionResponse> onComplete)
94127
{
95-
if (!CheckInitialized()) return;
128+
if (!CheckInitialized())
129+
{
130+
LootLockerSessionResponse response = new LootLockerSessionResponse();
131+
response.success = false;
132+
response.status = false;
133+
response.hasError = true;
134+
response.Error = "SDk not initialised";
135+
response.text = "SDk not initialised";
136+
onComplete?.Invoke(response);
137+
return;
138+
}
96139
LootLockerConfig.current.deviceID = deviceId;
97140
LootLockerSessionRequest sessionRequest = new LootLockerSessionRequest(deviceId);
98141
LootLockerAPIManager.Session(sessionRequest, onComplete);
@@ -938,7 +981,7 @@ public static void PickDropsFromDropTable(int[] picks, int tableId, Action<LootL
938981
PickDropsFromDropTableRequest data = new PickDropsFromDropTableRequest();
939982
data.picks = picks;
940983

941-
LootLockerAPIManager.PickDropsFromDropTable(data,tableId, onComplete);
984+
LootLockerAPIManager.PickDropsFromDropTable(data, tableId, onComplete);
942985
}
943986
#endregion
944987
}

0 commit comments

Comments
 (0)