public override void Save()
{
if (this.isNulledOutReflexive == true)
return;
bool openedMap = false;
if (map.isOpen == false)
{
map.OpenMap(MapTypes.Internal);
openedMap = true;
}
map.BW.BaseStream.Position = this.offsetInMap;
try
{
uint intToShift = 1;
uint tempIntToWrite = 0;
for (int counter = 0; counter < this.bitCount; counter++)
{
if (this.Bits[counter] == true)
{
tempIntToWrite += intToShift;
}
intToShift <<= 1;
}
this.value = tempIntToWrite;
switch (this.bitCount)
{
case 8:
{
map.BW.Write(Convert.ToByte(this.value));
break;
}
case 16:
{
map.BW.Write(Convert.ToUInt16(this.value));
break;
}
case 32:
{
map.BW.Write(Convert.ToUInt32(this.value));
break;
}
}
}
catch
{
MessageBox.Show("Man the hatches! Error in writing bitmask info to map!");
}
if (openedMap == true)
map.CloseMap();
}