From 87e502ed211acdb39f268e4e1d88475b6be0c277 Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Mon, 19 Sep 2022 19:48:01 +0800 Subject: [PATCH] Update GameActorExt.cs --- .../Scripts/Runtime/Actor/GameActorExt.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Assets/TEngine/Scripts/Runtime/Actor/GameActorExt.cs b/Assets/TEngine/Scripts/Runtime/Actor/GameActorExt.cs index f196e89c..4541ed7b 100644 --- a/Assets/TEngine/Scripts/Runtime/Actor/GameActorExt.cs +++ b/Assets/TEngine/Scripts/Runtime/Actor/GameActorExt.cs @@ -17,25 +17,25 @@ namespace TEngine.Runtime.Actor #region component - public T AddComponent() where T : ActorComponent, new() + public T Attach() where T : ActorComponent, new() { if (IsDestroyed || _isDestroying) { - Log.Fatal("Actor is destroyed, cant add component: {0}, Is Destroying[{1}]", + Log.Fatal("Actor is destroyed, cant attach component: {0}, Is Destroying[{1}]", GetClassName(typeof(T)), _isDestroying); return null; } - T component = GetComponent(); + T component = Get(); if (component != null) { return component; } component = ActorComponentPool.Instance.AllocComponent(); - if (!AddComponentImp(component)) + if (!AttachImp(component)) { - Log.Warning("AddComponent failed, Component name: {0}", GetClassName(typeof(T))); + Log.Warning("Attach failed, Component name: {0}", GetClassName(typeof(T))); component.BeforeDestroy(); ActorComponentPool.Instance.FreeComponent(component); return null; @@ -44,7 +44,7 @@ namespace TEngine.Runtime.Actor return component; } - public T GetComponent() where T : ActorComponent + public T Get() where T : ActorComponent { ActorComponent component; if (_mapComponents.TryGetValue(GetClassName(typeof(T)), out component)) @@ -55,7 +55,7 @@ namespace TEngine.Runtime.Actor return null; } - public void RemoveComponent() where T : ActorComponent + public void Detach() where T : ActorComponent { if (_isDestroying) { @@ -77,9 +77,9 @@ namespace TEngine.Runtime.Actor } } - private bool AddComponentImp(T component) where T : ActorComponent + private bool AttachImp(T component) where T : ActorComponent { - if (!component.BeforeAddToActor(this)) + if (!component.BeforeAttachToActor(this)) { return false; }