Perhaps some real programmers can offer some advice here
Imagine we have a building game. From various widgets you might select different things you could construct. You click an ACTION BUTTON and that is going to prepare for a certain action.
E.g. the building to be constructed might appear with an xray shader and then once you click, the actual action of building the thing occurs.
But we should be able to cancel that action, either before it starts or during a queue while it is happening.
In case that is not clear, I’ll describe how it might look in a game:
- Click widget button to select BuildingA
- Now image of that building follows mouse cursor
- Left click starts a queue and once the queue is finished the new building appears
- Right click cancels the order to build, either before you had started the building or during the queue as well
Ideally, this Request > Queue > Action process is encapsulated so that no matter what sort of request and action is meant to happen, a single event will always cancel them.
In order to accomplish that universal cancel, I believe something like a command pattern, in which we encapsulate a request into an object, might be appropriate here?
My idea is that PendingAction is a Uobject that gets created on button press. There would be a parent class which implements an interface, and children instances can implement whatever interface functions/events that they need. So, each instance can handle things in their own way.
One pendingAction object might handle an OnRequest() function by telling the player pawn to show the building model in xray mode. And then it would also handle the left click event and pass that to the player pawn, informing it to start teh queue and proceed with the building.
I suppose then that the Universal cancel could then exist on the parent class, and each instance then would just undo whatever things that had been responsible for doing.
I think that makes sense… If you have any input/advices I do appreciate it. Mostly I am using community for rubber ducky here but I figure it may get me some help and/or it may possibly help other people as well.