Skip to content

Commit 2a792a4

Browse files
committed
[修复]1. 修复Actor 激活的时候没有等待的问题
1 parent 0068aeb commit 2a792a4

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

GameFrameX.Core/Abstractions/Agent/IComponentAgent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public interface IComponentAgent : IWorker
4444
/// 用于初始化并启用组件代理的功能
4545
/// </remarks>
4646
/// </summary>
47-
void Active();
47+
Task Active();
4848

4949
/// <summary>
5050
/// 反激活组件代理

GameFrameX.Core/Actors/Actor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public async Task<IComponentAgent> GetComponentAgent(Type agentType, bool isNew
117117
async Task Worker()
118118
{
119119
await comp.Active();
120-
agent.Active();
120+
await agent.Active();
121121
}
122122

123123
await SendAsyncWithoutCheck(Worker);
@@ -137,7 +137,7 @@ async Task Worker()
137137
async Task Worker()
138138
{
139139
await component.Active();
140-
agent.Active();
140+
await agent.Active();
141141
}
142142

143143
await SendAsyncWithoutCheck(Worker);

GameFrameX.Core/Hotfix/Agent/BaseComponentAgent.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public void SetOwner(IComponent owner)
7070
/// <summary>
7171
/// 激活组件
7272
/// </summary>
73-
public virtual void Active()
73+
public virtual Task Active()
7474
{
75+
return Task.CompletedTask;
7576
}
7677

7778
/// <summary>

GameFrameX.Hotfix/Logic/Server/ServerComponentAgent.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
using GameFrameX.Core.Timer.Handler;
66
using GameFrameX.Hotfix.Logic.Role.Login;
77

8-
namespace GameFrameX.Hotfix.Logic.Server.Server;
8+
namespace GameFrameX.Hotfix.Logic.Server;
99

1010
public class ServerComponentAgent : StateComponentAgent<ServerComponent, ServerState>
1111
{
12-
public override void Active()
12+
public override async Task Active()
1313
{
1414
// 跨天定时器
1515
WithCronExpression<CrossDayTimeHandler>("0 0 0 * * ? *");
1616
if (State.FirstStartTime == default)
1717
{
1818
State.FirstStartTime = TimeHelper.UnixTimeSeconds();
19-
OwnerComponent.WriteStateAsync();
19+
await OwnerComponent.WriteStateAsync();
2020
}
2121
}
2222

0 commit comments

Comments
 (0)