mirror of
https://github.com/sebastian-heinz/Arrowgene.DragonsDogmaOnline
synced 2026-08-03 11:12:41 -04:00
refactor: Refactor code and show different scripting example
- Refactored code so implementation can be shared between Server and DdonGameServer. - Moved settings into settings module and implemented an example using a less structured scripting module interface. - Created new ScriptableSettings class to assist with interacting with non-structured settings module. - Created README.md files for suggestions and guidelines for module implementation.
This commit is contained in:
parent
62d1d74e0e
commit
e6e5073737
24 changed files with 1107 additions and 716 deletions
42
Arrowgene.Ddon.Server/Scripting/ScriptModule.cs
Normal file
42
Arrowgene.Ddon.Server/Scripting/ScriptModule.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
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 FileSystemWatcher Watcher { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public abstract bool EnableHotLoad { get; }
|
||||
|
||||
public HashSet<string> Scripts { get; set; }
|
||||
|
||||
public ScriptModule()
|
||||
{
|
||||
Scripts = new HashSet<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Options passed into the compilation unit.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract ScriptOptions Options();
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the result returned by the script.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to the script that was executed</param>
|
||||
/// <param name="result">The result object of the script that executed</param>
|
||||
/// <returns></returns>
|
||||
public abstract bool EvaluateResult(string path, ScriptState<object> result);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue