mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
refactoring
This commit is contained in:
parent
e728cacfc9
commit
cadf7abbd3
@ -1,6 +1,5 @@
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS.Editors
|
namespace DCFApixels.DragonECS.Editors
|
||||||
{
|
{
|
||||||
|
@ -204,7 +204,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
foreach (var intr in system.GetType().GetInterfaces())
|
foreach (var intr in system.GetType().GetInterfaces())
|
||||||
{
|
{
|
||||||
if(systemInterfaceType.IsAssignableFrom(intr) && systemInterfaceType != intr && (showHidden || intr.GetCustomAttribute<DebugHideAttribute>() == null))
|
if (systemInterfaceType.IsAssignableFrom(intr) && systemInterfaceType != intr && (showHidden || intr.GetCustomAttribute<DebugHideAttribute>() == null))
|
||||||
{
|
{
|
||||||
ProcessData data;
|
ProcessData data;
|
||||||
if (!_processeIndexes.TryGetValue(intr, out int index))
|
if (!_processeIndexes.TryGetValue(intr, out int index))
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using DCFApixels.DragonECS.Unity.Debug;
|
using DCFApixels.DragonECS.Unity.Debug;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
@ -72,8 +70,8 @@ namespace DCFApixels.DragonECS
|
|||||||
namespace Editors
|
namespace Editors
|
||||||
{
|
{
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEditor;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
[CustomEditor(typeof(WorldPoolsMonitor))]
|
[CustomEditor(typeof(WorldPoolsMonitor))]
|
||||||
public class WorldPoolsMonitorEditor : Editor
|
public class WorldPoolsMonitorEditor : Editor
|
||||||
@ -102,7 +100,7 @@ namespace DCFApixels.DragonECS
|
|||||||
int x = -1, y = 0;
|
int x = -1, y = 0;
|
||||||
foreach (var pool in pools)
|
foreach (var pool in pools)
|
||||||
{
|
{
|
||||||
if(++x >= widthCount)
|
if (++x >= widthCount)
|
||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
y++;
|
y++;
|
||||||
@ -124,7 +122,7 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
position = AddMargin(position, 1f, 1f);
|
position = AddMargin(position, 1f, 1f);
|
||||||
|
|
||||||
EditorGUI.DrawRect(position, Color.black* 0.16f);
|
EditorGUI.DrawRect(position, Color.black * 0.16f);
|
||||||
|
|
||||||
Rect progressBar = new Rect(Vector2.zero, _poolProgressBasrSize);
|
Rect progressBar = new Rect(Vector2.zero, _poolProgressBasrSize);
|
||||||
progressBar.width = position.width;
|
progressBar.width = position.width;
|
||||||
@ -152,7 +150,7 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
GUIStyle textStyle1 = new GUIStyle(EditorStyles.miniBoldLabel);
|
GUIStyle textStyle1 = new GUIStyle(EditorStyles.miniBoldLabel);
|
||||||
textStyle1.alignment = TextAnchor.UpperCenter;
|
textStyle1.alignment = TextAnchor.UpperCenter;
|
||||||
GUI.Label(AddMargin(position, 3f, 3f), "Total\r\n"+ capacity, textStyle1);
|
GUI.Label(AddMargin(position, 3f, 3f), "Total\r\n" + capacity, textStyle1);
|
||||||
|
|
||||||
GUI.contentColor = defaultContentColor;
|
GUI.contentColor = defaultContentColor;
|
||||||
GUIStyle textStyle2 = new GUIStyle(EditorStyles.miniBoldLabel);
|
GUIStyle textStyle2 = new GUIStyle(EditorStyles.miniBoldLabel);
|
||||||
|
@ -9,7 +9,7 @@ namespace DCFApixels.DragonECS
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public abstract class EntityTemplateEditorBase: Editor
|
public abstract class EntityTemplateEditorBase : Editor
|
||||||
{
|
{
|
||||||
private static readonly Rect RemoveButtonRect = new Rect(0f, 0f, 15f, 15f);
|
private static readonly Rect RemoveButtonRect = new Rect(0f, 0f, 15f, 15f);
|
||||||
private static readonly Rect TooltipIconRect = new Rect(0f, 0f, 15f, 15f);
|
private static readonly Rect TooltipIconRect = new Rect(0f, 0f, 15f, 15f);
|
||||||
@ -44,7 +44,7 @@ namespace DCFApixels.DragonECS
|
|||||||
genericMenu = new GenericMenu();
|
genericMenu = new GenericMenu();
|
||||||
|
|
||||||
var dummies = TemplateBrowsableTypeCache.Dummies;
|
var dummies = TemplateBrowsableTypeCache.Dummies;
|
||||||
foreach ( var dummy in dummies )
|
foreach (var dummy in dummies)
|
||||||
{
|
{
|
||||||
string name, description;
|
string name, description;
|
||||||
if (dummy is ITemplateComponentName browsableName)
|
if (dummy is ITemplateComponentName browsableName)
|
||||||
@ -137,7 +137,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private void DrawComponentData(SerializedProperty componentRefProp, int index)
|
private void DrawComponentData(SerializedProperty componentRefProp, int index)
|
||||||
{
|
{
|
||||||
ITemplateComponent browsable = componentRefProp.managedReferenceValue as ITemplateComponent;
|
ITemplateComponent browsable = componentRefProp.managedReferenceValue as ITemplateComponent;
|
||||||
if(browsable == null)
|
if (browsable == null)
|
||||||
{
|
{
|
||||||
DrawDamagedComponent(componentRefProp, index);
|
DrawDamagedComponent(componentRefProp, index);
|
||||||
return;
|
return;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using UnityEngine;
|
namespace DCFApixels.DragonECS
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
|
||||||
{
|
{
|
||||||
public interface ITemplate
|
public interface ITemplate
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using DCFApixels.DragonECS.Editors;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@ -122,7 +121,7 @@ namespace DCFApixels.DragonECS
|
|||||||
Type interfaceType = typeof(ITemplateComponent);
|
Type interfaceType = typeof(ITemplateComponent);
|
||||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
var targetTypes = assembly.GetTypes().Where(type => !type.IsGenericType && (type.IsValueType|| type.IsClass) && type.GetCustomAttribute<SerializableAttribute>() != null);
|
var targetTypes = assembly.GetTypes().Where(type => !type.IsGenericType && (type.IsValueType || type.IsClass) && type.GetCustomAttribute<SerializableAttribute>() != null);
|
||||||
|
|
||||||
types.AddRange(targetTypes.Where(type => interfaceType.IsAssignableFrom(type)));
|
types.AddRange(targetTypes.Where(type => interfaceType.IsAssignableFrom(type)));
|
||||||
|
|
||||||
@ -130,7 +129,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
if (t.IsSubclassOf(typeof(TemplateComponentInitializer<>)))
|
if (t.IsSubclassOf(typeof(TemplateComponentInitializer<>)))
|
||||||
{
|
{
|
||||||
if(t.GetCustomAttribute<SerializableAttribute>() != null)
|
if (t.GetCustomAttribute<SerializableAttribute>() != null)
|
||||||
types.Add(t);
|
types.Add(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public void ConnectWith(entlong entity, bool applyTemplates = false)
|
public void ConnectWith(entlong entity, bool applyTemplates = false)
|
||||||
{
|
{
|
||||||
if(_entity.TryGetID(out int oldE) && _world != null)
|
if (_entity.TryGetID(out int oldE) && _world != null)
|
||||||
{
|
{
|
||||||
var s = _world.GetAspect<Aspect>();
|
var s = _world.GetAspect<Aspect>();
|
||||||
s.unityGameObjects.Del(oldE);
|
s.unityGameObjects.Del(oldE);
|
||||||
@ -116,7 +116,7 @@ namespace DCFApixels.DragonECS
|
|||||||
else
|
else
|
||||||
GUILayout.Box("Not connected", _redStyle, GUILayout.ExpandWidth(true));
|
GUILayout.Box("Not connected", _redStyle, GUILayout.ExpandWidth(true));
|
||||||
|
|
||||||
if(Target.Entity.TryGetID(out int id))
|
if (Target.Entity.TryGetID(out int id))
|
||||||
EditorGUILayout.IntField(id);
|
EditorGUILayout.IntField(id);
|
||||||
else
|
else
|
||||||
EditorGUILayout.IntField(0);
|
EditorGUILayout.IntField(0);
|
||||||
@ -124,7 +124,7 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
base.OnInspectorGUI();
|
base.OnInspectorGUI();
|
||||||
|
|
||||||
if(GUILayout.Button("Autoset Templates"))
|
if (GUILayout.Button("Autoset Templates"))
|
||||||
{
|
{
|
||||||
Target.SetTemplates_Editor(Target.GetComponents<EntityTemplate>());
|
Target.SetTemplates_Editor(Target.GetComponents<EntityTemplate>());
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ namespace DCFApixels.DragonECS.Editors
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if(value)
|
if (value)
|
||||||
_data[index >> OFFSET] |= (1 << (index & MOD_MASK));
|
_data[index >> OFFSET] |= (1 << (index & MOD_MASK));
|
||||||
else
|
else
|
||||||
_data[index >> OFFSET] &= ~(1 << (index & MOD_MASK));
|
_data[index >> OFFSET] &= ~(1 << (index & MOD_MASK));
|
||||||
|
Loading…
Reference in New Issue
Block a user