DeckStacker v1.0
A card manager plugin for Unity games.
 
Loading...
Searching...
No Matches
DeckStacker.DSActionQueue Class Reference

Static Public Member Functions

static void RunUpdate ()
 
static void AddAction (DSAction newAction_, bool overrideCopyBlock_=false)
 
static void RemoveAction (DSAction action_)
 
static void ClearActionQueue ()
 
static void ClearActionQueueWithExclusions (List< DSAction > exclusionList_)
 
static void InsertAction (DSAction action_, int index_)
 
static void InsertActionList (List< DSAction > actionList_, int index_)
 
static List< string > PrintActionQueue ()
 

Properties

static bool queueIsClear [get]
 

Detailed Description

Manages the Action Queue for DeckStacker.

DeckStacker makes this key assumption for card games: You generally want to have one thing happen at a time.

This is accomplished by having a DSAction list called "_actionQueue" which tells DeckStacker what code to execute next.

This means you can queue up several pieces of code (aka DSActions) and the DSActionQueue will execute them one at a time.
This Action Queue script will look at the next action in actionQueue (index 0) and then execute that action.
After that action is "Resolved", it is removed from the queue and this script will move on to the next action in the next Update call.

A template action is provided to help with making custom actions for your game.
Assets/DeckStacker/DSCore/Scripts/CoreActions/DSTemplateAction.cs

This script's RunUpdate() method will be called by the DSTableRunner, which means you'll need to have that component on an object in your scene for anything to work.
___________________________
The group of methods marked with "Action Queue Management" will help manage the order of actions in the queue, safely. The most common instances where you'll want to manage action order is when you have a DSAction that adds more actions to the queue.

Why would an Action do that? Frequently, you'll want to queue up a bunch of actions, but you won't know the state of the table until that action is ready to execute. At that time, you may want to trigger more actions, so you'll setup an action that makes more actions, now that the table state is settled and subsequent actions can get the information they need. Those new actions will most likely need to be at the top of the action queue to maintain the original intended order, and so that the other actions, further down the list, don't corrupt the table state.

Example: I queue up these events...

  1. Make a deck of cards
  2. Shuffle the deck
  3. Move a random number of cards to Stack-A, and the rest to Stack-B.
  4. Then move the 3rd card of Stack-A to Stack-B.

Immediately there is a problem: We shuffled the deck and then grabbed a random number of cards for Stack-A.
There is no reasonable way of trying to predict what the state of Stack-A will be as we are queuing up the actions.
The solution is to make custom actions that execute at those points in the queue. Those custom actions will then have the necessary info about Stack-A to make informed commands.
That custom action will then create new DSActions in its place that are able to safely change the table in what ever way you'd like.

If this is confusing, I'm guessing that you'll run into this problem very quickly. DeckStacker provides a lot of common actions in the "CoreActions" folder, but these actions do not cover every possibility in game development. You'll need to make custom actions for your game...

Member Function Documentation

◆ AddAction()

static void DeckStacker.DSActionQueue.AddAction ( DSAction newAction_,
bool overrideCopyBlock_ = false )
inlinestatic

Safely adds a DSAction to the action queue.

◆ ClearActionQueue()

static void DeckStacker.DSActionQueue.ClearActionQueue ( )
inlinestatic

Clears all DSActions from the action queueu.

◆ ClearActionQueueWithExclusions()

static void DeckStacker.DSActionQueue.ClearActionQueueWithExclusions ( List< DSAction > exclusionList_)
inlinestatic

Similar to ClearActionQueue(), this clears all actions, but checks for actions to be excluded, recorded in exclusionList.

◆ InsertAction()

static void DeckStacker.DSActionQueue.InsertAction ( DSAction action_,
int index_ )
inlinestatic

Action Queue Management: Inserts a DSAction into the actionQueue at the specified index. InsertAction is ideal for when a DSAction just needs to replace itself with 1 Action.

◆ InsertActionList()

static void DeckStacker.DSActionQueue.InsertActionList ( List< DSAction > actionList_,
int index_ )
inlinestatic

Action Queue Management: Inserts a list of DSActions into the actionQueue at the specified index. InsertActionList is ideal for when a DSAction needs to replace itself with several Actions.

◆ PrintActionQueue()

static List< string > DeckStacker.DSActionQueue.PrintActionQueue ( )
inlinestatic

For debugging purposes: This method creates a List<string> that lists out the current actions in the queue.
Unity doesn't play nice with displaying abstract classes, so we need to be more inventive with debugging the queue.

◆ RemoveAction()

static void DeckStacker.DSActionQueue.RemoveAction ( DSAction action_)
inlinestatic

Safely removes a DSAction from the action queue.

◆ RunUpdate()

static void DeckStacker.DSActionQueue.RunUpdate ( )
inlinestatic

This needs to be called the by a GameObject in the scene with the DSTableRunner attached to it.

This method will grab the next action and execute it.

If an action never calls its Resolve() method, this Run method will always keep trying to run that action. (So be sure to Resolve() every action that is queued.)

If the game suddenly stops, you may have an Action that is not resolving...

Property Documentation

◆ queueIsClear

bool DeckStacker.DSActionQueue.queueIsClear
staticget

Returns true if the actionQueue is empty.


The documentation for this class was generated from the following file: