Skip to content

Commit 203a638

Browse files
authored
Merge pull request #1 from Watcher3056/dev
Dev
2 parents bfebe3e + 3db0a6f commit 203a638

27 files changed

+1409
-264
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.png filter=lfs diff=lfs merge=lfs -text

EasyCS.Runtime.asmdef

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
"includePlatforms": [],
1010
"excludePlatforms": [],
1111
"allowUnsafeCode": false,
12-
"overrideReferences": false,
13-
"precompiledReferences": [],
12+
"overrideReferences": true,
13+
"precompiledReferences": [
14+
"Sirenix.OdinInspector.Attributes.dll"
15+
],
1416
"autoReferenced": true,
1517
"defineConstraints": [],
1618
"versionDefines": [],

Entity System/Editor/EasyCSCodeGeneratorNew.cs

Lines changed: 903 additions & 197 deletions
Large diffs are not rendered by default.

Entity System/Unity Layer/Actor.cs

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ namespace EasyCS
88
{
99
[DisallowMultipleComponent]
1010
[SelectionBase]
11+
[IconClass(ConstantsIcons.IconActor)]
12+
#if ODIN_INSPECTOR
13+
[HideMonoScript]
14+
#endif
1115
public class Actor : EasyCSBehavior, IHasEntity
1216
{
1317
public enum EntityComponentSetupPolicy
@@ -17,7 +21,6 @@ public enum EntityComponentSetupPolicy
1721
OverrideFromActor,
1822
SetAsInActor
1923
}
20-
2124
[SerializeField, ReadOnly]
2225
private EntityProvider _entityProvider;
2326

@@ -83,9 +86,6 @@ public Actor Root
8386
private Dictionary<Type, ActorComponent> _actorComponents = new Dictionary<Type, ActorComponent>();
8487
private readonly Dictionary<Type, object> _actorComponentsAndData = new();
8588

86-
[field: SerializeField]
87-
public EntityTemplateAsset EntityTemplate { get; private set; }
88-
8989
[SerializeField, ReadOnly]
9090
private List<ActorComponent> _allComponents = new List<ActorComponent>();
9191

@@ -569,7 +569,6 @@ int GetPriority(Component c)
569569
foreach (var component in _allComponents)
570570
component.SetActor(this);
571571

572-
EditorApplyEntityTemplate();
573572
EditorValidateAllComponentDependencies();
574573
ValidateSetup();
575574
EditorUpdateUnusedDependencies();
@@ -689,44 +688,7 @@ private void EditorValidateActorComponentsDependencies()
689688
EditorUpdateMissingActorDependenciesList();
690689
}
691690

692-
private void EditorApplyEntityTemplate()
693-
{
694-
if (EntityTemplate == null)
695-
return;
696-
697-
var componentTypes = EntityTemplate.GetComponentTypes();
698-
699-
List<Type> providersToAdd = new List<Type>();
700-
701-
foreach (var type in componentTypes)
702-
{
703-
Type providerType = EntityComponentProviderFinder.FindEntityComponentProviderMatching(type);
704-
705-
if (providerType != null)
706-
{
707-
if (_allComponents.Exists(c => c.GetType() == providerType))
708-
continue;
709-
if (_entityComponentsMissing.Exists(c => c.GetType() == type))
710-
continue;
711-
712-
providersToAdd.Add(providerType);
713-
}
714-
}
715-
716-
if (providersToAdd.Count > 0)
717-
{
718-
UnityEditor.EditorApplication.delayCall += () =>
719-
{
720-
if (this == null) return;
721-
722-
foreach (var provider in providersToAdd)
723-
if (gameObject.GetComponent(provider) == null)
724-
UnityEditor.Undo.AddComponent(gameObject, provider);
725-
726-
UnityEditor.EditorUtility.SetDirty(gameObject);
727-
};
728-
}
729-
}
691+
730692

731693
public List<string> EditorGetMissingDependenciesNamesForAllComponents(EditorDependenciesType dependenciesType)
732694
{
@@ -877,11 +839,8 @@ public List<ActorComponent> EditorGetUnusedActorComponentsForComponent(ActorComp
877839

878840
public bool EditorHasUnusedDependencies() => _editorUnusedDependencies.Count > 0;
879841

880-
public void EditorSetEntityTemplate(EntityTemplateAsset entityTemplateAsset)
881-
{
882-
EntityTemplate = entityTemplateAsset;
883-
EditorApplyEntityTemplate();
884-
}
842+
public List<ActorComponent> EditorGetAllComponentsSerialized() => _allComponents;
843+
public List<IEntityComponent> EditorGetEntityComponentsMissingSerialized() => _entityComponentsMissing;
885844
#endif
886845
}
887846
}

