A Smoll game engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.1 KiB

using System.Collections.Specialized;
using System.Numerics;
using Raylib_cs;
namespace Smoll.Ex1 {
class CrosshairGizmoComponent : Smoll.Component {
Transform2DComponent? ownerTransform;
public CrosshairGizmoComponent()
{}
public override void OnAttached() {
ownerTransform = owner.GetComponent<Transform2DComponent>();
}
public override void Draw(Smoll.Layer.DrawMode drawMode) {
if(drawMode == Layer.DrawMode.Debug) {
ownerTransform ??= owner.GetComponent<Transform2DComponent>();
ownerTransform ??= new Transform2DComponent();
var tr = ownerTransform.AbsoluteTransform();
Raylib.DrawCircleLines((int)tr.position.Real, (int)tr.position.Imaginary, 5.5f, Color.Black);
Raylib.DrawLine(
(int)tr.position.Real,
(int)tr.position.Imaginary-10,
(int)tr.position.Real,
(int)tr.position.Imaginary+10,
Color.Lime);
Raylib.DrawLine(
(int)tr.position.Real-10,
(int)tr.position.Imaginary,
(int)tr.position.Real+10,
(int)tr.position.Imaginary,
Color.Red);
Raylib.DrawText(
tr.angle.ToString(),
(int)tr.position.Real+7,
(int)tr.position.Imaginary+7,
14,
Color.Magenta
);
Raylib.DrawText(
tr.position.Real.ToString(),
(int)tr.position.Real+7,
(int)tr.position.Imaginary+23,
14,
Color.Red
);
Raylib.DrawText(
tr.position.Imaginary.ToString(),
(int)tr.position.Real+7,
(int)tr.position.Imaginary+39,
14,
Color.Lime
);
}
}
}
}