Beispiel #1
0
 public void BindScript(IUserScript script)
 {
     if (script is IActionScript)
         myActionScripts.Add((IActionScript)script);
     if (script is IKeyboardScript)
         myKeyboardScripts.Add((IKeyboardScript)script);
     if (script is ICollisionScript)
         myCollisionScripts.Add((ICollisionScript)script);
 }
Beispiel #2
0
 public void UnbindScript(IUserScript script)
 {
     if (script is IActionScript)
     {
         myActionScripts.Remove((IActionScript)script);
     }
     if (script is IKeyboardScript)
     {
         myKeyboardScripts.Remove((IKeyboardScript)script);
     }
     if (script is ICollisionScript)
     {
         myCollisionScripts.Remove((ICollisionScript)script);
     }
 }
Beispiel #3
0
 public void BindScript(IUserScript script)
 {
     if (script is IActionScript)
     {
         myActionScripts.Add((IActionScript)script);
     }
     if (script is IKeyboardScript)
     {
         myKeyboardScripts.Add((IKeyboardScript)script);
     }
     if (script is ICollisionScript)
     {
         myCollisionScripts.Add((ICollisionScript)script);
     }
 }
Beispiel #4
0
        public static UserScript CreateFromFile(string id, string fileName, string?args, Master master)
        {
            log.Debug($"Loading script file '{fileName}'");

            string?scriptClassName = GetScriptClassName(fileName);

            if (string.IsNullOrEmpty(scriptClassName))
            {
                throw new Exception($"Script does not contain a class derived from UserScript (class MyClass : UserScript). File: {fileName}");
            }

            IUserScript scriptIntf = CSScriptLib.CSScript.Evaluator
                                     .ReferenceAssemblyByName("System")
                                     .ReferenceAssemblyByName("log4net")
                                     .ReferenceAssemblyByName("Dirigent.Common")
                                     .ReferenceAssemblyByName("Dirigent.Agent.Core")
                                     .LoadFile <IUserScript>(fileName)
            ;

            if (scriptIntf == null)
            {
                throw new Exception($"Not a valid script file: {fileName}");
            }

            var script = scriptIntf as UserScript;

            if (script is null)
            {
                scriptIntf.Dispose();
                throw new Exception($"Script not derived from Script class! File: {fileName}");
            }

            Dirigent.UserScript.InitScriptInstance(script, id, master, fileName, args);

            return(script);
        }
 public UserScriptValidateException(IUserScript ScriptItem, string Message) : base(Message)
 {
     this.ScriptItem = ScriptItem;
 }
Beispiel #6
0
 public void UnbindScript(IUserScript script)
 {
     if (script is IActionScript)
         myActionScripts.Remove((IActionScript)script);
     if (script is IKeyboardScript)
         myKeyboardScripts.Remove((IKeyboardScript)script);
     if (script is ICollisionScript)
         myCollisionScripts.Remove((ICollisionScript)script);
 }