Update GameActor.cs

This commit is contained in:
ALEXTANG
2022-09-19 19:59:04 +08:00
parent 87e502ed21
commit 752cf4bad6

View File

@@ -10,18 +10,19 @@ namespace TEngine.Runtime.Actor
public abstract partial class GameActor public abstract partial class GameActor
{ {
#region Propreties #region Propreties
public uint ActorId { get; set; } public uint ActorId { get; set; }
public bool IsCreated { get; set; } public bool IsCreated { get; set; }
public byte ActorSide; public byte ActorSide;
public abstract int GetActorType(); public abstract int GetActorType();
public bool IsDestroyed { get; set; } public bool IsDestroyed { get; set; }
public string Name = string.Empty; public string Name = string.Empty;
private ActorEventDispatcher _event = new ActorEventDispatcher(); private ActorEventDispatcher _event = new ActorEventDispatcher();
public ActorEventDispatcher Event => _event; public ActorEventDispatcher Event => _event;
@@ -29,11 +30,11 @@ namespace TEngine.Runtime.Actor
private GameObject _gameObject; private GameObject _gameObject;
public GameObject gameObject => _gameObject; public GameObject gameObject => _gameObject;
private float _visibleTime = 0; private float _visibleTime = 0;
private bool _visible; private bool _visible;
public bool Visible public bool Visible
{ {
get { return _visible; } get { return _visible; }
@@ -51,16 +52,17 @@ namespace TEngine.Runtime.Actor
{ {
_visibleTime = Time.time; _visibleTime = Time.time;
} }
Event.SendEvent(ActorEventType.ModelVisibleChange, _visible); Event.SendEvent(ActorEventType.ModelVisibleChange, _visible);
} }
} }
} }
public virtual bool CheckActorCanVisible() public virtual bool CheckActorCanVisible()
{ {
return true; return true;
} }
public string GetGameObjectName() public string GetGameObjectName()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
@@ -69,14 +71,16 @@ namespace TEngine.Runtime.Actor
return "GameActor"; return "GameActor";
#endif #endif
} }
public virtual string GetActorName() public virtual string GetActorName()
{ {
return "UNNAMED"; return "UNNAMED";
} }
#endregion #endregion
#region Transform #region Transform
public Transform transform public Transform transform
{ {
get get
@@ -85,7 +89,7 @@ namespace TEngine.Runtime.Actor
{ {
throw new Exception("Runtime GameActor gameObject is Null"); throw new Exception("Runtime GameActor gameObject is Null");
} }
return gameObject.transform; return gameObject.transform;
} }
} }
@@ -133,7 +137,7 @@ namespace TEngine.Runtime.Actor
transform.forward = value; transform.forward = value;
} }
} }
public Vector3 LocalScale public Vector3 LocalScale
{ {
get get
@@ -155,7 +159,7 @@ namespace TEngine.Runtime.Actor
transform.localScale = value; transform.localScale = value;
} }
} }
public Quaternion Rotation public Quaternion Rotation
{ {
get get
@@ -175,9 +179,11 @@ namespace TEngine.Runtime.Actor
} }
} }
} }
#endregion #endregion
#region Init #region Init
internal void Init() internal void Init()
{ {
Awake(); Awake();
@@ -188,19 +194,16 @@ namespace TEngine.Runtime.Actor
public virtual void Awake() public virtual void Awake()
{ {
} }
public virtual void OnInit() public virtual void OnInit()
{ {
} }
public virtual void AfterInit() public virtual void AfterInit()
{ {
} }
protected virtual GameObject CreateGameObject() protected virtual GameObject CreateGameObject()
{ {
return ActorManager.Instance.CreateGameObject(this); return ActorManager.Instance.CreateGameObject(this);
@@ -213,12 +216,12 @@ namespace TEngine.Runtime.Actor
_visible = false; _visible = false;
_gameObject = CreateGameObject(); _gameObject = CreateGameObject();
ActorManager.Instance.BindGameActorGo(this,_gameObject); ActorManager.Instance.BindGameActorGo(this, _gameObject);
} }
InitExt(); InitExt();
} }
#endregion #endregion
@@ -237,18 +240,20 @@ namespace TEngine.Runtime.Actor
if (gameObject != null) if (gameObject != null)
{ {
Object.Destroy(_gameObject); Object.Destroy(_gameObject);
_gameObject = null; _gameObject = null;
} }
IsDestroyed = true; IsDestroyed = true;
_isDestroying = false; _isDestroying = false;
} }
#endregion #endregion
#region Expand #region Expand
#region Base #region Base
public static bool operator ==(GameActor obj1, GameActor obj2) public static bool operator ==(GameActor obj1, GameActor obj2)
{ {
if (ReferenceEquals(obj1, obj2)) if (ReferenceEquals(obj1, obj2))
@@ -282,6 +287,7 @@ namespace TEngine.Runtime.Actor
{ {
return base.GetHashCode(); return base.GetHashCode();
} }
#endregion #endregion
#endregion #endregion