2025-01-08 18:46:17 +00:00
|
|
|
using Godot;
|
|
|
|
|
|
|
|
using System;
|
2025-04-23 12:00:43 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2025-01-08 18:46:17 +00:00
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
|
|
|
public class Bytes
|
|
|
|
{
|
|
|
|
|
|
|
|
public static byte SetBit( byte value, int position )
|
|
|
|
{
|
|
|
|
return (byte) ( ( 1 << position ) | value );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static byte UnsetBit( byte value, int position )
|
|
|
|
{
|
|
|
|
var mask = 1 << position;
|
|
|
|
var invertedMask = ~mask;
|
|
|
|
|
|
|
|
return (byte)( value & invertedMask );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool IsBitSet( byte value, int position )
|
|
|
|
{
|
|
|
|
var mask = 1 << position;
|
|
|
|
return ( mask & value ) == mask ;
|
|
|
|
}
|
2025-04-23 12:00:43 +00:00
|
|
|
|
|
|
|
public static List<byte> Convert( List<float> floats )
|
|
|
|
{
|
|
|
|
var list = new List<byte>();
|
|
|
|
floats.ForEach( f => list.AddRange( BitConverter.GetBytes( f ) ) );
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<byte> Convert( List<int> ints )
|
|
|
|
{
|
|
|
|
var list = new List<byte>();
|
|
|
|
ints.ForEach( i => list.AddRange( BitConverter.GetBytes( i ) ) );
|
|
|
|
return list;
|
|
|
|
}
|
2025-01-08 18:46:17 +00:00
|
|
|
}
|
|
|
|
}
|