Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wonder model #2393

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added client/public/models/buildings-opt/wonder.glb
Binary file not shown.
Binary file added client/public/models/buildings-opt/wonder2.glb
Binary file not shown.
6 changes: 6 additions & 0 deletions client/src/dojo/modelManager/TileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export class TileManager {
return (realm?.level || RealmLevels.Settlement) as RealmLevels;
};

getWonder = () => {
const realmEntityId = useUIStore.getState().structureEntityId;
const realm = getComponentValue(this.setup.components.Realm, getEntityIdFromKeys([BigInt(realmEntityId)]));
return realm?.has_wonder || false;
};

existingBuildings = () => {
const builtBuildings = Array.from(
runQuery([
Expand Down
5 changes: 4 additions & 1 deletion client/src/three/components/StructureManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const neutralColor = new THREE.Color(0xffffff);
const myColor = new THREE.Color("lime");

const MAX_INSTANCES = 1000;

const WONDER_MODEL_INDEX = 4;
export class StructureManager {
private scene: THREE.Scene;
private structureModels: Map<StructureType, InstancedModel[]> = new Map();
Expand Down Expand Up @@ -165,6 +165,9 @@ export class StructureManager {
let modelType = models[structure.stage];
if (structureType === StructureType.Realm) {
modelType = models[structure.level];
if (structure.hasWonder) {
modelType = models[WONDER_MODEL_INDEX];
}
}
const currentCount = modelType.getCount();
modelType.setMatrixAt(currentCount, this.dummy.matrix);
Expand Down
6 changes: 5 additions & 1 deletion client/src/three/scenes/Hexception.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
HEX_SIZE,
MinesMaterialsParams,
StructureProgress,
WONDER_REALM,
buildingModelPaths,
castleLevelToRealmCastle,
hyperstructureStageToModel,
Expand Down Expand Up @@ -97,7 +98,7 @@ interface Building {
export default class HexceptionScene extends HexagonScene {
private hexceptionRadius = 4;
private buildingModels: Map<
BuildingType | ResourceMiningTypes,
BuildingType | ResourceMiningTypes | typeof WONDER_REALM,
{ model: THREE.Group; animations: THREE.AnimationClip[] }
> = new Map();
private buildingInstances: Map<string, THREE.Group> = new Map();
Expand Down Expand Up @@ -469,6 +470,9 @@ export default class HexceptionScene extends HexagonScene {

if (parseInt(buildingType) === BuildingType.Castle) {
buildingType = castleLevelToRealmCastle[this.structureStage];
if (this.tileManager.getWonder()) {
buildingType = WONDER_REALM;
}
}
if (building.structureType === StructureType.Hyperstructure) {
buildingType = hyperstructureStageToModel[this.structureStage as StructureProgress];
Expand Down
6 changes: 5 additions & 1 deletion client/src/three/scenes/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export const hyperstructureStageToModel: Record<StructureProgress, string> = {
[StructureProgress.STAGE_3]: HyperstructureTypesNames.STAGE_3,
};

export const WONDER_REALM = "Wonder";

export const buildingModelPaths: Record<
BuildingType | ResourceMiningTypes | RealmLevelNames | HyperstructureTypesNames,
BuildingType | ResourceMiningTypes | RealmLevelNames | HyperstructureTypesNames | typeof WONDER_REALM,
string
> = {
// placeholder for now
Expand Down Expand Up @@ -70,6 +72,7 @@ export const buildingModelPaths: Record<
[HyperstructureTypesNames.STAGE_1]: "/models/buildings-opt/hyperstructure_init.glb",
[HyperstructureTypesNames.STAGE_2]: "/models/buildings-opt/hyperstructure_half.glb",
[HyperstructureTypesNames.STAGE_3]: "/models/buildings-opt/hyperstructure.glb",
[WONDER_REALM]: "/models/buildings-opt/wonder.glb",
};

const BASE_PATH = "/models/biomes-opt/";
Expand Down Expand Up @@ -102,6 +105,7 @@ export const StructureModelPaths: Record<StructureType, string[]> = {
"models/buildings-opt/castle1.glb",
"models/buildings-opt/castle2.glb",
"models/buildings-opt/castle3.glb",
"models/buildings-opt/wonder2.glb",
],
// Order follows StructureProgress
[StructureType.Hyperstructure]: [
Expand Down
Loading