2024-01-24 19:21:53 +03:00
|
|
|
using System;
|
|
|
|
|
|
|
|
using Syntriax.Engine.Core;
|
|
|
|
using Syntriax.Engine.Core.Abstract;
|
|
|
|
using Syntriax.Engine.Physics2D.Abstract;
|
|
|
|
using Syntriax.Engine.Physics2D.Primitives;
|
|
|
|
|
|
|
|
namespace Syntriax.Engine.Physics2D;
|
|
|
|
|
|
|
|
public class Collider2DShapeBehaviour : BehaviourOverride, IShapeCollider2D
|
|
|
|
{
|
|
|
|
public Action<ICollider2D, ICollider2D>? OnCollisionPreResolve { get; set; } = null;
|
|
|
|
public Action<ICollider2D, ICollider2D>? OnCollisionResolved { get; set; } = null;
|
|
|
|
|
|
|
|
|
|
|
|
public Shape ShapeWorld => _shapeWorld;
|
|
|
|
public Shape ShapeLocal { get; set; } = new([new(1f, 1f), new(-1f, 1f), new(-1f, -1f), new(1f, -1f)]);
|
|
|
|
public IRigidBody2D? RigidBody2D { get; set; } = null;
|
|
|
|
|
|
|
|
protected Shape _shapeWorld = new([new(1f, 1f), new(-1f, 1f), new(-1f, -1f), new(1f, -1f)]);
|
|
|
|
|
2024-01-25 12:42:16 +03:00
|
|
|
ITransform IAssignableTransform.Transform => Transform;
|
|
|
|
Action<IAssignableTransform>? IAssignableTransform.OnTransformAssigned { get => GameObject.OnTransformAssigned; set => GameObject.OnTransformAssigned = value; }
|
|
|
|
bool IAssignableTransform.Assign(ITransform transform) => GameObject.Assign(transform);
|
2024-01-24 19:21:53 +03:00
|
|
|
|
|
|
|
public virtual void Recalculate() => Transform.TransformShape(ShapeLocal, ref _shapeWorld);
|
|
|
|
}
|