Optimize imports

This commit is contained in:
Sardelka9515
2023-02-13 17:51:18 +08:00
parent ac07edfe68
commit f555fef48d
22 changed files with 77 additions and 81 deletions

View File

@ -76,7 +76,7 @@ namespace RageCoop.Client.Scripting
}
catch (Exception ex)
{
Main.Logger.Error(ex);
Log.Error(ex);
SetLastResult(ex.ToString());
return 0;
}

View File

@ -168,7 +168,7 @@ namespace RageCoop.Client.Scripting
{
var args = new CustomEventReceivedArgs { Hash = p.Hash, Args = p.Args };
// Main.Logger.Debug($"CustomEvent:\n"+args.Args.DumpWithType());
// Log.Debug($"CustomEvent:\n"+args.Args.DumpWithType());
if (CustomEventHandlers.TryGetValue(p.Hash, out var handlers))
handlers.ForEach(x => { x.Invoke(args); });
@ -400,7 +400,7 @@ namespace RageCoop.Client.Scripting
[Remoting]
public static ClientResource GetResource(string name)
{
if (Main.Resources.LoadedResources.TryGetValue(name, out var resource))
if (MainRes.LoadedResources.TryGetValue(name, out var resource))
return resource;
return null;

View File

@ -34,7 +34,7 @@ namespace RageCoop.Client.Scripting
public Resources()
{
Logger = Main.Logger;
Logger = Log;
}
private Logger Logger { get; }
@ -52,20 +52,18 @@ namespace RageCoop.Client.Scripting
Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories).Where(x => x.CanBeIgnored())
.ForEach(File.Delete);
// TODO Core.ScheduleLoad()...
// TODO: Core.ScheduleLoad()...
}
public void Unload()
{
// TODO Core.ScheduleUnload()...
// TODO: Core.ScheduleUnload()...
}
private ClientResource Unpack(string zipPath, string dataFolderRoot)
{
var r = new ClientResource
{
Logger = Logger,
Scripts = new List<ClientScript>(),
Name = Path.GetFileNameWithoutExtension(zipPath),
DataFolder = Path.Combine(dataFolderRoot, Path.GetFileNameWithoutExtension(zipPath)),
ScriptsDirectory = Path.Combine(TempPath, Path.GetFileNameWithoutExtension(zipPath))
@ -86,7 +84,6 @@ namespace RageCoop.Client.Scripting
IsDirectory = true,
Name = dir.Substring(scriptsDir.Length + 1).Replace('\\', '/')
});
var assemblies = new Dictionary<ResourceFile, Assembly>();
foreach (var file in Directory.GetFiles(scriptsDir, "*", SearchOption.AllDirectories))
{
if (Path.GetFileName(file).CanBeIgnored())
@ -105,9 +102,8 @@ namespace RageCoop.Client.Scripting
}
var relativeName = file.Substring(scriptsDir.Length + 1).Replace('\\', '/');
var rfile = new ResourceFile
var rfile = new ClientFile
{
GetStream = () => { return new FileStream(file, FileMode.Open, FileAccess.Read); },
IsDirectory = false,
Name = relativeName
};