#Is there a pattern for when a value is

1 messages · Page 1 of 1 (latest)

modest fulcrum
#

Some kind of StateMachine maybe ? If in UI open state you disable Input controls

modest copper
#

Hm I should rephrase. I want a pattern that asserts order within a set of managing objects.

#

RE:

I found the Context Stacking pattern:

This involves keeping a stack or list of contexts that influence a value. The "active" value is derived from the top of the stack or some aggregation of the stack.

modest fulcrum
#

Dive into Player Stats and Modifiers using the Broker Chain pattern! Uncover how this powerful design pattern can streamline your coding process and enhance game mechanics. Get ready to supercharge your programming skills and bring your game ideas to life like never before!

Remember! In C#, Delegates are invoked in the order they are added to t...

â–¶ Play video
#

In the video it explains how to stack modifier to a value like Buff spells in games

gloomy glade
#

I'm literally implementing this in my game right now, haha

#

Figuring out which point-of-view should be active given the current situation

tawdry hedge
#

for UI i quite like the pattern of using a state machine that keeps a stack of states, so for your example example you could push a menu state onto the top of the stack and the transition would disable the movement, then you can pop the menu and the transition back into the gameplay state would restore the controls

gloomy glade
#

If you can constrain yourself to a stack, it's relatively easy

worn turret
tawdry hedge
#

well i mean if you have a state machine it's easy to make that out of it!

gloomy glade
#

as the kids would say

#

"that's just a state machine with extra stacks!"

#

or something like that..

worn turret
#

that stats modifiers video above is also a bit overengineered and you would only do something like that if your game designer is unable to come up with a design/decision on threat of violence.

#

visitor + mediator + linked list... any self respecting gamedev should die a little inside when seeing that

worn turret
# modest copper RE: I found the Context Stacking pattern: This involves keeping a stack or lis...

you might what to look at it not from the perspective of an individual value but from the group of values that have to change for the same reason, like "menu mode, play mode, focus mode, near death, inside house, open world, etc.", that would then be best represented by a formal/rigid hierarchical state machine. The pattern in ui-terms would be a "modal view", and you can naturally make an abstraction of that which you attach to individual values but hat requires you to build a hierarchical framework in which all values participate, which is excessive.

#

Alternatively you can make a claim/release type API for the value, say a pause-mode, where N clients can "claim" pause-mode. internally it has a counter and when the counter is > 0, the game is paused, == 0 it is unpaused. Implementation wise you could just increment/decrement a counter or keep track of the claims in a list, return encapsulated release handles, add a notifier event for changes... what exactly you need depends on the project. This is somewhat similar to a "semaphore".

gloomy glade
#

excessively complicated systems tend to show up when you decide "It needs to be able to do anything!"

#

"...and can't just be a 30 line script!"

worn turret