Interface ILootableCorpse
A dead NPC that players may loot: an interactable whose contents were rolled once, at death, and are shared between everyone who earned rights to them.
public interface ILootableCorpse : IInteractable, ISceneObject
- Inherited Members
Remarks
The pile is shared rather than instanced. Taking a slot empties it for every viewer, which is why the server keeps the viewer list here on the corpse itself: the moment one looter takes something, everyone else looking at the same corpse has to be told.
Slots are never compacted. An emptied slot stays as a hole so that a slot index another client is already holding never comes to mean a different item — which is exactly the race that compaction would create between one player's take and another's in-flight request.
Properties
HasLoot
True while the corpse still holds an item or any currency.
bool HasLoot { get; }
Property Value
IsCorpse
True while the NPC is dead and has not yet decayed.
bool IsCorpse { get; }
Property Value
LootCurrency
Currency remaining on the corpse.
long LootCurrency { get; }
Property Value
LootItems
The corpse's item slots. Emptied slots read null and keep their index.
IReadOnlyList<Item> LootItems { get; }
Property Value
LootViewers
Connections currently viewing this corpse's loot.
IReadOnlyCollection<NetworkConnection> LootViewers { get; }
Property Value
- IReadOnlyCollection<NetworkConnection>
Methods
AddLootViewer(NetworkConnection)
Records that a connection has the loot window open on this corpse.
void AddLootViewer(NetworkConnection connection)
Parameters
connectionNetworkConnectionThe viewing connection.
IsEligibleLooter(long)
Returns true if the given character earned loot rights to this corpse.
bool IsEligibleLooter(long characterID)
Parameters
characterIDlongThe character ID to test.
Returns
RemoveLootViewer(NetworkConnection)
Records that a connection has closed the loot window on this corpse.
void RemoveLootViewer(NetworkConnection connection)
Parameters
connectionNetworkConnectionThe connection that closed it.
ReturnLootCurrency(long)
Puts currency back onto the corpse after a failed grant.
void ReturnLootCurrency(long amount)
Parameters
amountlongThe amount to restore.
ReturnLootItem(Item, int)
Puts an item back into a slot it was taken from.
bool ReturnLootItem(Item item, int slot)
Parameters
Returns
- bool
True when the item was restored.
Remarks
The take must be undoable because granting can fail after the corpse has already given the item up — a full inventory being the ordinary case. Without a way back, that item is destroyed rather than left on the corpse.
TryTakeLootCurrency(long, out long)
Takes up to maximum currency from the corpse.
bool TryTakeLootCurrency(long maximum, out long amount)
Parameters
maximumlongThe most the caller can accept. Must be positive.
amountlongReceives the amount actually taken.
Returns
- bool
True when any currency was taken.
Remarks
Capped rather than all-or-nothing because the destination has a ceiling: a character's currency is an int, and a taker already near that ceiling must be able to take what fits and leave the rest on the body rather than either overflowing or being refused.
TryTakeLootItem(int, out Item)
Removes the item in the given slot and hands it to the caller.
bool TryTakeLootItem(int slot, out Item item)
Parameters
Returns
- bool
True when a item was removed.
Events
OnCorpseExpired
Raised on the server when the corpse is about to leave the world, so open loot windows can be closed before the scene object ID they refer to stops resolving.
event Action<ILootableCorpse> OnCorpseExpired