refactoring

This commit is contained in:
Mikhail 2023-06-22 14:39:12 +08:00
parent 2b5cc8b27b
commit 6494030509
7 changed files with 11 additions and 15 deletions

View File

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace DCFApixels.DragonECS
{
@ -105,7 +103,7 @@ namespace DCFApixels.DragonECS
{
foreach (var word in nameWords)
{
if(!_words.TryGetValue(word, out WordColor color))
if (!_words.TryGetValue(word, out WordColor color))
{
color = new WordColor();
_words.Add(word, color);
@ -143,7 +141,7 @@ namespace DCFApixels.DragonECS
private static DebugColorAttribute.Color CalcNameColorFor(Type type)
{
Type targetType = type.IsGenericType ? type.GetGenericTypeDefinition() : type;
if(!_names.TryGetValue(targetType, out NameColor nameColor))
if (!_names.TryGetValue(targetType, out NameColor nameColor))
{
nameColor = new NameColor(SplitString(targetType.Name));
_names.Add(targetType, nameColor);
@ -186,7 +184,7 @@ namespace DCFApixels.DragonECS
public static bool TryGetColorRGB(Type type, out (byte, byte, byte) color)
{
var atr = type.GetCustomAttribute<DebugColorAttribute>();
if(atr != null)
if (atr != null)
{
color = (atr.r, atr.g, atr.b);
return true;

View File

@ -272,7 +272,7 @@ namespace DCFApixels.DragonECS
}
public int Bake(ref int[] entities)
{
if(entities.Length < _count)
if (entities.Length < _count)
entities = new int[_count];
Array.Copy(_dense, 1, entities, 0, _count);
return _count;

View File

@ -2,7 +2,6 @@
using DCFApixels.DragonECS.Utils;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@ -67,7 +66,7 @@ namespace DCFApixels.DragonECS
ref int itemIndex = ref _mapping[worldID];
if (itemIndex <= 0)
{
if(_recycledItemsCount > 0)
if (_recycledItemsCount > 0)
{
_count++;
itemIndex = _recycledItems[--_recycledItemsCount];
@ -84,7 +83,7 @@ namespace DCFApixels.DragonECS
private static void Release(int worldID)
{
ref int itemIndex = ref _mapping[worldID];
if(itemIndex != 0)
if (itemIndex != 0)
{
_interface.OnDestroy(ref _items[itemIndex], Worlds[worldID]);
_recycledItems[_recycledItemsCount++] = itemIndex;

View File

@ -42,6 +42,6 @@
#endif
return _filteredGroup.Readonly;
}
#endregion
#endregion
}
}

View File

@ -1,7 +1,6 @@
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
namespace DCFApixels.DragonECS

View File

@ -81,7 +81,7 @@ namespace DCFApixels.DragonECS
}
else
{
if(result.Length < targetSize)
if (result.Length < targetSize)
{
int oldSize = result.Length;
Array.Resize(ref result, targetSize);
@ -290,7 +290,7 @@ namespace DCFApixels.DragonECS
public bool IsDeclaredWorldComponentType(Type type) => _declaredWorldComponentTypes.ContainsKey(type);
public int GetWorldComponentID(Type type)
{
if(!_declaredWorldComponentTypes.TryGetValue(type, out int id))
if (!_declaredWorldComponentTypes.TryGetValue(type, out int id))
id = DeclareWorldComponentType(type);
return id;
}