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 });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using RPGCore.ObjectModules.ActionObjectModule;
|
||||
using RPGCoreCommon.DynamicValues;
|
||||
using RPGCoreCommon.Helpers.PropertyAttributeDrawers;
|
||||
using UnityEngine;
|
||||
@@ -6,16 +7,19 @@ using UnityEngine;
|
||||
namespace RPGCore.Core.Objects
|
||||
{
|
||||
[RequireComponent(typeof(CapsuleCollider))]
|
||||
[RequireComponent(typeof(ActionModule))]
|
||||
public class UnitObject : BaseObject
|
||||
{
|
||||
[DynamicValueProvider]
|
||||
private ObjectModule<UnitObject> UnitModuleProvider(Type moduleType) => GetComponent(moduleType) as ObjectModule<UnitObject>;
|
||||
|
||||
[field: SerializeField, ReadOnly] public CapsuleCollider unitCollider { get; private set; }
|
||||
[field: SerializeField, ReadOnly] public ActionModule actions { get; private set; }
|
||||
|
||||
protected new void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
actions = GetComponent<ActionModule>();
|
||||
unitCollider = GetComponent<CapsuleCollider>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user