Add gadget:TeamResourceExcess(teamID, metal, energy) -> bool#2530
Add gadget:TeamResourceExcess(teamID, metal, energy) -> bool#2530sprunk wants to merge 1 commit into
Conversation
|
I wonder, since the callin invocation instances scale with the number of teams per gameframe (the ones overflowing that is), whether it would make sense to have the callin grouped? this signature also future proofs engine supported custom resourcing (although single per team can be made that way too). |
The RecoilEngine/rts/Lua/LuaHandleSynced.cpp Lines 1240 to 1242 in 60d8fca If somebody wants a table they can declare the function as gadget:TeamResourceExcess(teamID, ...) since then resources will end up packed into the ... variadic table.
|
-- assume teamID 0 has 200 current, 1000 max metal
+Spring.AddTeamResource(0, "metal", 500) -- no event, we're at 700/1000
+Spring.AddTeamResource(0, "metal", 500) -- event with 200 excess, we're at 1000/1000
+Spring.AddTeamResource(0, "metal", 500) -- event with 500 excess, we're at 1000/1000
-Spring.UseTeamResource(0, "metal", 400) -- we're at 600/1000
+Spring.AddTeamResource(0, "metal", 300) -- no event, we're at 900/1000
+Spring.AddTeamResource(0, "metal", 500) -- event with 400 excess, we're at 1000/1000
-- assume teamID 0 has 200 current, 1000 max metal
+Spring.AddTeamResource(0, "metal", 100) -- no event, we're at 300/1000
+Spring.AddTeamResource(0, "metal", 100) -- no event, we're at 400/1000
+Spring.AddTeamResource(0, "metal", 100) -- no event, we're at 500/1000
|
I see. I didn't look in-depth into this but this implications does not seem acceptable (to me), or maybe I'm overestimating the overhead impact?
One question: how is it powerful? Which use cases does it enable? Shouldn't the resource delta source, or some other related data, be required to enable any use case where separate instances in a gameframe must be used for some feature?
A proposalMaybe this proposal might be "hacky" in its most naive implementation, but I'd seriously consider just accumulating the excess (properly accounting for negative deltas in gameframe) from pre- to post- gameframe sym, and then asking lua how to handle the excess. A few cons:
Remarks:
Keeping in mind, both considerations only exist in the scenario we allow the callin to alter normal overflow execution (instead of a purely "notification" callin), which I think is our intent. |
The resources are the amount over the storage max. Return true to take over engine handling; otherwise the native behaviour of buffering it until the next slowupdate will take place.
9bf24c8 to
d734d53
Compare
|
@badosu aggregating within a gameframe sounds good, I pushed something. |
|
Status:
|
Sounds good, I'll see if I can manage a build and test locally. |
|
Missing the basecontent gadgethandler part |
|
@sprunk One perhaps non-intuitive implication: RecoilEngine/rts/Sim/Misc/Team.cpp Lines 358 to 359 in 55e41df Resource adding increments |
|
Slowupdate (line 132) happens after GameFramePost (line 122) RecoilEngine/rts/Sim/Misc/TeamHandler.cpp Lines 122 to 132 in d734d53 |
|
|
||
| /*** Called when excess resources are added. | ||
| * Accumulates all excesses within a single gameframe. | ||
| * |
There was a problem hiding this comment.
Should document what happens if you generate more excess while inside this event.
|
I'm warming up to the idea of having a single call with a table containing all the teams, since there are practical differences compared to e.g. targeting. |
I opened #2642 which implements this and which I think I like more now after seeing how gamedevs actually use them. |
|
Superseded by #2642 |
The resources are the amount over the storage max. Return true to take over engine handling; otherwise the native behaviour of buffering it until the next slowupdate will take place.