using Microsoft.CodeAnalysis.Scripting; using System.Collections.Generic; using System.IO; namespace Arrowgene.Ddon.GameServer.Scripting { public abstract class ScriptModule { public abstract string ModuleRoot { get; } public abstract string Filter { get; } public abstract bool ScanSubdirectories { get; } public List Watchers { get; set; } /// /// Determines if this module is able to be hot-loadable or not. /// If a module is not hot-loadable, it will only be evaluated once /// when the server first loads. /// public abstract bool EnableHotLoad { get; } /// /// Determines if this module is enabled or not. Intended for development; /// should be used such that an in-development module can be checked in but /// disabled until the feature is ready. /// public virtual bool IsEnabled { get; } = true; public HashSet Scripts { get; set; } /// /// A list of scripts in the module directory which should be ignored /// and not compiled directly. These files may be interfaces or abstract classes /// which can't be instantiated directly. /// public HashSet IgnoredScripts { get; set; } public ScriptModule() { IgnoredScripts = new HashSet(); Scripts = new HashSet(); Watchers = new List(); } /// /// Code that a module can execute before EvaluateResult is called for each script. /// public virtual void Initialize() { } /// /// Options passed into the compilation unit. /// /// public abstract ScriptOptions Options(); /// /// Evaluates the result returned by the script. /// /// Path to the script that was executed /// The result object of the script that executed /// The local variables of the script that executed /// public abstract bool EvaluateResult(string path, object result, IDictionary variables); } }