Skip to content

Commit 0aa4c6b

Browse files
committed
why did I write that like that
1 parent dd6e290 commit 0aa4c6b

File tree

6 files changed

+23
-27
lines changed

6 files changed

+23
-27
lines changed

src/game-engine/world/action/hooks/task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class TaskExecutor<T> {
5454
const intervalMs = this.task.intervalMs !== undefined ? this.task.intervalMs :
5555
(this.task.interval * World.TICK_LENGTH);
5656

57-
await new Promise(resolve => {
57+
await new Promise<void>(resolve => {
5858
this.intervalSubscription = timer(0, intervalMs).subscribe(
5959
async() => {
6060
if(!await this.execute()) {

src/game-engine/world/action/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ export type ActionType =
4444
| 'equipment_change';
4545

4646

47+
export const gentleActions: ActionType[] = [
48+
'button', 'widget_interaction', 'player_init', 'npc_init',
49+
'move_item', 'item_swap', 'player_command', 'region_change'
50+
];
51+
52+
4753
/**
4854
* Methods in which action hooks in progress may be cancelled.
4955
*/
@@ -150,7 +156,10 @@ export class ActionPipeline {
150156
continue;
151157
}
152158

153-
await this.cancelRunningTasks();
159+
// Some actions are non-cancelling
160+
if(gentleActions.indexOf(hook.type) === -1) {
161+
await this.cancelRunningTasks();
162+
}
154163

155164
if(runnableHooks.actionPosition) {
156165
try {

src/game-engine/world/actor/player/interface-state.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class Widget {
6666

6767
export interface WidgetClosedEvent {
6868
widget: Widget;
69+
widgetId?: number;
6970
data?: number;
7071
}
7172

@@ -131,21 +132,14 @@ export class InterfaceState {
131132
filter(event => event.widget.slot === slot)).pipe(take(1)));
132133
}
133134

134-
public closeWidget(widgetId: number, data?: number): void;
135-
public closeWidget(slot: GameInterfaceSlot, data?: number): void;
136-
public closeWidget(i: GameInterfaceSlot | number, data?: number): void {
137-
let widget: Widget | null;
138-
if(typeof i === 'number') {
139-
widget = this.findWidget(i);
140-
} else {
141-
widget = this.widgetSlots[i] || null;
142-
}
135+
public closeWidget(slot: GameInterfaceSlot, widgetId?: number, data?: number): void {
136+
const widget: Widget | null = (slot ? this.widgetSlots[slot] : this.findWidget(widgetId)) || null;
143137

144138
if(!widget) {
145139
return;
146140
}
147141

148-
this.closed.next({ widget, data });
142+
this.closed.next({ widget, widgetId, data });
149143
this.widgetSlots[widget.slot] = null;
150144
}
151145

src/game-engine/world/actor/player/player.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,13 @@ export class Player extends Actor {
598598

599599
let showDialogue = false;
600600
let showInConsole = false;
601-
if(options && typeof options === 'boolean') {
602-
showDialogue = true;
603-
} else if(options) {
604-
showDialogue = options.dialogue || false;
605-
showInConsole = options.console || false;
601+
if(options) {
602+
if(typeof options === 'boolean') {
603+
showDialogue = true;
604+
} else {
605+
showDialogue = options.dialogue || false;
606+
showInConsole = options.console || false;
607+
}
606608
}
607609

608610
if(!showDialogue) {

src/game-engine/world/actor/walking-queue.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,6 @@ export class WalkingQueue {
144144

145145
const walkPosition = this.queue.shift();
146146

147-
if(this.actor instanceof Player) {
148-
this.actor.actionsCancelled.next('pathing-movement');
149-
// if(activeWidget.disablePlayerMovement) {
150-
// this.resetDirections();
151-
// return;
152-
// }
153-
//this.actor.interfaceState.closeAllSlots();
154-
}
155-
156147
if(this.actor.metadata['faceActorClearedByWalking'] === undefined || this.actor.metadata['faceActorClearedByWalking']) {
157148
this.actor.clearFaceActor();
158149
}

src/plugins/dialogue/dialogue-option.plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const dialogueIds = [
1212
*/
1313
export const action: widgetInteractionActionHandler = (details) => {
1414
const { player, widgetId, childId } = details;
15-
player.interfaceState.closeWidget(widgetId, childId);
15+
player.interfaceState.closeWidget('chatbox', widgetId, childId);
1616
};
1717

1818
export default {

0 commit comments

Comments
 (0)