1
This commit is contained in:
52
Unity/Scripts/Entity/Core/EntityComponent.cs
Normal file
52
Unity/Scripts/Entity/Core/EntityComponent.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user