HAARFTE/Assets/DemoGame/GameScript/Hotfix/FloorBase/GameObjectBase.cs

60 lines
1.3 KiB
C#
Raw Normal View History

using System;
using UnityEngine;
2024-10-24 16:16:57 +08:00
namespace ZC
{
public class GameObjectBase<T> : MonoBehaviour, IBehaviour
2024-10-24 16:16:57 +08:00
{
private long _id = 0;
2024-10-24 16:16:57 +08:00
private bool _isDisposed;
private bool _isPause;
GameObjectBinding _binding;
public GameObjectBinding binding => _binding;
2024-10-24 16:16:57 +08:00
public long Id => this._id;
public bool isDisposed => this._isDisposed;
public bool isPause => this._isPause;
private void Awake()
2024-10-24 16:16:57 +08:00
{
_binding = gameObject.GetComponent<GameObjectBinding>();
OnInit();
2024-10-24 16:16:57 +08:00
}
public void SetID(long id)
2024-10-24 16:16:57 +08:00
{
if (_id != 0)
throw new ArgumentException("id 不允许二次修改,一次固定的!");
_id = id;
2024-10-24 16:16:57 +08:00
}
public virtual void OnInit()
{
this._isDisposed = false;
this._isPause = false;
}
public virtual void OnUpdate(float dateTime)
{
}
public virtual void OnPause()
{
this._isPause = true;
}
public virtual void OnResume()
{
this._isPause = false;
}
public virtual void OnDispose()
{
this._isDisposed = true;
DestroyImmediate(this.gameObject);
2024-10-24 16:16:57 +08:00
}
}
}