-- Star Wars Empire at War: Secrets of a Fallen Empire
-- Lua Script: //Scripts/GameObject/Defense_Station_Teleport.lua
-- Author: Galyana
-- Updated: 6 February, 2026

-- script is activated by the "Defense_Station_Teleport_Marker" via FoW ping ability
-- simply check for which station is active (there can only ever be one) and teleport it to the marker location

require("PGStateMachine")

function Definitions()
	DebugMessage("%s -- In Definitions", tostring(Script))
	Define_State("State_Init", State_Init);
	ServiceRate = 1.0
end

function State_Init(message)
	if message == OnEnter then

		rebel_ds = Find_First_Object("Rebel_Defense_Station_GC")
		empire_ds = Find_First_Object("Empire_Defense_Station_GC")
		cons_ds = Find_First_Object("Underworld_Defense_Station_GC")
		hutt_ds = Find_First_Object("Hutt_Defense_Station_GC")

--		if not TestValid(rebel_ds) or if not TestValid(empire_ds) or if not TestValid(cons_ds) or if not TestValid(hutt_ds) then
--			ScriptExit()
--		end

		if TestValid(rebel_ds) then
			rebel_ds.Teleport(Object)
		elseif TestValid(empire_ds) then
			empire_ds.Teleport(Object)
		elseif TestValid(cons_ds) then
			cons_ds.Teleport(Object)
		elseif TestValid(hutt_ds) then
			hutt_ds.Teleport(Object)
		else ScriptExit()
		end

		ScriptExit()
	end
end