You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
/******************************************************************************/
|
|
|
|
|
/*
|
|
|
|
|
Project - MudBun
|
|
|
|
|
Publisher - Long Bunny Labs
|
|
|
|
|
http://LongBunnyLabs.com
|
|
|
|
|
Author - Ming-Lun "Allen" Chou
|
|
|
|
|
http://AllenChou.net
|
|
|
|
|
*/
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace MudBun
|
|
|
|
|
{
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 0)]
|
|
|
|
|
[Serializable]
|
|
|
|
|
public struct Bits32
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private uint m_bits;
|
|
|
|
|
public uint RawValue { get => m_bits; set => m_bits = value; }
|
|
|
|
|
|
|
|
|
|
public Bits32(uint bits = 0) { m_bits = bits; }
|
|
|
|
|
|
|
|
|
|
public void SetAllBits() { m_bits = ~0u; }
|
|
|
|
|
public void ClearAllBits() { m_bits = 0; }
|
|
|
|
|
|
|
|
|
|
public void AssignBit(int index, bool value)
|
|
|
|
|
{
|
|
|
|
|
if (value)
|
|
|
|
|
m_bits |= (1u << index);
|
|
|
|
|
else
|
|
|
|
|
m_bits &= ~(1u << index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetBit(int index)
|
|
|
|
|
{
|
|
|
|
|
AssignBit(index, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearBit(int index)
|
|
|
|
|
{
|
|
|
|
|
AssignBit(index, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsBitSet(int index)
|
|
|
|
|
{
|
|
|
|
|
return (m_bits & (1u << index)) != 0u;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|