mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
refactoring
This commit is contained in:
parent
2b5cc8b27b
commit
6494030509
@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
@ -105,7 +103,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
foreach (var word in nameWords)
|
foreach (var word in nameWords)
|
||||||
{
|
{
|
||||||
if(!_words.TryGetValue(word, out WordColor color))
|
if (!_words.TryGetValue(word, out WordColor color))
|
||||||
{
|
{
|
||||||
color = new WordColor();
|
color = new WordColor();
|
||||||
_words.Add(word, color);
|
_words.Add(word, color);
|
||||||
@ -143,7 +141,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private static DebugColorAttribute.Color CalcNameColorFor(Type type)
|
private static DebugColorAttribute.Color CalcNameColorFor(Type type)
|
||||||
{
|
{
|
||||||
Type targetType = type.IsGenericType ? type.GetGenericTypeDefinition() : 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));
|
nameColor = new NameColor(SplitString(targetType.Name));
|
||||||
_names.Add(targetType, nameColor);
|
_names.Add(targetType, nameColor);
|
||||||
@ -186,7 +184,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public static bool TryGetColorRGB(Type type, out (byte, byte, byte) color)
|
public static bool TryGetColorRGB(Type type, out (byte, byte, byte) color)
|
||||||
{
|
{
|
||||||
var atr = type.GetCustomAttribute<DebugColorAttribute>();
|
var atr = type.GetCustomAttribute<DebugColorAttribute>();
|
||||||
if(atr != null)
|
if (atr != null)
|
||||||
{
|
{
|
||||||
color = (atr.r, atr.g, atr.b);
|
color = (atr.r, atr.g, atr.b);
|
||||||
return true;
|
return true;
|
||||||
|
@ -272,7 +272,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public int Bake(ref int[] entities)
|
public int Bake(ref int[] entities)
|
||||||
{
|
{
|
||||||
if(entities.Length < _count)
|
if (entities.Length < _count)
|
||||||
entities = new int[_count];
|
entities = new int[_count];
|
||||||
Array.Copy(_dense, 1, entities, 0, _count);
|
Array.Copy(_dense, 1, entities, 0, _count);
|
||||||
return _count;
|
return _count;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using DCFApixels.DragonECS.Utils;
|
using DCFApixels.DragonECS.Utils;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ namespace DCFApixels.DragonECS
|
|||||||
ref int itemIndex = ref _mapping[worldID];
|
ref int itemIndex = ref _mapping[worldID];
|
||||||
if (itemIndex <= 0)
|
if (itemIndex <= 0)
|
||||||
{
|
{
|
||||||
if(_recycledItemsCount > 0)
|
if (_recycledItemsCount > 0)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
itemIndex = _recycledItems[--_recycledItemsCount];
|
itemIndex = _recycledItems[--_recycledItemsCount];
|
||||||
@ -84,7 +83,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private static void Release(int worldID)
|
private static void Release(int worldID)
|
||||||
{
|
{
|
||||||
ref int itemIndex = ref _mapping[worldID];
|
ref int itemIndex = ref _mapping[worldID];
|
||||||
if(itemIndex != 0)
|
if (itemIndex != 0)
|
||||||
{
|
{
|
||||||
_interface.OnDestroy(ref _items[itemIndex], Worlds[worldID]);
|
_interface.OnDestroy(ref _items[itemIndex], Worlds[worldID]);
|
||||||
_recycledItems[_recycledItemsCount++] = itemIndex;
|
_recycledItems[_recycledItemsCount++] = itemIndex;
|
||||||
|
@ -42,6 +42,6 @@
|
|||||||
#endif
|
#endif
|
||||||
return _filteredGroup.Readonly;
|
return _filteredGroup.Readonly;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using DCFApixels.DragonECS.Internal;
|
using DCFApixels.DragonECS.Internal;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
|
@ -81,7 +81,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(result.Length < targetSize)
|
if (result.Length < targetSize)
|
||||||
{
|
{
|
||||||
int oldSize = result.Length;
|
int oldSize = result.Length;
|
||||||
Array.Resize(ref result, targetSize);
|
Array.Resize(ref result, targetSize);
|
||||||
@ -290,7 +290,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsDeclaredWorldComponentType(Type type) => _declaredWorldComponentTypes.ContainsKey(type);
|
public bool IsDeclaredWorldComponentType(Type type) => _declaredWorldComponentTypes.ContainsKey(type);
|
||||||
public int GetWorldComponentID(Type type)
|
public int GetWorldComponentID(Type type)
|
||||||
{
|
{
|
||||||
if(!_declaredWorldComponentTypes.TryGetValue(type, out int id))
|
if (!_declaredWorldComponentTypes.TryGetValue(type, out int id))
|
||||||
id = DeclareWorldComponentType(type);
|
id = DeclareWorldComponentType(type);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user