This commit is contained in:
2026-04-25 23:37:10 +02:00
commit 19d6bd934a
476 changed files with 9198 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
using RPGCoreCommon.Helpers.PropertyAttributeDrawers;
using RPGCoreCommon.Settings;
using UnityEngine;
namespace RPGCore.Core
{
[CustomSettings("RPG Core/Main Settings")]
public class CoreSettings : CustomSettingsSO
{
[Header("Layers")]
[Layer] public int dynamicLayer;
[Layer] public int staticLayer;
[Layer] public int staticHideableLayer;
[Layer] public int triggerLayer;
[Layer] public int cameraLayer;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ae66b654cdd34f0eb7cb566026a04553
timeCreated: 1761916774
+13
View File
@@ -0,0 +1,13 @@
using System;
using UnityEngine;
namespace RPGCore.Core
{
/// <summary>
/// Extend this abstract class to create new module for global logic.
/// </summary>
[Serializable]
public abstract class GlobalModule : MonoBehaviour
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9bfe3de119af4cca916793ab7ab84f34
timeCreated: 1761424144
+15
View File
@@ -0,0 +1,15 @@
using System;
namespace RPGCore.Core
{
/// <summary>
/// With this interface you can create your own list of requirements for specific <see cref="Type"/> (and its implementations).
/// <see cref="Check"/> returns TRUE if defined requirement is met, otherwise FALSE.
/// Thanks to this we can create list of reusable requirements that further can be used to gate logic.
/// </summary>
/// <typeparam name="T">Type for which this requirement is</typeparam>
public interface IRequirement<in T>
{
public bool Check(T obj);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e865880889b3491aa34c60bc2fbca102
timeCreated: 1764886296
+15
View File
@@ -0,0 +1,15 @@
using RPGCore.Core.Objects;
using UnityEngine;
namespace RPGCore.Core
{
/// <summary>
/// This interface allow any <see cref="BaseObject"/> to call <see cref="OnEnter"/> and <see cref="OnExit"/>.<br/>
/// Setting <see cref="Collider"/>'s <see cref="Collider.isTrigger"/> to true is required!<br/>
/// </summary>
public interface ITrigger
{
public void OnEnter(BaseObject obj);
public void OnExit(BaseObject obj);
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c44b68608de84013b92b61d898ea8e2a
timeCreated: 1761916614
+39
View File
@@ -0,0 +1,39 @@
using System;
using RPGCore.Core.Objects;
using UnityEngine;
namespace RPGCore.Core
{
/// <summary>
/// Extend this abstract class to create new module for &lt;<typeparamref name="T"/>&gt; object type.<br/>
/// </summary>
/// <typeparam name="T">Type of object that this module will be attached to. Can be <see cref="BaseObject"/> or any of its children.</typeparam>
[Serializable]
public abstract class ObjectModule<T> : ObjectModule where T : BaseObject
{
public new T parent => (T)base.parent;
}
/// <summary>
/// <b>DO NOT EXTEND THIS</b>, use <see cref="ObjectModule{T}"/> instead!
/// </summary>
[Serializable]
public abstract class ObjectModule : MonoBehaviour
{
private BaseObject _parent;
internal BaseObject parent
{
get
{
if (!_parent) _parent = GetComponent<BaseObject>();
return _parent;
}
set => _parent = value;
}
private protected ObjectModule()
{
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3c6794c4f1c6dd149860a41f06978cad
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 182b5998cfbb6644da7a90e3b1765485
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,67 @@
using System;
using RPGCore.ObjectModules.ActionObjectModule;
using RPGCore.ObjectModules.EventObjectModule;
using RPGCore.ObjectModules.EventObjectModule.Events;
using RPGCoreCommon.DynamicValues;
using RPGCoreCommon.Helpers;
using RPGCoreCommon.Helpers.PropertyAttributeDrawers;
using UnityEngine;
namespace RPGCore.Core.Objects
{
[SelectionBase]
[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]
private ObjectModule<BaseObject> BaseModuleProvider(Type moduleType) => GetComponent(moduleType) as ObjectModule<BaseObject>;
protected void Start()
{
GetComponent<EventModule>().Invoke(new SpawnEvent());
}
protected void OnValidate()
{
rigidbody = GetComponent<Rigidbody>();
events = GetComponent<EventModule>();
actions = GetComponent<ActionModule>();
data = GetComponent<DataModule>();
GetComponents<ObjectModule>().ForEach(module => module.parent = this);
}
/// <summary>Removes this object from game.</summary>
public void Remove()
{
events.Invoke(new RemoveEvent{ obj = this });
Destroy(gameObject);
}
/// <summary>It'll execute <see cref="ITrigger"/>.<see cref="ITrigger.OnEnter"/> when this object enter its collider.</summary>
private void OnTriggerEnter(Collider other)
{
other.GetComponentsInParent<ITrigger>().ForEach(trigger => {
trigger.OnEnter(this);
events.Invoke(new TriggerEnterEvent { target = this, trigger = trigger });
});
}
/// <summary>It'll execute <see cref="ITrigger"/>.<see cref="ITrigger.OnExit"/> when this object exit its collider.</summary>
private void OnTriggerExit(Collider other)
{
other.GetComponentsInParent<ITrigger>().ForEach(trigger => {
trigger.OnExit(this);
events.Invoke(new TriggerExitEvent { target = this, trigger = trigger });
});
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e2798185b793dc9498d74d746f680c1c
@@ -0,0 +1,22 @@
using System;
using RPGCoreCommon.DynamicValues;
using RPGCoreCommon.Helpers.PropertyAttributeDrawers;
using UnityEngine;
namespace RPGCore.Core.Objects
{
[RequireComponent(typeof(CapsuleCollider))]
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; }
protected new void OnValidate()
{
base.OnValidate();
unitCollider = GetComponent<CapsuleCollider>();
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e0e44d2cfbb316343b9be0d7bee42909
+13
View File
@@ -0,0 +1,13 @@
using System;
using UnityEngine;
namespace RPGCore.Core
{
/// <summary>
/// Extend this abstract class to create new module for scene logic.
/// </summary>
[Serializable]
public abstract class SceneModule : MonoBehaviour
{
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ee04853ad1f04cf097b8b6c946f67896
timeCreated: 1761424233