Skip to content

feat: expose lifetime-owned currency pickup rules - #792

Closed
ou3051 wants to merge 1 commit into
LocalExile:mainfrom
ou3051:feat/mod-currency-pickup
Closed

ou3051 wants to merge 1 commit into
LocalExile:mainfrom
ou3051:feat/mod-currency-pickup

Conversation

@ou3051

@ou3051 ou3051 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

CurrencyPickupPolicy.Use(owner, options) exposes rules for currency pickup into an affinity stash. The server validates loot ownership and persists a complete stack transfer atomically.

The API follows the current Gateway owner lifecycle. Unloading an owner removes its registration. The companion mod is LocalExile-Mods #19.

Verification

@Wrathen

Wrathen commented Nov 10, 2026

Copy link
Copy Markdown
Member

The mod hook API changed under this PR (#818, in v0.4.1-beta)

Hi, and thanks for this. #818 is merged and shipped in v0.4.1-beta. It replaces the way mods get hooks from the server, which this PR builds on, so the PR now conflicts with main and needs reworking. I've moved it to draft; mark it ready again once it's rebased and builds.

What changed

  • ServerHooks is deleted, along with every hook method on IModContext (On*, Modify*, Use*, PublishExchangeRates). GameServer.Modding is now only the loader contract plus host services: IModContext has Manifest, Lifetime, Folder, CharacterBuilds, Log, Settings<T>() and SaveSettings<T>(). Don't add new members to it; the plan is to shrink it further (IPlayer/IPlayerWorld are next to move into the Gateway).
  • GameEvents is the one hook system for modules and mods (src/GameServer.Gateway/Modding/GameEvents.cs). A subscriber names its owner (the mod's or module's id): GameEvents.X.Add(id, handler). On unload, the host releases everything held under that id, so nobody tracks handles. Modules' subscribers run only in their leagues; mods' subscribers run in every league, after the modules.
  • Server switches are public Gateway members that take an owner. For example ChatRoutes.Use(string owner, string host, int port) => GameEventOwners.Own(owner, Use(host, port)), and ExchangeRateStore.Use(owner, options). GameEventOwners.Own(owner, disposable) resets the switch when its owner unloads.
  • Handlers get the connection (ClientState), not an IPlayer. Program.PlayerOf(conn) still gives the IPlayer when needed.
  • Payload and option types live in the Gateway (GameEventPayloads.cs): DropRoll, ExperienceGain, StatSheet, ExchangeOptions, … They used to live in GameServer.Modding.
  • The rule from AGENTS.md is unchanged: what the framework hands a mod is general (it names no mod), and the feature's logic, settings and defaults stay in the mod.

The docs are in Agents/docs/dev/modding.md ("Hooks") and Agents/docs/dev/modules.md ("What a module sees"). The official mods' ports in LocalExile/LocalExile-Mods#26 show the mod side.

For this PR

  • Drop IModContext.UseCurrencyPickupRules and its ModHost implementation. Make the store's Use public with an owner overload, the same as ChatRoutes.Use on main:
    public static IDisposable Use(string owner, CurrencyPickupRules options) => GameEventOwners.Own(owner, Use(options));
    The host then resets the rules when that owner unloads, which keeps your lifetime-owned behaviour without the context method.
  • Move CurrencyPickupRules from GameServer.Modding to the Gateway, as ExchangeOptions moved in feat!: one hook system, GameEvents, for modules and mods #818.
  • The mod side, feat(petcurrency): add pet currency pickup into affinity stashes LocalExile-Mods#19 (petcurrency), then calls <Store>.Use(mod.Manifest.Id, new CurrencyPickupRules(…)). I've commented there too.

@nikolos89

Copy link
Copy Markdown
Collaborator

Merge review of head 072fabac1b2789af9a66861776b7bd29725dcc2d against main 7dfe1fc7eff6b719eb95cb8d268e87b1cb2e2739:

  • This PR is still Draft. Complete the remaining work and verification, then mark it ready for review.
  • GitHub reports a conflict with main. Please update your branch and resolve it by preserving both mechanics, then rerun the solution build and Core/Data/Gateway suites on the updated head.
  • This PR changes protected files (src/GameServer.Gateway/Modding/CurrencyPickupPolicy.cs, src/GameServer.Gateway/Modding/CurrencyPickupRules.cs). AGENTS.md/CODEOWNERS require maintainer review and manual merge; an agent cannot approve/merge it. Please request that review after any code/conflict fixes. This restriction alone is not a code defect and does not ask you to remove necessary protected changes.

Left unmerged; no bypass of checks or review requirements.

@Wrathen

Wrathen commented Nov 14, 2026

Copy link
Copy Markdown
Member

Closing due to unresponsiveness.

@Wrathen Wrathen closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants