mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Kind of prevent creating invalid colliders sometimes
This commit is contained in:
@@ -640,8 +640,9 @@ namespace GlitchyEngine.World
|
||||
public float Restitution = 0.0f;
|
||||
public float RestitutionThreshold = 0.5f;
|
||||
|
||||
public float2[8] Vertices = .();
|
||||
public int8 VertexCount = 3;
|
||||
// initialize with a well formed shape
|
||||
public float2[8] Vertices = .(.(-0.5f, -0.5f), .(0.5f, -0.5f), .(0.5f, 0.5f), .(-0.5f, 0.5f),);
|
||||
public int8 VertexCount = 4;
|
||||
|
||||
private int _runtimeFixture = 0;
|
||||
|
||||
|
||||
@@ -103,6 +103,19 @@ namespace GlitchyEngine.World
|
||||
return component;
|
||||
}
|
||||
|
||||
public T* AddComponent<T>(in T value) where T: struct, new, ICopyComponent<T>
|
||||
{
|
||||
Log.EngineLogger.AssertDebug(!HasComponent<T>(), scope $"Entity already has component.");
|
||||
|
||||
T* component = _scene._ecsWorld.AssignComponent<T>(_entity, value);
|
||||
|
||||
T.Copy(&value, component);
|
||||
|
||||
_scene.[Friend]OnComponentAdded(this, typeof(T), component);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
public T* GetComponent<T>() where T: struct, new
|
||||
{
|
||||
Log.EngineLogger.AssertDebug(HasComponent<T>(), "Entity doesn't have component!");
|
||||
|
||||
@@ -240,12 +240,14 @@ namespace GlitchyEngine.World
|
||||
|
||||
if (!target.TryGetComponent<TComponent>(out targetComponent))
|
||||
{
|
||||
targetComponent = target.AddComponent<TComponent>();
|
||||
targetComponent = target.AddComponent<TComponent>(*sourceComponent);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
TComponent.Copy(sourceComponent, targetComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the scene.
|
||||
|
||||
Reference in New Issue
Block a user