2D Physics

This commit is contained in:
Simon Lübeß
2022-10-08 16:56:15 +02:00
parent 202083930a
commit a42544f171
12 changed files with 475 additions and 13 deletions
+14
View File
@@ -63,6 +63,8 @@ namespace GlitchyEngine.World
}
}
public TransformComponent* Transform => GetComponent<TransformComponent>();
public T* AddComponent<T>(T value = T()) where T: struct, new
{
Log.EngineLogger.AssertDebug(!HasComponent<T>(), scope $"Entity already has component.");
@@ -85,6 +87,18 @@ namespace GlitchyEngine.World
{
return _scene._ecsWorld.HasComponent<T>(_entity);
}
public bool TryGetComponent<T>(out T* component) where T: struct, new
{
if (HasComponent<T>())
{
component = GetComponent<T>();
return true;
}
component = null;
return false;
}
public void RemoveComponent<T>() where T: struct, new
{