mirror of
				https://github.com/unanmed/HumanBreak.git
				synced 2025-10-31 20:32:58 +08:00 
			
		
		
		
	fix: 弹幕发送与接受
This commit is contained in:
		
							parent
							
								
									27230b3d47
								
							
						
					
					
						commit
						e38f4ed224
					
				| @ -4425,19 +4425,19 @@ events.prototype.tryUseItem = function (itemId, noRoute, callback) { | ||||
|     if (itemId == 'book') { | ||||
|         core.ui.closePanel(); | ||||
|         core.openBook(false); | ||||
|         callback(); | ||||
|         callback?.(); | ||||
|         return; | ||||
|     } | ||||
|     if (itemId == 'fly') { | ||||
|         core.ui.closePanel(); | ||||
|         core.useFly(false); | ||||
|         callback(); | ||||
|         callback?.(); | ||||
|         return; | ||||
|     } | ||||
|     if (itemId == 'centerFly') { | ||||
|         core.ui.closePanel(); | ||||
|         core.ui._drawCenterFly(); | ||||
|         callback(); | ||||
|         callback?.(); | ||||
|         return; | ||||
|     } | ||||
|     if (core.canUseItem(itemId)) { | ||||
| @ -4446,5 +4446,5 @@ events.prototype.tryUseItem = function (itemId, noRoute, callback) { | ||||
|         core.playSound('操作失败'); | ||||
|         core.drawTip('当前无法使用' + core.material.items[itemId].name, itemId); | ||||
|     } | ||||
|     callback(); | ||||
|     callback?.(); | ||||
| }; | ||||
|  | ||||
| @ -568,6 +568,12 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { | ||||
| 
 | ||||
|             // 如需强行终止行走可以在这里条件判定:
 | ||||
|             // core.stopAutomaticRoute();
 | ||||
|             Mota.require('var', 'hook').emit( | ||||
|                 'moveOneStep', | ||||
|                 nowx, | ||||
|                 nowy, | ||||
|                 core.status.floorId | ||||
|             ); | ||||
|         }, | ||||
|         moveDirectly: function (x, y, ignoreSteps) { | ||||
|             // 瞬间移动;x,y为要瞬间移动的点;ignoreSteps为减少的步数,可能之前已经被计算过
 | ||||
|  | ||||
| @ -6,6 +6,7 @@ import { deleteWith, ensureArray, parseCss, tip } from '@/plugin/utils'; | ||||
| import axios, { toFormData } from 'axios'; | ||||
| import { Component, VNode, h, ref, shallowReactive } from 'vue'; | ||||
| /* @__PURE__ */ import { id, password } from '../../../../user'; | ||||
| import { mainSetting } from '../setting'; | ||||
| 
 | ||||
| type CSSObj = Partial<Record<CanParseCss, string>>; | ||||
| 
 | ||||
| @ -97,15 +98,26 @@ export class Danmaku extends EventEmitter<DanmakuEvent> { | ||||
|         const form = toFormData(data); | ||||
|         /* @__PURE__ */ form.append('userid', id); | ||||
|         /* @__PURE__ */ form.append('password', password); | ||||
|         const res = await axios.post<PostDanmakuResponse>( | ||||
|             Danmaku.backend, | ||||
|             form | ||||
|         ); | ||||
| 
 | ||||
|         this.id = res.data.id; | ||||
|         this.posting = false; | ||||
|         try { | ||||
|             const res = await axios.post<PostDanmakuResponse>( | ||||
|                 Danmaku.backend, | ||||
|                 form | ||||
|             ); | ||||
| 
 | ||||
|         return res; | ||||
|             this.id = res.data.id; | ||||
|             this.posting = false; | ||||
| 
 | ||||
|             return res; | ||||
|         } catch (e) { | ||||
|             this.posted = false; | ||||
|             this.posting = false; | ||||
|             logger.error( | ||||
|                 3, | ||||
|                 `Unexpected error when posting danmaku. Error info: ${e}` | ||||
|             ); | ||||
|             return Promise.resolve(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -425,6 +437,20 @@ Danmaku.registerSpecContent('i', content => { | ||||
| }); | ||||
| 
 | ||||
| /* @__PURE__ */ Danmaku.backend = `/danmaku`; | ||||
| 
 | ||||
| Mota.require('var', 'hook').once('reset', () => { | ||||
|     Danmaku.fetch(); | ||||
| }); | ||||
| 
 | ||||
| // 勇士移动后显示弹幕
 | ||||
| Mota.require('var', 'hook').on('moveOneStep', (x, y, floor) => { | ||||
|     const enabled = mainSetting.getValue('ui.danmaku', true); | ||||
|     if (!enabled) return; | ||||
|     const f = Danmaku.allInPos[floor]; | ||||
|     if (f) { | ||||
|         const danmaku = f[`${x},${y}`]; | ||||
|         if (danmaku) { | ||||
|             danmaku.show(); | ||||
|         } | ||||
|     } | ||||
| }); | ||||
|  | ||||
| @ -486,7 +486,7 @@ mainSetting | ||||
|             .register('bookScale', '怪物手册缩放', 100, COM.Number, [10, 500, 10]) | ||||
|             .setDisplayFunc('bookScale', value => `${value}%`) | ||||
|             .register('danmaku', '显示弹幕', true, COM.Boolean) | ||||
|             .register('danmakuSpeed', '弹幕速度', 60, COM.Number, [10, 200, 5]) | ||||
|             .register('danmakuSpeed', '弹幕速度', 60, COM.Number, [10, 1000, 5]) | ||||
|     ); | ||||
| 
 | ||||
| const loading = Mota.require('var', 'loading'); | ||||
| @ -521,7 +521,10 @@ loading.once('coreInit', () => { | ||||
|         ), | ||||
|         'ui.bookScale': storage.getValue('ui.bookScale', isMobile ? 100 : 80), | ||||
|         'ui.danmaku': storage.getValue('ui.danmaku', true), | ||||
|         'ui.danmakuSpeed': storage.getValue('ui.danmakuSpeed', 60), | ||||
|         'ui.danmakuSpeed': storage.getValue( | ||||
|             'ui.danmakuSpeed',  | ||||
|             Math.floor(window.innerWidth / 25) * 5 | ||||
|         ), | ||||
|     }); | ||||
| }); | ||||
| 
 | ||||
|  | ||||
| @ -91,6 +91,7 @@ export interface GameEvent extends EmitableEvent { | ||||
|     ) => void; | ||||
|     afterOpenDoor: (doorId: AllIdsOf<'animates'>, x: number, y: number) => void; | ||||
|     afterChangeFloor: (floorId: FloorIds) => void; | ||||
|     moveOneStep: (x: number, y: number, floorId: FloorIds) => void; | ||||
| } | ||||
| 
 | ||||
| export const hook = new EventEmitter<GameEvent>(); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user