PGRData/Script/matrix/xdlcfight/sceneobject/0008.lua

79 lines
2.3 KiB
Lua
Raw Normal View History

2024-09-01 20:49:41 +00:00
--- 锚点
local XSObjAnchor = XDlcScriptManager.RegSceneObjScript(0008, "XSObjAnchor") --调用使用冒号
local FuncSet = CS.StatusSyncFight.XFightScriptFuncs --调用使用句号
local Property = require("XDLCFight/Level/Common/SceneObjectsProperty").Anchor
---@param proxy StatusSyncFight.XScriptLuaProxy
function XSObjAnchor:Ctor(proxy)
self._proxy = proxy
self._enable = nil
self.EnableOnStart = true ---默认设置为开
self._type = nil ---23凸 24平
self._initialized = false ---是否执行开关的初始化
end
function XSObjAnchor:Init()
self._sceneObj = self._proxy:GetSceneObject()
self._sceneObjPlaceId = self._proxy:GetSceneObjectPlaceId()
end
---@param dt number @ delta time
function XSObjAnchor:Update(dt)
end
---设置猎矛是否启用在关卡初始化的时候调用InitState
---@param enable boolean
function XSObjAnchor:SetEnable(enable)
if enable == nil then
return
end
if enable ~= self._enable then
XLog.Debug("设置猎锚勾点" .. self._sceneObjPlaceId .. "状态为:" .. tostring(enable))
FuncSet.SetHookableSceneObjectEnable(self._sceneObjPlaceId, enable)
self._enable = enable
--表现相关
if self._type ~= nil then
if enable then
FuncSet.DoSceneObjectAction(self._sceneObjPlaceId, Property.Actions[self._type].Open)
else
FuncSet.DoSceneObjectAction(self._sceneObjPlaceId, Property.Actions[self._type].Close)
end
end
end
end
---@param eventType number
---@param eventArgs userdata
function XSObjAnchor:HandleEvent(eventType, eventArgs)
XSObjAnchor.Super.HandleEvent(self, eventType, eventArgs)
end
---初始化状态,设置猎锚勾点种类,确保播放特效类别正确
function XSObjAnchor:InitState(type, enable)
self._type = type
XLog.Debug("注册场景物体勾点 " .. tostring(self._sceneObjPlaceId) .. " 类型为 " .. tostring(type) .. "完成")
self:SetEnable(enable)
self._initialized = true
end
function XSObjAnchor:Terminate()
end
---如果关卡脚本没有挂初始化,就自己执行一次
function XSObjAnchor:OnResLoadComplete()
if not self._initialized then
self:SetEnable(self.EnableOnStart)
self._initialized = true
end
end
return XSObjAnchor