41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System;
|
|
#if UNITY_EDITOR
|
|
using UnityEditor;
|
|
#endif
|
|
using UnityEngine;
|
|
|
|
namespace BITKit.Entities
|
|
{
|
|
public interface IEntityComponent:BITKit.Core.Entites.IEntityComponent
|
|
{
|
|
IEntity entity { get; }
|
|
void Initialize(IEntity _entity);
|
|
void OnUpdate(float deltaTime);
|
|
void OnFixedUpdate(float deltaTime);
|
|
void OnLateUpdate(float deltaTime);
|
|
void OnDestroyComponent();
|
|
}
|
|
public abstract class EntityComponent : MonoBehaviour, IEntityComponent
|
|
{
|
|
public IEntity entity { get; private set; }
|
|
private IEntity mEntity;
|
|
public virtual void Initialize(IEntity _entity) { 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 OnDestroyComponent() { }
|
|
public virtual Type BaseType => GetType();
|
|
public Core.Entites.IEntity Entity { get; set; }
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
[CanEditMultipleObjects]
|
|
[CustomEditor(typeof(EntityComponent), true)]
|
|
public class EntityComponentInspector : BITInspector<EntityComponent>
|
|
{
|
|
|
|
}
|
|
#endif
|
|
} |