mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Run default constructor when assigning component
This commit is contained in:
@@ -145,7 +145,7 @@ namespace GlitchyEngine.World
|
||||
/**
|
||||
* Assigns a component of type T to the specified entity and returns it.
|
||||
*/
|
||||
public T* AssignComponent<T>(Entity entity) where T : struct
|
||||
public T* AssignComponent<T>(Entity entity) where T : struct, new
|
||||
{
|
||||
if(entity.Index > _entities.Count)
|
||||
return null;
|
||||
@@ -167,8 +167,12 @@ namespace GlitchyEngine.World
|
||||
// return null;
|
||||
|
||||
listEntity.ComponentMask[entry.Id] = true;
|
||||
|
||||
return (.)entry.Pool.Get(entity.Index);
|
||||
|
||||
T* component = (T*)entry.Pool.Get(entity.Index);
|
||||
|
||||
*component = T();
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user