function ActiveCastStatic.Pause(S)assert(getmetatable(S)==ActiveCastStatic,ERR_NOT_INSTANCE:format("\080\097\117\115\101","\065\099\116\105\118\101\067\097\115\116\046\110\101\119\040\046\046\046\041"))assert(S.StateInfo.UpdateConnection~=nil,ERR_OBJECT_DISPOSED)S.StateInfo.Paused=true end function ActiveCastStatic.Resume(S)assert(getmetatable(S)==ActiveCastStatic,ERR_NOT_INSTANCE:format("\082\101\115\117\109\101","\065\099\116\105\118\101\067\097\115\116\046\110\101\119\040\046\046\046\041"))assert(S.StateInfo.UpdateConnection~=nil,ERR_OBJECT_DISPOSED)S.StateInfo.Paused=false end function ActiveCastStatic.Terminate(S)assert(getmetatable(S)==ActiveCastStatic,ERR_NOT_INSTANCE:format("\084\101\114\109\105\110\097\116\101","\065\099\116\105\118\101\067\097\115\116\046\110\101\119\040\046\046\046\041"))assert(S.StateInfo.UpdateConnection~=nil,ERR_OBJECT_DISPOSED)local Q=S.StateInfo.Trajectories local X=Q[#Q]X.EndTime=S.StateInfo.TotalRuntime S.StateInfo.UpdateConnection:Disconnect()S.Caster.CastTerminating:FireSync(S)S.StateInfo.UpdateConnection=nil S.Caster=nil S.StateInfo=nil S.RayInfo=nil S.UserData=nil setmetatable(S,nil)end return ActiveCastStatic
---- STATE MODIFICATION ----

function ActiveCastStatic:Pause()
	assert(getmetatable(self) == ActiveCastStatic, ERR_NOT_INSTANCE:format("Pause", "ActiveCast.new(...)"))
	assert(self.StateInfo.UpdateConnection ~= nil, ERR_OBJECT_DISPOSED)

	self.StateInfo.Paused = true
end

function ActiveCastStatic:Resume()
	assert(getmetatable(self) == ActiveCastStatic, ERR_NOT_INSTANCE:format("Resume", "ActiveCast.new(...)"))
	assert(self.StateInfo.UpdateConnection ~= nil, ERR_OBJECT_DISPOSED)

	self.StateInfo.Paused = false
end

function ActiveCastStatic:Terminate()
	assert(getmetatable(self) == ActiveCastStatic, ERR_NOT_INSTANCE:format("Terminate", "ActiveCast.new(...)"))
	assert(self.StateInfo.UpdateConnection ~= nil, ERR_OBJECT_DISPOSED)

	-- First: Set EndTime on the latest trajectory since it is now done simulating.
	local trajectories = self.StateInfo.Trajectories
	local lastTrajectory = trajectories[#trajectories]
	lastTrajectory.EndTime = self.StateInfo.TotalRuntime

	-- Disconnect the update connection.
	self.StateInfo.UpdateConnection:Disconnect()

	-- Now fire CastTerminating
	self.Caster.CastTerminating:FireSync(self)

	-- And now set the update connection object to nil.
	self.StateInfo.UpdateConnection = nil

	-- And nuke everything in the table + clear the metatable.
	self.Caster = nil
	self.StateInfo = nil
	self.RayInfo = nil
	self.UserData = nil
	setmetatable(self, nil)
end

return ActiveCastStatic
