52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Sirenix.OdinInspector;
|
|
namespace BITKit.Entities
|
|
{
|
|
public interface IEntityComponent
|
|
{
|
|
bool isLocalPlayer { get; }
|
|
IEntity entity { get; }
|
|
void Initialize(IEntity entity);
|
|
void OnAwake();
|
|
void OnStart();
|
|
void OnUpdate(float deltaTime);
|
|
void OnFixedUpdate(float deltaTime);
|
|
void OnLateUpdate(float deltaTime);
|
|
void OnSetOverride(bool value);
|
|
void OnDestroyComponent();
|
|
void OnSpawn();
|
|
void OnDespawn();
|
|
void RegisterCallback() { }
|
|
void UnRegisterCallback() { }
|
|
|
|
}
|
|
public abstract partial class EntityComponent : MonoBehaviour, IEntityComponent
|
|
{
|
|
public IEntity entity { get; set; }
|
|
public bool isLocalPlayer => entity.Get<bool>(nameof(isLocalPlayer));
|
|
public bool isSpawned=> entity.Get<bool>(nameof(isSpawned));
|
|
private IEntity mEntity;
|
|
public virtual void Initialize(IEntity entity) { this.entity = entity; }
|
|
public virtual void OnAwake() { }
|
|
public virtual void OnStart() { }
|
|
public virtual void OnUpdate(float deltaTime) { }
|
|
public virtual void OnFixedUpdate(float deltaTime) { }
|
|
public virtual void OnLateUpdate(float deltaTime) { }
|
|
public virtual void OnSetOverride(bool value) { }
|
|
public virtual void OnDestroyComponent() { }
|
|
public virtual void RegisterCallback() { }
|
|
public virtual void UnRegisterCallback() { }
|
|
public virtual void OnSpawn() { }
|
|
public virtual void OnDespawn() { }
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
[UnityEditor.CustomEditor(typeof(EntityComponent), true)]
|
|
public class EntityComponentInspector : BITInspector<EntityComponent>
|
|
{
|
|
|
|
}
|
|
#endif
|
|
} |