From fb6c60cfc2caec9a8fa283a8b81daeebfa7c5644 Mon Sep 17 00:00:00 2001 From: Ben Parsons <9parsonsb@gmail.com> Date: Sun, 5 Dec 2021 01:46:54 +1100 Subject: [PATCH] Split CBool from utils --- Raylib-cs/types/native/CBool.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Raylib-cs/types/native/CBool.cs diff --git a/Raylib-cs/types/native/CBool.cs b/Raylib-cs/types/native/CBool.cs new file mode 100644 index 0000000..3fc3b06 --- /dev/null +++ b/Raylib-cs/types/native/CBool.cs @@ -0,0 +1,30 @@ +using System; +using System.Runtime.InteropServices; + +namespace Raylib_cs; + +[StructLayout(LayoutKind.Sequential)] +public readonly struct CBool +{ + private readonly byte value; + + private CBool(bool value) + { + this.value = Convert.ToByte(value); + } + + public static implicit operator CBool(bool value) + { + return new CBool(value); + } + + public static implicit operator bool(CBool x) + { + return Convert.ToBoolean(x.value); + } + + public override string ToString() + { + return Convert.ToBoolean(value).ToString(); + } +} \ No newline at end of file