mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
add set world component method
This commit is contained in:
parent
12efd35595
commit
520eb0b597
@ -158,6 +158,21 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
return (TExecutor)result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WorldComponents
|
||||
public void Set<T>(T component) where T : class
|
||||
{
|
||||
int index = WorldMetaStorage.GetWorldComponentID<T>(_worldTypeID);
|
||||
if (index >= _components.Length)
|
||||
Array.Resize(ref _components, _components.Length << 1);
|
||||
if (component == null)
|
||||
{
|
||||
_components[index] = component;
|
||||
if (component is IEcsWorldComponent intr)
|
||||
intr.Init(this);
|
||||
}
|
||||
}
|
||||
public T Get<T>() where T : class, new()
|
||||
{
|
||||
int index = WorldMetaStorage.GetWorldComponentID<T>(_worldTypeID);
|
||||
|
Loading…
Reference in New Issue
Block a user