-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"files.exclude": | ||
{ | ||
"**/.DS_Store":true, | ||
"**/.git":true, | ||
"**/.gitmodules":true, | ||
"**/*.booproj":true, | ||
"**/*.pidb":true, | ||
"**/*.suo":true, | ||
"**/*.user":true, | ||
"**/*.userprefs":true, | ||
"**/*.unityproj":true, | ||
"**/*.dll":true, | ||
"**/*.exe":true, | ||
"**/*.pdf":true, | ||
"**/*.mid":true, | ||
"**/*.midi":true, | ||
"**/*.wav":true, | ||
"**/*.gif":true, | ||
"**/*.ico":true, | ||
"**/*.jpg":true, | ||
"**/*.jpeg":true, | ||
"**/*.png":true, | ||
"**/*.psd":true, | ||
"**/*.tga":true, | ||
"**/*.tif":true, | ||
"**/*.tiff":true, | ||
"**/*.3ds":true, | ||
"**/*.3DS":true, | ||
"**/*.fbx":true, | ||
"**/*.FBX":true, | ||
"**/*.lxo":true, | ||
"**/*.LXO":true, | ||
"**/*.ma":true, | ||
"**/*.MA":true, | ||
"**/*.obj":true, | ||
"**/*.OBJ":true, | ||
"**/*.asset":true, | ||
"**/*.cubemap":true, | ||
"**/*.flare":true, | ||
"**/*.mat":true, | ||
"**/*.meta":true, | ||
"**/*.prefab":true, | ||
"**/*.unity":true, | ||
"build/":true, | ||
"Build/":true, | ||
"Library/":true, | ||
"library/":true, | ||
"obj/":true, | ||
"Obj/":true, | ||
"ProjectSettings/":true, | ||
"temp/":true, | ||
"Temp/":true | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using UnityEditor; | ||
using UnityEditor.UIElements; | ||
using UnityEditorInternal; | ||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace ECT.UnityEditor | ||
{ | ||
[CustomPropertyDrawer(typeof(ECTBranch<>), true)] | ||
public class BranchEditor : PropertyDrawer | ||
{ | ||
ReorderableList componentList; | ||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | ||
{ | ||
EditorGUI.BeginProperty(position, label, property); | ||
|
||
if(componentList == null) PrepareList(property); | ||
|
||
componentList.DoList(position); | ||
|
||
EditorGUI.EndProperty(); | ||
} | ||
|
||
public void PrepareList (SerializedProperty property) | ||
{ | ||
var components = property.FindPropertyRelative("Components"); | ||
componentList = new(property.serializedObject, components, false, true, true, true) | ||
{ | ||
drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => | ||
{ | ||
EditorGUI.PropertyField(rect, components.GetArrayElementAtIndex(index)); | ||
}, | ||
|
||
drawHeaderCallback = (Rect rect) => | ||
{ | ||
EditorGUI.LabelField(rect, "Components"); | ||
} | ||
}; | ||
} | ||
|
||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) | ||
{ | ||
return componentList?.GetHeight() ?? base.GetPropertyHeight(property, label); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using UnityEditor; | ||
using UnityEditorInternal; | ||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace ECT.UnityEditor | ||
{ | ||
[CustomPropertyDrawer(typeof(ECTComponent<,,>), true)] | ||
public class ComponentEditor : PropertyDrawer | ||
{ | ||
Editor editor; | ||
|
||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | ||
{ | ||
EditorGUI.PropertyField(position, property, new(), true); | ||
|
||
// Make child fields be indented | ||
EditorGUI.indentLevel++; | ||
|
||
// background | ||
GUILayout.BeginVertical("box"); | ||
|
||
if (!editor) | ||
Editor.CreateCachedEditor(property.objectReferenceValue, null, ref editor); | ||
|
||
// Draw object properties | ||
EditorGUI.BeginChangeCheck(); | ||
if (editor) // catch empty property | ||
{ | ||
editor.OnInspectorGUI (); | ||
} | ||
if (EditorGUI.EndChangeCheck()) | ||
property.serializedObject.ApplyModifiedProperties(); | ||
|
||
GUILayout.EndVertical (); | ||
|
||
// Set indent back to what it was | ||
EditorGUI.indentLevel--; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace ECT | ||
{ | ||
[System.Serializable] | ||
public class ECTBranch<MyComponent> : IBranch where MyComponent : class, IComponent | ||
{ | ||
public MyComponent[] Components; | ||
} | ||
|
||
public interface IBranch | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using UnityEngine; | ||
|
||
namespace ECT | ||
{ | ||
public abstract class ECTComponent<MyRoot, MyParent, MyComponent> : ScriptableObject, IComponent where MyRoot : class, IParent where MyParent : class, IParent where MyComponent : class, IComponent | ||
{ | ||
protected MyComponent ThisComponent => this as MyComponent; | ||
|
||
protected abstract ISystem System { get; } | ||
public ISystem CreateSystem() => System; | ||
|
||
protected virtual IReference CreateReference (MyRoot root, MyParent parent, ISystem system) => new ComponentReference(ThisComponent, root, parent, system); | ||
public IReference CreateReference(IParent root, IParent parent) | ||
{ | ||
ISystem system = System; | ||
if(parent as MyParent == null) Debug.Log(typeof(MyParent)); | ||
IReference reference = CreateReference((MyRoot)root, (MyParent)parent, system); | ||
system.SetReference(reference); | ||
|
||
return reference; | ||
} | ||
|
||
public abstract class ComponentSystem<Component> : ECTSystem<ComponentReference, Component, MyRoot, MyParent> where Component : class, IComponent {} | ||
|
||
public class ComponentReference : ECTReference<MyRoot, MyParent, MyComponent> | ||
{ | ||
public ComponentReference(MyComponent reference, MyRoot root, MyParent parent, ISystem system) : base(reference, root, parent, system) {} | ||
} | ||
|
||
public abstract class ComponentGroup : ECTComponent<MyRoot, MyParent, MyComponent>, IParent | ||
{ | ||
public ECTBranch<ChildComponent> Components; | ||
|
||
protected override IReference CreateReference(MyRoot root, MyParent parent, ISystem system) => new ComponentGroupReference(this, root, parent, system, Components); | ||
|
||
public abstract class ChildComponent : ECTComponent<MyRoot, ComponentGroup, ChildComponent> {} | ||
|
||
public class ComponentGroupReference : ECTReference<MyRoot, MyParent, ComponentGroup> | ||
{ | ||
public ECTReferenceBranch ReferenceBranch { get; } | ||
|
||
public ComponentGroupReference(ComponentGroup reference, MyRoot root, MyParent parent, ISystem system, ECTBranch<ChildComponent> branch) : base(reference, root, parent, system) => ReferenceBranch = new(branch.Components); | ||
|
||
public override FindSystem Get<FindSystem>() => System is FindSystem system ? system : ReferenceBranch.Get<FindSystem>(); | ||
} | ||
|
||
public new abstract class ComponentSystem<Component> : ECTSystem<ComponentGroupReference, Component, MyRoot, MyParent> where Component : class, IComponent | ||
{ | ||
protected override void OnUpdate() => Reference.ReferenceBranch.Update(Reference.Root, Reference.Component); | ||
} | ||
} | ||
} | ||
|
||
public interface IComponent | ||
{ | ||
public ISystem CreateSystem(); | ||
public IReference CreateReference(IParent root, IParent parent); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using UnityEngine; | ||
|
||
namespace ECT | ||
{ | ||
public abstract class ECTEntity<MyEntity> : MonoBehaviour, IEntity where MyEntity : class, IEntity | ||
{ | ||
public ECTBranch<ECTComponent<MyEntity, MyEntity, EntityComponent>> ComponentBranch; | ||
|
||
public ECTReferenceBranch ReferenceBranch { get; set; } | ||
|
||
public abstract class EntityComponent : ECTComponent<MyEntity, MyEntity, EntityComponent> {} | ||
|
||
void Awake () | ||
{ | ||
ReferenceBranch = new(ComponentBranch.Components); | ||
} | ||
} | ||
|
||
public interface IEntity : IParent | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace ECT | ||
{ | ||
public interface IParent | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace ECT | ||
{ | ||
[System.Serializable] | ||
public abstract class ECTReference<MyRoot, MyParent, MyComponent> : IReference where MyRoot : class, IParent where MyParent : class, IParent where MyComponent : class, IComponent | ||
{ | ||
public ECTReference(MyComponent component, MyRoot root, MyParent parent, ISystem system) | ||
{ | ||
Component = component; | ||
Root = root; | ||
Parent = parent; | ||
System = system; | ||
} | ||
|
||
public bool State = true; | ||
public MyComponent Component { get; } | ||
public MyRoot Root { get; } | ||
public MyParent Parent { get; } | ||
public ISystem System { get; } | ||
|
||
bool IReference.State { get => State; set => State = value; } | ||
IComponent IReference.Component => Component; | ||
IParent IReference.Root => Root; | ||
IParent IReference.Parent => Parent; | ||
|
||
public virtual FindSystem Get<FindSystem>() where FindSystem : class, ISystem => System as FindSystem; | ||
} | ||
|
||
public interface IReference | ||
{ | ||
public bool State { get; set; } | ||
public IComponent Component { get; } | ||
public IParent Root { get; } | ||
public IParent Parent { get; } | ||
public ISystem System { get; } | ||
public FindSystem Get<FindSystem>() where FindSystem : class, ISystem; | ||
} | ||
} |