using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using KairoEngine.Core; using KairoEngine.Core.ModuleSystem; using Sirenix.OdinInspector; namespace KairoEngine.SteamIntegration { public class SteamModule : GameModuleBase { public override string name => "Steam Module"; [LabelText("Steamworks App ID")] public uint appId = 0000000; public bool showDebug = false; public bool useSteamStats = true; public bool useSteamAchievements = true; [NonSerialized, ShowInInspector, InlineEditor(InlineEditorObjectFieldModes.Boxed), PropertySpace(4,0), ShowIf("@useSteamStats")] public SteamworksStatLibrary steamStats; public SteamModule(GameConfig config) : base(config) { this.gameConfig = config; this.className = this.GetType().AssemblyQualifiedName; this.typeName = "SteamModule"; } public override void Load(Transform parent) { GameObject obj = GameObject.Instantiate(new GameObject(), parent); obj.name = "SteamIntegration"; SteamworksManager steamworksManager = obj.AddComponent(); steamworksManager.appId = appId; steamworksManager.ShowDebug(showDebug); steamworksManager.useStats = useSteamStats; if(useSteamStats && steamStats != null) steamworksManager.steamStatsLibray = steamStats; steamworksManager.useAchievements = useSteamAchievements; } public override void Start() { } public override void Reset() { } public override void Destroy() { } public static SteamModule JSONToSteamModule(string data) { try { return JsonUtility.FromJson(data); } catch (System.Exception e) { Debug.LogError($"Could not deserialize SteamModule: \n{e}"); return new SteamModule(null); } } public override void OnBeforeSerialize(ObjectSerializer serializer) { if(steamStats != null) serializer.AddScriptableObject("SteamIntegration_statsLibrary", steamStats); } public override void OnBeforeDeserialize(ObjectSerializer serializer) { steamStats = (SteamworksStatLibrary)serializer.GetScriptableObject("SteamIntegration_statsLibrary"); } } }