import { readBattleBuffPassiveSpawnWeapon2Id } from '../../manager/battleBuff/BattleBuffPassiveSkillUtil'; import type { BattleGamePassiveSkillHost } from './BattleGamePassiveSkillHost'; /** * functiontype=3 蟠桃树:CD 结束优先空 Dig、否则空 Put 产字。 */ export class BattleGamePassivePeachTreeSpawn { /** * 尝试产字并播放飞行动画。 * @param slotIndex 被动槽下标 * @returns 是否已受理(含异步飞行) */ static trySpawn(row: ITableBattlebuff, host: BattleGamePassiveSkillHost, slotIndex: number): boolean { if (slotIndex < 0) return false; const weapon2Id = readBattleBuffPassiveSpawnWeapon2Id(row); if (weapon2Id <= 0) return false; host.setPassiveSpawnInflight(slotIndex, true); const battle = host.battle; const bagView = host.bagView; const bagSession = battle?.bagSession; if (!bagSession || !bagView) { console.log('[PassiveSkill] 蟠桃树产字失败:bag 未就绪'); host.setPassiveSpawnInflight(slotIndex, false); return false; } const gridIndex = bagSession.findPassiveDigSpawnGrid(); if (gridIndex == null) { host.setPassiveSpawnInflight(slotIndex, false); return false; } const fromWorld = host.getIconWorldPosition(slotIndex); if (!fromWorld) { console.log('[PassiveSkill] 蟠桃树产字失败:被动图标坐标缺失', slotIndex); host.setPassiveSpawnInflight(slotIndex, false); return false; } bagView.playPassiveTileSpawnFlight({ fromWorld, gridIndex, weapon2Id, onComplete: () => { host.setPassiveSpawnInflight(slotIndex, false); host.restartPassiveCd(slotIndex); }, }); return true; } }