Re-add Spring.AddTeamResourceStats for Lua economy controllers#3032
Conversation
2cdb8bc to
0777126
Compare
|
@sprunk I did rebase master since we were pretty far behind. |
0777126 to
e88cdbb
Compare
|
I think this should be just for the excess stat, since the others already have functions to adjust them. |
e88cdbb to
4813b7d
Compare
|
@sprunk
Poking around for another way to do this now but yeah, that's one of the main reasons I moved away from the existing API originally, it just wasn't designed with the game doing the underlying math comprehensively in mind. That said, there is a path that uses only existing calls if we accept lossy stats under tax:
The catch is that ShareTeamResource being 1:1 makes So the two viable options are: keep AddTeamResourceStats carrying gross sent/received/excess (faithful to the numbers the game computes), or take the ShareTeamResource + SetTeamResource route and accept sent==net under tax. I lean toward the former since it preserves the gross figures, but I'm happy either way. |
4813b7d to
e88cdbb
Compare
|
Stats can be implemented in Lua, and for BAR specifically there are motions in that direction already (cf. beyond-all-reason/Beyond-All-Reason#7584, beyond-all-reason/Beyond-All-Reason#6862 and the others linked from discussion there). If you go this route you can design the stats to be whatever you want. The engine's native stats implementation seems to be designed as a sort of ledger where every resource is accounted for, with |
4813b7d to
fd89cf0
Compare
|
Aite the consumer side wasn't as bad as I imagined because of the way stats already worked over there. I was worried I'd have to unpack waterfill into a per-team munge step and that's a hot path, but it turned out to be like 4 lines of code so yay. Note I renamed it to AddTeamResourceExcessStats to reflect its diminished scope. @sprunk how do you want to do this? I'm currently targetting your branch with this PR but can open a new PR and switch it to master if that's easier. Merging this should make your PR the clean merge point. |
|
I don't mind this going either onto the ResourceExcess branch or directly to master, but either way it probably shouldn't have 264 commits though. The code itself looks alright. |
|
The 264 commits are a byproduct of the merge target being your branch, which is not rebased on master. Rebasing your branch then merging it should produce the desired single-commit merge. Or just force-pushing your branch here and merging master. I can rebase again whenever you're ready if that helps. |
024e0ce to
cc28920
Compare
Economy controllers that redistribute pools via Spring.SetTeamResource bypass the engine's resource ledger, so per-frame excess would otherwise be miscounted as production. This call records a team's excess (per-tick prev-excess + lifetime total) without moving resources. Scoped to excess only, as a plain amount: excess is the one quantity that legitimately leaves the conservation ledger (cf. gadget:ResourceExcess). Conserved transfer stats (sent/received) belong in Lua, where controllers can shape them freely.
fd89cf0 to
938f165
Compare
sprunk
left a comment
There was a problem hiding this comment.
Looks good, just minor nits.
Co-authored-by: sprunk <spr.ng@o2.pl>
48acdac
into
beyond-all-reason:resource-excess-callin
|
Cool, thanks. |
Ported from the eco branch. BAR's resource transfer controller moves shared pools via Spring.SetTeamResource on the gadget:ResourceExcess path; without this, sharing is miscounted as production/usage. Records sent/received/excess into team + lifetime stats without moving resources.