Entity System/Unity Layer/ActorBehavior.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
using TriInspector;
2+
using UnityEngine;
3+
14
namespace EasyCS
25
{
6+
[IconClass(ConstantsIcons.IconActor)]
37
public abstract class ActorBehavior : ActorComponent
48
{
59
//protected override void OnGUI()

Entity System/Unity Layer/ActorBehavior.cs.meta

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Entity System/Unity Layer/ActorComponent.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,48 @@
66
namespace EasyCS
77
{
88
[HideMonoScript]
9-
public class ActorComponent : EasyCSBehavior, IEventListener<EventEntityKilled>
9+
#if ODIN_INSPECTOR
10+
[Sirenix.OdinInspector.HideMonoScript]
11+
#endif
12+
public abstract class ActorComponent : EasyCSBehavior, IEventListener<EventEntityKilled>
1013
{
14+
#if ODIN_INSPECTOR
15+
[SerializeField, Sirenix.OdinInspector.ReadOnly, Sirenix.OdinInspector.Required, Sirenix.OdinInspector.ShowIf("EditorShowActor")]
16+
#else
1117
[SerializeField, ReadOnly, Required, ShowIf("EditorShowActor")]
18+
#endif
1219
private Actor _actor;
1320
public Actor Actor => _actor;
1421
public Entity Entity => _actor != null ? _actor.Entity : Entity.Empty;
1522

1623
#if UNITY_EDITOR
24+
#if ODIN_INSPECTOR
25+
[Sirenix.OdinInspector.InfoBox("Disable reason: Entity not set", Sirenix.OdinInspector.InfoMessageType.Warning, "EditorShowWarningDisabledEntityNotSet")]
26+
[Sirenix.OdinInspector.ShowInInspector, Sirenix.OdinInspector.ReadOnly, Sirenix.OdinInspector.ShowIf("EditorShowWarningDisabledEntityNotSet"), Sirenix.OdinInspector.HideInEditorMode]
27+
#else
1728
[InfoBox("Disable reason: Entity not set", TriMessageType.Warning, "EditorShowWarningDisabledEntityNotSet")]
1829
[ShowInInspector, ReadOnly, ShowIf("EditorShowWarningDisabledEntityNotSet"), ShowInPlayMode]
30+
#endif
1931
private bool _entityNotSet = true;
32+
33+
#if ODIN_INSPECTOR
34+
[Sirenix.OdinInspector.InfoBox("Disable reason: Entity not alive", Sirenix.OdinInspector.InfoMessageType.Warning, "EditorShowWarningDisabledEntityNotAlive")]
35+
[Sirenix.OdinInspector.ShowInInspector, Sirenix.OdinInspector.ReadOnly, Sirenix.OdinInspector.ShowIf("EditorShowWarningDisabledEntityNotAlive"), Sirenix.OdinInspector.HideInEditorMode]
36+
#else
2037
[InfoBox("Disable reason: Entity not alive", TriMessageType.Warning, "EditorShowWarningDisabledEntityNotAlive")]
2138
[ShowInInspector, ReadOnly, ShowIf("EditorShowWarningDisabledEntityNotAlive"), ShowInPlayMode]
39+
#endif
2240
private bool _entityNotAlive = true;
41+
42+
#if ODIN_INSPECTOR
43+
[Sirenix.OdinInspector.LabelText("Missing Dependencies"), Sirenix.OdinInspector.ShowInInspector, Sirenix.OdinInspector.ShowIf("EditorHasMissingDependencies"), Sirenix.OdinInspector.ReadOnly,
44+
Sirenix.OdinInspector.InfoBox("Actor has missing dependencies for this component!", Sirenix.OdinInspector.InfoMessageType.Error, "EditorHasMissingDependencies"),
45+
Sirenix.OdinInspector.ListDrawerSettings(ShowFoldout = false)]
46+
#else
2347
[LabelText("Missing Dependencies"), ShowInInspector, ShowIf("EditorHasMissingDependencies"), ReadOnly,
2448
InfoBox("Actor has missing dependencies for this component!", TriMessageType.Error, "EditorHasMissingDependencies"),
2549
ListDrawerSettings(AlwaysExpanded = true)]
50+
#endif
2651
private List<string> _editorMissingDependencies = new List<string>();
2752
#endif
2853

Entity System/Unity Layer/ActorData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
2+
using TriInspector;
23

34
namespace EasyCS
45
{
6+
[IconClass(ConstantsIcons.IconActor)]
57
public abstract class ActorData : ActorComponent, IActorData, IActorDataProvider
68
{
79
public IActorData GetActorData() => this;

Entity System/Unity Layer/ActorData.cs.meta

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Entity System/Unity Layer/ActorDataSharedProviderBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace EasyCS
77
{
8+
[IconClass(ConstantsIcons.IconActor)]
89
public abstract class ActorDataSharedProviderBase<T1, T2> : ActorComponent, IActorDataProvider
910
where T1 : IActorData
1011
where T2 : IActorDataFactory

0 commit comments

Comments
 (0)