123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- //------------------------------------------------------------
- // Game Framework
- // Copyright © 2013-2021 Jiang Yin. All rights reserved.
- // Homepage: https://gameframework.cn/
- // Feedback: mailto:ellan@gameframework.cn
- //------------------------------------------------------------
- using GameFramework;
- using UnityEngine;
- using UnityGameFramework.Runtime;
- namespace MetaClient
- {
- public abstract class Entity : EntityLogic
- {
- [SerializeField]
- private EntityData m_EntityData = null;
- public int Id
- {
- get
- {
- return Entity.Id;
- }
- }
- public Animation CachedAnimation
- {
- get;
- private set;
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnInit(object userData)
- #else
- protected internal override void OnInit(object userData)
- #endif
- {
- base.OnInit(userData);
- CachedAnimation = GetComponent<Animation>();
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnRecycle()
- #else
- protected internal override void OnRecycle()
- #endif
- {
- base.OnRecycle();
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnShow(object userData)
- #else
- protected internal override void OnShow(object userData)
- #endif
- {
- base.OnShow(userData);
- m_EntityData = userData as EntityData;
- if (m_EntityData == null)
- {
- Log.Error("Entity data is invalid.");
- return;
- }
- Name = Utility.Text.Format("[Entity {0}]", Id);
- CachedTransform.localPosition = m_EntityData.Position;
- CachedTransform.localRotation = m_EntityData.Rotation;
- CachedTransform.localScale = Vector3.one;
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnHide(bool isShutdown, object userData)
- #else
- protected internal override void OnHide(bool isShutdown, object userData)
- #endif
- {
- base.OnHide(isShutdown, userData);
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnAttached(EntityLogic childEntity, Transform parentTransform, object userData)
- #else
- protected internal override void OnAttached(EntityLogic childEntity, Transform parentTransform, object userData)
- #endif
- {
- base.OnAttached(childEntity, parentTransform, userData);
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnDetached(EntityLogic childEntity, object userData)
- #else
- protected internal override void OnDetached(EntityLogic childEntity, object userData)
- #endif
- {
- base.OnDetached(childEntity, userData);
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnAttachTo(EntityLogic parentEntity, Transform parentTransform, object userData)
- #else
- protected internal override void OnAttachTo(EntityLogic parentEntity, Transform parentTransform, object userData)
- #endif
- {
- base.OnAttachTo(parentEntity, parentTransform, userData);
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnDetachFrom(EntityLogic parentEntity, object userData)
- #else
- protected internal override void OnDetachFrom(EntityLogic parentEntity, object userData)
- #endif
- {
- base.OnDetachFrom(parentEntity, userData);
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
- #else
- protected internal override void OnUpdate(float elapseSeconds, float realElapseSeconds)
- #endif
- {
- base.OnUpdate(elapseSeconds, realElapseSeconds);
- }
- }
- }
|