CORE dashboard + a lot of changes
This commit is contained in:
@@ -13,13 +13,11 @@ namespace RPGCore.Core.Objects
|
||||
[DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
[RequireComponent(typeof(EventModule))]
|
||||
[RequireComponent(typeof(ActionModule))]
|
||||
[RequireComponent(typeof(DataModule))]
|
||||
public abstract class BaseObject : MonoBehaviour
|
||||
{
|
||||
[field: SerializeField, ReadOnly] public new Rigidbody rigidbody { get; private set; }
|
||||
[field: SerializeField, ReadOnly] public EventModule events { get; private set; }
|
||||
[field: SerializeField, ReadOnly] public ActionModule actions { get; private set; }
|
||||
[field: SerializeField, ReadOnly] public DataModule data { get; private set; }
|
||||
|
||||
[DynamicValueProvider]
|
||||
@@ -34,7 +32,6 @@ namespace RPGCore.Core.Objects
|
||||
{
|
||||
rigidbody = GetComponent<Rigidbody>();
|
||||
events = GetComponent<EventModule>();
|
||||
actions = GetComponent<ActionModule>();
|
||||
data = GetComponent<DataModule>();
|
||||
GetComponents<ObjectModule>().ForEach(module => module.parent = this);
|
||||
}
|
||||
@@ -42,25 +39,31 @@ namespace RPGCore.Core.Objects
|
||||
/// <summary>Removes this object from game.</summary>
|
||||
public void Remove()
|
||||
{
|
||||
events.Invoke(new TriggerClearEvent { obj = this });
|
||||
events.Invoke(new RemoveEvent{ obj = this });
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
public void OnDisable()
|
||||
{
|
||||
events.Invoke(new TriggerClearEvent { obj = this });
|
||||
}
|
||||
|
||||
/// <summary>It'll execute <see cref="ITrigger"/>.<see cref="ITrigger.OnEnter"/> when this object enter its collider.</summary>
|
||||
/// <summary>It'll execute <see cref="Trigger"/>.<see cref="Trigger.OnEnter"/> when this object enter its collider.</summary>
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
other.GetComponentsInParent<ITrigger>().ForEach(trigger => {
|
||||
other.GetComponentsInParent<Trigger>().ForEach(trigger => {
|
||||
trigger.OnEnter(this);
|
||||
events.Invoke(new TriggerEnterEvent { target = this, trigger = trigger });
|
||||
events.Invoke(new TriggerEnterEvent { obj = this, trigger = trigger });
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>It'll execute <see cref="ITrigger"/>.<see cref="ITrigger.OnExit"/> when this object exit its collider.</summary>
|
||||
/// <summary>It'll execute <see cref="Trigger"/>.<see cref="Trigger.OnExit"/> when this object exit its collider.</summary>
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
other.GetComponentsInParent<ITrigger>().ForEach(trigger => {
|
||||
other.GetComponentsInParent<Trigger>().ForEach(trigger => {
|
||||
trigger.OnExit(this);
|
||||
events.Invoke(new TriggerExitEvent { target = this, trigger = trigger });
|
||||
events.Invoke(new TriggerExitEvent { obj = this, trigger = trigger });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user