5 changed files with 85 additions and 12 deletions
@ -0,0 +1,21 @@ |
|||||||
|
MIT License |
||||||
|
|
||||||
|
Copyright (c) 2023 凉鞋 |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all |
||||||
|
copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||||
|
SOFTWARE. |
@ -1,26 +1,68 @@ |
|||||||
using Godot; |
using Godot; |
||||||
using static Godot.GD; |
using static Godot.GD; |
||||||
using System; |
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
namespace EGFramework{ |
namespace EGFramework{ |
||||||
public partial class EGThread : Node{ |
public partial class EGThread : Node,IModule,IEGFramework{ |
||||||
|
|
||||||
|
public Queue<Action> ActionQueue = new Queue<Action>(); |
||||||
|
public IOCContainer ActionPool = new IOCContainer(); |
||||||
|
|
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
public override void _Ready() |
public override void _Ready() |
||||||
{ |
{ |
||||||
base._Ready(); |
|
||||||
} |
} |
||||||
|
|
||||||
public override void _Process(double delta) |
public override void _Process(double delta) |
||||||
{ |
{ |
||||||
base._Process(delta); |
//base._Process(delta); |
||||||
|
if(ActionQueue.Count>0){ |
||||||
|
Action execute = ActionQueue.Dequeue(); |
||||||
|
execute.Invoke(); |
||||||
|
execute = null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void ExecuteInMainThread(Action action){ |
||||||
|
ActionQueue.Enqueue(action); |
||||||
|
} |
||||||
|
|
||||||
|
public void ExecuteInMainThread<T>(Action<T> action){ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public IArchitecture GetArchitecture() |
||||||
|
{ |
||||||
|
return EGArchitectureImplement.Interface; |
||||||
} |
} |
||||||
} |
} |
||||||
public static class EGThreadExtension |
public static class EGThreadExtension |
||||||
{ |
{ |
||||||
public static void ExecuteInMainThread(this Node self, Action action){ |
public static void ExecuteInMainThread(this Node self, Action action){ |
||||||
//action.Invoke(); |
//action.Invoke(); |
||||||
|
self.NodeModule<EGThread>().ExecuteInMainThread(action); |
||||||
|
} |
||||||
|
|
||||||
|
public static void ExecuteInMainThread<T>(this Node self, Action<T> action){ |
||||||
|
//action.Invoke(); |
||||||
} |
} |
||||||
|
|
||||||
public static void ExecuteAfterSecond(this Node self, Action action,float delay){ |
public static void ExecuteAfterSecond(this Node self, Action action,float delay){ |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
|
public static void ExecuteAfterSecond<T>(this Node self, Action<T> action,float delay){ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static void EGEnabledThread(this Node self){ |
||||||
|
self.NodeModule<EGThread>(); |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
Loading…
Reference in new issue