Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Steam.cs
Go to the documentation of this file.
1using System.IO;
2using HeathenEngineering.SteamworksIntegration;
3using HeathenEngineering.SteamworksIntegration.API;
4using Steamworks;
5using UnityEngine;
6
7public class Steam : MonoBehaviour
8{
9 public static Steam Instance;
10
11 public SteamworksBehaviour steamworks;
12
13 public UserGeneratedContentQueryManager ugc;
14
15 public WorkshopItem testData;
16
18
19 private void Awake()
20 {
21 Instance = this;
22 }
23
24 public void Init()
25 {
26 SteamAPI.Init();
27 BaseCore.IsOffline = !App.Client.LoggedOn || SteamSettings.behaviour == null;
28 }
29
30 public void CheckUpdate()
31 {
32 }
33
34 public void CheckDLC()
35 {
36 Debug.Log(HasDLC(ID_DLC.Test));
37 }
38
39 public static bool HasDLC(ID_DLC id)
40 {
41 return id switch
42 {
43 ID_DLC.CursedManor => true,
44 ID_DLC.BackerReward => EClass.core.config.HasBackerRewardCode(),
46 };
47 }
48
49 public static void GetAchievement(ID_Achievement id)
50 {
51 string text = "acv_" + id;
52 foreach (AchievementObject achievement in Instance.steamworks.settings.achievements)
53 {
54 if (achievement.Id == text)
55 {
56 if (!achievement.IsAchieved)
57 {
58 achievement.Unlock();
59 EClass.ui.Say("sys_acv".lang(text.lang()), Resources.Load<Sprite>("Media/Graphics/Icon/Achievement/" + text));
60 }
61 return;
62 }
63 }
64 Debug.Log("Achievement not found:" + text);
65 }
66
67 public void TestHasDLC()
68 {
69 Debug.Log(HasDLC(ID_DLC.Test));
70 Debug.Log(HasDLC(ID_DLC.CursedManor));
71 }
72
74 {
75 LayerProgress.Start("Uploading").onCancel = delegate
76 {
77 };
78 p.UpdateMeta(updateOnly: true);
80 UgcQuery myPublished = UgcQuery.GetMyPublished();
81 myPublished.SetReturnKeyValueTags(tags: true);
82 myPublished.Execute(CreateUserContent2);
83 }
84
85 private void CreateUserContent2(UgcQuery query)
86 {
87 Debug.Log("Creating Content2");
88 BaseModPackage baseModPackage = currentPackage;
89 if (query.ResultsList != null)
90 {
91 Debug.Log(query.ResultsList.Count);
92 }
93 foreach (WorkshopItem results in query.ResultsList)
94 {
95 if (results.keyValueTags == null)
96 {
97 continue;
98 }
99 StringKeyValuePair[] keyValueTags = results.keyValueTags;
100 for (int i = 0; i < keyValueTags.Length; i++)
101 {
102 StringKeyValuePair stringKeyValuePair = keyValueTags[i];
103 if (stringKeyValuePair.key == "id" && stringKeyValuePair.value == baseModPackage.id && results.Owner.id == App.Client.Owner.id)
104 {
105 Debug.Log("Updating Content");
106 UpdateUserContent(results.FileId);
107 return;
108 }
109 }
110 }
111 Debug.Log("Creating Content");
112 CreateItemData(baseModPackage).Create(null, null, new WorkshopItemKeyValueTag[1]
113 {
114 new WorkshopItemKeyValueTag
115 {
116 key = "id",
117 value = baseModPackage.id
118 }
119 }, delegate(WorkshopItemDataCreateStatus result)
120 {
121 LayerProgress.completed = true;
122 if (result.hasError)
123 {
124 Dialog.Ok("mod_publish_error");
125 EClass.ui.Say(result.errorMessage);
126 Debug.Log("error:" + result.errorMessage);
127 }
128 else
129 {
130 Dialog.Ok("mod_created");
131 Debug.Log("created");
132 }
133 });
134 }
135
136 public void UpdateUserContent(PublishedFileId_t fileId)
137 {
138 Debug.Log("Updating Content");
140 WorkshopItemData workshopItemData = CreateItemData(p);
141 workshopItemData.publishedFileId = fileId;
142 workshopItemData.Update(delegate(WorkshopItemDataUpdateStatus result)
143 {
144 LayerProgress.completed = true;
145 if (result.hasError)
146 {
147 Dialog.Ok("mod_publish_error");
148 EClass.ui.Say(result.errorMessage);
149 Debug.Log("error:" + result.errorMessage);
150 }
151 else
152 {
153 Dialog.Ok("mod_updated");
154 Debug.Log("updated");
155 }
156 });
157 }
158
159 public WorkshopItemData CreateItemData(BaseModPackage p)
160 {
161 FileInfo fileInfo = new FileInfo(p.dirInfo.FullName + "/preview.jpg");
162 DirectoryInfo directoryInfo = new DirectoryInfo(p.dirInfo.FullName);
163 WorkshopItemData workshopItemData = default(WorkshopItemData);
164 workshopItemData.appId = steamworks.settings.applicationId;
165 workshopItemData.title = p.title;
166 workshopItemData.description = p.description;
167 workshopItemData.content = directoryInfo;
168 workshopItemData.preview = fileInfo;
169 workshopItemData.metadata = p.id ?? "";
170 workshopItemData.tags = p.tags;
171 workshopItemData.visibility = ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPublic;
172 WorkshopItemData result = workshopItemData;
173 switch (p.visibility)
174 {
175 case "Unlisted":
176 result.visibility = ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityUnlisted;
177 break;
178 case "Private":
179 result.visibility = ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate;
180 break;
181 case "FriendsOnly":
182 result.visibility = ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityFriendsOnly;
183 break;
184 }
185 Debug.Log(App.Client.Owner.id);
186 Debug.Log(result.appId);
187 Debug.Log(p.id);
188 Debug.Log(directoryInfo.Exists + "/" + directoryInfo.FullName);
189 Debug.Log(fileInfo.Exists + "/" + fileInfo.FullName);
190 return result;
191 }
192}
ID_Achievement
ID_DLC
Definition: ID_DLC.cs:2
DirectoryInfo dirInfo
void UpdateMeta(bool updateOnly=false)
bool HasBackerRewardCode()
Definition: CoreConfig.cs:720
CoreConfig config
Definition: Core.cs:70
Definition: Dialog.cs:7
static Dialog Ok(string langDetail, Action action=null)
Definition: Dialog.cs:222
Definition: EClass.cs:5
static Core core
Definition: EClass.cs:6
static UI ui
Definition: EClass.cs:16
static LayerProgress Start(string text, Action onComplete=null)
Definition: Steam.cs:8
void UpdateUserContent(PublishedFileId_t fileId)
Definition: Steam.cs:136
SteamworksBehaviour steamworks
Definition: Steam.cs:11
static void GetAchievement(ID_Achievement id)
Definition: Steam.cs:49
void CheckDLC()
Definition: Steam.cs:34
void Awake()
Definition: Steam.cs:19
static Steam Instance
Definition: Steam.cs:9
BaseModPackage currentPackage
Definition: Steam.cs:17
void Init()
Definition: Steam.cs:24
void TestHasDLC()
Definition: Steam.cs:67
static bool HasDLC(ID_DLC id)
Definition: Steam.cs:39
WorkshopItemData CreateItemData(BaseModPackage p)
Definition: Steam.cs:159
void CheckUpdate()
Definition: Steam.cs:30
void CreateUserContent2(UgcQuery query)
Definition: Steam.cs:85
UserGeneratedContentQueryManager ugc
Definition: Steam.cs:13
void CreateUserContent(BaseModPackage p)
Definition: Steam.cs:73
WorkshopItem testData
Definition: Steam.cs:15