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
@ -14,7 +14,7 @@ namespace DCFApixels.DragonECS
|
||||
public DebugColorAttribute(DebugColor color) => this.color = new Color((int)color);
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Pack = 1, Size = 4)]
|
||||
internal readonly struct Color
|
||||
internal readonly struct Color
|
||||
{
|
||||
[FieldOffset(0)] public readonly int full;
|
||||
[FieldOffset(3)] public readonly byte r;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -42,6 +42,6 @@
|
||||
#endif
|
||||
return _filteredGroup.Readonly;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
using DCFApixels.DragonECS.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
|
@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
//TODO этот класс требует переработки, изначально такая конструкция имела хорошую производительность, но сейчас он слишком раздулся
|
||||
internal static class WorldMetaStorage
|
||||
internal static class WorldMetaStorage
|
||||
{
|
||||
private static int _tokenCount = 0;
|
||||
private static List<ResizerBase> _resizers = new List<ResizerBase>();
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user