Class ExtendedCommands


  • public class ExtendedCommands
    extends java.lang.Object
    This class holds the commands for all units.
    Version:
    1.0, 11.09.2007
    Author:
    Thoralf Rickert
    • Field Detail

      • fireChangeEvent

        protected boolean fireChangeEvent
      • useThread

        protected boolean useThread
    • Constructor Detail

      • ExtendedCommands

        public ExtendedCommands​(Client client)
        Constructor for the extended commands container object
        Parameters:
        client - The GUI client that holds the configuration etc.
      • ExtendedCommands

        public ExtendedCommands​(java.lang.String commandsFilename)
        Constructor for the extended commands container object. This method is for GUI-less usage only!
        Parameters:
        commandsFilename -
    • Method Detail

      • hasCommands

        public boolean hasCommands()
        Returns true if there are any commands set.
      • hasCommands

        public boolean hasCommands​(UnitContainer container)
        Returns true if there is a command for the given unitcontainer.
      • hasAllCommands

        public boolean hasAllCommands​(GameData world,
                                      UnitContainer container)
        Returns true if there is a command for the given unitcontainer.
      • hasCommands

        public boolean hasCommands​(Unit unit)
        Returns true if there is a command for the given unit.
      • getCommands

        public Script getCommands​(UnitContainer container)
        Returns the command script for the given unitcontainer.
      • getCommands

        public Script getCommands​(Unit unit)
        Returns the command script for the given unit.
      • setCommands

        public void setCommands​(Unit unit,
                                Script script)
        Sets the commands for a given unit.
      • setCommands

        public void setCommands​(UnitContainer container,
                                Script script)
        Sets the commands for a given unit.
      • getLibrary

        public Script getLibrary()
        Returns the value of library.
        Returns:
        Returns library.
      • setLibrary

        public void setLibrary​(Script library)
        Sets the value of library.
        Parameters:
        library - The value for library.
      • getUnitsWithCommands

        public java.util.List<Unit> getUnitsWithCommands​(GameData world)
        Returns a list of all units with commands.
      • getUnitContainersWithCommands

        public java.util.List<UnitContainer> getUnitContainersWithCommands​(GameData world)
        Returns a list of all unitcontainerss with commands.
      • clearUnusedUnits

        public int clearUnusedUnits​(GameData world)
        Clears the commands if there are now units associated with this script
      • clearUnusedContainers

        public int clearUnusedContainers​(GameData world)
        Clears the commands if there are now unitcontainers associated with this script
      • execute

        public void execute​(GameData world,
                            Unit unit)
        Executes the commands/script for a given unit.
      • execute

        public void execute​(GameData world,
                            UnitContainer container)
        Executes the commands/script for a given unitcontainer.
      • execute

        public void execute​(GameData world)
        Executes the library commands/script.
      • read

        protected void read​(java.io.File file)
        Reads a file with commands
      • save

        public void save()
      • write

        protected void write​(java.io.File file)
        Writes the commands
      • getDefaultLibrary

        public java.lang.String getDefaultLibrary()
        Returns the default libary script.
      • setDefaultLibrary

        public void setDefaultLibrary​(java.lang.String script)
        Returns the default libary script.
      • getDefaultUnitScript

        public java.lang.String getDefaultUnitScript()
        Return default script for units.
      • setDefaultUnitScript

        public void setDefaultUnitScript​(java.lang.String script)
        Sets the default script for units.
      • getDefaultContainerScript

        public java.lang.String getDefaultContainerScript()
        Return default script for units.
      • setDefaultContainerScript

        public void setDefaultContainerScript​(java.lang.String script)
        Sets the default script for units.
      • createScript

        public Script createScript​(Unit unit)
      • isFireChangeEvent

        public boolean isFireChangeEvent()
        Returns true, if the current thread should fire an ChangeEvent for the whole world.
      • setFireChangeEvent

        public void setFireChangeEvent​(boolean fireChangeEvent)
        Set to true true, if the current thread should fire an ChangeEvent for the whole world.
      • isUseThread

        public boolean isUseThread()
        Returns true, if any command execution should be done inside it's own execution thread
      • setUseThread

        public void setUseThread​(boolean useThread)
        Set to true (default) to execute any command inside its own execution thread