Files
7d2dXG/XG-Rebirth/Mods/0A-KFCommonUtilityLib/KFAttached/RigAdaptors/Utils/InventorySlotGurad.cs
2025-05-30 00:19:27 +09:30

26 lines
684 B
C#

public class InventorySlotGurad
{
public int Slot { get; private set; } = -1;
#if NotEditor
public bool IsValid(EntityAlive entity)
{
if (entity && entity.inventory != null)
{
if (Slot < 0)
{
Slot = entity.inventory.holdingItemIdx;
return true;
}
if (Slot != entity.inventory.holdingItemIdx)
{
Log.Warning($"trying to set ammo for slot {Slot} while holding slot {entity.inventory.holdingItemIdx} on entity {entity.entityId}!");
return false;
}
return true;
}
return false;
}
#endif
}