class_name SimLoot extends RefCounted ## An item lying on the ground in one [SimWorld]. ## ## Ground loot does not move, so unlike bullets it needs no event stream: it ## rides the snapshot alongside enemies and is re-sent 20 times a second. That ## also means a lost packet costs nothing, which a spawn-once event could not ## claim. var id: int = 0 var item: StringName = &"" var pos := Vector2.ZERO ## 0 means world-shared: everyone sees it, the first to reach it takes it. ## Otherwise the ONLY peer that may see or take it -- the server filters it out ## of every other snapshot, so instancing is enforced on the wire and not by ## asking the client to be polite. var owner_peer: int = 0 ## World tick it appeared, used only to decide what to evict when an instance ## somehow accumulates more loot than it should hold. var born_tick: int = 0 ## Whether [param peer_id] is allowed to see and take this. func visible_to(peer_id: int) -> bool: return owner_peer == 0 or owner_peer == peer_id