Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: timer.Create with a round-sensitive context #1434

Open
EntranceJew opened this issue Feb 25, 2024 · 0 comments
Open

API: timer.Create with a round-sensitive context #1434

EntranceJew opened this issue Feb 25, 2024 · 0 comments
Labels
type/feature New functionality

Comments

@EntranceJew
Copy link
Contributor

EntranceJew commented Feb 25, 2024

Is your feature request related to a problem? Please describe.

several addons frequently do something foolhearty like doing a timer.Create and losing track of the things they were meant to apply or being interrupted by a round lifecycle event like a round ending -- or more likely not being interrupted when they should be.
some examples:

  • literally everything the mario mushroom does, it could not possibly be more wrong
  • eagleflight / tasers will restore a "bad" copy of your inventory and statuses (if at all) if the game as a short post-round + pre-round
  • entity bound things are frequently given timers that make it so only one can possibly exist at a time due to Works On My Machine™ network conditions

Describe the solution you'd like

the fundamental problem has two main components:

  • people lack the foresight to bind things to EntIndex()
  • people frequently use timers to "undo" shit that they are about to "do"

Thus the solution should be shaped like:

local duration = 30
local doOperation = function(ent)
  self:SetNWVar("pickles", 30)
  self:Ignite()
end
local undoOperation = function(ent)
  self:SetNWVar("pickles", 0)
  self:Extinguish()
end
local target = Player(1)
local token = target:CreateTimedRoundSensitiveEffect(duration, doOperation, undoOperation)
-- ...
local timeExtensionAmount = 15
target:ExtendTimedRoundSensitiveEffect(token, duration)
-- ...
target:CancelTimedRoundSensitiveEffect(token)

and behind the scenes we:

  • manage the timers
  • destroy and apply the undo operations prior to TTTPostRound or when transitioning to any phase other than the current one
  • migrate as much code as is appropriate to use these APIs and include using these types of things as examples of "porting" an addon to TTT2

I didn't include all the timer arguments here for brevity but the idea is apparent: create a superset of that API more tightly coupled to the lifecycle of entities via extending the EntityMeta or whatever. Special handling may be warranted by making the implementation for PlayerMeta different.

Describe alternatives you've considered

there is no way to stop people from making chatgpt-tier addons

@Histalek Histalek added the type/feature New functionality label Feb 25, 2024
@Histalek Histalek added this to the Feature Backlog milestone May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature New functionality
Projects
None yet
Development

No branches or pull requests

2 participants