Skip to content

Commit 474d00d

Browse files
committed
[增加]1. 增加Actor类型获取失败的处理容错
1 parent 16759c8 commit 474d00d

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

GameFrameX.Core/Components/ComponentRegister.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,29 @@ internal static async Task ActiveComponents(IActor actor, Func<Type, bool> predi
182182
{
183183
var compTypes = GetComponents(actor.Type);
184184

185-
foreach (var compType in compTypes)
185+
if (compTypes != null)
186186
{
187-
if (predict == null || predict(compType))
187+
foreach (var compType in compTypes)
188188
{
189-
var agentType = HotfixManager.GetAgentType(compType);
190-
try
189+
if (predict == null || predict(compType))
191190
{
192-
await actor.GetComponentAgent(agentType);
193-
}
194-
catch (Exception e)
195-
{
196-
LogHelper.Info(e);
197-
// throw;
191+
var agentType = HotfixManager.GetAgentType(compType);
192+
try
193+
{
194+
await actor.GetComponentAgent(agentType);
195+
}
196+
catch (Exception e)
197+
{
198+
LogHelper.Info(e);
199+
// throw;
200+
}
198201
}
199202
}
200203
}
204+
else
205+
{
206+
LogHelper.Fatal($"获取不属于此actor:{actor.Type}的组件");
207+
}
201208
}
202209

203210
internal static BaseComponent NewComp(Actor actor, Type compType)

0 commit comments

Comments
 (0)