mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-19 02:24:37 +08:00
fix
This commit is contained in:
parent
266da2d85d
commit
21ee6aee00
@ -49,6 +49,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
private static string AutoToString(object target, Type type, bool isWriteName)
|
private static string AutoToString(object target, Type type, bool isWriteName)
|
||||||
{
|
{
|
||||||
|
//TODO сделать специальный вывод в виде названий констант для Enum-ов
|
||||||
var fields = type.GetFields(RFL_FLAGS);
|
var fields = type.GetFields(RFL_FLAGS);
|
||||||
string[] values = new string[fields.Length];
|
string[] values = new string[fields.Length];
|
||||||
for (int i = 0; i < fields.Length; i++)
|
for (int i = 0; i < fields.Length; i++)
|
||||||
|
@ -71,16 +71,18 @@ namespace DCFApixels.DragonECS
|
|||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
_listeners.InvokeOnAdd(entityID);
|
_listeners.InvokeOnAdd(entityID);
|
||||||
if (isMain)
|
if (isMain)
|
||||||
|
{
|
||||||
component.OnAddToPool(_source.GetEntityLong(entityID));
|
component.OnAddToPool(_source.GetEntityLong(entityID));
|
||||||
|
}
|
||||||
_items[itemIndex] = component;
|
_items[itemIndex] = component;
|
||||||
_entities[itemIndex] = entityID;
|
_entities[itemIndex] = entityID;
|
||||||
}
|
}
|
||||||
public void Add(int entityID, T component)
|
public void Add(int entityID, T component)
|
||||||
{
|
{
|
||||||
HybridMapping mapping = _source.GetHybridMapping(component.GetType());
|
HybridMapping mapping = _source.GetHybridMapping(component.GetType());
|
||||||
mapping.GetTargetTypePool().AddRefInternal(entityID, component, false);
|
mapping.GetTargetTypePool().AddRefInternal(entityID, component, true);
|
||||||
foreach (var pool in mapping.GetPools())
|
foreach (var pool in mapping.GetPools())
|
||||||
pool.AddRefInternal(entityID, component, true);
|
pool.AddRefInternal(entityID, component, false);
|
||||||
}
|
}
|
||||||
public void Set(int entityID, T component)
|
public void Set(int entityID, T component)
|
||||||
{
|
{
|
||||||
@ -122,9 +124,13 @@ namespace DCFApixels.DragonECS
|
|||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
T component = _items[itemIndex];
|
T component = _items[itemIndex];
|
||||||
if (isMain)
|
if (isMain)
|
||||||
|
{
|
||||||
component.OnDelFromPool(_source.GetEntityLong(entityID));
|
component.OnDelFromPool(_source.GetEntityLong(entityID));
|
||||||
|
}
|
||||||
if (_recycledItemsCount >= _recycledItems.Length)
|
if (_recycledItemsCount >= _recycledItems.Length)
|
||||||
|
{
|
||||||
Array.Resize(ref _recycledItems, _recycledItems.Length << 1);
|
Array.Resize(ref _recycledItems, _recycledItems.Length << 1);
|
||||||
|
}
|
||||||
_recycledItems[_recycledItemsCount++] = itemIndex;
|
_recycledItems[_recycledItemsCount++] = itemIndex;
|
||||||
_mapping[entityID] = 0;
|
_mapping[entityID] = 0;
|
||||||
_entities[itemIndex] = 0;
|
_entities[itemIndex] = 0;
|
||||||
@ -136,9 +142,11 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
var component = Get(entityID);
|
var component = Get(entityID);
|
||||||
HybridMapping mapping = _source.GetHybridMapping(component.GetType());
|
HybridMapping mapping = _source.GetHybridMapping(component.GetType());
|
||||||
mapping.GetTargetTypePool().DelInternal(entityID, false);
|
mapping.GetTargetTypePool().DelInternal(entityID, true);
|
||||||
foreach (var pool in mapping.GetPools())
|
foreach (var pool in mapping.GetPools())
|
||||||
pool.DelInternal(entityID, true);
|
{
|
||||||
|
pool.DelInternal(entityID, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void TryDel(int entityID)
|
public void TryDel(int entityID)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user