diff --git a/src/Debug/Editor/DebugMonitorPrefs.cs b/src/Debug/Editor/DebugMonitorPrefs.cs index 276f963..b502b93 100644 --- a/src/Debug/Editor/DebugMonitorPrefs.cs +++ b/src/Debug/Editor/DebugMonitorPrefs.cs @@ -1,6 +1,5 @@ #if UNITY_EDITOR using UnityEditor; -using UnityEngine; namespace DCFApixels.DragonECS.Editors { diff --git a/src/Debug/Editor/EcsEditor.cs b/src/Debug/Editor/EcsEditor.cs index 3bbd300..9266277 100644 --- a/src/Debug/Editor/EcsEditor.cs +++ b/src/Debug/Editor/EcsEditor.cs @@ -9,7 +9,7 @@ namespace DCFApixels.DragonECS.Editors [InitializeOnLoad] public static class EcsEditor { - static EcsEditor() + static EcsEditor() { colorBoxeStyles = new SparseArray(); } diff --git a/src/Debug/Systems/PipelineDebugSystem.cs b/src/Debug/Systems/PipelineDebugSystem.cs index 273a103..35b089b 100644 --- a/src/Debug/Systems/PipelineDebugSystem.cs +++ b/src/Debug/Systems/PipelineDebugSystem.cs @@ -204,7 +204,7 @@ namespace DCFApixels.DragonECS { foreach (var intr in system.GetType().GetInterfaces()) { - if(systemInterfaceType.IsAssignableFrom(intr) && systemInterfaceType != intr && (showHidden || intr.GetCustomAttribute() == null)) + if (systemInterfaceType.IsAssignableFrom(intr) && systemInterfaceType != intr && (showHidden || intr.GetCustomAttribute() == null)) { ProcessData data; if (!_processeIndexes.TryGetValue(intr, out int index)) @@ -217,7 +217,7 @@ namespace DCFApixels.DragonECS data.name = EcsEditor.GetGenericName(intr); data.interfaceType = intr; - data.systemsBitMask = new BitMask(_systems.Length); + data.systemsBitMask = new BitMask(_systems.Length); } data = _processesList[index]; data.systemsBitMask[i] = true; @@ -266,7 +266,7 @@ namespace DCFApixels.DragonECS rect.y = _nameCellSize.y; rect.width = _nameCellSize.x; rect.height = _cellsize.x; - rect.y -= _cellsize.y; + rect.y -= _cellsize.y; for (int i = 0; i < _processesList.Count; i++) { lineRect = rect; @@ -301,7 +301,7 @@ namespace DCFApixels.DragonECS lineRect.width = rectView.width; GUI.Label(lineRect, "", i % 2 == 1 ? whiteStyle : blackStyle); - // GUIContent label = new GUIContent(name, i + " " + name); + // GUIContent label = new GUIContent(name, i + " " + name); label.text = name; label.tooltip = i + " " + name; GUI.Label(rect, label, EditorStyles.miniBoldLabel); diff --git a/src/Debug/Systems/WorldDebugSystem.cs b/src/Debug/Systems/WorldDebugSystem.cs index 7b92448..fee56cb 100644 --- a/src/Debug/Systems/WorldDebugSystem.cs +++ b/src/Debug/Systems/WorldDebugSystem.cs @@ -1,12 +1,10 @@ using DCFApixels.DragonECS.Unity.Debug; -using System.Collections; -using System.Collections.Generic; using UnityEngine; namespace DCFApixels.DragonECS { [DebugHide, DebugColor(DebugColor.Gray)] - public class WorldDebugSystem : IEcsRunProcess + public class WorldDebugSystem : IEcsRunProcess { private string _monitorName; private EcsWorld _ecsWorld; @@ -72,8 +70,8 @@ namespace DCFApixels.DragonECS namespace Editors { using System.Linq; - using UnityEditor; using System.Reflection; + using UnityEditor; [CustomEditor(typeof(WorldPoolsMonitor))] public class WorldPoolsMonitorEditor : Editor @@ -87,30 +85,30 @@ namespace DCFApixels.DragonECS public override void OnInspectorGUI() { - _scroll = GUILayout.BeginScrollView(_scroll, GUILayout.Height(800f)); + _scroll = GUILayout.BeginScrollView(_scroll, GUILayout.Height(800f)); - var pools = Target.world.AllPools.ToArray().Where(o => !o.IsNullOrDummy()).OfType(); - - GUILayout.Label("", GUILayout.ExpandWidth(true)); - - float width = GUILayoutUtility.GetLastRect().width; - - Vector3 newPoolBlockSize = _poolBlockMinSize; - int widthCount = Mathf.Max(1, Mathf.Min((Mathf.FloorToInt(width / _poolBlockMinSize.x)), pools.Count())); - newPoolBlockSize.x = width / widthCount; - - int x = -1, y = 0; - foreach (var pool in pools) - { - if(++x >= widthCount) - { - x = 0; - y++; - } - - DrawPoolBlock(pool, new Rect(newPoolBlockSize.x * x, newPoolBlockSize.y * y, newPoolBlockSize.x, newPoolBlockSize.y)); - } - GUILayout.EndScrollView(); + var pools = Target.world.AllPools.ToArray().Where(o => !o.IsNullOrDummy()).OfType(); + + GUILayout.Label("", GUILayout.ExpandWidth(true)); + + float width = GUILayoutUtility.GetLastRect().width; + + Vector3 newPoolBlockSize = _poolBlockMinSize; + int widthCount = Mathf.Max(1, Mathf.Min((Mathf.FloorToInt(width / _poolBlockMinSize.x)), pools.Count())); + newPoolBlockSize.x = width / widthCount; + + int x = -1, y = 0; + foreach (var pool in pools) + { + if (++x >= widthCount) + { + x = 0; + y++; + } + + DrawPoolBlock(pool, new Rect(newPoolBlockSize.x * x, newPoolBlockSize.y * y, newPoolBlockSize.x, newPoolBlockSize.y)); + } + GUILayout.EndScrollView(); } @@ -121,16 +119,16 @@ namespace DCFApixels.DragonECS Color defaultContentColor = GUI.contentColor; GUI.contentColor = Color.black * 0.925f; - + 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); progressBar.width = position.width; progressBar.center = position.center - Vector2.up * _poolBlockMinSize.y * 0.09f; - - + + Color mainColor = new Color(0.3f, 1f, 0f, 1f); var debugColor = pool.ComponentType.GetCustomAttribute(); if (debugColor != null) @@ -138,22 +136,22 @@ namespace DCFApixels.DragonECS mainColor = debugColor.GetUnityColor(); } Color backgroundColor = mainColor * 0.3f + Color.white * 0.2f; - + EditorGUI.DrawRect(progressBar, backgroundColor); - + progressBar.yMin = progressBar.yMax - ((float)count / capacity) * progressBar.height; - + GUIStyle textStyle0 = new GUIStyle(EditorStyles.miniBoldLabel); textStyle0.alignment = TextAnchor.MiddleCenter; - + Color foregroundColor = mainColor; EditorGUI.DrawRect(progressBar, foregroundColor); GUI.Label(progressBar, count.ToString(), textStyle0); - + GUIStyle textStyle1 = new GUIStyle(EditorStyles.miniBoldLabel); 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; GUIStyle textStyle2 = new GUIStyle(EditorStyles.miniBoldLabel); textStyle2.wordWrap = true; @@ -161,7 +159,7 @@ namespace DCFApixels.DragonECS string name = EcsEditor.GetGenericName(pool.ComponentType); GUIContent label = new GUIContent(name, $"{name} e:{count}"); GUI.Label(AddMargin(position, -10f, 3f), label, textStyle2); - + } private Rect AddMargin(Rect rect, Vector2 value) diff --git a/src/EcsUnityConsts.cs b/src/EcsUnityConsts.cs index 5196c2e..72a6350 100644 --- a/src/EcsUnityConsts.cs +++ b/src/EcsUnityConsts.cs @@ -1,6 +1,6 @@ namespace DCFApixels.DragonECS { - public static class EcsUnityConsts + public static class EcsUnityConsts { public const string INFO_MARK = "[i]"; } diff --git a/src/EntityTemplate/EntityTemplate.cs b/src/EntityTemplate/EntityTemplate.cs index 837cae8..12a437f 100644 --- a/src/EntityTemplate/EntityTemplate.cs +++ b/src/EntityTemplate/EntityTemplate.cs @@ -21,7 +21,7 @@ namespace DCFApixels.DragonECS { if (item is ITemplateComponentGizmos g) g.OnGizmos(transform, ITemplateComponentGizmos.Mode.Always); - } + } } private void OnDrawGizmosSelected() { diff --git a/src/EntityTemplate/EntityTemplateEditor.cs b/src/EntityTemplate/EntityTemplateEditor.cs index 35d073f..c300991 100644 --- a/src/EntityTemplate/EntityTemplateEditor.cs +++ b/src/EntityTemplate/EntityTemplateEditor.cs @@ -9,7 +9,7 @@ namespace DCFApixels.DragonECS using UnityEditor; 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 TooltipIconRect = new Rect(0f, 0f, 15f, 15f); @@ -31,7 +31,7 @@ namespace DCFApixels.DragonECS removeButtonStyle = new GUIStyle(EditorStyles.linkLabel); removeButtonStyle.alignment = TextAnchor.MiddleCenter; - + removeButtonStyle.normal = tmpstylebase.normal; removeButtonStyle.hover = tmpStyle.normal; removeButtonStyle.active = tmpStyle.normal; @@ -44,7 +44,7 @@ namespace DCFApixels.DragonECS genericMenu = new GenericMenu(); var dummies = TemplateBrowsableTypeCache.Dummies; - foreach ( var dummy in dummies ) + foreach (var dummy in dummies) { string name, description; if (dummy is ITemplateComponentName browsableName) @@ -137,7 +137,7 @@ namespace DCFApixels.DragonECS private void DrawComponentData(SerializedProperty componentRefProp, int index) { ITemplateComponent browsable = componentRefProp.managedReferenceValue as ITemplateComponent; - if(browsable == null) + if (browsable == null) { DrawDamagedComponent(componentRefProp, index); return; @@ -173,7 +173,7 @@ namespace DCFApixels.DragonECS Color panelColor = customInitializer != null ? customInitializer.Color : EcsDebugUtility.GetColorRGB(initializerType).ToUnityColor(); GUILayout.BeginHorizontal(); - + GUILayout.BeginVertical(EcsEditor.GetStyle(panelColor, 0.2f)); EditorGUI.BeginChangeCheck(); @@ -198,7 +198,7 @@ namespace DCFApixels.DragonECS GUILayout.EndVertical(); GUILayout.Label("", GUILayout.Width(removeButtonRect.width)); - + if (GUI.Button(removeButtonRect, "x", removeButtonStyle)) OnRemoveComponentAt(index); diff --git a/src/EntityTemplate/ITemplate.cs b/src/EntityTemplate/ITemplate.cs index c331ec0..9a45baa 100644 --- a/src/EntityTemplate/ITemplate.cs +++ b/src/EntityTemplate/ITemplate.cs @@ -1,6 +1,4 @@ -using UnityEngine; - -namespace DCFApixels.DragonECS +namespace DCFApixels.DragonECS { public interface ITemplate { @@ -9,7 +7,7 @@ namespace DCFApixels.DragonECS public interface ITemplateInternal : ITemplate { - // internal ITemplateBrowsable[] Components { get; set; } + // internal ITemplateBrowsable[] Components { get; set; } internal string ComponentsPropertyName { get; } } diff --git a/src/EntityTemplate/TemplateComponent.cs b/src/EntityTemplate/TemplateComponent.cs index f9cb3c2..9837e67 100644 --- a/src/EntityTemplate/TemplateComponent.cs +++ b/src/EntityTemplate/TemplateComponent.cs @@ -1,5 +1,4 @@ -using DCFApixels.DragonECS.Editors; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -51,7 +50,7 @@ namespace DCFApixels.DragonECS int iBacktick = friendlyName.IndexOf('`'); if (iBacktick > 0) friendlyName = friendlyName.Remove(iBacktick); - + friendlyName += "/" + friendlyName; friendlyName += "<"; Type[] typeParameters = type.GetGenericArguments(); @@ -122,7 +121,7 @@ namespace DCFApixels.DragonECS Type interfaceType = typeof(ITemplateComponent); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { - var targetTypes = assembly.GetTypes().Where(type => !type.IsGenericType && (type.IsValueType|| type.IsClass) && type.GetCustomAttribute() != null); + var targetTypes = assembly.GetTypes().Where(type => !type.IsGenericType && (type.IsValueType || type.IsClass) && type.GetCustomAttribute() != null); types.AddRange(targetTypes.Where(type => interfaceType.IsAssignableFrom(type))); @@ -130,7 +129,7 @@ namespace DCFApixels.DragonECS { if (t.IsSubclassOf(typeof(TemplateComponentInitializer<>))) { - if(t.GetCustomAttribute() != null) + if (t.GetCustomAttribute() != null) types.Add(t); } } diff --git a/src/Extensions/EcsEntityConnect.cs b/src/Extensions/EcsEntityConnect.cs index a32f320..7ffe3c4 100644 --- a/src/Extensions/EcsEntityConnect.cs +++ b/src/Extensions/EcsEntityConnect.cs @@ -47,7 +47,7 @@ namespace DCFApixels.DragonECS 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(); s.unityGameObjects.Del(oldE); @@ -115,8 +115,8 @@ namespace DCFApixels.DragonECS GUILayout.Box("Connected", _greenStyle, GUILayout.ExpandWidth(true)); else 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); else EditorGUILayout.IntField(0); @@ -124,10 +124,10 @@ namespace DCFApixels.DragonECS base.OnInspectorGUI(); - if(GUILayout.Button("Autoset Templates")) + if (GUILayout.Button("Autoset Templates")) { Target.SetTemplates_Editor(Target.GetComponents()); - + EditorUtility.SetDirty(target); } if (GUILayout.Button("Autoset Templates Cascade")) diff --git a/src/Extensions/UnityGameObject.cs b/src/Extensions/UnityGameObject.cs index aaa8025..b1b9614 100644 --- a/src/Extensions/UnityGameObject.cs +++ b/src/Extensions/UnityGameObject.cs @@ -65,7 +65,7 @@ namespace DCFApixels.DragonECS entlong result = self.GetEntityLong(self.NewEmptyEntity()); GameObject newGameObject = new GameObject(name); newGameObject.AddComponent().ConnectWith(result); - // self.GetPool().Add(result.id) = + // self.GetPool().Add(result.id) = #if UNITY_EDITOR if (icon != GameObjectIcon.NONE) { diff --git a/src/Utils/BitMask.cs b/src/Utils/BitMask.cs index 7096bfe..17c9b07 100644 --- a/src/Utils/BitMask.cs +++ b/src/Utils/BitMask.cs @@ -25,7 +25,7 @@ namespace DCFApixels.DragonECS.Editors [MethodImpl(MethodImplOptions.AggressiveInlining)] set { - if(value) + if (value) _data[index >> OFFSET] |= (1 << (index & MOD_MASK)); else _data[index >> OFFSET] &= ~(1 << (index & MOD_MASK));