note description: "[ Command for changing the `home_base' of units. ]" author: "Jimmy J. Johnson" class REBASE_COMMAND inherit VITP_COMMAND redefine -- default_create, text, execute, undo end -- LOCATION_CONSTANTS -- undefine -- default_create -- end -- ATTACK_UNIT_CONSTANTS -- undefine -- default_create -- end create -- default_create, make feature {NONE} -- Initialization -- default_create -- -- Create an instance -- do -- Precursor {VITP_COMMAND} -- unit := Default_ship -- -- Just pick a port -- port := Attu -- old_port := Attu -- end make (a_unit: like unit; a_port: like port) -- Initialize a command that can change the `home_port of `a_unit' -- to `a_port' require unit_exists: a_unit /= Void port_exists: a_port /= Void do default_create unit := a_unit port := a_port old_port := a_port affected_objects.extend (unit) end feature -- Access text: STRING -- Description of the command do Result := "COMMAND: Rebase -- "+ unit.name + " from " + old_port.name + " to " + port.name end unit: ATTACK_UNIT -- The unit to be moved port: PORT -- The port to which `unit' is to be rebased old_port: PORT -- The port from which `unit' was rebased feature -- Basic operations execute -- Perform the action do Precursor {VITP_COMMAND} old_port := unit.home_port unit.set_home_port (port) end undo -- Reverse the effects of executing the command do Precursor {VITP_COMMAND} unit.set_home_port (old_port) end end