CodeSubWars 0.4.7b
ARSTD::RepeatCommand Class Reference

#include <BasicCommands.h>

Inheritance diagram for ARSTD::RepeatCommand:

Public Member Functions

virtual ARSTD::Command::PtrType copy () const
 
virtual std::string getName () const
 
- Public Member Functions inherited from ARSTD::Command
virtual PtrType copy () const =0
 
virtual std::string getName () const =0
 
virtual bool wasExecuted () const
 
virtual double getProgress () const
 

Static Public Member Functions

static PtrType create (int nCycles=-1)
 

Detailed Description

This command makes commands executing again until the given number of cycles is reached. Its behavior is depend on how the command is executed.

  1. The command is executed directly by the command processor: All previously executed commands are executed again.
  2. The command is part of macro command: All previously attached commands are executed again. That means the repeat command attached to a macro command repeats only commands of this command also if this macro is attached to another macro.
    Example: two loops in one command plus a seperate repeat. 2 times 2 times 2 (8) torpedos with
    litte pauses are fired. (in python)
    innerLoop = MacroCommand.create('InnerLoop')
    innerLoop.attach(CSWFireCommand.create(self.getFrontLeftWeaponBattery(), None))
    innerLoop.attach(CSWWaitCommand.create(2.5))
    innerLoop.attach(RepeatCommand.create(1))
    outerLoop = MacroCommand.create('OuterLoop')
    outerLoop.attach(CSWWaitCommand.create(5))
    outerLoop.attach(innerLoop)
    outerLoop.attach(RepeatCommand.create(1))
    self.getCommandProcessor().execute(outerLoop)
    self.getCommandProcessor().execute(RepeatCommand.create(1))
    Definition: MacroCommand.h:18
    static PtrType create(const std::string &strName)
    Definition: MacroCommand.cpp:19
    Definition: BasicCommands.h:41
    static PtrType create(int nCycles=-1)
    Definition: BasicCommands.cpp:13

Member Function Documentation

◆ copy()

ARSTD::Command::PtrType ARSTD::RepeatCommand::copy ( ) const
virtual

Returns a copy of the command.

Returns
The copied command.

Implements ARSTD::Command.

◆ create()

RepeatCommand::PtrType ARSTD::RepeatCommand::create ( int  nCycles = -1)
static

Creates a new repeat command.

Parameters
nCyclesThe number of cycles that all previous commands should repeat. If a negativ value is given the repeating does not terminate automatically.
Returns
Returns the new constructed command.

◆ getName()

std::string ARSTD::RepeatCommand::getName ( ) const
virtual

Returns the name of the command.

Returns
The name of the command.

Implements ARSTD::Command.


Generated at Sun Aug 7 2022 for project CodeSubWars. www.codesubwars.org