示例#1
0
        public void LoadRunningScriptsFromWorld()
        {
            Log.Info("Loading running scripts from world...");
            if (MyAPIGateway.Utilities.FileExistsInWorldStorage(runningScriptsFileName, typeof(ScriptManagerConfig)))
            {
                //Dictionary<long, long> runningScripts;

                Dictionary <long, long> runningScripts = null;
                try
                {
                    using (var reader = MyAPIGateway.Utilities.ReadBinaryFileInWorldStorage(runningScriptsFileName, typeof(ScriptManagerConfig)))
                        runningScripts = MyAPIGateway.Utilities.SerializeFromBinary <Dictionary <long, long> >(reader.ReadBytes((int)reader.BaseStream.Length));

                    //runningScripts = MyAPIGateway.Utilities.SerializeFromXML<Dictionary<long, long>>(serialized);
                }
                catch (Exception e)
                {
                    Log.Warn($"Parsing running scripts failed: {e.Message}");
                    return;
                }

                foreach (var kvp in runningScripts)
                {
                    var script = Whitelist.First(item => item.Id == kvp.Value);
                    AddRunningScript(kvp.Key, script);
                }
            }
        }