--------------------------------------------------------------------------------
--                      Seiren Castle Main File                               --
--------------------------------------------------------------------------------

require( "common" )

require( "ID/Siren/Data/Name" )				-- File path, file name table for the name, the reference station, proceed step
require( "ID/Siren/Data/Chat" )				-- All related chat
require( "ID/Siren/Data/Process" )			-- Progress-related data, such as information and links to various delay times, the quest
require( "ID/Siren/Data/Regen" )			-- Regeneration data (group-related regeneration type, location, and properties of the mob, NPC, statements, items, etc.)
require( "ID/Siren/Data/Stuff" )			-- Stuff related to data processing (information element for causing the NPC action information and action)
require( "ID/Siren/Data/Boss" )				-- Boss-related data processing (Boss Phase Data (including Summon monsters), more than the state, Chief mob-related warning information)
                                            
require( "ID/Siren/Functions/SubFunc" )		-- Various Sub Functions necessary for the overall progress
require( "ID/Siren/Functions/Routine" )		-- The AI ??routines attached mob-related, etc.
require( "ID/Siren/Functions/Progress" )	-- Each phase advance function is defined


function Main( Field )
cExecCheck "Main"

	local Var = InstanceField[ Field ]

	if Var == nil
	then

		InstanceField[ Field ] = {}

		Var					= InstanceField[ Field ]
		Var["MapIndex"]		= Field

		Var["Enemy"]		= {}	-- Information enemies that holds memory
		Var["Door"]			= {}	-- Ordering information that holds memory
		Var["Portal"]		= {}	-- Memory that holds information portal
		Var["RoutineTime"] 	= {}	-- Every time the routine memory that stores the handle


		cSetFieldScript ( Var["MapIndex"], MainLuaScriptPath )
		cFieldScriptFunc( Var["MapIndex"], "MapLogin", "PlayerMapLogin" )


		Var["StepIndex"]	= nil
		Var["StepFunc"] 	= nil


		-- First time entry
		Var["InitialSec"] 	= cCurrentSecond()
		Var["CurSec"] 	  	= cCurrentSecond()


		-- The first step
		GoToNextStep( Var )

	end


	-- 0.5 It runs every second
	if Var["CurSec"] + 0.5 > cCurrentSecond()
	then
		return
	else
		Var["CurSec"] = cCurrentSecond()
	end


	-- Run step function ( Functions/Progress.lua )
	Var["StepFunc"]( Var )
end
