public static void LoadJDeployables(string pluginname) { if (!DeployableTypesByPlugin.ContainsKey(pluginname)) { return; } if (DataManager.data == null || DataManager.data.p == null) { DataManager.Load(); } Dictionary <int, DeployableSaveData> pluginsavedata; if (!DataManager.data.p.TryGetValue(pluginname, out pluginsavedata)) { return; } int totalloadcount = 0; Dictionary <JInfoAttribute, int> loadcount = new Dictionary <JInfoAttribute, int>(); foreach (var de in pluginsavedata) { Type deployabletype; JInfoAttribute info; if (TryGetType(de.Value.t, out deployabletype) && DeployableTypes.TryGetValue(deployabletype, out info)) { if (!loadcount.Keys.Contains(info)) { loadcount.Add(info, 0); } if (LoadJDeployable(de.Key, de.Value)) { loadcount[info]++; totalloadcount++; } else { Interface.Oxide.LogWarning($"[JtechCore] Failed to Load JDeployable: [{pluginname}] {de.Value} {de.Key}"); } } } string top = $"--- {totalloadcount} JDeployable(s) from {pluginname} Loaded ---"; Interface.Oxide.LogInfo($"[JtechCore] {top}"); foreach (var count in loadcount) { Interface.Oxide.LogInfo($"[JtechCore] > {count.Value} {count.Key.Name}(s)"); } Interface.Oxide.LogInfo($"[JtechCore] {new String('-', top.Length)}"); }
public static void SaveJDeployables(string pluginname) { if (!DeployableTypesByPlugin.ContainsKey(pluginname)) { return; } if (DataManager.data == null || DataManager.data.p == null) { DataManager.Load(); } Dictionary <int, DeployableSaveData> pluginsavedata; if (DataManager.data.p.ContainsKey(pluginname)) { if (!DataManager.data.p.TryGetValue(pluginname, out pluginsavedata)) { return; } } else { pluginsavedata = new Dictionary <int, DeployableSaveData>(); DataManager.data.p.Add(pluginname, pluginsavedata); } pluginsavedata.Clear(); int totalsavecount = 0; Dictionary <JInfoAttribute, int> savecount = new Dictionary <JInfoAttribute, int>(); List <JDeployable> deps; if (!spawnedDeployablesByPlugin.TryGetValue(pluginname, out deps)) { return; } foreach (var de in deps) { JInfoAttribute info; if (DeployableTypes.TryGetValue(de.GetType(), out info)) { if (!savecount.ContainsKey(info)) { savecount.Add(info, 0); } if (SaveJDeployable(de.Id, de)) { totalsavecount++; savecount[info]++; } else { Interface.Oxide.LogWarning($"[JtechCore] Failed to Save JDeployable: [{pluginname}] {info.Name} {de.Id}"); } } } string top = $"--- {totalsavecount} JDeployable(s) from {pluginname} Saved ---"; Interface.Oxide.LogInfo($"[JtechCore] {top}"); foreach (var count in savecount) { if (count.Value > 0) { Interface.Oxide.LogInfo($"[JtechCore] > {count.Value} {count.Key.Name}(s)"); } } Interface.Oxide.LogInfo($"[JtechCore] {new String('-', top.Length)}"); }