init
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
internal sealed class AttachEntityInfo : IReference
|
||||
{
|
||||
private Transform m_ParentTransform;
|
||||
private object m_UserData;
|
||||
|
||||
public AttachEntityInfo()
|
||||
{
|
||||
m_ParentTransform = null;
|
||||
m_UserData = null;
|
||||
}
|
||||
|
||||
public Transform ParentTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ParentTransform;
|
||||
}
|
||||
}
|
||||
|
||||
public object UserData
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UserData;
|
||||
}
|
||||
}
|
||||
|
||||
public static AttachEntityInfo Create(Transform parentTransform, object userData)
|
||||
{
|
||||
AttachEntityInfo attachEntityInfo = ReferencePool.Acquire<AttachEntityInfo>();
|
||||
attachEntityInfo.m_ParentTransform = parentTransform;
|
||||
attachEntityInfo.m_UserData = userData;
|
||||
return attachEntityInfo;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
m_ParentTransform = null;
|
||||
m_UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93ee8133074b5234da08e1308a55efb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认实体组辅助器。
|
||||
/// </summary>
|
||||
public class DefaultEntityGroupHelper : EntityGroupHelperBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2eae0b22de94ba442b482bff7fab17ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.Entity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认实体辅助器。
|
||||
/// </summary>
|
||||
public class DefaultEntityHelper : EntityHelperBase
|
||||
{
|
||||
private ResourceComponent m_ResourceComponent = null;
|
||||
|
||||
/// <summary>
|
||||
/// 实例化实体。
|
||||
/// </summary>
|
||||
/// <param name="entityAsset">要实例化的实体资源。</param>
|
||||
/// <returns>实例化后的实体。</returns>
|
||||
public override object InstantiateEntity(object entityAsset)
|
||||
{
|
||||
return Instantiate((Object)entityAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建实体。
|
||||
/// </summary>
|
||||
/// <param name="entityInstance">实体实例。</param>
|
||||
/// <param name="entityGroup">实体所属的实体组。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>实体。</returns>
|
||||
public override IEntity CreateEntity(object entityInstance, IEntityGroup entityGroup, object userData)
|
||||
{
|
||||
GameObject gameObject = entityInstance as GameObject;
|
||||
if (gameObject == null)
|
||||
{
|
||||
Log.Error("Entity instance is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
Transform transform = gameObject.transform;
|
||||
transform.SetParent(((MonoBehaviour)entityGroup.Helper).transform);
|
||||
|
||||
return gameObject.GetOrAddComponent<Entity>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放实体。
|
||||
/// </summary>
|
||||
/// <param name="entityAsset">要释放的实体资源。</param>
|
||||
/// <param name="entityInstance">要释放的实体实例。</param>
|
||||
public override void ReleaseEntity(object entityAsset, object entityInstance)
|
||||
{
|
||||
m_ResourceComponent.UnloadAsset(entityAsset);
|
||||
Destroy((Object)entityInstance);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_ResourceComponent = GameEntry.GetComponent<ResourceComponent>();
|
||||
if (m_ResourceComponent == null)
|
||||
{
|
||||
Log.Fatal("Resource component is invalid.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b0ffb61c68e948498fa57c1901f0001
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,280 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Entity;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 实体。
|
||||
/// </summary>
|
||||
public sealed class Entity : MonoBehaviour, IEntity
|
||||
{
|
||||
private int m_Id;
|
||||
private string m_EntityAssetName;
|
||||
private IEntityGroup m_EntityGroup;
|
||||
private EntityLogic m_EntityLogic;
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体编号。
|
||||
/// </summary>
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体资源名称。
|
||||
/// </summary>
|
||||
public string EntityAssetName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_EntityAssetName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体实例。
|
||||
/// </summary>
|
||||
public object Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
return gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体所属的实体组。
|
||||
/// </summary>
|
||||
public IEntityGroup EntityGroup
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_EntityGroup;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体逻辑。
|
||||
/// </summary>
|
||||
public EntityLogic Logic
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_EntityLogic;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体初始化。
|
||||
/// </summary>
|
||||
/// <param name="entityId">实体编号。</param>
|
||||
/// <param name="entityAssetName">实体资源名称。</param>
|
||||
/// <param name="entityGroup">实体所属的实体组。</param>
|
||||
/// <param name="isNewInstance">是否是新实例。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnInit(int entityId, string entityAssetName, IEntityGroup entityGroup, bool isNewInstance, object userData)
|
||||
{
|
||||
m_Id = entityId;
|
||||
m_EntityAssetName = entityAssetName;
|
||||
if (isNewInstance)
|
||||
{
|
||||
m_EntityGroup = entityGroup;
|
||||
}
|
||||
else if (m_EntityGroup != entityGroup)
|
||||
{
|
||||
Log.Error("Entity group is inconsistent for non-new-instance entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
ShowEntityInfo showEntityInfo = (ShowEntityInfo)userData;
|
||||
Type entityLogicType = showEntityInfo.EntityLogicType;
|
||||
if (entityLogicType == null)
|
||||
{
|
||||
Log.Error("Entity logic type is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_EntityLogic != null)
|
||||
{
|
||||
if (m_EntityLogic.GetType() == entityLogicType)
|
||||
{
|
||||
m_EntityLogic.enabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Destroy(m_EntityLogic);
|
||||
m_EntityLogic = null;
|
||||
}
|
||||
|
||||
m_EntityLogic = gameObject.AddComponent(entityLogicType) as EntityLogic;
|
||||
if (m_EntityLogic == null)
|
||||
{
|
||||
Log.Error("Entity '{0}' can not add entity logic.", entityAssetName);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_EntityLogic.OnInit(showEntityInfo.UserData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("Entity '[{0}]{1}' OnInit with exception '{2}'.", m_Id, m_EntityAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体回收。
|
||||
/// </summary>
|
||||
public void OnRecycle()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_EntityLogic.OnRecycle();
|
||||
m_EntityLogic.enabled = false;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("Entity '[{0}]{1}' OnRecycle with exception '{2}'.", m_Id, m_EntityAssetName, exception);
|
||||
}
|
||||
|
||||
m_Id = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体显示。
|
||||
/// </summary>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnShow(object userData)
|
||||
{
|
||||
ShowEntityInfo showEntityInfo = (ShowEntityInfo)userData;
|
||||
try
|
||||
{
|
||||
m_EntityLogic.OnShow(showEntityInfo.UserData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("Entity '[{0}]{1}' OnShow with exception '{2}'.", m_Id, m_EntityAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体隐藏。
|
||||
/// </summary>
|
||||
/// <param name="isShutdown">是否是关闭实体管理器时触发。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnHide(bool isShutdown, object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_EntityLogic.OnHide(isShutdown, userData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("Entity '[{0}]{1}' OnHide with exception '{2}'.", m_Id, m_EntityAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体附加子实体。
|
||||
/// </summary>
|
||||
/// <param name="childEntity">附加的子实体。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnAttached(IEntity childEntity, object userData)
|
||||
{
|
||||
AttachEntityInfo attachEntityInfo = (AttachEntityInfo)userData;
|
||||
try
|
||||
{
|
||||
m_EntityLogic.OnAttached(((Entity)childEntity).Logic, attachEntityInfo.ParentTransform, attachEntityInfo.UserData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("Entity '[{0}]{1}' OnAttached with exception '{2}'.", m_Id, m_EntityAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体解除子实体。
|
||||
/// </summary>
|
||||
/// <param name="childEntity">解除的子实体。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnDetached(IEntity childEntity, object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_EntityLogic.OnDetached(((Entity)childEntity).Logic, userData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("Entity '[{0}]{1}' OnDetached with exception '{2}'.", m_Id, m_EntityAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体附加子实体。
|
||||
/// </summary>
|
||||
/// <param name="parentEntity">被附加的父实体。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnAttachTo(IEntity parentEntity, object userData)
|
||||
{
|
||||
AttachEntityInfo attachEntityInfo = (AttachEntityInfo)userData;
|
||||
try
|
||||
{
|
||||
m_EntityLogic.OnAttachTo(((Entity)parentEntity).Logic, attachEntityInfo.ParentTransform, attachEntityInfo.UserData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("Entity '[{0}]{1}' OnAttachTo with exception '{2}'.", m_Id, m_EntityAssetName, exception);
|
||||
}
|
||||
|
||||
ReferencePool.Release(attachEntityInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体解除子实体。
|
||||
/// </summary>
|
||||
/// <param name="parentEntity">被解除的父实体。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnDetachFrom(IEntity parentEntity, object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_EntityLogic.OnDetachFrom(((Entity)parentEntity).Logic, userData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("Entity '[{0}]{1}' OnDetachFrom with exception '{2}'.", m_Id, m_EntityAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体轮询。
|
||||
/// </summary>
|
||||
/// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
|
||||
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
||||
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_EntityLogic.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("Entity '[{0}]{1}' OnUpdate with exception '{2}'.", m_Id, m_EntityAssetName, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bac1e67b934ef0944b6de46554cf5042
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class EntityComponent : GameFrameworkComponent
|
||||
{
|
||||
[Serializable]
|
||||
private sealed class EntityGroup
|
||||
{
|
||||
[SerializeField]
|
||||
private string m_Name = null;
|
||||
|
||||
[SerializeField]
|
||||
private float m_InstanceAutoReleaseInterval = 60f;
|
||||
|
||||
[SerializeField]
|
||||
private int m_InstanceCapacity = 16;
|
||||
|
||||
[SerializeField]
|
||||
private float m_InstanceExpireTime = 60f;
|
||||
|
||||
[SerializeField]
|
||||
private int m_InstancePriority = 0;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
}
|
||||
|
||||
public float InstanceAutoReleaseInterval
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_InstanceAutoReleaseInterval;
|
||||
}
|
||||
}
|
||||
|
||||
public int InstanceCapacity
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_InstanceCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
public float InstanceExpireTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_InstanceExpireTime;
|
||||
}
|
||||
}
|
||||
|
||||
public int InstancePriority
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_InstancePriority;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d93d1ae840acb2f449ac5f5cad2d0259
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58aa63e99dabf9c4fb61a9ec4ac4d8ca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.Entity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 实体组辅助器基类。
|
||||
/// </summary>
|
||||
public abstract class EntityGroupHelperBase : MonoBehaviour, IEntityGroupHelper
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb8122bd1a1ff7d4cb0a9806d5b3f065
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.Entity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 实体辅助器基类。
|
||||
/// </summary>
|
||||
public abstract class EntityHelperBase : MonoBehaviour, IEntityHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化实体。
|
||||
/// </summary>
|
||||
/// <param name="entityAsset">要实例化的实体资源。</param>
|
||||
/// <returns>实例化后的实体。</returns>
|
||||
public abstract object InstantiateEntity(object entityAsset);
|
||||
|
||||
/// <summary>
|
||||
/// 创建实体。
|
||||
/// </summary>
|
||||
/// <param name="entityInstance">实体实例。</param>
|
||||
/// <param name="entityGroup">实体所属的实体组。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>实体。</returns>
|
||||
public abstract IEntity CreateEntity(object entityInstance, IEntityGroup entityGroup, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 释放实体。
|
||||
/// </summary>
|
||||
/// <param name="entityAsset">要释放的实体资源。</param>
|
||||
/// <param name="entityInstance">要释放的实体实例。</param>
|
||||
public abstract void ReleaseEntity(object entityAsset, object entityInstance);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8992f89de70519047ba31e6383445cca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,202 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 实体逻辑基类。
|
||||
/// </summary>
|
||||
public abstract class EntityLogic : MonoBehaviour
|
||||
{
|
||||
private bool m_Available = false;
|
||||
private bool m_Visible = false;
|
||||
private Entity m_Entity = null;
|
||||
private Transform m_CachedTransform = null;
|
||||
private int m_OriginalLayer = 0;
|
||||
private Transform m_OriginalTransform = null;
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体。
|
||||
/// </summary>
|
||||
public Entity Entity
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Entity;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置实体名称。
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return gameObject.name;
|
||||
}
|
||||
set
|
||||
{
|
||||
gameObject.name = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体是否可用。
|
||||
/// </summary>
|
||||
public bool Available
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Available;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置实体是否可见。
|
||||
/// </summary>
|
||||
public bool Visible
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Available && m_Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!m_Available)
|
||||
{
|
||||
Log.Warning("Entity '{0}' is not available.", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Visible == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Visible = value;
|
||||
InternalSetVisible(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取已缓存的 Transform。
|
||||
/// </summary>
|
||||
public Transform CachedTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CachedTransform;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体初始化。
|
||||
/// </summary>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnInit(object userData)
|
||||
{
|
||||
if (m_CachedTransform == null)
|
||||
{
|
||||
m_CachedTransform = transform;
|
||||
}
|
||||
|
||||
m_Entity = GetComponent<Entity>();
|
||||
m_OriginalLayer = gameObject.layer;
|
||||
m_OriginalTransform = CachedTransform.parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体回收。
|
||||
/// </summary>
|
||||
protected internal virtual void OnRecycle()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体显示。
|
||||
/// </summary>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnShow(object userData)
|
||||
{
|
||||
m_Available = true;
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体隐藏。
|
||||
/// </summary>
|
||||
/// <param name="isShutdown">是否是关闭实体管理器时触发。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnHide(bool isShutdown, object userData)
|
||||
{
|
||||
gameObject.SetLayerRecursively(m_OriginalLayer);
|
||||
Visible = false;
|
||||
m_Available = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体附加子实体。
|
||||
/// </summary>
|
||||
/// <param name="childEntity">附加的子实体。</param>
|
||||
/// <param name="parentTransform">被附加父实体的位置。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnAttached(EntityLogic childEntity, Transform parentTransform, object userData)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体解除子实体。
|
||||
/// </summary>
|
||||
/// <param name="childEntity">解除的子实体。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnDetached(EntityLogic childEntity, object userData)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体附加子实体。
|
||||
/// </summary>
|
||||
/// <param name="parentEntity">被附加的父实体。</param>
|
||||
/// <param name="parentTransform">被附加父实体的位置。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnAttachTo(EntityLogic parentEntity, Transform parentTransform, object userData)
|
||||
{
|
||||
CachedTransform.SetParent(parentTransform);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体解除子实体。
|
||||
/// </summary>
|
||||
/// <param name="parentEntity">被解除的父实体。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnDetachFrom(EntityLogic parentEntity, object userData)
|
||||
{
|
||||
CachedTransform.SetParent(m_OriginalTransform);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体轮询。
|
||||
/// </summary>
|
||||
/// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
|
||||
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
||||
protected internal virtual void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置实体的可见性。
|
||||
/// </summary>
|
||||
/// <param name="visible">实体的可见性。</param>
|
||||
protected virtual void InternalSetVisible(bool visible)
|
||||
{
|
||||
gameObject.SetActive(visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 699dd149c0a53234e8f76e6d6c1b5545
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,108 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Entity;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 隐藏实体完成事件。
|
||||
/// </summary>
|
||||
public sealed class HideEntityCompleteEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 隐藏实体完成事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(HideEntityCompleteEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化隐藏实体完成事件的新实例。
|
||||
/// </summary>
|
||||
public HideEntityCompleteEventArgs()
|
||||
{
|
||||
EntityId = 0;
|
||||
EntityAssetName = null;
|
||||
EntityGroup = null;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取隐藏实体完成事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体编号。
|
||||
/// </summary>
|
||||
public int EntityId
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体资源名称。
|
||||
/// </summary>
|
||||
public string EntityAssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体所属的实体组。
|
||||
/// </summary>
|
||||
public IEntityGroup EntityGroup
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户自定义数据。
|
||||
/// </summary>
|
||||
public object UserData
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建隐藏实体完成事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的隐藏实体完成事件。</returns>
|
||||
public static HideEntityCompleteEventArgs Create(GameFramework.Entity.HideEntityCompleteEventArgs e)
|
||||
{
|
||||
HideEntityCompleteEventArgs hideEntityCompleteEventArgs = ReferencePool.Acquire<HideEntityCompleteEventArgs>();
|
||||
hideEntityCompleteEventArgs.EntityId = e.EntityId;
|
||||
hideEntityCompleteEventArgs.EntityAssetName = e.EntityAssetName;
|
||||
hideEntityCompleteEventArgs.EntityGroup = e.EntityGroup;
|
||||
hideEntityCompleteEventArgs.UserData = e.UserData;
|
||||
return hideEntityCompleteEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理隐藏实体完成事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
EntityId = 0;
|
||||
EntityAssetName = null;
|
||||
EntityGroup = null;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 852f69476ad9a2e4cb44c564a250aff2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,157 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using System;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示实体时加载依赖资源事件。
|
||||
/// </summary>
|
||||
public sealed class ShowEntityDependencyAssetEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示实体时加载依赖资源事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ShowEntityDependencyAssetEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化显示实体时加载依赖资源事件的新实例。
|
||||
/// </summary>
|
||||
public ShowEntityDependencyAssetEventArgs()
|
||||
{
|
||||
EntityId = 0;
|
||||
EntityLogicType = null;
|
||||
EntityAssetName = null;
|
||||
EntityGroupName = null;
|
||||
DependencyAssetName = null;
|
||||
LoadedCount = 0;
|
||||
TotalCount = 0;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取显示实体时加载依赖资源事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体编号。
|
||||
/// </summary>
|
||||
public int EntityId
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体逻辑类型。
|
||||
/// </summary>
|
||||
public Type EntityLogicType
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体资源名称。
|
||||
/// </summary>
|
||||
public string EntityAssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体组名称。
|
||||
/// </summary>
|
||||
public string EntityGroupName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取被加载的依赖资源名称。
|
||||
/// </summary>
|
||||
public string DependencyAssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前已加载依赖资源数量。
|
||||
/// </summary>
|
||||
public int LoadedCount
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取总共加载依赖资源数量。
|
||||
/// </summary>
|
||||
public int TotalCount
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户自定义数据。
|
||||
/// </summary>
|
||||
public object UserData
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建显示实体时加载依赖资源事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的显示实体时加载依赖资源事件。</returns>
|
||||
public static ShowEntityDependencyAssetEventArgs Create(GameFramework.Entity.ShowEntityDependencyAssetEventArgs e)
|
||||
{
|
||||
ShowEntityInfo showEntityInfo = (ShowEntityInfo)e.UserData;
|
||||
ShowEntityDependencyAssetEventArgs showEntityDependencyAssetEventArgs = ReferencePool.Acquire<ShowEntityDependencyAssetEventArgs>();
|
||||
showEntityDependencyAssetEventArgs.EntityId = e.EntityId;
|
||||
showEntityDependencyAssetEventArgs.EntityLogicType = showEntityInfo.EntityLogicType;
|
||||
showEntityDependencyAssetEventArgs.EntityAssetName = e.EntityAssetName;
|
||||
showEntityDependencyAssetEventArgs.EntityGroupName = e.EntityGroupName;
|
||||
showEntityDependencyAssetEventArgs.DependencyAssetName = e.DependencyAssetName;
|
||||
showEntityDependencyAssetEventArgs.LoadedCount = e.LoadedCount;
|
||||
showEntityDependencyAssetEventArgs.TotalCount = e.TotalCount;
|
||||
showEntityDependencyAssetEventArgs.UserData = showEntityInfo.UserData;
|
||||
return showEntityDependencyAssetEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理显示实体时加载依赖资源事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
EntityId = 0;
|
||||
EntityLogicType = null;
|
||||
EntityAssetName = null;
|
||||
EntityGroupName = null;
|
||||
DependencyAssetName = null;
|
||||
LoadedCount = 0;
|
||||
TotalCount = 0;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cef77d19116ea6f4aaa8b77116df65c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,134 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using System;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示实体失败事件。
|
||||
/// </summary>
|
||||
public sealed class ShowEntityFailureEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示实体失败事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ShowEntityFailureEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化显示实体失败事件的新实例。
|
||||
/// </summary>
|
||||
public ShowEntityFailureEventArgs()
|
||||
{
|
||||
EntityId = 0;
|
||||
EntityLogicType = null;
|
||||
EntityAssetName = null;
|
||||
EntityGroupName = null;
|
||||
ErrorMessage = null;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取显示实体失败事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体编号。
|
||||
/// </summary>
|
||||
public int EntityId
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体逻辑类型。
|
||||
/// </summary>
|
||||
public Type EntityLogicType
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体资源名称。
|
||||
/// </summary>
|
||||
public string EntityAssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体组名称。
|
||||
/// </summary>
|
||||
public string EntityGroupName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取错误信息。
|
||||
/// </summary>
|
||||
public string ErrorMessage
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户自定义数据。
|
||||
/// </summary>
|
||||
public object UserData
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建显示实体失败事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的显示实体失败事件。</returns>
|
||||
public static ShowEntityFailureEventArgs Create(GameFramework.Entity.ShowEntityFailureEventArgs e)
|
||||
{
|
||||
ShowEntityInfo showEntityInfo = (ShowEntityInfo)e.UserData;
|
||||
ShowEntityFailureEventArgs showEntityFailureEventArgs = ReferencePool.Acquire<ShowEntityFailureEventArgs>();
|
||||
showEntityFailureEventArgs.EntityId = e.EntityId;
|
||||
showEntityFailureEventArgs.EntityLogicType = showEntityInfo.EntityLogicType;
|
||||
showEntityFailureEventArgs.EntityAssetName = e.EntityAssetName;
|
||||
showEntityFailureEventArgs.EntityGroupName = e.EntityGroupName;
|
||||
showEntityFailureEventArgs.ErrorMessage = e.ErrorMessage;
|
||||
showEntityFailureEventArgs.UserData = showEntityInfo.UserData;
|
||||
ReferencePool.Release(showEntityInfo);
|
||||
return showEntityFailureEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理显示实体失败事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
EntityId = 0;
|
||||
EntityLogicType = null;
|
||||
EntityAssetName = null;
|
||||
EntityGroupName = null;
|
||||
ErrorMessage = null;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7188888f5121ad44bfaba20e4ed7ca9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
internal sealed class ShowEntityInfo : IReference
|
||||
{
|
||||
private Type m_EntityLogicType;
|
||||
private object m_UserData;
|
||||
|
||||
public ShowEntityInfo()
|
||||
{
|
||||
m_EntityLogicType = null;
|
||||
m_UserData = null;
|
||||
}
|
||||
|
||||
public Type EntityLogicType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_EntityLogicType;
|
||||
}
|
||||
}
|
||||
|
||||
public object UserData
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UserData;
|
||||
}
|
||||
}
|
||||
|
||||
public static ShowEntityInfo Create(Type entityLogicType, object userData)
|
||||
{
|
||||
ShowEntityInfo showEntityInfo = ReferencePool.Acquire<ShowEntityInfo>();
|
||||
showEntityInfo.m_EntityLogicType = entityLogicType;
|
||||
showEntityInfo.m_UserData = userData;
|
||||
return showEntityInfo;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
m_EntityLogicType = null;
|
||||
m_UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5535dde509ba87b42912084f30591779
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,110 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using System;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示实体成功事件。
|
||||
/// </summary>
|
||||
public sealed class ShowEntitySuccessEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示实体成功事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ShowEntitySuccessEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化显示实体成功事件的新实例。
|
||||
/// </summary>
|
||||
public ShowEntitySuccessEventArgs()
|
||||
{
|
||||
EntityLogicType = null;
|
||||
Entity = null;
|
||||
Duration = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取显示实体成功事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体逻辑类型。
|
||||
/// </summary>
|
||||
public Type EntityLogicType
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取显示成功的实体。
|
||||
/// </summary>
|
||||
public Entity Entity
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载持续时间。
|
||||
/// </summary>
|
||||
public float Duration
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户自定义数据。
|
||||
/// </summary>
|
||||
public object UserData
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建显示实体成功事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的显示实体成功事件。</returns>
|
||||
public static ShowEntitySuccessEventArgs Create(GameFramework.Entity.ShowEntitySuccessEventArgs e)
|
||||
{
|
||||
ShowEntityInfo showEntityInfo = (ShowEntityInfo)e.UserData;
|
||||
ShowEntitySuccessEventArgs showEntitySuccessEventArgs = ReferencePool.Acquire<ShowEntitySuccessEventArgs>();
|
||||
showEntitySuccessEventArgs.EntityLogicType = showEntityInfo.EntityLogicType;
|
||||
showEntitySuccessEventArgs.Entity = (Entity)e.Entity;
|
||||
showEntitySuccessEventArgs.Duration = e.Duration;
|
||||
showEntitySuccessEventArgs.UserData = showEntityInfo.UserData;
|
||||
ReferencePool.Release(showEntityInfo);
|
||||
return showEntitySuccessEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理显示实体成功事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
EntityLogicType = null;
|
||||
Entity = null;
|
||||
Duration = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9786630f2f7760f4da147cd8173e9b18
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,133 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using System;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示实体更新事件。
|
||||
/// </summary>
|
||||
public sealed class ShowEntityUpdateEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示实体更新事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ShowEntityUpdateEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化显示实体更新事件的新实例。
|
||||
/// </summary>
|
||||
public ShowEntityUpdateEventArgs()
|
||||
{
|
||||
EntityId = 0;
|
||||
EntityLogicType = null;
|
||||
EntityAssetName = null;
|
||||
EntityGroupName = null;
|
||||
Progress = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取显示实体更新事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体编号。
|
||||
/// </summary>
|
||||
public int EntityId
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体逻辑类型。
|
||||
/// </summary>
|
||||
public Type EntityLogicType
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体资源名称。
|
||||
/// </summary>
|
||||
public string EntityAssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体组名称。
|
||||
/// </summary>
|
||||
public string EntityGroupName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取显示实体进度。
|
||||
/// </summary>
|
||||
public float Progress
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户自定义数据。
|
||||
/// </summary>
|
||||
public object UserData
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建显示实体更新事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的显示实体更新事件。</returns>
|
||||
public static ShowEntityUpdateEventArgs Create(GameFramework.Entity.ShowEntityUpdateEventArgs e)
|
||||
{
|
||||
ShowEntityInfo showEntityInfo = (ShowEntityInfo)e.UserData;
|
||||
ShowEntityUpdateEventArgs showEntityUpdateEventArgs = ReferencePool.Acquire<ShowEntityUpdateEventArgs>();
|
||||
showEntityUpdateEventArgs.EntityId = e.EntityId;
|
||||
showEntityUpdateEventArgs.EntityLogicType = showEntityInfo.EntityLogicType;
|
||||
showEntityUpdateEventArgs.EntityAssetName = e.EntityAssetName;
|
||||
showEntityUpdateEventArgs.EntityGroupName = e.EntityGroupName;
|
||||
showEntityUpdateEventArgs.Progress = e.Progress;
|
||||
showEntityUpdateEventArgs.UserData = showEntityInfo.UserData;
|
||||
return showEntityUpdateEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理显示实体更新事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
EntityId = 0;
|
||||
EntityLogicType = null;
|
||||
EntityAssetName = null;
|
||||
EntityGroupName = null;
|
||||
Progress = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fb90ce75efc136468379f5728401d0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user