captainbattle 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/CallID.d.ts +121 -105
- package/dist/core/CallID.js +128 -105
- package/dist/core/ListenID.d.ts +503 -443
- package/dist/core/ListenID.js +513 -443
- package/dist/core/config/AccessoriesDrawCfg.d.ts +9 -0
- package/dist/core/config/AccessoriesDrawCfg.js +8 -0
- package/dist/core/config/BadgeCfg.d.ts +76 -19
- package/dist/core/config/BadgeCfg.js +76 -19
- package/dist/core/config/BountyTaskCfg.d.ts +1 -1
- package/dist/core/config/BuffCfg.d.ts +3 -0
- package/dist/core/config/BuffCfg.js +3 -0
- package/dist/core/config/Cfg.d.ts +224 -120
- package/dist/core/config/Cfg.js +251 -121
- package/dist/core/config/ChatChannelCfg.d.ts +8 -2
- package/dist/core/config/ChatChannelCfg.js +7 -1
- package/dist/core/config/ChatEmojiCfg.d.ts +0 -2
- package/dist/core/config/Const.d.ts +3 -1
- package/dist/core/config/Const.js +2 -0
- package/dist/core/config/DailyTrialMapCfg.d.ts +1 -2
- package/dist/core/config/EmailCfg.d.ts +13 -1
- package/dist/core/config/EmailCfg.js +13 -1
- package/dist/core/config/FirstRechargeCfg.d.ts +1 -0
- package/dist/core/config/FuncDescCfg.d.ts +33 -3
- package/dist/core/config/FuncDescCfg.js +33 -3
- package/dist/core/config/FusionLevelCfg.d.ts +10 -0
- package/dist/core/config/FusionLevelCfg.js +8 -0
- package/dist/core/config/GuildBonusLogCfg.d.ts +8 -0
- package/dist/core/config/GuildBonusLogCfg.js +8 -0
- package/dist/core/config/GuildBossRankRewardCfg.d.ts +2 -1
- package/dist/core/config/GuildConfigCfg.d.ts +1 -1
- package/dist/core/config/GuildConfigCfg.js +1 -1
- package/dist/core/config/GuildDonateCfg.d.ts +4 -2
- package/dist/core/config/GuildIslandBuildCfg.d.ts +16 -0
- package/dist/core/config/GuildIslandBuildCfg.js +8 -0
- package/dist/core/config/GuildIslandBuildItemCfg.d.ts +11 -0
- package/dist/core/config/GuildIslandBuildItemCfg.js +8 -0
- package/dist/core/config/GuildIslandConfigCfg.d.ts +19 -0
- package/dist/core/config/GuildIslandConfigCfg.js +16 -0
- package/dist/core/config/GuildIslandIslandCfg.d.ts +9 -0
- package/dist/core/config/GuildIslandIslandCfg.js +8 -0
- package/dist/core/config/GuildIslandRankCfg.d.ts +11 -0
- package/dist/core/config/GuildIslandRankCfg.js +8 -0
- package/dist/core/config/GuildIslandZoneCfg.d.ts +11 -0
- package/dist/core/config/GuildIslandZoneCfg.js +8 -0
- package/dist/core/config/GuildLogCfg.d.ts +1 -0
- package/dist/core/config/GuildLvCfg.d.ts +1 -1
- package/dist/core/config/InviteConfigCfg.d.ts +14 -0
- package/dist/core/config/InviteConfigCfg.js +11 -0
- package/dist/core/config/InviteRewardCfg.d.ts +9 -0
- package/dist/core/config/InviteRewardCfg.js +8 -0
- package/dist/core/config/ItemsCfg.d.ts +5 -1
- package/dist/core/config/ItemsCfg.js +4 -0
- package/dist/core/config/MarqueeContentCfg.d.ts +7 -0
- package/dist/core/config/MarqueeContentCfg.js +7 -1
- package/dist/core/config/ModAffixLvCfg.d.ts +12 -0
- package/dist/core/config/ModAffixLvCfg.js +8 -0
- package/dist/core/config/PetCfg.d.ts +0 -2
- package/dist/core/config/PetConfigCfg.d.ts +19 -0
- package/dist/core/config/PetConfigCfg.js +16 -0
- package/dist/core/config/PetDrawCfg.d.ts +9 -0
- package/dist/core/config/PetDrawCfg.js +8 -0
- package/dist/core/config/PetSkillCfg.d.ts +2 -1
- package/dist/core/config/PrivilegeCfg.d.ts +2 -0
- package/dist/core/config/PrivilegeCfg.js +2 -0
- package/dist/core/config/ProDefineCfg.d.ts +2 -0
- package/dist/core/config/QualityCfg.d.ts +1 -0
- package/dist/core/config/RelicDungeonConfigCfg.d.ts +14 -4
- package/dist/core/config/RelicDungeonConfigCfg.js +14 -4
- package/dist/core/config/RelicDungeonGrowCfg.d.ts +7 -0
- package/dist/core/config/RelicDungeonGrowCfg.js +8 -0
- package/dist/core/config/RelicDungeonLevelCfg.d.ts +4 -10
- package/dist/core/config/RelicDungeonRankRewardCfg.d.ts +9 -0
- package/dist/core/config/RelicDungeonRankRewardCfg.js +8 -0
- package/dist/core/config/RelicDungeonScoreCfg.d.ts +11 -0
- package/dist/core/config/RelicDungeonScoreCfg.js +8 -0
- package/dist/core/config/RelicDungeonScoreRewardCfg.d.ts +9 -0
- package/dist/core/config/RelicDungeonScoreRewardCfg.js +8 -0
- package/dist/core/config/RelicTiesCfg.d.ts +1 -0
- package/dist/core/config/RobotConfigCfg.d.ts +17 -0
- package/dist/core/config/RobotConfigCfg.js +8 -0
- package/dist/core/config/RoleCfg.d.ts +1 -0
- package/dist/core/config/RuleDescCfg.d.ts +12 -2
- package/dist/core/config/RuleDescCfg.js +12 -2
- package/dist/core/config/SeaArenaConfigCfg.d.ts +22 -0
- package/dist/core/config/SeaArenaConfigCfg.js +19 -0
- package/dist/core/config/SeaArenaRankRewardCfg.d.ts +10 -0
- package/dist/core/config/SeaArenaRankRewardCfg.js +8 -0
- package/dist/core/config/SeaArenaRobotCfg.d.ts +8 -0
- package/dist/core/config/SeaArenaRobotCfg.js +8 -0
- package/dist/core/config/SeaArenaTierCfg.d.ts +13 -0
- package/dist/core/config/SeaArenaTierCfg.js +8 -0
- package/dist/core/config/ShopCfg.d.ts +1 -0
- package/dist/core/config/SkillLvCfg.d.ts +10 -0
- package/dist/core/config/SkillLvCfg.js +8 -0
- package/dist/core/config/SkinSkillCfg.d.ts +2 -1
- package/dist/core/config/SprintActivityConfigCfg.d.ts +18 -3
- package/dist/core/config/SprintActivityConfigCfg.js +18 -3
- package/dist/core/config/StageCfg.d.ts +2 -0
- package/dist/core/config/TConfig.d.ts +1 -1
- package/dist/core/config/TConfig.js +6 -4
- package/dist/core/config/TalentTreeLvCfg.d.ts +1 -1
- package/dist/core/config/TurretFusionLevelCfg.d.ts +10 -0
- package/dist/core/config/TurretFusionLevelCfg.js +8 -0
- package/dist/core/config/TurretModAffixLvCfg.d.ts +12 -0
- package/dist/core/config/TurretModAffixLvCfg.js +8 -0
- package/dist/core/config/TurretModCfg.d.ts +20 -0
- package/dist/core/config/TurretModCfg.js +8 -0
- package/dist/core/config/TurretModConfigCfg.d.ts +20 -0
- package/dist/core/config/TurretModConfigCfg.js +17 -0
- package/dist/core/config/TurretModQualityCfg.d.ts +12 -0
- package/dist/core/config/TurretModQualityCfg.js +8 -0
- package/dist/core/config/TurretSkillLvCfg.d.ts +10 -0
- package/dist/core/config/TurretSkillLvCfg.js +8 -0
- package/dist/core/config/VehicleWashAffixCfg.d.ts +14 -0
- package/dist/core/config/VehicleWashAffixCfg.js +8 -0
- package/dist/core/config/VehicleWashLevelCfg.d.ts +6 -2
- package/dist/core/framework/Pool.d.ts +4 -1
- package/dist/core/framework/Pool.js +19 -21
- package/dist/core/framework/Time.js +13 -3
- package/dist/core/framework/Watcher.js +0 -1
- package/dist/core/framework/collections/MinSortList.d.ts +0 -2
- package/dist/core/framework/collections/MinSortList.js +9 -33
- package/dist/core/framework/collections/ObjectPool.js +6 -3
- package/dist/core/framework/notify/Notifier.d.ts +1 -1
- package/dist/core/framework/notify/Notifier.js +5 -4
- package/dist/core/framework/notify/NotifyID.d.ts +2 -1
- package/dist/core/framework/notify/NotifyID.js +1 -0
- package/dist/core/framework/notify/NotifyListener.js +35 -9
- package/dist/core/module/arena/ArenaBattleModule.d.ts +7 -0
- package/dist/core/module/arena/ArenaBattleModule.js +32 -0
- package/dist/core/module/arena/index.d.ts +1 -0
- package/dist/core/module/arena/index.js +13 -0
- package/dist/core/module/battle/Game.d.ts +104 -13
- package/dist/core/module/battle/Game.js +218 -45
- package/dist/core/module/battle/IGameModule.d.ts +6 -0
- package/dist/core/module/battle/IGameModule.js +19 -6
- package/dist/core/module/battle/battle.interface.d.ts +31 -7
- package/dist/core/module/battle/battle.interface.js +5 -1
- package/dist/core/module/battle/buff/BuffMgr.d.ts +25 -0
- package/dist/core/module/battle/buff/BuffMgr.js +43 -0
- package/dist/core/module/battle/buff/BuffTrigger.js +9 -1
- package/dist/core/module/battle/buff/buffitem/AddPhysicDamBuff.js +2 -2
- package/dist/core/module/battle/buff/buffitem/ChangeSetpAddDamageBuff.js +3 -2
- package/dist/core/module/battle/buff/buffitem/DeltaUseSkillBuff.js +3 -2
- package/dist/core/module/battle/buff/buffitem/DiceAddCritBuff.d.ts +8 -0
- package/dist/core/module/battle/buff/buffitem/DiceAddCritBuff.js +35 -0
- package/dist/core/module/battle/buff/buffitem/FireHurtLayerBuff.d.ts +7 -0
- package/dist/core/module/battle/buff/buffitem/FireHurtLayerBuff.js +28 -0
- package/dist/core/module/battle/buff/buffitem/ForceTargetBuff.js +2 -1
- package/dist/core/module/battle/buff/buffitem/HitBoundAddDamageBuff.js +1 -1
- package/dist/core/module/battle/buff/buffitem/HitBoundAddScaleBuff.d.ts +11 -0
- package/dist/core/module/battle/buff/buffitem/HitBoundAddScaleBuff.js +79 -0
- package/dist/core/module/battle/buff/buffitem/LinkCurseBuff.js +3 -2
- package/dist/core/module/battle/buff/buffitem/MonitorBuff.js +10 -12
- package/dist/core/module/battle/buff/buffitem/PosionBanCureBuff.d.ts +3 -0
- package/dist/core/module/battle/buff/buffitem/PosionBanCureBuff.js +18 -0
- package/dist/core/module/battle/buff/buffitem/PosionBuff.d.ts +1 -0
- package/dist/core/module/battle/buff/buffitem/PosionBuff.js +15 -4
- package/dist/core/module/battle/buff/buffitem/ProjectileOrbLinkBuff.js +1 -1
- package/dist/core/module/battle/buff/buffitem/ProjectileScaleUpBuff.js +4 -2
- package/dist/core/module/battle/buff/buffitem/SameHitAddDamageBuff.js +8 -0
- package/dist/core/module/battle/buff/buffitem/SlayBuff.js +1 -1
- package/dist/core/module/battle/buff/buffitem/TimeAddDamageBuff.d.ts +1 -1
- package/dist/core/module/battle/buff/buffitem/TimeAddDamageBuff.js +36 -27
- package/dist/core/module/battle/buff/buffitem/index.d.ts +4 -0
- package/dist/core/module/battle/buff/buffitem/index.js +5 -1
- package/dist/core/module/battle/entity/BaseEntityData.d.ts +15 -1
- package/dist/core/module/battle/entity/BaseEntityData.js +27 -0
- package/dist/core/module/battle/entity/DragonBodyData.d.ts +19 -1
- package/dist/core/module/battle/entity/DragonBodyData.js +34 -0
- package/dist/core/module/battle/entity/DragonData.d.ts +18 -1
- package/dist/core/module/battle/entity/DragonData.js +32 -0
- package/dist/core/module/battle/entity/EntityPool.d.ts +1 -2
- package/dist/core/module/battle/entity/EntityPool.js +9 -18
- package/dist/core/module/battle/entity/FighterData.d.ts +114 -3
- package/dist/core/module/battle/entity/FighterData.js +350 -6
- package/dist/core/module/battle/entity/ProjectileData.d.ts +2 -0
- package/dist/core/module/battle/entity/ProjectileData.js +25 -0
- package/dist/core/module/battle/entity/RoleData.d.ts +12 -1
- package/dist/core/module/battle/entity/RoleData.js +19 -0
- package/dist/core/module/battle/entity/TurnUnit.d.ts +36 -0
- package/dist/core/module/battle/entity/TurnUnit.js +74 -0
- package/dist/core/module/battle/entity/index.d.ts +1 -1
- package/dist/core/module/battle/entity/index.js +1 -1
- package/dist/core/module/battle/event/EntityEvent.d.ts +13 -0
- package/dist/core/module/battle/event/EntityEvent.js +14 -0
- package/dist/core/module/battle/event/EntityEventBus.d.ts +10 -0
- package/dist/core/module/battle/event/EntityEventBus.js +35 -0
- package/dist/core/module/battle/event/EventListener.d.ts +6 -1
- package/dist/core/module/battle/event/EventListener.js +140 -7
- package/dist/core/module/battle/event/GameEvent.d.ts +8 -0
- package/dist/core/module/battle/event/GameEvent.js +9 -0
- package/dist/core/module/battle/factory/FighterFactory.js +26 -10
- package/dist/core/module/battle/fsm-state/AnyFighterStateTransitions.js +24 -12
- package/dist/core/module/battle/fsm-state/AnyFighterStates.js +9 -5
- package/dist/core/module/battle/fsm-state/Boss18110CallState.d.ts +1 -1
- package/dist/core/module/battle/fsm-state/Boss18110State.d.ts +1 -1
- package/dist/core/module/battle/fsm-state/FighterStateMachine.d.ts +2 -0
- package/dist/core/module/battle/fsm-state/FighterStateMachine.js +6 -0
- package/dist/core/module/battle/fsm-state/FighterStateProfiles.d.ts +8 -1
- package/dist/core/module/battle/fsm-state/FighterStateProfiles.js +31 -0
- package/dist/core/module/battle/fsm-state/FighterStateRegistry.d.ts +3 -0
- package/dist/core/module/battle/fsm-state/FighterStateRegistry.js +27 -8
- package/dist/core/module/battle/fsm-state/FighterStateShared.js +2 -2
- package/dist/core/module/battle/fsm-state/FighterStateType.d.ts +2 -1
- package/dist/core/module/battle/fsm-state/FighterStateType.js +2 -1
- package/dist/core/module/battle/fsm-state/TurnState.d.ts +29 -0
- package/dist/core/module/battle/fsm-state/TurnState.js +208 -0
- package/dist/core/module/battle/fsm-state/TurnTransitions.d.ts +36 -0
- package/dist/core/module/battle/fsm-state/TurnTransitions.js +90 -0
- package/dist/core/module/battle/fsm-state/index.d.ts +2 -0
- package/dist/core/module/battle/fsm-state/index.js +3 -1
- package/dist/core/module/battle/manager/EntityManager.d.ts +1 -0
- package/dist/core/module/battle/manager/EntityManager.js +138 -20
- package/dist/core/module/battle/skill/SkillData.d.ts +27 -0
- package/dist/core/module/battle/skill/SkillData.js +43 -0
- package/dist/core/module/battle/skill/emitter/SkillEmitter.js +4 -1
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter1.d.ts +3 -0
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter1.js +30 -2
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter10.js +2 -2
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter13.d.ts +1 -0
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter13.js +25 -2
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter15.js +1 -1
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter2.js +1 -1
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter23.d.ts +9 -0
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter23.js +75 -11
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter24.js +1 -1
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter26.js +4 -0
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter28.js +1 -1
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter3.d.ts +14 -8
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter3.js +127 -31
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter30.d.ts +36 -0
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter30.js +235 -0
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter31.d.ts +13 -0
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter31.js +47 -0
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter4.d.ts +1 -0
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter4.js +25 -2
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter6.js +10 -6
- package/dist/core/module/battle/skill/emitter/projectiles/ProjectileEmitter8.js +2 -2
- package/dist/core/module/battle/skill/emitter/projectiles/index.d.ts +2 -0
- package/dist/core/module/battle/skill/emitter/projectiles/index.js +3 -1
- package/dist/core/module/battle/skill/impacts/Impact1.js +2 -0
- package/dist/core/module/battle/skill/impacts/Impact10.js +1 -1
- package/dist/core/module/battle/skill/impacts/Impact100.d.ts +13 -0
- package/dist/core/module/battle/skill/impacts/Impact100.js +61 -0
- package/dist/core/module/battle/skill/impacts/Impact101.d.ts +13 -0
- package/dist/core/module/battle/skill/impacts/Impact101.js +49 -0
- package/dist/core/module/battle/skill/impacts/Impact17.d.ts +1 -1
- package/dist/core/module/battle/skill/impacts/Impact18.d.ts +1 -1
- package/dist/core/module/battle/skill/impacts/Impact19.d.ts +13 -0
- package/dist/core/module/battle/skill/impacts/Impact19.js +31 -0
- package/dist/core/module/battle/skill/impacts/Impact2.js +1 -1
- package/dist/core/module/battle/skill/impacts/Impact3.js +6 -5
- package/dist/core/module/battle/skill/impacts/index.d.ts +3 -0
- package/dist/core/module/battle/skill/impacts/index.js +4 -1
- package/dist/core/module/battle/skill/pool/SkillEmitterPool.js +11 -6
- package/dist/core/module/battle/system/BornSystem.js +2 -2
- package/dist/core/module/battle/system/BuffSystem.d.ts +8 -5
- package/dist/core/module/battle/system/BuffSystem.js +47 -22
- package/dist/core/module/battle/system/CollisionSystem.d.ts +4 -0
- package/dist/core/module/battle/system/CollisionSystem.js +31 -22
- package/dist/core/module/battle/system/DestroySystem.d.ts +6 -0
- package/dist/core/module/battle/system/DestroySystem.js +61 -20
- package/dist/core/module/battle/system/InputSystem.d.ts +3 -1
- package/dist/core/module/battle/system/InputSystem.js +15 -4
- package/dist/core/module/battle/system/ProjectileSystem.d.ts +1 -0
- package/dist/core/module/battle/system/ProjectileSystem.js +49 -29
- package/dist/core/module/battle/system/SkillSystem.d.ts +3 -1
- package/dist/core/module/battle/system/SkillSystem.js +55 -25
- package/dist/core/module/battle/system/TurnPhaseSystem.d.ts +52 -0
- package/dist/core/module/battle/system/TurnPhaseSystem.js +189 -0
- package/dist/core/module/battle/system/TurnSchedulerSystem.d.ts +51 -0
- package/dist/core/module/battle/system/TurnSchedulerSystem.js +363 -0
- package/dist/core/module/battle/target/CloseAngleTargetSelection.js +30 -10
- package/dist/core/module/battle/target/CloseDownTargetSelection.js +64 -17
- package/dist/core/module/battle/target/CloseTargetSelection.js +22 -5
- package/dist/core/module/battle/target/RandomRangeTargetSelection.js +8 -8
- package/dist/core/module/battle/target/SelfRandomTargetSelection.js +2 -0
- package/dist/core/module/battle/target/SelfRandomTowerTargetSelection.js +0 -1
- package/dist/core/module/battle/turn/TurnBattleGame.d.ts +85 -0
- package/dist/core/module/battle/turn/TurnBattleGame.js +453 -0
- package/dist/core/module/battle/turn/TurnBattleModule.d.ts +14 -0
- package/dist/core/module/battle/turn/TurnBattleModule.js +65 -0
- package/dist/core/module/battle/turn/TurnBattleTypes.d.ts +25 -0
- package/dist/core/module/battle/turn/TurnBattleTypes.js +15 -0
- package/dist/core/module/battle/util/BattleInputCodec.d.ts +2 -3
- package/dist/core/module/battle/util/BattleInputCodec.js +14 -3
- package/dist/core/module/battle/util/BattleUtils.d.ts +21 -1
- package/dist/core/module/battle/util/BattleUtils.js +217 -41
- package/dist/core/module/battle/util/EllipseArc.d.ts +2 -0
- package/dist/core/module/battle/util/EllipseArc.js +43 -0
- package/dist/core/module/battle/util/HitDataPool.js +3 -1
- package/dist/core/module/battle/util/Random.js +13 -4
- package/dist/core/module/dailyTrial/DailyTrialBattleModule.d.ts +11 -0
- package/dist/core/module/dailyTrial/DailyTrialBattleModule.js +103 -0
- package/dist/core/module/dailyTrial/index.d.ts +1 -0
- package/dist/core/module/dailyTrial/index.js +13 -0
- package/dist/core/module/guild/view/boss/GuildBossBattleModule.d.ts +2 -1
- package/dist/core/module/guild/view/boss/GuildBossBattleModule.js +12 -2
- package/dist/core/module/module.interface.d.ts +1 -0
- package/dist/core/module/property/Property.d.ts +22 -3
- package/dist/core/module/property/Property.js +43 -5
- package/dist/core/module/property/PropertyUtil.d.ts +17 -2
- package/dist/core/module/property/PropertyUtil.js +67 -7
- package/dist/core/module/relicDungeon/RelicBattleModule.d.ts +5 -0
- package/dist/core/module/relicDungeon/RelicBattleModule.js +26 -2
- package/dist/core/module/stage/StageBattleModule.js +1 -0
- package/dist/core/proto/CommonProto.d.ts +24671 -14643
- package/dist/core/proto/Proto.d.ts +289 -77
- package/dist/index.d.ts +39 -3
- package/dist/index.js +215 -11
- package/dist/register-all.d.ts +2 -0
- package/dist/register-all.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TurnPhaseSystem = void 0;
|
|
4
|
+
const Notifier_1 = require("../../../framework/notify/Notifier");
|
|
5
|
+
const ListenID_1 = require("../../../ListenID");
|
|
6
|
+
const battle_interface_1 = require("../battle.interface");
|
|
7
|
+
const EntityEvent_1 = require("../event/EntityEvent");
|
|
8
|
+
const GameEvent_1 = require("../event/GameEvent");
|
|
9
|
+
const TurnBattleTypes_1 = require("../turn/TurnBattleTypes");
|
|
10
|
+
const Property_1 = require("./../../property/Property");
|
|
11
|
+
const GameSystem_1 = require("./GameSystem");
|
|
12
|
+
/**
|
|
13
|
+
* 阵营阶段机:MY → ENEMY → ROUND_END → MY(下一回合)。
|
|
14
|
+
* 只维护阶段与行动队列,外部调度器负责推进和单位行动。
|
|
15
|
+
*/
|
|
16
|
+
class TurnPhaseSystem extends GameSystem_1.GameSystem {
|
|
17
|
+
name = "TurnPhaseSystem";
|
|
18
|
+
_round = 0;
|
|
19
|
+
get round() {
|
|
20
|
+
return this._round;
|
|
21
|
+
}
|
|
22
|
+
set round(value) {
|
|
23
|
+
this._round = value;
|
|
24
|
+
Notifier_1.Notifier.send(ListenID_1.ListenID.Battle_TurnChange, value, this.game.config.maxRounds);
|
|
25
|
+
}
|
|
26
|
+
phase = TurnBattleTypes_1.TurnPhase.NONE;
|
|
27
|
+
_units = [];
|
|
28
|
+
_pending = [];
|
|
29
|
+
/** 本回合先手/后手阵营:由双方主角属性 50000 决定,每回合开始时重算 */
|
|
30
|
+
_firstCamp = battle_interface_1.CampType.MY;
|
|
31
|
+
_secondCamp = battle_interface_1.CampType.ENEMY;
|
|
32
|
+
get firstCamp() {
|
|
33
|
+
return this._firstCamp;
|
|
34
|
+
}
|
|
35
|
+
get secondCamp() {
|
|
36
|
+
return this._secondCamp;
|
|
37
|
+
}
|
|
38
|
+
get turnGame() {
|
|
39
|
+
return this.game;
|
|
40
|
+
}
|
|
41
|
+
onUpdate(dt) {
|
|
42
|
+
}
|
|
43
|
+
init(options) {
|
|
44
|
+
this.phase = TurnBattleTypes_1.TurnPhase.NONE;
|
|
45
|
+
}
|
|
46
|
+
onDestroy() {
|
|
47
|
+
this.clear();
|
|
48
|
+
}
|
|
49
|
+
setup(units) {
|
|
50
|
+
this._units = units;
|
|
51
|
+
this._pending.length = 0;
|
|
52
|
+
}
|
|
53
|
+
startBattle() {
|
|
54
|
+
this.round = 1;
|
|
55
|
+
this.onRoundStart();
|
|
56
|
+
this.enterPhase(this.phaseOf(this._firstCamp));
|
|
57
|
+
}
|
|
58
|
+
getPending() {
|
|
59
|
+
return this._pending;
|
|
60
|
+
}
|
|
61
|
+
getUnits() {
|
|
62
|
+
return this._units;
|
|
63
|
+
}
|
|
64
|
+
getUnit(id) {
|
|
65
|
+
for (let i = 0; i < this._units.length; i++) {
|
|
66
|
+
if (this._units[i].id === id)
|
|
67
|
+
return this._units[i];
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
consume(unit) {
|
|
72
|
+
if (!unit)
|
|
73
|
+
return;
|
|
74
|
+
unit.finishTurn();
|
|
75
|
+
this.removeFromPending(unit.id);
|
|
76
|
+
}
|
|
77
|
+
removeUnit(id) {
|
|
78
|
+
this.removeFromPending(id);
|
|
79
|
+
for (let i = this._units.length - 1; i >= 0; i--) {
|
|
80
|
+
if (this._units[i].id === id) {
|
|
81
|
+
this._units[i].markDead();
|
|
82
|
+
this._units.splice(i, 1);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
isPhaseComplete() {
|
|
88
|
+
return this._pending.length === 0;
|
|
89
|
+
}
|
|
90
|
+
advancePhase() {
|
|
91
|
+
if (this.phase === this.phaseOf(this._firstCamp)) {
|
|
92
|
+
this.transitionTo(this.phaseOf(this._secondCamp));
|
|
93
|
+
}
|
|
94
|
+
else if (this.phase === this.phaseOf(this._secondCamp)) {
|
|
95
|
+
this.transitionTo(TurnBattleTypes_1.TurnPhase.ROUND_END);
|
|
96
|
+
}
|
|
97
|
+
return this.phase;
|
|
98
|
+
}
|
|
99
|
+
beginNextRound() {
|
|
100
|
+
this.round++;
|
|
101
|
+
this.onRoundStart();
|
|
102
|
+
this.transitionTo(this.phaseOf(this._firstCamp));
|
|
103
|
+
}
|
|
104
|
+
onRoundStart() {
|
|
105
|
+
this.resetActed();
|
|
106
|
+
this.updateTurnOrder();
|
|
107
|
+
for (let i = 0; i < this.turnGame.gameContext.fighters.length; i++) {
|
|
108
|
+
const fighter = this.turnGame.gameContext.fighters[i];
|
|
109
|
+
if (!fighter.isDead) {
|
|
110
|
+
fighter.doubleShootNum = fighter.property[50101] || 0;
|
|
111
|
+
this.turnGame.emit(fighter, EntityEvent_1.EntityEvent.TurnStart, this.round);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
this.game.emit(GameEvent_1.GameEvent.StepSkill, 1);
|
|
115
|
+
}
|
|
116
|
+
/** 战斗结束:进入 FINISHED */
|
|
117
|
+
finish() {
|
|
118
|
+
if (this.phase === TurnBattleTypes_1.TurnPhase.FINISHED)
|
|
119
|
+
return;
|
|
120
|
+
this.phase = TurnBattleTypes_1.TurnPhase.FINISHED;
|
|
121
|
+
}
|
|
122
|
+
clear() {
|
|
123
|
+
this._units.length = 0;
|
|
124
|
+
this._pending.length = 0;
|
|
125
|
+
this.round = 0;
|
|
126
|
+
this.phase = TurnBattleTypes_1.TurnPhase.NONE;
|
|
127
|
+
}
|
|
128
|
+
/** 阶段进入:重建行动队列 */
|
|
129
|
+
enterPhase(phase) {
|
|
130
|
+
this.phase = phase;
|
|
131
|
+
switch (phase) {
|
|
132
|
+
case TurnBattleTypes_1.TurnPhase.MY:
|
|
133
|
+
this.buildPending(battle_interface_1.CampType.MY);
|
|
134
|
+
break;
|
|
135
|
+
case TurnBattleTypes_1.TurnPhase.ENEMY:
|
|
136
|
+
this.buildPending(battle_interface_1.CampType.ENEMY);
|
|
137
|
+
break;
|
|
138
|
+
case TurnBattleTypes_1.TurnPhase.ROUND_END:
|
|
139
|
+
this._pending.length = 0;
|
|
140
|
+
break;
|
|
141
|
+
default:
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
transitionTo(phase) {
|
|
146
|
+
if (this.phase === phase)
|
|
147
|
+
return;
|
|
148
|
+
this.enterPhase(phase);
|
|
149
|
+
}
|
|
150
|
+
/** 每回合重算先手:双方主角属性 50000 大者先手,相同则挑战者(MY)先手 */
|
|
151
|
+
updateTurnOrder() {
|
|
152
|
+
this._firstCamp = this.getFirstCamp();
|
|
153
|
+
this._secondCamp = this._firstCamp === battle_interface_1.CampType.MY ? battle_interface_1.CampType.ENEMY : battle_interface_1.CampType.MY;
|
|
154
|
+
}
|
|
155
|
+
/** 本回合先手阵营:双方主角属性 50000 大者先手,相同则挑战者(MY)先手 */
|
|
156
|
+
getFirstCamp() {
|
|
157
|
+
const myMain = this.turnGame.mainRoleId ? this.turnGame.getEntityLogic(this.turnGame.mainRoleId) : null;
|
|
158
|
+
const enemyMain = this.turnGame.enemyMainRoleId ? this.turnGame.getEntityLogic(this.turnGame.enemyMainRoleId) : null;
|
|
159
|
+
const myValue = myMain ? (Property_1.PropertyHelper.turnSpeed(myMain.property)) : 0;
|
|
160
|
+
const enemyValue = enemyMain ? (Property_1.PropertyHelper.turnSpeed(enemyMain.property)) : 0;
|
|
161
|
+
return enemyValue > myValue ? battle_interface_1.CampType.ENEMY : battle_interface_1.CampType.MY;
|
|
162
|
+
}
|
|
163
|
+
phaseOf(camp) {
|
|
164
|
+
return camp === battle_interface_1.CampType.MY ? TurnBattleTypes_1.TurnPhase.MY : TurnBattleTypes_1.TurnPhase.ENEMY;
|
|
165
|
+
}
|
|
166
|
+
resetActed() {
|
|
167
|
+
for (let i = 0; i < this._units.length; i++) {
|
|
168
|
+
this._units[i].resetTurn();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
buildPending(camp) {
|
|
172
|
+
this._pending.length = 0;
|
|
173
|
+
for (let i = 0; i < this._units.length; i++) {
|
|
174
|
+
const unit = this._units[i];
|
|
175
|
+
if (unit.camp !== camp || !unit.alive)
|
|
176
|
+
continue;
|
|
177
|
+
this._pending.push(unit);
|
|
178
|
+
unit.fighter.game.emit(unit.fighter, EntityEvent_1.EntityEvent.TurnActionStart);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
removeFromPending(id) {
|
|
182
|
+
for (let i = this._pending.length - 1; i >= 0; i--) {
|
|
183
|
+
if (this._pending[i].id === id) {
|
|
184
|
+
this._pending.splice(i, 1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.TurnPhaseSystem = TurnPhaseSystem;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type FighterData from "../entity/FighterData";
|
|
2
|
+
import { TurnUnit } from "../entity/TurnUnit";
|
|
3
|
+
import type { GameOptions } from "../Game";
|
|
4
|
+
import { GameSystem } from "./GameSystem";
|
|
5
|
+
/**
|
|
6
|
+
* 回合调度器:只负责“什么时候允许哪个单位行动”。
|
|
7
|
+
* 移动、攻击、技能、子弹、碰撞全部由原有实时系统按固定帧推进。
|
|
8
|
+
*
|
|
9
|
+
* 行动以栈结构组织:正常单位行动期间,若被插入一次行动(如反击),
|
|
10
|
+
* 插入行动压栈成为栈顶,发起单位暂停驱动;插入行动走完自己的
|
|
11
|
+
* 前摇/攻击/收招流程后出栈,再把发起单位的本次行动结束。
|
|
12
|
+
*/
|
|
13
|
+
export declare class TurnSchedulerSystem extends GameSystem {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
private _frames;
|
|
16
|
+
init(options?: GameOptions): void;
|
|
17
|
+
onDestroy(): void;
|
|
18
|
+
onUpdate(dt: number): void;
|
|
19
|
+
/** 当前行动单位(不含插入行动) */
|
|
20
|
+
getActiveUnit(): TurnUnit | null;
|
|
21
|
+
/** 该单位当前是否处于某次行动流程中(正常行动或插入行动) */
|
|
22
|
+
isActing(fighterId: number): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 请求在本次行动中插入一次行动(例如反击)。
|
|
25
|
+
* 同一时间只允许一个插入行动,避免反击连锁;插入行动不占用阶段队列。
|
|
26
|
+
*/
|
|
27
|
+
requestInterrupt(fighter: FighterData, skillId: number, targetId: number): boolean;
|
|
28
|
+
/** 该单位是否有待执行的插入行动(供 FSM 在攻击结束后切到 WAIT) */
|
|
29
|
+
isInterruptRequested(fighterId: number): boolean;
|
|
30
|
+
private startNextAction;
|
|
31
|
+
private beginAction;
|
|
32
|
+
/** 栈顶单位允许由调度器手动驱动状态转移,其余单位的状态机不推进 */
|
|
33
|
+
private updateNormal;
|
|
34
|
+
private updateInterrupt;
|
|
35
|
+
/** 等发起单位攻击结束并进入 WAIT(AttackToWait)后,再开始插入行动 */
|
|
36
|
+
private canStartInterrupt;
|
|
37
|
+
private startInterrupt;
|
|
38
|
+
private isNormalComplete;
|
|
39
|
+
private isInterruptComplete;
|
|
40
|
+
/** 插入行动结束后,发起单位先收招回到初始位置,回到 IDLE 后才结束本次行动 */
|
|
41
|
+
private finishInsertParent;
|
|
42
|
+
private finishNormal;
|
|
43
|
+
private syncActiveFighter;
|
|
44
|
+
private hasPendingEffects;
|
|
45
|
+
/** 只等待飞行中的子弹;原地停留的陷阱/持续区域不阻塞下一次行动 */
|
|
46
|
+
private hasActiveProjectiles;
|
|
47
|
+
/** 开场双方出场动画未播完时先不开始行动,避免目标仍处于不可选取状态 */
|
|
48
|
+
private hasPendingBorn;
|
|
49
|
+
/** 死亡动画未播完时暂停切入下一个单位,保证击杀表现完整 */
|
|
50
|
+
private hasPendingDeath;
|
|
51
|
+
}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TurnSchedulerSystem = void 0;
|
|
4
|
+
const TurnUnit_1 = require("../entity/TurnUnit");
|
|
5
|
+
const GameEvent_1 = require("../event/GameEvent");
|
|
6
|
+
const FighterStateMachine_1 = require("../fsm-state/FighterStateMachine");
|
|
7
|
+
const FighterStateType_1 = require("../fsm-state/FighterStateType");
|
|
8
|
+
const TurnBattleTypes_1 = require("../turn/TurnBattleTypes");
|
|
9
|
+
const GameSystem_1 = require("./GameSystem");
|
|
10
|
+
/** 一次行动最长允许的逻辑时间(秒),防止异常弹道/发射器卡住回合 */
|
|
11
|
+
const MAX_ACTION_TIME = 30;
|
|
12
|
+
/** 插入行动等待发起单位完成攻击流程的上限(秒),超时放弃插入 */
|
|
13
|
+
const MAX_INTERRUPT_WAIT = 5;
|
|
14
|
+
/** 激活单位后给 FSM 的反应时间;超过仍停在 IDLE 视为无法行动 */
|
|
15
|
+
const SKIP_GRACE_TIME = 0.1;
|
|
16
|
+
/**
|
|
17
|
+
* 回合调度器:只负责“什么时候允许哪个单位行动”。
|
|
18
|
+
* 移动、攻击、技能、子弹、碰撞全部由原有实时系统按固定帧推进。
|
|
19
|
+
*
|
|
20
|
+
* 行动以栈结构组织:正常单位行动期间,若被插入一次行动(如反击),
|
|
21
|
+
* 插入行动压栈成为栈顶,发起单位暂停驱动;插入行动走完自己的
|
|
22
|
+
* 前摇/攻击/收招流程后出栈,再把发起单位的本次行动结束。
|
|
23
|
+
*/
|
|
24
|
+
class TurnSchedulerSystem extends GameSystem_1.GameSystem {
|
|
25
|
+
name = "TurnSchedulerSystem";
|
|
26
|
+
_frames = [];
|
|
27
|
+
init(options) {
|
|
28
|
+
}
|
|
29
|
+
onDestroy() {
|
|
30
|
+
this._frames.length = 0;
|
|
31
|
+
}
|
|
32
|
+
onUpdate(dt) {
|
|
33
|
+
const game = this.game;
|
|
34
|
+
if (game.isOver())
|
|
35
|
+
return;
|
|
36
|
+
// 回合末表现(维修等)延迟未结束,停在当前回合不推进任何行动
|
|
37
|
+
if (game.tickRoundEndDelay(dt))
|
|
38
|
+
return;
|
|
39
|
+
if (this._frames.length === 0) {
|
|
40
|
+
this.startNextAction();
|
|
41
|
+
if (this._frames.length === 0)
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const frame = this._frames[this._frames.length - 1];
|
|
45
|
+
frame.elapsed += dt;
|
|
46
|
+
if (frame.interrupt) {
|
|
47
|
+
this.updateInterrupt(frame);
|
|
48
|
+
if (!this.isInterruptComplete(frame))
|
|
49
|
+
return;
|
|
50
|
+
this._frames.pop();
|
|
51
|
+
this.syncActiveFighter();
|
|
52
|
+
// 插入行动结束后,发起单位先收招回初始位置;收招完才真正结束本次行动
|
|
53
|
+
this.finishInsertParent();
|
|
54
|
+
if (this._frames.length === 0)
|
|
55
|
+
this.startNextAction();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.updateNormal(frame);
|
|
59
|
+
if (!this.isNormalComplete(frame))
|
|
60
|
+
return;
|
|
61
|
+
this.finishNormal(frame);
|
|
62
|
+
if (this._frames.length === 0)
|
|
63
|
+
this.startNextAction();
|
|
64
|
+
}
|
|
65
|
+
/** 当前行动单位(不含插入行动) */
|
|
66
|
+
getActiveUnit() {
|
|
67
|
+
for (let i = this._frames.length - 1; i >= 0; i--) {
|
|
68
|
+
const unit = this._frames[i].unit;
|
|
69
|
+
if (unit)
|
|
70
|
+
return unit;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
/** 该单位当前是否处于某次行动流程中(正常行动或插入行动) */
|
|
75
|
+
isActing(fighterId) {
|
|
76
|
+
for (let i = 0; i < this._frames.length; i++) {
|
|
77
|
+
if (this._frames[i].fighter.ID === fighterId)
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 请求在本次行动中插入一次行动(例如反击)。
|
|
84
|
+
* 同一时间只允许一个插入行动,避免反击连锁;插入行动不占用阶段队列。
|
|
85
|
+
*/
|
|
86
|
+
requestInterrupt(fighter, skillId, targetId) {
|
|
87
|
+
if (!fighter || fighter.isDead || fighter.curHp <= 0)
|
|
88
|
+
return false;
|
|
89
|
+
if (!skillId || !targetId)
|
|
90
|
+
return false;
|
|
91
|
+
if (!fighter.skillDatas || !fighter.skillDatas[skillId])
|
|
92
|
+
return false;
|
|
93
|
+
const target = this.game.getEntityLogic(targetId);
|
|
94
|
+
if (!target || target.isDead || target.curHp <= 0)
|
|
95
|
+
return false;
|
|
96
|
+
const top = this._frames[this._frames.length - 1];
|
|
97
|
+
if (!top || top.interrupt)
|
|
98
|
+
return false;
|
|
99
|
+
if (this.isActing(fighter.ID))
|
|
100
|
+
return false;
|
|
101
|
+
this._frames.push({
|
|
102
|
+
interrupt: true,
|
|
103
|
+
unit: null,
|
|
104
|
+
fighter,
|
|
105
|
+
skillId,
|
|
106
|
+
targetId,
|
|
107
|
+
started: false,
|
|
108
|
+
elapsed: 0,
|
|
109
|
+
idleWaited: 0,
|
|
110
|
+
});
|
|
111
|
+
// 请求阻断:被反击的单位清空连击次数,并回收其射向反击者的在飞子弹
|
|
112
|
+
target.curDoubleShootNum = 0;
|
|
113
|
+
const game = this.game;
|
|
114
|
+
const projectiles = game.gameContext.projectiles;
|
|
115
|
+
for (let i = projectiles.length - 1; i >= 0; i--) {
|
|
116
|
+
const projectile = projectiles[i];
|
|
117
|
+
if (projectile.isDead || projectile.owner !== targetId || projectile.target !== fighter.ID)
|
|
118
|
+
continue;
|
|
119
|
+
game.emit(GameEvent_1.GameEvent.RecycleProjectile, projectile);
|
|
120
|
+
}
|
|
121
|
+
this.syncActiveFighter();
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
/** 该单位是否有待执行的插入行动(供 FSM 在攻击结束后切到 WAIT) */
|
|
125
|
+
isInterruptRequested(fighterId) {
|
|
126
|
+
for (let i = 0; i < this._frames.length; i++) {
|
|
127
|
+
const frame = this._frames[i];
|
|
128
|
+
if (frame.interrupt && frame.targetId === fighterId)
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
startNextAction() {
|
|
134
|
+
const game = this.game;
|
|
135
|
+
if (this.hasPendingDeath() || this.hasPendingBorn())
|
|
136
|
+
return;
|
|
137
|
+
let guard = 0;
|
|
138
|
+
while (!game.isOver() && guard++ < 8) {
|
|
139
|
+
const phase = game.phaseSystem;
|
|
140
|
+
if (!phase.isPhaseComplete()) {
|
|
141
|
+
const unit = phase.getPending()[0];
|
|
142
|
+
if (!unit.alive) {
|
|
143
|
+
if (this.hasPendingDeath())
|
|
144
|
+
return;
|
|
145
|
+
phase.consume(unit);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
this.beginAction(unit);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const next = phase.advancePhase();
|
|
152
|
+
game.syncState();
|
|
153
|
+
if (next === TurnBattleTypes_1.TurnPhase.ROUND_END) {
|
|
154
|
+
game.endRound();
|
|
155
|
+
// 回合末还有延迟(维修表现等)时停在 ROUND_END,等延迟结束后再进入下一回合
|
|
156
|
+
if (game.getCurrentPhase() === TurnBattleTypes_1.TurnPhase.ROUND_END)
|
|
157
|
+
return;
|
|
158
|
+
if (this.hasPendingDeath())
|
|
159
|
+
return;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (next === TurnBattleTypes_1.TurnPhase.FINISHED)
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
beginAction(unit) {
|
|
167
|
+
unit.startTurn();
|
|
168
|
+
const actor = unit.fighter;
|
|
169
|
+
// 记录本次行动的起点,收招(BACK)时回到这里
|
|
170
|
+
actor.moveStartX = actor.x;
|
|
171
|
+
actor.moveStartY = actor.y;
|
|
172
|
+
this._frames.push({
|
|
173
|
+
interrupt: false,
|
|
174
|
+
unit,
|
|
175
|
+
fighter: actor,
|
|
176
|
+
skillId: 0,
|
|
177
|
+
targetId: 0,
|
|
178
|
+
started: true,
|
|
179
|
+
elapsed: 0,
|
|
180
|
+
idleWaited: 0,
|
|
181
|
+
});
|
|
182
|
+
this.syncActiveFighter();
|
|
183
|
+
}
|
|
184
|
+
/** 栈顶单位允许由调度器手动驱动状态转移,其余单位的状态机不推进 */
|
|
185
|
+
updateNormal(frame) {
|
|
186
|
+
const actor = frame.fighter;
|
|
187
|
+
if (!actor || actor.isDead)
|
|
188
|
+
return;
|
|
189
|
+
// 停在 IDLE 时由调度器手动触发一次转移(进入前摇);之后前摇→攻击→收招→IDLE 全部由状态机自动完成
|
|
190
|
+
if (actor.curState !== FighterStateType_1.StateType.IDLE)
|
|
191
|
+
return;
|
|
192
|
+
FighterStateMachine_1.FighterStateMachine.checkTransitionManual(actor);
|
|
193
|
+
}
|
|
194
|
+
updateInterrupt(frame) {
|
|
195
|
+
const actor = frame.fighter;
|
|
196
|
+
if (!actor || actor.isDead || frame.started)
|
|
197
|
+
return;
|
|
198
|
+
if (frame.elapsed >= MAX_INTERRUPT_WAIT)
|
|
199
|
+
return;
|
|
200
|
+
if (!this.canStartInterrupt(frame))
|
|
201
|
+
return;
|
|
202
|
+
this.startInterrupt(frame);
|
|
203
|
+
}
|
|
204
|
+
/** 等发起单位攻击结束并进入 WAIT(AttackToWait)后,再开始插入行动 */
|
|
205
|
+
canStartInterrupt(frame) {
|
|
206
|
+
const actor = frame.fighter;
|
|
207
|
+
if (!actor || actor.isDead || actor.curHp <= 0)
|
|
208
|
+
return false;
|
|
209
|
+
const state = actor.curState;
|
|
210
|
+
if (state !== FighterStateType_1.StateType.IDLE && state !== FighterStateType_1.StateType.NONE)
|
|
211
|
+
return false;
|
|
212
|
+
// 目标可能在等待期间已经死亡,重新校验后再进入前摇
|
|
213
|
+
const target = this.game.getEntityLogic(frame.targetId);
|
|
214
|
+
if (!target || target.isDead || target.curHp <= 0)
|
|
215
|
+
return false;
|
|
216
|
+
const parent = this._frames[this._frames.length - 2];
|
|
217
|
+
const parentActor = parent ? parent.fighter : null;
|
|
218
|
+
if (parentActor && !parentActor.isDead) {
|
|
219
|
+
const parentState = parentActor.curState;
|
|
220
|
+
// 攻击结束的发起单位会通过 AttackToWait 自动进入 WAIT
|
|
221
|
+
if (parentState !== FighterStateType_1.StateType.WAIT
|
|
222
|
+
&& parentState !== FighterStateType_1.StateType.IDLE
|
|
223
|
+
&& parentState !== FighterStateType_1.StateType.NONE
|
|
224
|
+
&& parentState !== FighterStateType_1.StateType.DEAD) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
startInterrupt(frame) {
|
|
231
|
+
const actor = frame.fighter;
|
|
232
|
+
// 插入行动从当前位置开始,收招时回到这里
|
|
233
|
+
actor.moveStartX = actor.x;
|
|
234
|
+
actor.moveStartY = actor.y;
|
|
235
|
+
actor.curSkillId = frame.skillId;
|
|
236
|
+
actor.attackTarget = frame.targetId;
|
|
237
|
+
actor.needFindTarget = false;
|
|
238
|
+
frame.started = true;
|
|
239
|
+
// 反击不走普通技能的冷却/装填校验,直接进入前摇
|
|
240
|
+
FighterStateMachine_1.FighterStateMachine.change(actor, FighterStateType_1.StateType.PREATTACK);
|
|
241
|
+
}
|
|
242
|
+
isNormalComplete(frame) {
|
|
243
|
+
const actor = frame.fighter;
|
|
244
|
+
if (!actor || actor.isDead || frame.unit.state === TurnUnit_1.TurnUnitState.DEAD)
|
|
245
|
+
return true;
|
|
246
|
+
if (frame.elapsed >= MAX_ACTION_TIME)
|
|
247
|
+
return true;
|
|
248
|
+
// 自身子弹、技能发射器、延迟技能都结算完,才算这次行动结束
|
|
249
|
+
if (this.hasPendingEffects(actor))
|
|
250
|
+
return false;
|
|
251
|
+
const state = actor.curState;
|
|
252
|
+
if (state === FighterStateType_1.StateType.IDLE || state === FighterStateType_1.StateType.NONE) {
|
|
253
|
+
// 刚回到 IDLE 时先让 FSM 跑一帧(BORN/HIT/MOVE 结束后的下一帧才轮到 IDLE 转移)
|
|
254
|
+
if (frame.idleWaited === 0) {
|
|
255
|
+
frame.idleWaited = 1;
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
return frame.elapsed >= SKIP_GRACE_TIME;
|
|
259
|
+
}
|
|
260
|
+
frame.idleWaited = 0;
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
isInterruptComplete(frame) {
|
|
264
|
+
const actor = frame.fighter;
|
|
265
|
+
if (!actor || actor.isDead || actor.curHp <= 0)
|
|
266
|
+
return true;
|
|
267
|
+
if (frame.elapsed >= MAX_ACTION_TIME)
|
|
268
|
+
return true;
|
|
269
|
+
if (!frame.started) {
|
|
270
|
+
if (frame.elapsed >= MAX_INTERRUPT_WAIT)
|
|
271
|
+
return true;
|
|
272
|
+
const target = this.game.getEntityLogic(frame.targetId);
|
|
273
|
+
return !target || target.isDead || target.curHp <= 0;
|
|
274
|
+
}
|
|
275
|
+
if (this.hasPendingEffects(actor))
|
|
276
|
+
return false;
|
|
277
|
+
const state = actor.curState;
|
|
278
|
+
return state === FighterStateType_1.StateType.IDLE || state === FighterStateType_1.StateType.NONE;
|
|
279
|
+
}
|
|
280
|
+
/** 插入行动结束后,发起单位先收招回到初始位置,回到 IDLE 后才结束本次行动 */
|
|
281
|
+
finishInsertParent() {
|
|
282
|
+
const parent = this._frames[this._frames.length - 1];
|
|
283
|
+
if (!parent || parent.interrupt)
|
|
284
|
+
return;
|
|
285
|
+
const actor = parent.fighter;
|
|
286
|
+
if (actor && !actor.isDead && actor.curHp > 0) {
|
|
287
|
+
if (actor.curState === FighterStateType_1.StateType.WAIT) {
|
|
288
|
+
// 被打断停在 WAIT 的发起单位:收招回初始位置,BACK→IDLE 后再结束行动
|
|
289
|
+
FighterStateMachine_1.FighterStateMachine.change(actor, FighterStateType_1.StateType.BACK);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (actor.curState !== FighterStateType_1.StateType.IDLE && actor.curState !== FighterStateType_1.StateType.NONE) {
|
|
293
|
+
// 仍在 PREATTACK/ATTACK/BACK:交给状态机走完,isNormalComplete 会负责收尾
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
this.finishNormal(parent);
|
|
298
|
+
}
|
|
299
|
+
finishNormal(frame) {
|
|
300
|
+
const game = this.game;
|
|
301
|
+
const index = this._frames.indexOf(frame);
|
|
302
|
+
if (index >= 0)
|
|
303
|
+
this._frames.splice(index, 1);
|
|
304
|
+
const unit = frame.unit;
|
|
305
|
+
if (unit) {
|
|
306
|
+
const actor = unit.fighter;
|
|
307
|
+
// 异常超时被强制结束时,确保不会把 MOVE/PREATTACK/ATTACK/BACK 状态留给下一回合
|
|
308
|
+
if (actor && !actor.isDead
|
|
309
|
+
&& actor.curState !== FighterStateType_1.StateType.IDLE
|
|
310
|
+
&& actor.curState !== FighterStateType_1.StateType.NONE
|
|
311
|
+
&& actor.curState !== FighterStateType_1.StateType.DEAD) {
|
|
312
|
+
game.emit(GameEvent_1.GameEvent.FsmChangeState, actor, FighterStateType_1.StateType.IDLE);
|
|
313
|
+
}
|
|
314
|
+
game.phaseSystem.consume(unit);
|
|
315
|
+
}
|
|
316
|
+
this.syncActiveFighter();
|
|
317
|
+
}
|
|
318
|
+
syncActiveFighter() {
|
|
319
|
+
const game = this.game;
|
|
320
|
+
const top = this._frames[this._frames.length - 1];
|
|
321
|
+
const fighterId = top ? top.fighter.ID : 0;
|
|
322
|
+
game.turnActiveFighterId = fighterId;
|
|
323
|
+
game.turnState.currentActorId = fighterId;
|
|
324
|
+
}
|
|
325
|
+
hasPendingEffects(actor) {
|
|
326
|
+
const waitSkills = this.game.gameContext.waitUseSkill[actor.ID];
|
|
327
|
+
return this.hasActiveProjectiles(actor.ID)
|
|
328
|
+
|| (actor.skillEmitters && actor.skillEmitters.length > 0)
|
|
329
|
+
|| (waitSkills && waitSkills.length > 0);
|
|
330
|
+
}
|
|
331
|
+
/** 只等待飞行中的子弹;原地停留的陷阱/持续区域不阻塞下一次行动 */
|
|
332
|
+
hasActiveProjectiles(ownerId) {
|
|
333
|
+
const projectiles = this.game.gameContext.projectiles;
|
|
334
|
+
for (let i = 0; i < projectiles.length; i++) {
|
|
335
|
+
const projectile = projectiles[i];
|
|
336
|
+
if (!projectile.isDead && projectile.owner === ownerId && projectile.moveSpeed > 0 && projectile.lifeTime > 0) {
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
/** 开场双方出场动画未播完时先不开始行动,避免目标仍处于不可选取状态 */
|
|
343
|
+
hasPendingBorn() {
|
|
344
|
+
const fighters = this.game.gameContext.fighters;
|
|
345
|
+
for (let i = 0; i < fighters.length; i++) {
|
|
346
|
+
const fighter = fighters[i];
|
|
347
|
+
if (fighter.curState === FighterStateType_1.StateType.BORN && fighter.actionTime > 0)
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
/** 死亡动画未播完时暂停切入下一个单位,保证击杀表现完整 */
|
|
353
|
+
hasPendingDeath() {
|
|
354
|
+
const fighters = this.game.gameContext.fighters;
|
|
355
|
+
for (let i = 0; i < fighters.length; i++) {
|
|
356
|
+
const fighter = fighters[i];
|
|
357
|
+
if (fighter.curState === FighterStateType_1.StateType.DEAD && fighter.actionTime > 0)
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
exports.TurnSchedulerSystem = TurnSchedulerSystem;
|
|
@@ -6,6 +6,8 @@ const battle_interface_1 = require("../battle.interface");
|
|
|
6
6
|
const BattleUtils_1 = require("../util/BattleUtils");
|
|
7
7
|
const BVec2_1 = require("../util/BVec2");
|
|
8
8
|
const TargetSelection_1 = require("./TargetSelection");
|
|
9
|
+
/** 随机分支的候选缓存:只存目标,下标即候选原有顺序;复用数组避免每次查询分配 {target, dis} */
|
|
10
|
+
const candTargets = [];
|
|
9
11
|
class CloseAngleTargetSelection {
|
|
10
12
|
static select(owner, targetTypes, x, y, ignoreList, searchRange, forceSkillId) {
|
|
11
13
|
let realx = owner.x;
|
|
@@ -31,23 +33,41 @@ class CloseAngleTargetSelection {
|
|
|
31
33
|
// targetTypes[2]: 1 picks a random one of the candidates, anything else picks the closest one
|
|
32
34
|
const isRandom = targetTypes[2] === 1;
|
|
33
35
|
const fighters = owner.game.gameContext.fighters;
|
|
34
|
-
|
|
36
|
+
if (isRandom) {
|
|
37
|
+
// 随机取 1 个:只按候选原有顺序收集目标,随机数消耗与旧实现 getRandomSDiffInArray(list, 1) 一致
|
|
38
|
+
// —— 单候选不消耗随机数,多候选消耗一次并取该下标的元素。
|
|
39
|
+
candTargets.length = 0;
|
|
40
|
+
for (let i = 0; i < fighters.length; i++) {
|
|
41
|
+
const value = fighters[i];
|
|
42
|
+
if (!(0, TargetSelection_1.isEnemyTarget)(owner, value, skillId, maxDis, minDis, ignoreList))
|
|
43
|
+
continue;
|
|
44
|
+
if (angle > 0 && !BattleUtils_1.BattleUtils.isInAtkAimAngle(owner, value, angle))
|
|
45
|
+
continue;
|
|
46
|
+
candTargets.push(value);
|
|
47
|
+
}
|
|
48
|
+
const len = candTargets.length;
|
|
49
|
+
if (len <= 0)
|
|
50
|
+
return [];
|
|
51
|
+
const picked = len === 1 ? candTargets[0] : candTargets[owner.game.randomRange(0, len - 1)];
|
|
52
|
+
candTargets.length = 0;
|
|
53
|
+
return [picked];
|
|
54
|
+
}
|
|
55
|
+
// 取最近 1 个:单次线性扫描,等价于"稳定升序排序后取首元素"(距离并列时取候选顺序靠前者)
|
|
56
|
+
let best = null;
|
|
57
|
+
let bestDis = Number.MAX_VALUE;
|
|
35
58
|
for (let i = 0; i < fighters.length; i++) {
|
|
36
59
|
const value = fighters[i];
|
|
37
60
|
if (!(0, TargetSelection_1.isEnemyTarget)(owner, value, skillId, maxDis, minDis, ignoreList))
|
|
38
61
|
continue;
|
|
39
62
|
if (angle > 0 && !BattleUtils_1.BattleUtils.isInAtkAimAngle(owner, value, angle))
|
|
40
63
|
continue;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
owner.game.getRandomSDiffInArray(waitList, 1);
|
|
47
|
-
return [waitList[0].target];
|
|
64
|
+
const dis = BVec2_1.BVecHelper.distanceSqr(value, TargetSelection_1.tempTargetVec);
|
|
65
|
+
if (dis < bestDis) {
|
|
66
|
+
bestDis = dis;
|
|
67
|
+
best = value;
|
|
68
|
+
}
|
|
48
69
|
}
|
|
49
|
-
|
|
50
|
-
return [waitList[0].target];
|
|
70
|
+
return best ? [best] : [];
|
|
51
71
|
}
|
|
52
72
|
}
|
|
53
73
|
exports.CloseAngleTargetSelection = CloseAngleTargetSelection;
|