PickupShareApi

版本 v1.0.0·更新於 2026-08-14

Library. Lets a loot-sharing mod publish which players have already collected which drop, so another mod can move that drop without the lobby losing track. Does nothing on its own.

模組介紹 作者原文

PickupShareApi

A library. Installing it on its own does nothing — something else has to use it.

It solves one specific problem: Risk of Rain 2 never synchronises the position of a

spawned pickup. CharacterNetworkTransform only ever rides on characters, and a drop's

position reaches other players exactly once, inside its spawn message. So a mod that wants

to move a drop cannot move it — it has to destroy it and spawn a replacement.

That is fine, until a loot-sharing mod is also installed. Those track drops by instance id,

and the replacement gets a new one. A drop that half the lobby had already collected comes

back looking untouched, and everyone gets a second copy.

This library is the hand-off between the two.

For a mod that tracks drops

Implement IPickupStateProvider and register in Awake:

[BepInDependency("com.majai.pickupshareapi", BepInDependency.DependencyFlags.HardDependency)]

public class MyLootPlugin: BaseUnityPlugin

{

private readonly MyStateProvider _provider = new MyStateProvider();

public void Awake() => PickupShareApi.RegisterProvider(_provider);

public void OnDestroy() => PickupShareApi.UnregisterProvider(_provider);

}

One provider at a time. Registering a second replaces the first and logs loudly about it,

because two mods tracking the same drops would contradict each other.

For a mod that moves drops

Call the static forwarders. Spawn the replacement before destroying the original —

Unity is free to hand the freed instance id straight back out, and a replacement that

inherited the old id would be matched against the very record you are moving off it.

var replacement = GenericPickupController.CreatePickup(in info);

PickupShareApi.TransferOrbState(original.GetInstanceID(), replacement.GetInstanceID());

NetworkServer.Destroy(original.gameObject);

Every call is safe with no provider registered — the transfers return false, the queries

return false, the forgets do nothing. That is the correct answer for a vanilla run, where

a drop is either untouched or already gone. So a consumer does not need to know whether a

loot-sharing mod is installed, and does not need to depend on one.

PickupShareApi.HasProvider is there if you want to check anyway. Check it at the point of

use rather than at load — load order is not guaranteed to favour you.

Also included

PickupClassifier.IsCommandCube(picker) — PickupPickerController also drives the

Scrapper, 3D printers, Meal Prep, the Hoard, the Solus vendor, Lemurian eggs, Delusion and

Rebirth. Those take an item from a player rather than handing one out, and treating one as

a Command cube breaks it badly. Fails to false when it cannot tell.

PickupClassifier.IsRuntimeSpawned(component) — whether an object was dropped during the

run or shipped with the scene. Only a runtime object can be destroyed and respawned.

API version

PickupShareApi.ApiVersion is 1. It is bumped only when an existing member changes

meaning or disappears; new members leave it alone.

ภาษาไทย

เป็น library ล้วน ลงเฉยๆ ไม่ทำอะไรเลย ต้องมี mod อื่นเรียกใช้

แก้ปัญหาเดียว: RoR2 ไม่ sync ตำแหน่งของ pickup ที่ spawn แล้ว ตำแหน่งถูกส่งครั้งเดียว

ตอน spawn เท่านั้น mod ที่อยากย้าย orb เลยย้ายตรงๆ ไม่ได้ ต้องทำลายของเดิมแล้ว spawn ตัวใหม่

ปัญหาคือ mod แชร์ของจำ orb ด้วย instance id ซึ่งตัวใหม่ได้ id ใหม่ orb ที่ครึ่งห้องเก็บไปแล้ว

จะกลับมาดูเหมือนยังไม่มีใครแตะ แล้วทุกคนเก็บซ้ำได้ library ตัวนี้คือสะพานส่งต่อสถานะระหว่างสองฝั่ง

  • ฝั่งที่เก็บสถานะ implement IPickupStateProvider แล้ว RegisterProvider ตอน Awake
  • ฝั่งที่ย้าย orb เรียก PickupShareApi.TransferOrbState(oldId, newId) — spawn ตัวใหม่ก่อน

ทำลายตัวเก่าทีหลังเสมอ เพราะ Unity คืน instance id มาใช้ซ้ำได้

  • ถ้าไม่มีใคร register ทุก call ปลอดภัยหมด (คืน false / ไม่ทำอะไร) ซึ่งถูกต้องสำหรับ run vanilla

安裝與使用 安裝:BepInEx 外掛

  1. 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
  2. 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
  3. 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
  4. 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。

帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

bbepis-BepInExPack

檔案與校驗

檔案名稱
PickupShareApi-1.0.0.zip
檔案大小
15.0 KiB