void ClearOwnerOf(int obj)
{
// Stop the associated object script code (else crashes might occurs)
StopObjectScriptCore((ushort)obj);
if (GetOwnerCore(obj) == OwnerRoom)
{
for (var i = 0; i < _objs.Length; i++)
{
if (_objs[i].Number == obj && (_objs[i].FloatingObjectIndex != 0))
{
// Removing an flObject from a room means we can nuke it
// _res->nukeResource(rtFlObject, _objs[i].fl_object_index);
_objs[i] = new ObjectData();
}
}
}
else
{
// Alternatively, scan the inventory to see if the object is in there...
for (int i = 0; i < _resManager.NumInventory; i++)
{
if (_inventory[i] == obj)
{
// Found the object! Nuke it from the inventory.
_inventory[i] = 0;
// Now fill up the gap removing the object from the inventory created.
for (i = 0; i < _resManager.NumInventory - 1; i++)
{
if (_inventory[i] == 0 && _inventory[i + 1] != 0)
{
_inventory[i] = _inventory[i + 1];
_invData[i] = _invData[i + 1];
_inventory[i + 1] = 0;
// FIXME FIXME FIXME: This is incomplete, as we do not touch flags, status... BUG
// TODO:
//_res->_types[rtInventory][i]._address = _res->_types[rtInventory][i + 1]._address;
//_res->_types[rtInventory][i]._size = _res->_types[rtInventory][i + 1]._size;
//_res->_types[rtInventory][i + 1]._address = NULL;
//_res->_types[rtInventory][i + 1]._size = 0;
}
}
break;
}
}
}
}
}