1111 lines
32 KiB
Lua
1111 lines
32 KiB
Lua
local phaseBase = require_ex('Phase/Core/PhaseBase')
|
|
local PHASE_ID = PhaseId.Wiki
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki = HL.Class('PhaseWiki', phaseBase.PhaseBase)
|
|
|
|
|
|
|
|
local WIKI_CATEGORY_TO_PANEL_CFG = {
|
|
[WikiConst.EWikiCategoryType.Weapon] = {
|
|
groupPanelId = PanelId.WikiGroup,
|
|
detailPanelId = PanelId.WikiWeapon,
|
|
includeLocked = true,
|
|
},
|
|
[WikiConst.EWikiCategoryType.Equip] = {
|
|
groupPanelId = PanelId.WikiEquipSuit,
|
|
detailPanelId = PanelId.WikiEquip,
|
|
},
|
|
[WikiConst.EWikiCategoryType.Item] = {
|
|
groupPanelId = PanelId.WikiGroup,
|
|
detailPanelId = PanelId.WikiItem,
|
|
},
|
|
[WikiConst.EWikiCategoryType.Monster] = {
|
|
groupPanelId = PanelId.WikiGroup,
|
|
detailPanelId = PanelId.WikiMonster,
|
|
},
|
|
[WikiConst.EWikiCategoryType.Building] = {
|
|
groupPanelId = PanelId.WikiGroup,
|
|
detailPanelId = PanelId.WikiBuilding,
|
|
},
|
|
[WikiConst.EWikiCategoryType.Tutorial] = {
|
|
groupPanelId = nil,
|
|
detailPanelId = PanelId.WikiGuide,
|
|
},
|
|
}
|
|
|
|
local SHOW_MODEL_FUNC = {
|
|
[WikiConst.EWikiCategoryType.Weapon] = "_ShowWeaponModel",
|
|
[WikiConst.EWikiCategoryType.Monster] = "_ShowMonsterModel",
|
|
[WikiConst.EWikiCategoryType.Building] = "_ShowBuildingModel",
|
|
}
|
|
|
|
local MODEL_ROOT_ANIM_NAME = {
|
|
[WikiConst.EWikiCategoryType.Weapon] = "wiki_model_in_weapon",
|
|
[WikiConst.EWikiCategoryType.Monster] = "wiki_model_in_monster",
|
|
[WikiConst.EWikiCategoryType.Building] = "wiki_model_in_building"
|
|
}
|
|
|
|
|
|
local SCENE_ITEM_NAME = "WikiModelShow"
|
|
local CAMERA_GROUP_NAME = "WikiCameraGroup"
|
|
local LIGHT_GROUP_NAME = "WikiLightGroup"
|
|
|
|
local WIKI_ENY_POSE_CONTROLLER_PATH = "Assets/Beyond/DynamicAssets/Gameplay/Prefabs/UIModels/WikiEnyPose/%s.overrideController"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.s_messages = HL.StaticField(HL.Table) << {
|
|
|
|
|
|
[MessageConst.SHOW_WIKI_ENTRY] = { 'OnShowWikiEntry', false },
|
|
|
|
|
|
|
|
[MessageConst.SHOW_WIKI_WEAPON_PREVIEW] = { 'OnShowWeaponPreview', false },
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.OnShowWikiEntry = HL.StaticMethod(HL.Table) << function(args)
|
|
local categoryId, wikiDetailArgs = PhaseWiki.ProcessArgs(args)
|
|
if not string.isEmpty(categoryId) then
|
|
PhaseManager:GoToPhase(PHASE_ID, { categoryType = categoryId, wikiDetailArgs = wikiDetailArgs })
|
|
else
|
|
local toastTxt = Language.LUA_WIKI_ENTRY_NOT_SUPPORT
|
|
if not string.isEmpty(args.buildingId) then
|
|
toastTxt = Language.LUA_WIKI_BUILDING_NOT_SUPPORT
|
|
elseif not string.isEmpty(args.monsterId) then
|
|
toastTxt = Language.LUA_WIKI_MONSTER_NOT_SUPPORT
|
|
elseif not string.isEmpty(args.itemId) then
|
|
toastTxt = Language.LUA_WIKI_ITEM_NOT_SUPPORT
|
|
end
|
|
Notify(MessageConst.SHOW_TOAST, toastTxt)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.OnShowWeaponPreview = HL.StaticMethod(HL.Table) << function(args)
|
|
PhaseManager:GoToPhase(PHASE_ID, args)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.OnShowItemCraft = HL.Method(HL.Table) << function(self, args)
|
|
PhaseManager:GoToPhase(PHASE_ID, args)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.m_isShowBackBtn = HL.Field(HL.Boolean) << false
|
|
|
|
|
|
PhaseWiki.m_isSceneInit = HL.Field(HL.Boolean) << false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki._OnInit = HL.Override() << function(self)
|
|
PhaseWiki.Super._OnInit(self)
|
|
self.m_activeModelGos = {}
|
|
self.m_modelRequestIdLut = {}
|
|
self.m_animatorControllerCache = {}
|
|
|
|
|
|
self.m_isShowBackBtn = self.arg == nil
|
|
|
|
|
|
self.arg = self.arg or {}
|
|
self:_ActivateBlackboxEffect(false)
|
|
CS.HG.Rendering.ScriptBridge.HGRenderBridgeStatics.SetVFXPPPriorityFilterCinematic()
|
|
CS.HG.Rendering.ScriptBridge.HGRenderBridgeStatics.SetSceneDarkEnabled(false)
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki._OnActivated = HL.Override() << function(self)
|
|
CameraManager:AddMainCamCullingMaskConfig("CharFormation", UIConst.LAYERS.CharFormation)
|
|
CS.HG.Rendering.ScriptBridge.HGRenderBridgeStatics.SetVFXPPPriorityFilterCinematic()
|
|
CS.HG.Rendering.ScriptBridge.HGRenderBridgeStatics.SetSceneDarkEnabled(false)
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki._OnDeActivated = HL.Override() << function(self)
|
|
CameraManager:RemoveMainCamCullingMaskConfig("CharFormation")
|
|
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki._OnDestroy = HL.Override() << function(self)
|
|
PhaseWiki.Super._OnDestroy(self)
|
|
self:DestroyModel()
|
|
self.m_isSceneInit = false
|
|
GameInstance.remoteFactoryManager:ForceCullingExecute()
|
|
self:_ActivateBlackboxEffect(true)
|
|
CameraManager:RemoveMainCamCullingMaskConfig("CharFormation")
|
|
CS.HG.Rendering.ScriptBridge.HGRenderBridgeStatics.SetVFXPPPriorityFilterNormal()
|
|
CS.HG.Rendering.ScriptBridge.HGRenderBridgeStatics.SetSceneDarkEnabled(true)
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki._InitAllPhaseItems = HL.Override() << function(self)
|
|
self:_InitSceneRoot()
|
|
self:_OpenByArgs()
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki._OnRefresh = HL.Override() << function(self)
|
|
PhaseWiki.Super._OnRefresh(self)
|
|
self:_OpenByArgs()
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki._OpenByArgs = HL.Method() << function(self)
|
|
if self.arg and self.arg.isWeaponPreview then
|
|
self:CreatePhasePanelItem(PanelId.WikiWeaponPreview, self.arg)
|
|
elseif self.arg and self.arg.isItemCraft then
|
|
local wikiEntryShowData = WikiUtils.getWikiEntryShowData(self.arg.itemId, WikiConst.EWikiCategoryType.Item)
|
|
self:CreatePhasePanelItem(PanelId.WikiCraftingTree, { wikiEntryShowData = wikiEntryShowData, craftId = self.arg.craftId })
|
|
else
|
|
self:OpenCategoryByPhaseArgs()
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki._DoPhaseTransitionIn = HL.Override(HL.Boolean, HL.Opt(HL.Table)) << function(self, fastMode, args)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki._DoPhaseTransitionOut = HL.Override(HL.Boolean, HL.Opt(HL.Table)) << function(self, fastMode, args)
|
|
if self.m_restoreHyperlinkPopupCallback ~= nil then
|
|
self.m_restoreHyperlinkPopupCallback()
|
|
end
|
|
self.m_sceneRoot.view.decoAnim:PlayOutAnimation(function()
|
|
if self.m_sceneRoot then
|
|
self.m_sceneRoot:SetActive(false)
|
|
end
|
|
end)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki._DoPhaseTransitionBehind = HL.Override(HL.Boolean, HL.Opt(HL.Table)) << function(self, fastMode, args)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki._DoPhaseTransitionBackToTop = HL.Override(HL.Boolean, HL.Opt(HL.Table)) << function(self, fastMode, args)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.curSearchKeyword = HL.Field(HL.String) << ""
|
|
|
|
|
|
PhaseWiki.m_currentWikiGroupArgs = HL.Field(HL.Table)
|
|
|
|
|
|
PhaseWiki.m_currentWikiDetailArgs = HL.Field(HL.Table)
|
|
|
|
|
|
PhaseWiki.m_restoreHyperlinkPopupCallback = HL.Field(HL.Function)
|
|
|
|
|
|
|
|
PhaseWiki.OpenCategoryByPhaseArgs = HL.Method() << function(self)
|
|
local categoryType = self.arg.categoryType
|
|
local wikiDetailArgs = self.arg.wikiDetailArgs
|
|
if string.isEmpty(categoryType) then
|
|
categoryType, wikiDetailArgs = PhaseWiki.ProcessArgs(self.arg)
|
|
self.m_restoreHyperlinkPopupCallback = self.arg.restoreHyperlinkPopupCallback
|
|
end
|
|
self:OpenCategory(categoryType, wikiDetailArgs)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.OpenCategory = HL.Method(HL.Any, HL.Opt(HL.Table)) << function(self, categoryId, args)
|
|
self.m_currentWikiDetailArgs = args
|
|
local panelCfg = WIKI_CATEGORY_TO_PANEL_CFG[categoryId]
|
|
if panelCfg then
|
|
|
|
local wikiGroupArgs = {
|
|
categoryType = categoryId,
|
|
detailPanelId = panelCfg.detailPanelId,
|
|
includeLocked = panelCfg.includeLocked,
|
|
}
|
|
self.m_currentWikiGroupArgs = wikiGroupArgs
|
|
|
|
if panelCfg.groupPanelId and not args then
|
|
self:CreateOrShowPhasePanelItem(panelCfg.groupPanelId, wikiGroupArgs)
|
|
else
|
|
self:RemovePhasePanelItemById(PanelId.WikiGroup)
|
|
self:RemovePhasePanelItemById(PanelId.WikiEquipSuit)
|
|
for panelId, panelItem in pairs(self.m_panel2Item) do
|
|
if panelId == PanelId.WikiSearch then
|
|
if panelItem.uiCtrl:IsShow(true) then
|
|
panelItem.uiCtrl:Hide()
|
|
end
|
|
elseif panelId ~= panelCfg.detailPanelId and panelId ~= PanelId.Wiki then
|
|
self:RemovePhasePanelItem(panelItem)
|
|
end
|
|
end
|
|
if UIManager:IsShow(panelCfg.detailPanelId) then
|
|
self:_GetPanelPhaseItem(panelCfg.detailPanelId).uiCtrl:Refresh(args)
|
|
else
|
|
self:CreateOrShowPhasePanelItem(panelCfg.detailPanelId, args)
|
|
end
|
|
end
|
|
else
|
|
self.m_currentWikiGroupArgs = nil
|
|
self:CreateOrShowPhasePanelItem(PanelId.Wiki)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.GetCategoryPanelCfg = HL.Method(HL.String).Return(HL.Table) << function(self, categoryId)
|
|
return WIKI_CATEGORY_TO_PANEL_CFG[categoryId]
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki.ProcessArgs = HL.StaticMethod(HL.Table).Return(HL.String, HL.Table) << function(args)
|
|
if not args then
|
|
return '', nil
|
|
end
|
|
local targetCategoryId, targetGroupId, targetEntryId
|
|
|
|
if not string.isEmpty(args.wikiEntryId) then
|
|
targetEntryId = args.wikiEntryId
|
|
elseif not string.isEmpty(args.itemId) then
|
|
targetEntryId = WikiUtils.getWikiEntryIdFromItemId(args.itemId)
|
|
elseif not string.isEmpty(args.buildingId) then
|
|
targetEntryId = WikiUtils.getWikiEntryIdFromItemId(FactoryUtils.getBuildingItemId(args.buildingId))
|
|
elseif not string.isEmpty(args.monsterId) then
|
|
targetEntryId = WikiUtils.getWikiEntryIdFromItemId(args.monsterId)
|
|
end
|
|
|
|
if string.isEmpty(targetEntryId) or
|
|
GameInstance.player.wikiSystem:GetWikiEntryState(targetEntryId) == CS.Beyond.Gameplay.WikiSystem.EWikiEntryState.Locked then
|
|
return '', nil
|
|
end
|
|
|
|
local _, wikiEntryData = Tables.wikiEntryDataTable:TryGetValue(targetEntryId)
|
|
if wikiEntryData then
|
|
targetEntryId = wikiEntryData.id
|
|
targetGroupId = wikiEntryData.groupId
|
|
end
|
|
|
|
if targetGroupId then
|
|
for wikiCategoryType, wikiGroupDataList in pairs(Tables.wikiGroupTable) do
|
|
for _, wikiGroupData in pairs(wikiGroupDataList.list) do
|
|
if wikiGroupData.groupId == targetGroupId then
|
|
targetCategoryId = wikiCategoryType
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
if targetCategoryId then
|
|
local panelCfg = WIKI_CATEGORY_TO_PANEL_CFG[targetCategoryId]
|
|
if panelCfg then
|
|
local wikiGroupShowDataList, wikiEntryShowData = WikiUtils.getWikiGroupShowDataList(targetCategoryId, targetEntryId, panelCfg.includeLocked)
|
|
|
|
local wikiDetailArgs = {
|
|
categoryType = targetCategoryId,
|
|
wikiGroupShowDataList = wikiGroupShowDataList,
|
|
wikiEntryShowData = wikiEntryShowData,
|
|
}
|
|
return targetCategoryId, wikiDetailArgs
|
|
end
|
|
end
|
|
return '', nil
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.m_sceneRoot = HL.Field(HL.Forward("PhaseGameObjectItem"))
|
|
|
|
|
|
PhaseWiki.m_cameraGroup = HL.Field(HL.Forward("PhaseGameObjectItem"))
|
|
|
|
|
|
PhaseWiki.m_currentCamera = HL.Field(HL.Table)
|
|
|
|
|
|
PhaseWiki.m_lightGroup = HL.Field(HL.Forward("PhaseGameObjectItem"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.m_categorySceneItem = HL.Field(HL.Table)
|
|
|
|
|
|
PhaseWiki.m_currentModelCategory = HL.Field(HL.String) << ''
|
|
|
|
|
|
|
|
PhaseWiki._InitSceneRoot = HL.Method() << function(self)
|
|
if self.m_sceneRoot == nil then
|
|
self.m_sceneRoot = self:CreatePhaseGOItem(SCENE_ITEM_NAME)
|
|
self.m_cameraGroup = self:CreatePhaseGOItem(CAMERA_GROUP_NAME, self.m_sceneRoot.view.sceneCamera)
|
|
self.m_lightGroup = self:CreatePhaseGOItem(LIGHT_GROUP_NAME, self.m_sceneRoot.view.sceneLight)
|
|
if UNITY_EDITOR then
|
|
|
|
local additionLightGroup = self.m_lightGroup.go:AddComponent(typeof(CS.Beyond.DevTools.AdditionalLightGroup))
|
|
additionLightGroup.savePath = "Assets/Beyond/DynamicAssets/Gameplay/Prefabs/Wiki/"
|
|
end
|
|
self.m_categorySceneItem = {}
|
|
self.m_categorySceneItem[WikiConst.EWikiCategoryType.Weapon] = {
|
|
camera = self.m_cameraGroup.view.weapon,
|
|
light = self.m_lightGroup.view.weapon,
|
|
}
|
|
self.m_categorySceneItem[WikiConst.EWikiCategoryType.Building] = {
|
|
camera = self.m_cameraGroup.view.building,
|
|
light = self.m_lightGroup.view.building,
|
|
}
|
|
self.m_categorySceneItem[WikiConst.EWikiCategoryType.Monster] = {
|
|
camera = self.m_cameraGroup.view.monster,
|
|
light = self.m_lightGroup.view.monster,
|
|
}
|
|
for _, sceneItem in pairs(self.m_categorySceneItem) do
|
|
sceneItem.camera.gameObject:SetActive(false)
|
|
sceneItem.camera.gameObject:SetAllChildrenActiveIfNecessary(false)
|
|
sceneItem.light.gameObject:SetActive(false)
|
|
end
|
|
self.m_isSceneInit = true
|
|
end
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki.m_modelRequestIdLut = HL.Field(HL.Table)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.m_activeModelGos = HL.Field(HL.Table)
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.m_animatorControllerCache = HL.Field(HL.Table)
|
|
|
|
|
|
PhaseWiki.m_buildingRenderer = HL.Field(HL.Userdata)
|
|
|
|
|
|
PhaseWiki.m_buildingPhaseItem = HL.Field(HL.Forward("PhaseGameObjectItem"))
|
|
|
|
|
|
PhaseWiki.m_weaponDecoBundleList = HL.Field(HL.Table)
|
|
|
|
|
|
PhaseWiki.m_monsterEffectList = HL.Field(HL.Table)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.ShowModel = HL.Method(HL.Table, HL.Opt(HL.Table)) << function(self, wikiEntryShowData, extraArgs)
|
|
if not self.m_isSceneInit then
|
|
return
|
|
end
|
|
self.m_currentModelCategory = wikiEntryShowData.wikiCategoryType
|
|
self:ActiveCategorySceneItem(wikiEntryShowData.wikiCategoryType)
|
|
self:ResetModelRotateRoot()
|
|
self:ResetScene()
|
|
local showFunc = SHOW_MODEL_FUNC[wikiEntryShowData.wikiCategoryType]
|
|
if showFunc then
|
|
self[showFunc](self, wikiEntryShowData, extraArgs)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki._ShowWeaponModel = HL.Method(HL.Table, HL.Opt(HL.Table)) << function(self, wikiEntryShowData, extraArgs)
|
|
self:DestroyModel()
|
|
local hasValue
|
|
|
|
local weaponBasicData
|
|
hasValue, weaponBasicData = Tables.weaponBasicTable:TryGetValue(wikiEntryShowData.wikiEntryData.refItemId)
|
|
if hasValue then
|
|
local isMax = extraArgs.isWeaponRefinedMax == true
|
|
local isGemMax = extraArgs.isWeaponGemMax == true
|
|
local playInAim = extraArgs.playInAnim == true
|
|
local modelPath
|
|
hasValue, modelPath = CS.Beyond.Gameplay.WeaponUtil.TryGetWeaponModelByTemplateId(weaponBasicData.weaponId, isMax)
|
|
|
|
|
|
local wikiWeaponData
|
|
hasValue, wikiWeaponData = DataManager.wikiModelConfig.weaponDataDict:TryGetValue(weaponBasicData.weaponType)
|
|
if hasValue then
|
|
local spawnDataList = wikiWeaponData.spawnDataList
|
|
for i = 1, spawnDataList.Length do
|
|
local spawnData = spawnDataList[CSIndex(i)]
|
|
self:_LoadModelAsync(modelPath, function(goInfo)
|
|
|
|
local go = goInfo.gameObject
|
|
go.transform.localPosition = spawnData.position
|
|
go.transform.localEulerAngles = spawnData.rotation
|
|
go.transform.localScale = spawnData.scale
|
|
|
|
|
|
if isGemMax and #weaponBasicData.weaponSkillList >= 3 then
|
|
|
|
local decoEffectData
|
|
local hasValue
|
|
hasValue, decoEffectData = DataManager.weaponDecoEffectConfig.weaponDecoEffectDict:TryGetValue(weaponBasicData.weaponId)
|
|
if hasValue then
|
|
local decoDataList = {}
|
|
table.insert(decoDataList, decoEffectData.gemMaxDeco)
|
|
|
|
self.m_weaponDecoBundleList = self.m_weaponDecoBundleList or {}
|
|
local weaponDecoBundle = CS.Beyond.Gameplay.WeaponUtil.SetWeaponDecoEffect(go.transform, decoDataList)
|
|
table.insert(self.m_weaponDecoBundleList, weaponDecoBundle)
|
|
end
|
|
end
|
|
|
|
if playInAim then
|
|
self:PlayModelRootInAnim(WikiConst.EWikiCategoryType.Weapon)
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
PhaseWiki.m_curBuildingRendererTemplateId = HL.Field(HL.String) << ''
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki._ShowBuildingModel = HL.Method(HL.Table, HL.Opt(HL.Table)) << function(self, wikiEntryShowData, extraArgs)
|
|
local rendererTemplateId
|
|
local _, factoryBuildingItemData = Tables.factoryBuildingItemTable:TryGetValue(wikiEntryShowData.wikiEntryData.refItemId)
|
|
if factoryBuildingItemData then
|
|
rendererTemplateId = factoryBuildingItemData.buildingId
|
|
else
|
|
local _, factoryLogisticItemData = Tables.factoryItem2LogisticIdTable:TryGetValue(wikiEntryShowData.wikiEntryData.refItemId)
|
|
if factoryLogisticItemData then
|
|
rendererTemplateId = factoryLogisticItemData.logisticId
|
|
end
|
|
end
|
|
if rendererTemplateId then
|
|
local model = self.m_sceneRoot.view.buildingECSModel
|
|
|
|
local spawnData
|
|
_, spawnData = DataManager.wikiModelConfig.buildingDataDict:TryGetValue(rendererTemplateId)
|
|
if not spawnData then
|
|
spawnData = DataManager.wikiModelConfig.defaultBuildingSpawnData
|
|
end
|
|
model.transform.localPosition = spawnData.position
|
|
model.transform.localEulerAngles = spawnData.rotation
|
|
self:_SetCameraParams(self.m_currentCamera.vcam_entry, spawnData.cameraDistance)
|
|
self:_SetCameraParams(self.m_currentCamera.vcam_show, spawnData.cameraDistance * DataManager.wikiModelConfig.buildingShowCameraDistanceScale)
|
|
local cameraDistance = DataManager.wikiModelConfig.buildingDefaultCameraDistance
|
|
local sceneScale = (spawnData.cameraDistance - cameraDistance) / cameraDistance + 1
|
|
self:SetSceneScale(sceneScale)
|
|
local factor = DataManager.wikiModelConfig.buildingSceneScaleOffsetFactor
|
|
local sceneOffset = -factor * sceneScale + factor + DataManager.wikiModelConfig.buildingSceneOffsetY * sceneScale
|
|
self:SetSceneOffset(sceneOffset)
|
|
self.m_sceneRoot.view.ground:SetParent(self.m_currentCamera.vcam_entry.transform, true)
|
|
self.m_sceneRoot.view.ground.localPosition = self.m_sceneRoot.view.config.BUILDING_GROUND_OFFSET
|
|
self.m_sceneRoot.view.ground.localScale = self.m_sceneRoot.view.config.BUILDING_GROUND_SCALE
|
|
|
|
local playInAnim = extraArgs and extraArgs.playInAnim
|
|
if playInAnim then
|
|
self:PlayModelRootInAnim(WikiConst.EWikiCategoryType.Building)
|
|
end
|
|
|
|
model.gameObject:SetActiveIfNecessary(true)
|
|
if rendererTemplateId ~= self.m_curBuildingRendererTemplateId then
|
|
model:ChangeTemplate(rendererTemplateId, true, true)
|
|
end
|
|
model:Cutoff(true, 0, 1)
|
|
|
|
if playInAnim then
|
|
model:OnEnterWikiBuildingDetailUI()
|
|
end
|
|
|
|
self.m_curBuildingRendererTemplateId = rendererTemplateId
|
|
|
|
if UNITY_EDITOR then
|
|
DataManager.wikiModelConfig:TryEditModel()
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki._ShowMonsterModel = HL.Method(HL.Table, HL.Opt(HL.Table)) << function(self, wikiEntryShowData, extraArgs)
|
|
self:DestroyModel()
|
|
local monsterTemplateId = wikiEntryShowData.wikiEntryData.refMonsterTemplateId
|
|
local _, monsterTemplateData = DataManager:TryGetEntityTemplate(Const.ObjectType.Enemy, monsterTemplateId)
|
|
if not monsterTemplateData then
|
|
return
|
|
end
|
|
|
|
local modelCompData = monsterTemplateData:FindComponentData(typeof(CS.Beyond.Gameplay.View.ModelComponentData))
|
|
if not modelCompData then
|
|
return
|
|
end
|
|
local modelId = modelCompData.modelId
|
|
if not modelId or string.isEmpty(modelId) then
|
|
return
|
|
end
|
|
local _, modelData = DataManager.modelData:TryGetValue(modelId)
|
|
if not modelData or not modelData.path or string.isEmpty(modelData.path) then
|
|
return
|
|
end
|
|
|
|
local playInAim = false
|
|
if extraArgs then
|
|
playInAim = extraArgs.playInAnim == true
|
|
end
|
|
self:_LoadModelAsync(modelData.path, function(enemyModelGoInfo)
|
|
local enemyModelGo = enemyModelGoInfo.gameObject
|
|
local animator = enemyModelGoInfo.animator
|
|
local isSuccess, rigBuilder = enemyModelGo:TryGetComponent(typeof(Unity.Animations.Rigging.RigBuilder))
|
|
if isSuccess then
|
|
rigBuilder.enabled = false
|
|
end
|
|
local clothCpts = enemyModelGo:GetComponentsInChildren(typeof(CS.BeyondDynamicBone.BeyondBoneCloth))
|
|
if clothCpts then
|
|
for i = 0, clothCpts.Length - 1 do
|
|
clothCpts[i].enabled = false
|
|
end
|
|
end
|
|
local _, wikiMonsterSpawnData = DataManager.wikiModelConfig.monsterDataDict:TryGetValue(monsterTemplateId)
|
|
if not wikiMonsterSpawnData then
|
|
wikiMonsterSpawnData = DataManager.wikiModelConfig.defaultMonsterSpawnData
|
|
end
|
|
enemyModelGo.transform.localPosition = wikiMonsterSpawnData.position
|
|
enemyModelGo.transform.localEulerAngles = wikiMonsterSpawnData.rotation
|
|
enemyModelGo.transform.localScale = wikiMonsterSpawnData.scale
|
|
if animator then
|
|
|
|
local animatorCtrlAsset = self.m_animatorControllerCache[monsterTemplateId]
|
|
if not animatorCtrlAsset then
|
|
animatorCtrlAsset = self.m_resourceLoader:LoadAnimatorController(string.format(WIKI_ENY_POSE_CONTROLLER_PATH, monsterTemplateId))
|
|
self.m_animatorControllerCache[monsterTemplateId] = animatorCtrlAsset
|
|
end
|
|
if animatorCtrlAsset then
|
|
animator.runtimeAnimatorController = animatorCtrlAsset
|
|
animator:Update(0)
|
|
end
|
|
end
|
|
|
|
if wikiMonsterSpawnData.effects and wikiMonsterSpawnData.effects.Length > 0 then
|
|
for i = 0, wikiMonsterSpawnData.effects.Length - 1 do
|
|
|
|
local effectData = wikiMonsterSpawnData.effects[i]
|
|
if effectData and not string.isEmpty(effectData.name) then
|
|
local mountPoint = enemyModelGo.transform
|
|
if not string.isEmpty(effectData.mountPoint) then
|
|
mountPoint = enemyModelGo.transform:FindRecursive(effectData.mountPoint)
|
|
end
|
|
if mountPoint then
|
|
|
|
local mountPointHelper = Unity.GameObject("mountPointHelper").transform
|
|
mountPointHelper:SetParent(mountPoint, false)
|
|
mountPointHelper.localPosition = effectData.offset
|
|
mountPointHelper.localEulerAngles = effectData.rotation
|
|
mountPointHelper.localScale = effectData.scale
|
|
local scaleTransform = nil
|
|
if effectData.followScale then
|
|
scaleTransform = mountPointHelper
|
|
end
|
|
local effectInstance = GameInstance.effectManager:CreateEffectOnTransform(
|
|
effectData.name, mountPointHelper, effectData.followRotation, scaleTransform)
|
|
self.m_monsterEffectList = self.m_monsterEffectList or {}
|
|
table.insert(self.m_monsterEffectList, effectInstance)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
if playInAim then
|
|
self:PlayModelRootInAnim(WikiConst.EWikiCategoryType.Monster)
|
|
end
|
|
end)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki._LoadModelAsync = HL.Method(HL.String, HL.Function) << function(self, modelPath, callback)
|
|
local m_modelRequestId = self.modelLoader:LoadModelAsync(modelPath, self.m_sceneRoot.view.modelRoot, function(activeModelGo)
|
|
self.m_modelRequestIdLut[modelPath] = nil
|
|
if activeModelGo and callback then
|
|
|
|
|
|
local activeModelInfo = {
|
|
gameObject = activeModelGo
|
|
}
|
|
|
|
local success, animator = activeModelGo:TryGetComponent(typeof(CS.UnityEngine.Animator))
|
|
if success then
|
|
activeModelInfo.animator = animator
|
|
activeModelInfo.animatorController = animator.runtimeAnimatorController
|
|
end
|
|
table.insert(self.m_activeModelGos, activeModelInfo)
|
|
callback(activeModelInfo)
|
|
if UNITY_EDITOR then
|
|
self:_StartCoroutine(function()
|
|
coroutine.step()
|
|
coroutine.step()
|
|
DataManager.wikiModelConfig:TryEditModel()
|
|
end)
|
|
end
|
|
end
|
|
end)
|
|
self.m_modelRequestIdLut[modelPath] = m_modelRequestId
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki._SetCameraParams = HL.Method(HL.Userdata, HL.Number) << function(self, vcam, cameraDistance)
|
|
local vcamTransform = vcam.transform
|
|
local cameraPosition = vcamTransform.localPosition
|
|
cameraPosition.z = cameraDistance
|
|
vcamTransform.localPosition = cameraPosition
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki.DestroyModel = HL.Method() << function(self)
|
|
if not self.m_isSceneInit then
|
|
return
|
|
end
|
|
self.m_currentModelCategory = ''
|
|
if self.m_weaponDecoBundleList then
|
|
for _, bundle in ipairs(self.m_weaponDecoBundleList) do
|
|
bundle:Dispose()
|
|
end
|
|
self.m_weaponDecoBundleList = nil
|
|
end
|
|
|
|
if self.m_monsterEffectList then
|
|
for _, effect in ipairs(self.m_monsterEffectList) do
|
|
effect:Finish(true)
|
|
end
|
|
self.m_monsterEffectList = nil
|
|
end
|
|
|
|
for path, requestId in pairs(self.m_modelRequestIdLut) do
|
|
self.modelLoader:Cancel(requestId)
|
|
self.m_modelRequestIdLut[path] = nil
|
|
end
|
|
|
|
for index, activeModelInfo in pairs(self.m_activeModelGos) do
|
|
local activeModel = activeModelInfo.gameObject
|
|
|
|
local animator = activeModelInfo.animator
|
|
if animator then
|
|
animator.runtimeAnimatorController = activeModelInfo.animatorController
|
|
end
|
|
activeModel.transform.localScale = Vector3.one
|
|
self.modelLoader:UnloadModel(activeModel)
|
|
self.m_activeModelGos[index] = nil
|
|
end
|
|
|
|
if IsNull(self.m_sceneRoot.view.gameObject) then
|
|
return
|
|
end
|
|
|
|
|
|
self.m_sceneRoot.view.buildingECSModel:Cutoff(false)
|
|
self.m_sceneRoot.view.buildingECSModel:OnLeaveWikiBuildingDetailUI()
|
|
self.m_sceneRoot.view.buildingECSModel.gameObject:SetActiveIfNecessary(false)
|
|
self.m_curBuildingRendererTemplateId = ''
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.SetSceneScale = HL.Method(HL.Number) << function(self, scale)
|
|
if not self.m_isSceneInit then
|
|
return
|
|
end
|
|
self.m_sceneRoot.view.sceneRoot.transform.localScale = Vector3.one * scale
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.SetSceneOffset = HL.Method(HL.Number) << function(self, offsetY)
|
|
if not self.m_isSceneInit then
|
|
return
|
|
end
|
|
local pos = self.m_sceneRoot.view.sceneRoot.transform.localPosition
|
|
pos.y = offsetY
|
|
self.m_sceneRoot.view.sceneRoot.transform.localPosition = pos
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.RotateModel = HL.Method(HL.Number) << function(self, deltaX)
|
|
if not self.m_isSceneInit then
|
|
return
|
|
end
|
|
local rotateRoot = self.m_sceneRoot.view.modelRotateRoot.transform
|
|
rotateRoot:Rotate(rotateRoot.up, -deltaX)
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki.ResetModelRotateRoot = HL.Method() << function(self)
|
|
if not self.m_isSceneInit then
|
|
return
|
|
end
|
|
self:ActiveModelRotateRoot(true)
|
|
self.m_sceneRoot.view.modelRotateRoot.transform.localPosition = Vector3.zero
|
|
self:ResetModelRotation()
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki.ResetModelRotation = HL.Method() << function(self)
|
|
if not self.m_isSceneInit then
|
|
return
|
|
end
|
|
self.m_sceneRoot.view.modelRotateRoot.transform.localEulerAngles = Vector3.zero
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseWiki.ActiveModelRotateRoot = HL.Method(HL.Boolean, HL.Opt(HL.Boolean)) << function(self, active, noResetScene)
|
|
if not self.m_isSceneInit or IsNull(self.m_sceneRoot.go) then
|
|
return
|
|
end
|
|
if self.m_sceneRoot.view.modelRotateRoot.gameObject.activeSelf ~= active then
|
|
self.m_sceneRoot.view.modelRotateRoot.gameObject:SetActive(active)
|
|
local buildingModel = self.m_sceneRoot.view.buildingECSModel
|
|
if buildingModel.gameObject.activeSelf then
|
|
if active then
|
|
buildingModel:OnEnterWikiBuildingDetailUI()
|
|
else
|
|
buildingModel:OnLeaveWikiBuildingDetailUI()
|
|
end
|
|
end
|
|
end
|
|
|
|
if not active and noResetScene ~= true then
|
|
self:ResetScene()
|
|
end
|
|
|
|
if self.m_monsterEffectList then
|
|
for _, effect in ipairs(self.m_monsterEffectList) do
|
|
effect:SetVisible(active)
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
PhaseWiki.ResetScene = HL.Method() << function(self)
|
|
if not self.m_isSceneInit or IsNull(self.m_sceneRoot.go) then
|
|
return
|
|
end
|
|
self:SetSceneScale(1)
|
|
self:SetSceneOffset(0)
|
|
self.m_sceneRoot.view.ground:SetParent(self.m_sceneRoot.view.bgAnim.transform, true)
|
|
self.m_sceneRoot.view.ground.localPosition = Vector3.zero
|
|
self.m_sceneRoot.view.ground.localScale = self.m_sceneRoot.view.config.DEFAULT_GROUND_SCALE
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.PlayModelRootInAnim = HL.Method(HL.String) << function(self, modelType)
|
|
local animWrapper = modelType == WikiConst.EWikiCategoryType.Building and
|
|
self.m_sceneRoot.view.buildingModelAnimWrapper or
|
|
self.m_sceneRoot.view.modelRootAnimWrapper
|
|
animWrapper:Play(MODEL_ROOT_ANIM_NAME[modelType])
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.ActiveEntryVirtualCamera = HL.Method(HL.Boolean) << function(self, active)
|
|
if not IsNull(self.m_currentCamera) and self.m_isSceneInit then
|
|
self.m_currentCamera.vcam_entry.gameObject:SetActive(active)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.ActiveShowVirtualCamera = HL.Method(HL.Boolean) << function(self, active)
|
|
if not IsNull(self.m_currentCamera) and self.m_isSceneInit then
|
|
self.m_currentCamera.vcam_show.gameObject:SetActive(active)
|
|
|
|
if self.m_currentModelCategory == WikiConst.EWikiCategoryType.Building then
|
|
local parent = active and self.m_currentCamera.vcam_show.transform or self.m_currentCamera.vcam_entry.transform
|
|
self.m_sceneRoot.view.ground:SetParent(parent, true)
|
|
self.m_sceneRoot.view.ground.localPosition = self.m_sceneRoot.view.config.BUILDING_GROUND_OFFSET
|
|
self.m_sceneRoot.view.ground.localScale = self.m_sceneRoot.view.config.BUILDING_GROUND_SCALE
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.ActiveCategorySceneItem = HL.Method(HL.String) << function(self, categoryType)
|
|
if not self.m_isSceneInit then
|
|
return
|
|
end
|
|
self:ActiveMainSceneItem(false)
|
|
self:ActiveCommonSceneItem(false)
|
|
local camera
|
|
for id, sceneItem in pairs(self.m_categorySceneItem) do
|
|
local isActivated = id == categoryType
|
|
sceneItem.camera.gameObject:SetActive(isActivated)
|
|
sceneItem.light.gameObject:SetActive(isActivated)
|
|
if isActivated then
|
|
camera = sceneItem.camera
|
|
end
|
|
end
|
|
|
|
self.m_currentCamera = camera
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.ActiveMainSceneItem = HL.Method(HL.Boolean) << function(self, active)
|
|
if IsNull(self.m_lightGroup.go) or IsNull(self.m_cameraGroup.go) then
|
|
return
|
|
end
|
|
if active then
|
|
self:ActiveCategorySceneItem('')
|
|
self:ActiveCommonSceneItem(false)
|
|
end
|
|
self.m_lightGroup.view.common.gameObject:SetActive(active)
|
|
self.m_cameraGroup.view.main.gameObject:SetActive(active)
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.ActiveCommonSceneItem = HL.Method(HL.Boolean) << function(self, active)
|
|
if IsNull(self.m_lightGroup.go) or IsNull(self.m_cameraGroup.go) then
|
|
return
|
|
end
|
|
if active then
|
|
self:ActiveCategorySceneItem('')
|
|
self:ActiveMainSceneItem(false)
|
|
end
|
|
self.m_lightGroup.view.common.gameObject:SetActive(active)
|
|
self.m_cameraGroup.view.common.gameObject:SetActive(active)
|
|
end
|
|
|
|
|
|
PhaseWiki.m_blackBoxEffectActive = HL.Field(HL.Any)
|
|
|
|
|
|
|
|
|
|
PhaseWiki._ActivateBlackboxEffect = HL.Method(HL.Boolean) << function(self, active)
|
|
if not Utils.isInBlackbox() then
|
|
return
|
|
end
|
|
if not GameInstance.remoteFactoryManager.blackboxIntroEffectController or
|
|
not GameInstance.remoteFactoryManager.blackboxIntroEffectController.effect or
|
|
not GameInstance.remoteFactoryManager.blackboxIntroEffectController.effect.ActivateVFXPPBlackBox then
|
|
return
|
|
end
|
|
if active == self.m_blackBoxEffectActive then
|
|
return
|
|
end
|
|
self.m_blackBoxEffectActive = active
|
|
GameInstance.remoteFactoryManager.blackboxIntroEffectController.effect:ActivateVFXPPBlackBox(active)
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.PlayDecoAnim = HL.Method(HL.String) << function(self, animName)
|
|
if not self.m_isSceneInit or not self:_CheckAllTransitionDone() then
|
|
return
|
|
end
|
|
self.m_sceneRoot.view.decoAnim:ClearTween()
|
|
self.m_sceneRoot.view.decoAnim:Play(animName)
|
|
end
|
|
|
|
|
|
|
|
|
|
PhaseWiki.PlayBgAnim = HL.Method(HL.String) << function(self, animName)
|
|
if not self.m_isSceneInit then
|
|
return
|
|
end
|
|
self.m_sceneRoot.view.bgAnim:ClearTween()
|
|
self.m_sceneRoot.view.bgAnim:Play(animName)
|
|
end
|
|
|
|
|
|
|
|
HL.Commit(PhaseWiki) |