-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
c200cef
commit 6f46447
Showing
63 changed files
with
319 additions
and
183 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
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
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
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
58 changes: 58 additions & 0 deletions
58
ts/src/game/component/selection/provider/workerSelectionInfoProvider.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,58 @@ | ||
import { Sprite2, sprites2 } from "../../../../asset/sprite.js"; | ||
import { ItemCategory } from "../../../../data/inventory/inventoryItem.js"; | ||
import { Entity } from "../../../entity/entity.js"; | ||
import { WorkerSpriteComponent } from "../../actor/mob/workerSpriteComponent.js"; | ||
import { EquipmentComponent } from "../../inventory/equipmentComponent.js"; | ||
import { SelectionInfo } from "../selectionInfo.js"; | ||
import { SelectionInfoProvider } from "../selectionInfoProvider.js"; | ||
|
||
export class WorkerSelectionInfoProvider implements SelectionInfoProvider { | ||
getInfo(entity: Entity): SelectionInfo | null { | ||
const workerSpriteComponent = entity.getComponent( | ||
WorkerSpriteComponent, | ||
); | ||
const equipmentComponent = entity.getComponent(EquipmentComponent); | ||
|
||
if (workerSpriteComponent && equipmentComponent) { | ||
const mainItem = equipmentComponent.mainItem.getItem(); | ||
if (mainItem) { | ||
switch (mainItem.category) { | ||
case ItemCategory.Magic: | ||
return this.makeSelectionInfo( | ||
"Wizard", | ||
workerSpriteComponent.getSprite(), | ||
); | ||
case ItemCategory.Melee: | ||
return this.makeSelectionInfo( | ||
"Knight", | ||
workerSpriteComponent.getSprite(), | ||
); | ||
case ItemCategory.Productivity: | ||
return this.makeSelectionInfo( | ||
"Worker", | ||
workerSpriteComponent.getSprite(), | ||
); | ||
case ItemCategory.Ranged: | ||
return this.makeSelectionInfo( | ||
"Archer", | ||
workerSpriteComponent.getSprite(), | ||
); | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
return this.makeSelectionInfo("Villager", sprites2.worker); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
private makeSelectionInfo(label: string, sprite: Sprite2): SelectionInfo { | ||
return { | ||
icon: sprite, | ||
title: label, | ||
subtitle: "Villager", | ||
}; | ||
} | ||
} |
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
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
Oops, something went wrong.