ScriptSystem Class
Namespace: Stride.Engine.ProcessorsAssembly: Stride.Engine.dll
The script system handles scripts scheduling in a game.
public sealed class ScriptSystem : GameSystemBase, IDisposable, ICollectorHolder, IGameSystemBase, IComponent, IReferencable, IUpdateable, IDrawable, IContentable
              | Name | Description | |
|---|---|---|
| Constructors | ||
| ScriptSystem(IServiceRegistry) | Initializes a new instance of the GameSystemBase class.  | 
                          |
| Properties | ||
| Scheduler | Gets the scheduler.  | 
                          |
| Methods | ||
| Add(ScriptComponent) | Add the provided script to the script system.  | 
                          |
| AddTask(Func<Task>, Int64) | Adds the specified micro thread function.  | 
                          |
| Destroy() | ||
| LiveReload(ScriptComponent, ScriptComponent) | Called by a live scripting debugger to notify the ScriptSystem about reloaded scripts.  | 
                          |
| NextFrame() | Allows to wait for next frame.  | 
                          |
| Remove(ScriptComponent) | Remove the provided script from the script system.  | 
                          |
| Update(GameTime) | ||
| WhenAll(MicroThread[]) | Waits all micro thread finished their task completion.  | 
                          |
Constructors
ScriptSystem(IServiceRegistry)
Initializes a new instance of the GameSystemBase class.
public ScriptSystem(IServiceRegistry registry)
              Parameters
| Type | Name | Description | 
|---|---|---|
| IServiceRegistry | registry | The registry.  | 
                  
Remarks
The GameSystem is expecting the following services to be registered: IGame and ContentManager.
Properties
Scheduler
Gets the scheduler.
public Scheduler Scheduler { get; }
              Property Value
| Type | Description | 
|---|---|
| Scheduler | The scheduler.  | 
                  
Methods
Add(ScriptComponent)
Add the provided script to the script system.
public void Add(ScriptComponent script)
              Parameters
| Type | Name | Description | 
|---|---|---|
| ScriptComponent | script | The script to add  | 
                  
AddTask(Func<Task>, Int64)
Adds the specified micro thread function.
public MicroThread AddTask(Func<Task> microThreadFunction, long priority = 0L)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Func<System.Threading.Tasks.Task> | microThreadFunction | The micro thread function.  | 
                  
| System.Int64 | priority | 
Returns
| Type | Description | 
|---|---|
| MicroThread | MicroThread.  | 
                  
Destroy()
protected override void Destroy()
              Overrides
LiveReload(ScriptComponent, ScriptComponent)
Called by a live scripting debugger to notify the ScriptSystem about reloaded scripts.
public void LiveReload(ScriptComponent oldScript, ScriptComponent newScript)
              Parameters
| Type | Name | Description | 
|---|---|---|
| ScriptComponent | oldScript | The old script  | 
                  
| ScriptComponent | newScript | The new script  | 
                  
NextFrame()
Allows to wait for next frame.
public ChannelMicroThreadAwaiter<int> NextFrame()
              Returns
| Type | Description | 
|---|---|
| ChannelMicroThreadAwaiter<System.Int32> | ChannelMicroThreadAwaiter<System.Int32>.  | 
                  
Remove(ScriptComponent)
Remove the provided script from the script system.
public void Remove(ScriptComponent script)
              Parameters
| Type | Name | Description | 
|---|---|---|
| ScriptComponent | script | The script to remove  | 
                  
Update(GameTime)
public override void Update(GameTime gameTime)
              Parameters
| Type | Name | Description | 
|---|---|---|
| GameTime | gameTime | 
Overrides
WhenAll(MicroThread[])
Waits all micro thread finished their task completion.
public async Task WhenAll(params MicroThread[] microThreads)
              Parameters
| Type | Name | Description | 
|---|---|---|
| MicroThread[] | microThreads | The micro threads.  | 
                  
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | Task.  |