simple refactoring

This commit is contained in:
Mikhail 2023-12-20 23:21:10 +08:00
parent 4b0d188955
commit e7c623daf8
7 changed files with 20 additions and 24 deletions

View File

@ -143,7 +143,7 @@ namespace DCFApixels.DragonECS
foreach (var id in maskInc)
{
var bit = EcsMaskBit.FromID(id);
if(!r.TryAdd(bit.chankIndex, bit.mask))
if (!r.TryAdd(bit.chankIndex, bit.mask))
r[bit.chankIndex] = r[bit.chankIndex] | bit.mask;
}
EcsMaskBit[] incMasks = r.Select(o => new EcsMaskBit(o.Key, o.Value)).ToArray();

View File

@ -162,7 +162,7 @@ namespace DCFApixels.DragonECS
private static TInterface Instantiate(EcsPipeline source, TInterface[] targets, bool isHasFilter, object filter)
{
if(_subclass == null)
if (_subclass == null)
{
Type interfaceType = typeof(TInterface);
if (interfaceType.TryGetCustomAttribute(out BindWithEcsRunnerAttribute atr))
@ -333,7 +333,7 @@ namespace DCFApixels.DragonECS
public static IEnumerable<Type> GetEcsProcessInterfaces(this Type self)
{
return self.GetInterfaces().Where(o=> o.IsEcsProcessInterface());
return self.GetInterfaces().Where(o => o.IsEcsProcessInterface());
}
#endregion

View File

@ -1,7 +1,4 @@
using DCFApixels.DragonECS.Utils;
using System;
namespace DCFApixels.DragonECS
namespace DCFApixels.DragonECS
{
public abstract partial class EcsWorld
{

View File

@ -146,7 +146,7 @@ namespace DCFApixels.DragonECS
#region Entity
public int NewEntity()
{
if(_freeSpace <= 1 && _delEntBufferCount > _delEntBufferMinCount)
if (_freeSpace <= 1 && _delEntBufferCount > _delEntBufferMinCount)
ReleaseDelEntityBuffer();
int entityID = _entityDispenser.GetFree();

View File

@ -70,7 +70,7 @@ namespace DCFApixels.DragonECS
}
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
_listeners.InvokeOnAdd(entityID);
if(isMain)
if (isMain)
component.OnAddToPool(_source.GetEntityLong(entityID));
_items[itemIndex] = component;
_entities[itemIndex] = entityID;
@ -84,7 +84,7 @@ namespace DCFApixels.DragonECS
}
public void Set(int entityID, T component)
{
if(Has(entityID))
if (Has(entityID))
Del(entityID);
Add(entityID, component);
}
@ -121,7 +121,7 @@ namespace DCFApixels.DragonECS
#endif
ref int itemIndex = ref _mapping[entityID];
T component = _items[itemIndex];
if(isMain)
if (isMain)
component.OnDelFromPool(_source.GetEntityLong(entityID));
if (_recycledItemsCount >= _recycledItems.Length)
Array.Resize(ref _recycledItems, _recycledItems.Length << 1);
@ -296,7 +296,7 @@ namespace DCFApixels.DragonECS
private Dictionary<Type, HybridMapping> _hybridMapping = new Dictionary<Type, HybridMapping>();
internal HybridMapping GetHybridMapping(Type type)
{
if(!_hybridMapping.TryGetValue(type, out HybridMapping mapping))
if (!_hybridMapping.TryGetValue(type, out HybridMapping mapping))
{
mapping = new HybridMapping(this, type);
_hybridMapping.Add(type, mapping);
@ -346,17 +346,17 @@ namespace DCFApixels.DragonECS
_source = source;
_type = type;
_relatedPools = new List<IEcsHybridPoolInternal>();
_sourceForReflection = new object[]{ source };
_sourceForReflection = new object[] { source };
_targetTypePool = CreateHybridPool(type);
foreach (var item in type.GetInterfaces())
{
if(IsEcsHybridComponentType(item))
if (IsEcsHybridComponentType(item))
{
_relatedPools.Add(CreateHybridPool(item));
}
}
Type baseType = type.BaseType;
while(baseType != typeof(object) && IsEcsHybridComponentType(baseType))
while (baseType != typeof(object) && IsEcsHybridComponentType(baseType))
{
_relatedPools.Add(CreateHybridPool(baseType));
baseType = baseType.BaseType;

View File

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