inetraction stuff
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Component, computed, effect, inject, input, InputSignal, Signal } from '@angular/core';
|
||||
import { Component, computed, effect, inject, input, InputSignal, signal, Signal, WritableSignal } from '@angular/core';
|
||||
import { HeaderComponent } from "../../components/ui-elements/header/header.component";
|
||||
import { ERouteKey } from '../../types/route-key';
|
||||
import { Chibi, ChibiId } from '../../types/chibi/chibi';
|
||||
@@ -11,6 +11,14 @@ import { EChibiInteraction } from '../../types/chibi/chibi-interaction';
|
||||
import { IBrain } from '../../logic/chibi-behaviour/brain';
|
||||
import { BRAIN_MAP } from '../../logic/chibi-behaviour/brain-map';
|
||||
import { TranslateableComponent } from '../../components/translateable.component';
|
||||
import { Food } from '../../types/food';
|
||||
import { interval } from 'rxjs';
|
||||
|
||||
enum EInteractionMenuState {
|
||||
Neutral,
|
||||
Pantry,
|
||||
Inventory
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'ff-interactions',
|
||||
@@ -25,23 +33,41 @@ export class InteractionsComponent extends TranslateableComponent {
|
||||
protected readonly chibi: Signal<Chibi> = computed(() => {
|
||||
return this.chibiStore.chibis().find((chibi: Chibi) => chibi.id === this.chibiId()) as Chibi;
|
||||
});
|
||||
protected readonly interactionMenuState: WritableSignal<EInteractionMenuState> = signal(EInteractionMenuState.Neutral);
|
||||
|
||||
protected readonly EInteractionMenuState: typeof EInteractionMenuState = EInteractionMenuState;
|
||||
protected readonly ERouteKey: typeof ERouteKey = ERouteKey;
|
||||
protected readonly EChibiInteraction: typeof EChibiInteraction = EChibiInteraction;
|
||||
|
||||
private brain!: IBrain;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
effect(() => {
|
||||
if (this.chibi()) {
|
||||
this.brain = BRAIN_MAP[this.chibi().name]!;
|
||||
}
|
||||
})
|
||||
interval(1000).subscribe(() => {
|
||||
this.brain.exist(this.chibi());
|
||||
})
|
||||
}
|
||||
|
||||
public interact(interaction: EChibiInteraction): void {
|
||||
console.log(`${interaction} ${this.chibi().name}`);
|
||||
this.chibi().state = this.brain.resolveInteraction(this.chibi().state, interaction);
|
||||
public interact(interaction: EChibiInteraction, item?: Food): void {
|
||||
console.log(`${interaction} ${this.chibi().name} and item ${item}`);
|
||||
this.brain.resolveInteraction(this.chibi(), interaction, item);
|
||||
}
|
||||
|
||||
public openFoodPantry(): void {
|
||||
this.interactionMenuState.set(EInteractionMenuState.Pantry);
|
||||
}
|
||||
|
||||
public openInventory(): void {
|
||||
this.interactionMenuState.set(EInteractionMenuState.Inventory);
|
||||
}
|
||||
|
||||
public closeMenu(): void {
|
||||
this.interactionMenuState.set(EInteractionMenuState.Neutral);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user