generated from maximegris/angular-electron
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
615 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ISpawnerData } from '../../interfaces'; | ||
import { id } from './id'; | ||
|
||
export const defaultSpawner: () => ISpawnerData = () => ({ | ||
_id: id(), | ||
tag: '', | ||
paths: [], | ||
shouldSerialize: false, | ||
alwaysSpawn: false, | ||
requireDeadToRespawn: false, | ||
doInitialSpawnImmediately: false, | ||
canSlowDown: true, | ||
isDangerous: false, | ||
npcAISettings: [], | ||
npcIds: [], | ||
respawnRate: 120, | ||
randomWalkRadius: 10, | ||
leashRadius: 20, | ||
eliteTickCap: 50, | ||
initialSpawn: 0, | ||
spawnRadius: 0, | ||
maxCreatures: 5, | ||
stripRadius: 0, | ||
stripX: 0, | ||
stripY: 0, | ||
shouldEatTier: 0, | ||
shouldStrip: false, | ||
stripOnSpawner: false, | ||
respectKnowledge: true, | ||
attributeAddChance: 0, | ||
requireHoliday: undefined as unknown as string, | ||
_paths: '', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/app/shared/components/input-npc/input-npc.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<div class="relative"> | ||
<ng-select class="form-control" [items]="values()" bindValue="data" groupBy="category" [(ngModel)]="npc" | ||
placeholder="Select NPC..." (change)="change.emit($event?.value)" [compareWith]="npcCompare" [searchFn]="search"> | ||
|
||
<ng-template ng-label-tmp let-item="item"> | ||
<div class="relative"> | ||
@if(item.data) { | ||
<app-sprite class="absolute -top-5 -left-5" [scale]="0.5" [type]="'creatures'" | ||
[sprite]="item.data.sprite"></app-sprite> | ||
} | ||
<div class="ml-7 text-white"> | ||
{{ item.data.npcId }} | ||
</div> | ||
</div> | ||
</ng-template> | ||
|
||
<ng-template ng-option-tmp let-item="item"> | ||
<div class="relative"> | ||
<app-sprite class="absolute -top-5 -left-7" [scale]="0.5" [type]="'creatures'" | ||
[sprite]="item.data.sprite"></app-sprite> | ||
<div class="ml-5 text-white"> | ||
{{ item.data.npcId }} | ||
</div> | ||
</div> | ||
</ng-template> | ||
</ng-select> | ||
|
||
<app-input-floating-label>{{ label() }}</app-input-floating-label> | ||
</div> |
Empty file.
55 changes: 55 additions & 0 deletions
55
src/app/shared/components/input-npc/input-npc.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { | ||
Component, | ||
computed, | ||
inject, | ||
input, | ||
model, | ||
OnInit, | ||
output, | ||
} from '@angular/core'; | ||
import { INPCDefinition } from '../../../../interfaces'; | ||
import { ModService } from '../../../services/mod.service'; | ||
|
||
type NPCModel = { category: string; data: INPCDefinition; value: string }; | ||
|
||
@Component({ | ||
selector: 'app-input-npc', | ||
templateUrl: './input-npc.component.html', | ||
styleUrl: './input-npc.component.scss', | ||
}) | ||
export class InputNpcComponent implements OnInit { | ||
private modService = inject(ModService); | ||
|
||
public npc = model.required<INPCDefinition | undefined>(); | ||
public label = input<string>('NPC'); | ||
public defaultValue = input<string>(); | ||
public change = output<string>(); | ||
|
||
public values = computed(() => { | ||
const mod = this.modService.mod(); | ||
|
||
return [ | ||
...mod.npcs.map((i) => ({ | ||
category: 'My Mod NPCs', | ||
data: i, | ||
value: i.npcId, | ||
})), | ||
]; | ||
}); | ||
|
||
ngOnInit() { | ||
const defaultItem = this.defaultValue(); | ||
if (defaultItem) { | ||
const foundItem = this.values().find((i) => i.value === defaultItem); | ||
this.npc.set(foundItem as unknown as INPCDefinition); | ||
} | ||
} | ||
|
||
public itemCompare(itemA: NPCModel, itemB: NPCModel): boolean { | ||
return itemA.value === itemB.value; | ||
} | ||
|
||
public search(term: string, item: { value: string }) { | ||
return item.value.toLowerCase().includes(term.toLowerCase()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.