Skip to content

[FEATURE] Add item-slot lock state and lifecycle events #295

Closed

Description

@ifBars

What would you like to see?

Extend S1API.Items.ItemSlotInstance with managed lock state and slot lifecycle events.

The initial API should expose:

  • IsLocked, IsAddLocked, and IsRemovalLocked;
  • a managed snapshot of the active lock reason without exposing its native FishNet owner;
  • locked and unlocked events;
  • item-instance, item-data, and filter-change events where those native callbacks are available.

Why would this help?

ItemSlotInstance currently exposes quantity, item, and quantity mutation, while the native slot has explicit lock states and callbacks used by stations, storage, employee tasks, and multiplayer ownership. Inventory UI and automation mods otherwise have to inspect ItemSlot, ItemSlotLock, and native delegates directly.

Extra Context (Optional)

Keep applying/removing network-owned locks and exposing native NetworkObject instances out of the first version. If authoritative lock mutation is needed later, it should use an S1API-owned handle with explicit lifecycle and ownership rules.

Validate event subscription cleanup, slot reuse, save reload, and host/client lock replication separately on Mono and IL2CPP.

Activity

  1. added
    enhancementNew feature or request
    LowVery minor issue, non gameplay hindering, fix all high prio first
    on Aug 29, 2026
  2. ifBars commented on Sep 6, 2026

    @ifBars
    OwnerAuthor

    @Diffuin Research this accordingly and create an implementation plan

  3. diffuin commented on Sep 6, 2026

    @diffuin

    Issue investigation

    Confidence: Medium

    Issue #295 supports an additive, read-only wrapper extension. The smallest scope is direct lock-state forwarding, a reason-only immutable lock snapshot, and managed adapters for the five native callbacks; lock mutation and FishNet owner exposure remain excluded. IL2CPP generated-wrapper shape still needs verification before implementation.

    Recommended next steps

    1. Forward the three lock booleans directly. Expose ActiveLock as null or a fresh immutable S1API-owned value containing only the reason; do not expose the native lock or its FishNet owner.
    2. Use managed Action events named Locked, Unlocked, ItemInstanceChanged, ItemDataChanged, and FilterChanged. Register one stored native adapter per managed add and remove exactly that adapter on -= so other native listeners remain intact.
    3. Keep state non-persistent and read-only. The API observes the state delivered to the current peer and makes no replication-order, authority, or lock-mutation promise.

    Open questions

    • Does the target IL2CPP import expose all five native callback fields and the lock members with directly usable generated types? If not, the affected surface should wait for a compatible game target rather than gain reflection fallback behavior.
    Evidence and validation

    Evidence inspected

    • The current S1API ItemSlotInstance wraps a native slot but exposes only quantity, item instance, and quantity mutation. It has no existing lock state or lifecycle event surface.
    • Regular and beta Mono source declare the same ItemSlot seam: IsLocked, IsAddLocked, IsRemovalLocked, ActiveLock, and onLocked, onUnlocked, onItemInstanceChanged, onItemDataChanged, and onFilterChange. The native lock carries a LockReason plus a FishNet owner.
    • Native IItemSlotOwner and StorageEntity declare server/observer lock and filter RPC routes. That supports observation of locally delivered native callbacks, but does not prove callback timing or host/client behavior.
    • S1API already bridges native callbacks with runtime-specific delegates and ManagedEventRegistrationTracker in TemperatureEmitter and TrashContainer. The tracker preserves duplicate add/remove semantics and supports cleanup without replacing native delegate lists.

    Validation performed

    • Read issue [FEATURE] Add item-slot lock state and lifecycle events #295 and confirmed the current remote ItemSlotInstance matches the checkout.
    • Compared regular and beta Mono declarations for ItemSlot, ItemSlotLock, IItemSlotOwner, StorageEntity, and ItemSlotUI.
    • Inspected S1API's existing managed native-event registration and cleanup pattern.
    • Ran git diff --check; the checkout has no local changes.

    Runtime validation remaining

    • Inspect the generated IL2CPP ItemSlot wrapper and compile both target graphs before implementing.
    • After implementation, run the full MonoMelon and Il2CppMelon build and contract-test commands.
    • Human runtime validation on both runtimes: subscribe/unsubscribe and duplicate handlers, acquire new wrappers for a reused slot, save reload, and host/client lock and filter replication. No in-game or end-to-end validation was run.
    • Create a pull request to implement this plan and close this issue when merged.
    Diffuin run details
    • Provider: codex
    • Model: gpt-5.6-terra
    • Reasoning: xhigh (Luna advisor: complexity (high); baseline coupled source-backed request)
    • Elapsed: 260s
    • Codex thread: 01a0740d-2709-7022-915e-2f10edd76418

    AI notice: Generated with AI assistance and not guaranteed accurate. Verify findings and plans against the current source and runtime.

  4. diffuin commented on Oct 15, 2026

    @diffuin

    I opened #365

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    LowVery minor issue, non gameplay hindering, fix all high prio firstenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions