diff options
Diffstat (limited to 'ShiftOS_TheReturn/Scripting.cs')
| -rw-r--r-- | ShiftOS_TheReturn/Scripting.cs | 57 |
1 files changed, 8 insertions, 49 deletions
diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index 61c6676..081a6ae 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -205,55 +205,14 @@ end"); //This temporary proxy() method will be used by the API prober. Lua.proxy = new Func<string, dynamic>((objName) => { - foreach (var f in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (f.EndsWith(".exe") || f.EndsWith(".dll")) - { - try - { - - var asm = Assembly.LoadFile(f); - foreach (var type in asm.GetTypes()) - { - if (type.Name == objName) - { - dynamic dynObj = Activator.CreateInstance(type); - return dynObj; - } - - } - } - catch { } - } - } + dynamic dynObj = ReflectMan.Types.FirstOrDefault(t => t.Name == objName); + if (dynObj != null) + return dynObj; throw new Exception("{CLASS_NOT_FOUND}"); }); - - foreach (var f in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (f.EndsWith(".exe") || f.EndsWith(".dll")) - { - try - { - var thisasm = Assembly.LoadFile(f); - foreach (var type in thisasm.GetTypes()) - { - foreach (var attr in type.GetCustomAttributes(false)) - { - if (attr is ExposedAttribute) - { - var eattr = attr as ExposedAttribute; - Lua($"{eattr.Name} = proxy(\"{type.Name}\")"); - } - } - } - } - catch - { - - } - } - } + foreach (var type in ReflectMan.Types) + foreach (var attr in Array.FindAll(type.GetCustomAttributes(false), a => a is ExposedAttribute)) + Lua($"{(attr as ExposedAttribute).Name} = proxy(\"{type.Name}\")"); //Now we can null out the proxy() method as it can cause security risks. Lua.isRunning = new Func<bool>(() => { return this.Running; }); Lua.proxy = null; @@ -444,7 +403,7 @@ end"); /// Retrieves the user's Codepoints from the save file. /// </summary> /// <returns>The user's Codepoints.</returns> - public long getCodepoints() { return SaveSystem.CurrentSave.Codepoints; } + public ulong getCodepoints() { return SaveSystem.CurrentSave.Codepoints; } /// <summary> /// Run a command in the Terminal. @@ -462,7 +421,7 @@ end"); /// Adds the specified amount of Codepoints to the save flie. /// </summary> /// <param name="cp">The codepoints to add.</param> - public void addCodepoints(int cp) + public void addCodepoints(uint cp) { if (cp > 100 || cp <= 0) { |
