Syntriax.Engine/Engine.Physics2D/Collider2DCircleBehaviour.cs

27 lines
1.1 KiB
C#

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 Collider2DCircleBehaviour : BehaviourOverride, ICircleCollider2D
{
public Action<ICollider2D, ICollider2D>? OnCollisionPreResolve { get; set; } = null;
public Action<ICollider2D, ICollider2D>? OnCollisionResolved { get; set; } = null;
public Circle CircleWorld { get; protected set; } = new(Vector2D.Zero, 1f);
public Circle CircleLocal { get; set; } = new(Vector2D.Zero, 1f);
public IRigidBody2D? RigidBody2D { get; set; } = null;
ITransform IAssignableTransform.Transform => Transform;
Action<IAssignableTransform>? IAssignableTransform.OnTransformAssigned { get => GameObject.OnTransformAssigned; set => GameObject.OnTransformAssigned = value; }
bool IAssignableTransform.Assign(ITransform transform) => GameObject.Assign(transform);
public virtual void Recalculate() => CircleWorld = Transform.TransformCircle(CircleLocal).Displace(Transform.Position);
}